3840 Commits

Author SHA1 Message Date
Azat Khuzhin
266f43af77 Fix arc4random_addrandom() detecting and fallback (regression)
But this is kind of hot-fix, we definitelly need more sane arc4random
compat layer.

Fixes: #488
Introduced-in: 6541168 ("Detect arch4random_addrandom() existence")
2017-03-27 17:04:33 +03:00
Azat Khuzhin
177e2171cb Make event_count macros cleaner
Fixes: #489
2017-03-26 21:42:19 +03:00
Xiang Zhang
2e52bace9f fix evutil_make_internal_pipe_'s comment that fd[0] for read and f[1] for write 2017-03-18 15:25:20 +03:00
Azat Khuzhin
b1e8a4138f cmake: use APPEND during exporting targets (for old cmake)
On centos with cmake 2.8.12.2:
  CMake Error at cmake/AddEventLibrary.cmake:92 (export):
    export called with target "event_extra_shared" which requires target
    "event_core_shared" that is not in the export list.

    If the required target is not easy to reference in this call, consider
    using the APPEND option with multiple separate calls.

But on newer cmake I guess everything is ok.

Fixes: 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED
and STATIC libraries (like autoconf does)")
2017-03-14 13:37:59 +03:00
Azat Khuzhin
d84f020545 Merge branch 'win32-fixes'
This patchset fixes win32 builds after some previous patches (referenced
in particular commits), and also removes some quirks for win32.

* win32-fixes:
  test: do not return void
  log/win32: fix exporting extern variable
  log-internal: missing extern "C"
  log: remove USE_GLOBAL_FOR_DEBUG_LOGGING
  cmake: Export missing symbols for win32
  cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libs
  test: windows doesn't have WNOWAIT
  cmake: clean not used #defines from event-config.h
  cmake: add <pthread.h> only for non-win32
2017-03-14 13:31:02 +03:00
Azat Khuzhin
8acfb0cd21 test: do not return void 2017-03-14 13:21:16 +03:00
Azat Khuzhin
92cf234b0c log/win32: fix exporting extern variable
==> win:   C:\vagrant\log.c(73): error C2370: 'event_debug_logging_mask_' : redefinition; different storage class [C:\vagrant\.cmake-vagrant\event_core_shared.vcxproj]
2017-03-14 12:55:40 +03:00
Azat Khuzhin
a9c2116fac log-internal: missing extern "C" 2017-03-14 08:47:18 +03:00
Azat Khuzhin
49dcf4d554 log: remove USE_GLOBAL_FOR_DEBUG_LOGGING
Fixes: 9081b66c9c1446b11c0052bade799fafb460efed ("Export symbols for
-fvisibility=hidden (under cmake)")
2017-03-14 08:47:18 +03:00
Azat Khuzhin
48ead58e77 cmake: Export missing symbols for win32 2017-03-14 08:47:18 +03:00
Azat Khuzhin
30f2a969e8 cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libs
Before 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED
and STATIC libraries (like autoconf does)") it links with *.c.
2017-03-14 00:33:37 +03:00
Azat Khuzhin
a4b1828d6d test: windows doesn't have WNOWAIT
Fixes: 66a4eb0c3ae3b1f22b084b2d3aeb5c872f37efbd ("Check for WNOWAIT in
waitpid() in runtime (not in cmake/configure)")
2017-03-14 00:04:26 +03:00
Azat Khuzhin
d5e1087044 cmake: clean not used #defines from event-config.h
- _LARGE_FILES: we have it in evconfig-private.h.in, drop from event-config.h
- EVENT___FILE_OFFSET_BITS: remove it for now
- EVENT__const
2017-03-13 22:13:13 +03:00
Azat Khuzhin
2d2299cf7a cmake: add <pthread.h> only for non-win32
Fixes: b2b4b4d74e78a3e4fe7a74224d1e6aada5bde351 ("cmake: add <pthread.h>
into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)")
2017-03-13 22:09:27 +03:00
Azat Khuzhin
882f537c40 cmake: fix pkgconfig generation (copy-paste typo) 2017-03-13 21:41:10 +03:00
Azat Khuzhin
489991a2b2 Merge branch 'cmake-missing-bits'
This patchset adds next missing things (in compare to autotools):
- pkgconfig
- event_pthreads/event_openssl
- compile shared/static libraries always

And some fixes, because it will not build after fixing other things:
- export missing symbols for cmake (-fvisibility=hidden)

* cmake-missing-bits:
  cmake: support visibility for AppleClang too
  cmake: fix export absolute path and relative path and cleanup a bit
  cmake: generate and install pkgconfig files
  cmake: build SHARED and STATIC libraries (like autoconf does)
  cmake: add missing event_openssl/event_pthreads libraries
  Export symbols for -fvisibility=hidden (under cmake)

Refs: #246
2017-03-13 21:08:07 +03:00
Azat Khuzhin
805e1aa819 cmake: support visibility for AppleClang too
Defaults apple linker behaviour is -two_levelnamespace, and you cannot
use "-undefined suppress" with it, so let's link non event_core with
event_core library to avoid undefined symbols.
2017-03-13 16:25:30 +03:00
Azat Khuzhin
fd5a3fc036 cmake: fix export absolute path and relative path and cleanup a bit
Remove next vars, since I don't think that somebody want to change it:
- bin
- lib
- include

And fix exports problem:
  CMake Error: INSTALL(EXPORT "LibeventTargets") given absolute DESTINATION "/usr/lib/cmake/libevent" but the export references an installation of target "event_core_static" which has relative DESTINATION "lib".
2017-03-13 16:20:40 +03:00
Azat Khuzhin
86c7357525 cmake: generate and install pkgconfig files
Fixes: #443
2017-03-13 16:20:40 +03:00
Azat Khuzhin
7182c2f561 cmake: build SHARED and STATIC libraries (like autoconf does)
Since they are useful for debugging, and if autotools build them then
cmamke has to do this too, to make migration more simple.

And now:
- tests: uses shared libraries (since this is upstreams one)
- other binaries: uses static libraries

This removes next private config:
- EVENT__NEED_DLLIMPORT
2017-03-13 16:20:40 +03:00
Azat Khuzhin
72ef9d1652 cmake: add missing event_openssl/event_pthreads libraries
This will remove openssl requirement if you don't use it (i.e. if you
not link with openssl_pthreads).

Plus it fixes some linking dependencies:
- libm required only for test-ratelim

And fix some coding style alignment issues.

Refs: #246
2017-03-13 12:57:22 +03:00
Azat Khuzhin
9081b66c9c Export symbols for -fvisibility=hidden (under cmake)
Fixes: #442
2017-03-13 12:57:22 +03:00
Azat Khuzhin
83b1584700 travis-ci: do not run coverage on osx
First of all we don't really need two of them, and also with apple-clang
it will fail (because of our checks in cmake), so just exclude it from
the build matrix.
2017-03-12 15:01:09 +03:00
Azat Khuzhin
7004ee8e86 travis-ci: use travis_retry to reduce number of problems with flacky tests 2017-03-12 13:21:53 +03:00
Azat Khuzhin
e01b993703 appveyor: remove -DEVENT__ENABLE_VERBOSE_DEBUG=ON build
See-also: c199df7bc78824ff579ff34c5f9f922034e8fa31 ("travis-ci: remove
-DEVENT__ENABLE_VERBOSE_DEBUG=ON (too much useless logs)")
2017-03-12 13:21:53 +03:00
Shuo Chen
65870949e7 Fix detection of timerfd_create() in CMake. 2017-03-12 01:00:41 -08:00
Azat Khuzhin
819d049377 Do not add epoll_sub (syscall wrappers) for epoll in cmake
Nowadays mostly all supported OS'es has this wrappers, and some of them (like
SmartOS) has wrappers but doesn't have __NR_epoll* defines for syscall numbers,
so just drop them (instead of adding yet another check int cmake like autotools
has, since this will break building in cross-compile environment).

Also one minor note, configure doesn't added epoll_sub.c either, since it check
epoll_create() in runtime.

And I tested it in SmartOS and it even works (`make verify`).

Fixes: #463
2017-03-08 23:34:44 +03:00
Azat Khuzhin
5aade2d30b Merge branch 'cmake-configure-fixes-v2'
Fixes in cmake, to make it more like configure and support some
cross-compiling.

* cmake-configure-fixes-v2:
  cmake: fix extracting of the version from git (check for number of matches)
  Detect arch4random_addrandom() existence
  Use off_t instead of ev_off_t for sendfile() (fixes android build)
  cmake: detect _GNU_SOURCE not by __GNU_LIBRARY__ only (fallback to _GNU_SOURCE)
  Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
  cmake: add <pthread.h> into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)
  cmake: fix values for #cmakedefine
  cmake: drop duplicates from event-config template
  cmake: add value for the #cmakedefine macros (like autoconf)
  cmake: Fix checking of enum values from sysctl.h
2017-03-08 17:58:26 +03:00
Azat Khuzhin
d65e3e1dbe cmake: fix extracting of the version from git (check for number of matches) 2017-03-08 13:31:55 +03:00
Marek Sebera
6541168d70 Detect arch4random_addrandom() existence
Refs: #370
Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
f479a00894 Use off_t instead of ev_off_t for sendfile() (fixes android build)
Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
71a56bd3a7 cmake: detect _GNU_SOURCE not by __GNU_LIBRARY__ only (fallback to _GNU_SOURCE)
Fixes pipe2() on Android-9/armv7-a

Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
66a4eb0c3a Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
Because checking in cmake breaks cross-compiling.

Introduced-in: 43eb56c7c738e3642f0981e3dd6ab9e082eec798.
Fixes: #482
Fixes: #462
Refs: #475

v2: use waitid() with WNOWAIT
v3: use WNOWAIT only if it available in waitpid(), because not all netbsd
    supports it
2017-03-08 13:31:55 +03:00
Azat Khuzhin
b2b4b4d74e cmake: add <pthread.h> into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)
Fixes: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
7f945b2d1b cmake: fix values for #cmakedefine 2017-03-08 13:31:53 +03:00
Azat Khuzhin
852726028f cmake: drop duplicates from event-config template 2017-03-08 12:47:32 +03:00
Azat Khuzhin
336ab816c8 cmake: add value for the #cmakedefine macros (like autoconf)
Before this patch for cmake we had:
  #define EVENT__HAVE_ACCEPT4
  /* #undef EVENT__HAVE_ARC4RANDOM */

While autotools has:
 #define EVENT__HAVE_ACCEPT4 1
 /* #undef EVENT__HAVE_ARC4RANDOM */
2017-03-08 12:47:31 +03:00
Azat Khuzhin
fa135bdcd9 cmake: Fix checking of enum values from sysctl.h
CheckSymbolExists do not do this, so add new CheckConstExists that will
use CheckCSourceCompiles() to check this.

v2: use set() instead of string(APPEND)
2017-03-08 12:47:22 +03:00
Azat Khuzhin
c199df7bc7 travis-ci: remove -DEVENT__ENABLE_VERBOSE_DEBUG=ON (too much useless logs)
I guess we can revert part of 59649f7 commit, we tried, but it adds more problems than solves.

Refs: https://github.com/libevent/libevent/pull/476#issuecomment-284259602
2017-03-06 02:56:27 +03:00
Azat Khuzhin
98faf19895 Merge branch 'fix-openssl-linking'
* fix-openssl-linking:
  sample/https-client: use ERR_remove_*state() when we have them
  Do not check for ERR_remove_thread_state() (do not link ssl into every library)

Closes: #476
2017-03-06 02:46:38 +03:00
Pierce Lopez
05318f1314 sample/https-client: use ERR_remove_*state() when we have them
ERR_remove_thread_state:
- openssl 0.9.8         does not have
- openssl 1.0/libressl  has
- openssl 1.1           deprecates
2017-03-06 02:44:58 +03:00
Pierce Lopez
5d18d87916 Do not check for ERR_remove_thread_state() (do not link ssl into every library)
This reverts commit c4e9d9bd662de7f575f2172c160795d452ebe709
("sample/https-client: check for ERR_remove_thread_state() existence").

Calling AC_SEARCH_LIBS() modifies LIBS - -lcrypto incorrectly
ends up in LIBS, and thus linked to by libevent_core.so.

Checking for ERR_remove_thread_state should no longer be needed
because it was introduced in openssl 1.0.0, and the previous line
0.9.8 had support discontinued at the end of 2015.

Fixes: #473
2017-03-06 01:39:29 +03:00
tim-le
8df81546f3 evutil: fix a typo of comment
Fixes: #481
Fixes: #480
2017-03-05 18:14:02 +03:00
Trond Norbye
cc0e04d798 Fix RPATH for APPLE
By setting the CMake minimum version to 3.1 CMake automatically
adds the correct magic to make the library relocatable on
the filesystem (instead of burning the location of the library
at link time into the binary).

ex:
otool -L bin/http-connect
bin/http-connect:
	@rpath/libevent_extra.2.2.0.dylib (compatibility version 2.2.0, current version 0.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

Fixes: #468 (cherry-picked)
2017-02-28 11:02:39 +03:00
David Disseldorp
55cadb2b03 sample/dns-example: fix compiler warning (getopt() returns an int)
Signed-off-by: David Disseldorp <ddiss@suse.de>
Closes: #449
2017-02-28 00:39:50 +03:00
David Disseldorp
e139cbac0a sample/https-client: use host SSL certificate store by default
Currently a static (Debian) certificate path is used by default, which
can be overridden using the -crt parameter. This commit changes the
default behaviour such that the openssl default certificate store is
used, unless overridden by -crt.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2017-02-28 00:39:50 +03:00
Azat Khuzhin
ffbce578c4 Fix clang 3 (some versions) misbehaviour for __has_attribute()
Refs: #447
Clang: https://reviews.llvm.org/rL223468 ("Modify __has_attribute so
that it only looks for GNU-style attributes")
2017-01-30 11:50:02 +03:00
Jan Beich
d057c45e8f Unbreak build with LibreSSL after openssl 1.1 support added
Fixes: 3e9e0a0d46e4 ("Make it build using OpenSSL 1.1.0")
Fixes: #445
2017-01-30 00:25:26 +03:00
Azat Khuzhin
9d5a4bdc5c Merge branch 'fix-struct-linger'
@jbech
  "Accidentally disabled by 0dda56a due to confusion between struct
  linger vs. SO_LINGER and #define vs. AC_DEFINE. Try adding synthetic
  #error test to confirm."

* fix-struct-linger:
  cmake: check for 'struct linger' existence
  test/bench*: prefix event-config.h macros after 0dda56a48e94
  test/bench_httpclient: restore SO_LINGER usage after 0dda56a48e94

Fixes: #444 (original pull-request)
2017-01-29 23:07:40 +03:00
Azat Khuzhin
b24a78cccf cmake: check for 'struct linger' existence 2017-01-29 23:06:34 +03:00