From 10c834c4dfda193c031a6bab9e86e0dcb818a061 Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 01:22:25 -0500 Subject: [PATCH 01/17] Include arpa/inet.h as needed on HPUX --- http.c | 3 +++ sample/hello-world.c | 3 +++ sample/http-server.c | 3 +++ test/bench_httpclient.c | 3 +++ test/regress_listener.c | 3 +++ test/test-ratelim.c | 3 +++ 6 files changed, 18 insertions(+) diff --git a/http.c b/http.c index 3b947aae..9c1481e6 100644 --- a/http.c +++ b/http.c @@ -56,6 +56,9 @@ #ifdef _EVENT_HAVE_NETINET_IN_H #include #endif +#ifdef _EVENT_HAVE_ARPA_INET_H +#include +#endif #ifdef _EVENT_HAVE_NETDB_H #include #endif diff --git a/sample/hello-world.c b/sample/hello-world.c index 90df85f7..d40af529 100644 --- a/sample/hello-world.c +++ b/sample/hello-world.c @@ -13,6 +13,9 @@ #include #ifndef WIN32 #include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif #include #endif diff --git a/sample/http-server.c b/sample/http-server.c index f9e84d1c..e8b7b408 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -36,6 +36,9 @@ #ifdef _EVENT_HAVE_NETINET_IN_H #include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif #endif #ifdef WIN32 diff --git a/test/bench_httpclient.c b/test/bench_httpclient.c index 19f025f1..f0888e6c 100644 --- a/test/bench_httpclient.c +++ b/test/bench_httpclient.c @@ -31,6 +31,9 @@ #else #include #include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif #endif #include #include diff --git a/test/regress_listener.c b/test/regress_listener.c index 1438f3aa..44fee7f4 100644 --- a/test/regress_listener.c +++ b/test/regress_listener.c @@ -34,6 +34,9 @@ #ifndef WIN32 #include #include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif #include #endif diff --git a/test/test-ratelim.c b/test/test-ratelim.c index 824434e0..edd7ae21 100644 --- a/test/test-ratelim.c +++ b/test/test-ratelim.c @@ -36,6 +36,9 @@ #else #include #include +# ifdef _XOPEN_SOURCE_EXTENDED +# include +# endif #endif #include From bbf55150b65a5de2edf7c77e3acd1c52caf364a9 Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 01:25:33 -0500 Subject: [PATCH 02/17] Include util-internal.h as needed to build on platforms with no sockaddr_storage --- sample/dns-example.c | 2 ++ sample/http-server.c | 4 ++++ test/regress_dns.c | 2 ++ test/regress_testutils.c | 2 ++ test/test-ratelim.c | 2 ++ 5 files changed, 12 insertions(+) diff --git a/sample/dns-example.c b/sample/dns-example.c index 55318215..e555af56 100644 --- a/sample/dns-example.c +++ b/sample/dns-example.c @@ -7,6 +7,8 @@ #include +#include "../ipv6-internal.h" + #include #ifdef WIN32 diff --git a/sample/http-server.c b/sample/http-server.c index e8b7b408..0739b21d 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -41,6 +41,8 @@ # endif #endif +#include <../util-internal.h> + #ifdef WIN32 #define stat _stat #define fstat _fstat @@ -369,9 +371,11 @@ main(int argc, char **argv) if (ss.ss_family == AF_INET) { got_port = ntohs(((struct sockaddr_in*)&ss)->sin_port); inaddr = &((struct sockaddr_in*)&ss)->sin_addr; +#ifdef AF_INET6 } else if (ss.ss_family == AF_INET6) { got_port = ntohs(((struct sockaddr_in6*)&ss)->sin6_port); inaddr = &((struct sockaddr_in6*)&ss)->sin6_addr; +#endif } else { fprintf(stderr, "Weird address family %d\n", ss.ss_family); diff --git a/test/regress_dns.c b/test/regress_dns.c index 255f613a..086fd429 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -71,6 +71,8 @@ #include "regress.h" #include "regress_testutils.h" +#include "../util-internal.h" + static int dns_ok = 0; static int dns_got_cancel = 0; static int dns_err = 0; diff --git a/test/regress_testutils.c b/test/regress_testutils.c index b5bef1ab..8902e631 100644 --- a/test/regress_testutils.c +++ b/test/regress_testutils.c @@ -68,6 +68,8 @@ #include "regress.h" #include "regress_testutils.h" +#include "../util-internal.h" + /* globals */ static struct evdns_server_port *dns_port; evutil_socket_t dns_sock = -1; diff --git a/test/test-ratelim.c b/test/test-ratelim.c index edd7ae21..bbbd7608 100644 --- a/test/test-ratelim.c +++ b/test/test-ratelim.c @@ -49,6 +49,8 @@ #include "event2/listener.h" #include "event2/thread.h" +#include "../util-internal.h" + static int cfg_verbose = 0; static int cfg_help = 0; From eb692be9c8ea2d52e28a0b7b8258bd76483c3f3c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 13 Feb 2011 01:27:06 -0500 Subject: [PATCH 03/17] NM: Fix sample/http-server ipv6 fixes Fix 1: Use #include "../xyz" rather than #include <../xyz> Fix 2: util-internal.h includes ipv6-internal.h, which in turn defines a replacement AF_INET6 on platforms that don't have it. As such, the AF_INET6 checks shouldn't be needed. (right?) --- sample/http-server.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sample/http-server.c b/sample/http-server.c index 0739b21d..76026a51 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -41,7 +41,7 @@ # endif #endif -#include <../util-internal.h> +#include "../util-internal.h" #ifdef WIN32 #define stat _stat @@ -371,11 +371,9 @@ main(int argc, char **argv) if (ss.ss_family == AF_INET) { got_port = ntohs(((struct sockaddr_in*)&ss)->sin_port); inaddr = &((struct sockaddr_in*)&ss)->sin_addr; -#ifdef AF_INET6 } else if (ss.ss_family == AF_INET6) { got_port = ntohs(((struct sockaddr_in6*)&ss)->sin6_port); inaddr = &((struct sockaddr_in6*)&ss)->sin6_addr; -#endif } else { fprintf(stderr, "Weird address family %d\n", ss.ss_family); From 4eb281c8a96e246b7493570a89686f8c56c75853 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 13 Feb 2011 01:29:54 -0500 Subject: [PATCH 04/17] FIX: comment internal headers used in sample code. --- sample/dns-example.c | 1 + sample/http-server.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sample/dns-example.c b/sample/dns-example.c index e555af56..439a486a 100644 --- a/sample/dns-example.c +++ b/sample/dns-example.c @@ -7,6 +7,7 @@ #include +/* Compatibility for possible missing IPv6 declarations */ #include "../ipv6-internal.h" #include diff --git a/sample/http-server.c b/sample/http-server.c index 76026a51..d5212c51 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -41,6 +41,7 @@ # endif #endif +/* Compatibility for possible missing IPv6 declarations */ #include "../util-internal.h" #ifdef WIN32 From 05a2c22fee8821e7d36837e1b3cba3b105dd5dfc Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 01:30:37 -0500 Subject: [PATCH 05/17] Make test-eof fail with a timeout if we never get an eof. Previously, it would just wait forever. --- test/test-eof.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/test-eof.c b/test/test-eof.c index 90b40938..417476e8 100644 --- a/test/test-eof.c +++ b/test/test-eof.c @@ -32,6 +32,7 @@ int test_okay = 1; int called = 0; +struct timeval timeout = {60, 0}; static void read_cb(evutil_socket_t fd, short event, void *arg) @@ -39,6 +40,11 @@ read_cb(evutil_socket_t fd, short event, void *arg) char buf[256]; int len; + if (EV_TIMEOUT & event) { + printf("%s: Timeout!\n", __func__); + exit(1); + } + len = recv(fd, buf, sizeof(buf), 0); printf("%s: read %d%s\n", __func__, @@ -46,7 +52,7 @@ read_cb(evutil_socket_t fd, short event, void *arg) if (len) { if (!called) - event_add(arg, NULL); + event_add(arg, &timeout); } else if (called == 1) test_okay = 0; @@ -85,9 +91,9 @@ main(int argc, char **argv) event_init(); /* Initalize one event */ - event_set(&ev, pair[1], EV_READ, read_cb, &ev); + event_set(&ev, pair[1], EV_READ | EV_TIMEOUT, read_cb, &ev); - event_add(&ev, NULL); + event_add(&ev, &timeout); event_dispatch(); From a317c068fe573050677599736a59b0b101bfa07c Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 01:34:40 -0500 Subject: [PATCH 06/17] Skip check for zlib if we have no zlib.h --- configure.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.in b/configure.in index 626e6b13..92a45809 100644 --- a/configure.in +++ b/configure.in @@ -60,6 +60,9 @@ AC_SEARCH_LIBS([inet_aton], [resolv]) AC_SEARCH_LIBS([clock_gettime], [rt]) AC_SEARCH_LIBS([sendfile], [sendfile]) +AC_CHECK_HEADERS([zlib.h]) + +if test "x$ac_cv_header_zlib_h" = "xyes"; then dnl Determine if we have zlib for regression tests dnl Don't put this one in LIBS save_LIBS="$LIBS" @@ -72,6 +75,7 @@ AC_SEARCH_LIBS([inflateEnd], [z], AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])]) LIBS="$save_LIBS" AC_SUBST(ZLIB_LIBS) +fi AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"]) dnl See if we have openssl. This doesn't go in LIBS either. From 833e5e9fcd3d06adfbd7c47d4f1fe42f46fbb26b Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 01:39:10 -0500 Subject: [PATCH 07/17] Fix autoconf bracket issues; make check for getaddrinfo include netdb.h --- configure.in | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 92a45809..33084e75 100644 --- a/configure.in +++ b/configure.in @@ -94,7 +94,7 @@ fi dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h stddef.h poll.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in.h netinet/in6.h sys/socket.h sys/uio.h arpa/inet.h sys/eventfd.h sys/mman.h sys/sendfile.h sys/wait.h netdb.h) +AC_CHECK_HEADERS([fcntl.h stdarg.h inttypes.h stdint.h stddef.h poll.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in.h netinet/in6.h sys/socket.h sys/uio.h arpa/inet.h sys/eventfd.h sys/mman.h sys/sendfile.h sys/wait.h netdb.h]) AC_CHECK_HEADERS(sys/sysctl.h, [], [], [ #ifdef HAVE_SYS_PARAM_H #include @@ -203,9 +203,30 @@ AC_C_INLINE AC_HEADER_TIME dnl Checks for library functions. -AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy inet_ntop inet_pton signal sigaction strtoll inet_aton pipe eventfd sendfile mmap splice arc4random arc4random_buf issetugid geteuid getegid getservbyname getprotobynumber setenv unsetenv putenv) +AC_CHECK_FUNCS([gettimeofday vasprintf fcntl clock_gettime strtok_r strsep]) +AC_CHECK_FUNCS([getnameinfo strlcpy inet_ntop inet_pton signal sigaction strtoll inet_aton pipe eventfd sendfile mmap splice arc4random arc4random_buf issetugid geteuid getegid getprotobynumber setenv unsetenv putenv]) -if test "$ac_cv_func_getaddrinfo" != "yes" ; then +AC_CACHE_CHECK( + [for getaddrinfo], + [libevent_cv_getaddrinfo], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ + #ifdef HAVE_NETDB_H + #include + #endif + ]], + [[ + getaddrinfo; + ]] + )], + [libevent_cv_getaddrinfo=yes], + [libevent_cv_getaddrinfo=no] + )] +) +if test "$libevent_cv_getaddrinfo" = "yes" ; then + AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?]) +else # Check for gethostbyname_r in all its glorious incompatible versions. # (This is cut-and-pasted from Tor, which based its logic on From af08a94085e49e6942835b4c6b50a774536d5b5b Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 01:42:58 -0500 Subject: [PATCH 08/17] Check for getservbyname even if not on win32. --- configure.in | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.in b/configure.in index 33084e75..53701368 100644 --- a/configure.in +++ b/configure.in @@ -228,6 +228,7 @@ if test "$libevent_cv_getaddrinfo" = "yes" ; then AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?]) else +AC_CHECK_FUNCS([getservbyname]) # Check for gethostbyname_r in all its glorious incompatible versions. # (This is cut-and-pasted from Tor, which based its logic on # Python's configure.in.) From 0965c563568e49448955aea30bd43df30e544b92 Mon Sep 17 00:00:00 2001 From: Dave Hart Date: Sun, 13 Feb 2011 01:50:40 -0500 Subject: [PATCH 09/17] Use the gcc -ffunction-segments feature to allow gc when linking with static libevent --- configure.in | 32 ++++++++++++++++++++++++++++++++ sample/Makefile.am | 2 +- test/Makefile.am | 10 +++++----- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index 53701368..c00abd20 100644 --- a/configure.in +++ b/configure.in @@ -628,5 +628,37 @@ if test x$enable_gcc_warnings = xyes && test "$GCC" = "yes"; then fi +LIBEVENT_GC_SECTIONS= +if test "$GCC" = yes ; then + AC_CACHE_CHECK( + [if linker supports omitting unused code and data], + [libevent_cv_gc_sections_works], + [ + origCFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Wl,--gc-sections" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [ + if grep gc-sections conftest.err ; then + libevent_cv_gc_sections_works=no + else + libevent_cv_gc_sections_works=yes + fi + ], + [libevent_cv_gc_sections_works=no] + ) + CFLAGS="$origCFLAGS" + AS_UNSET([origCFLAGS]) + ] + ) + case "$libevent_cv_gc_sections_works" in + yes) + CFLAGS="-ffunction-sections -fdata-sections $CFLAGS" + LIBEVENT_GC_SECTIONS="-Wl,--gc-sections" + ;; + esac +fi +AC_SUBST([LIBEVENT_GC_SECTIONS]) + AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc] ) AC_OUTPUT(Makefile include/Makefile test/Makefile sample/Makefile) diff --git a/sample/Makefile.am b/sample/Makefile.am index 0071d26f..2d616f9e 100644 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = foreign no-dependencies -LDADD = ../libevent.la +LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include noinst_PROGRAMS = event-test time-test signal-test dns-example hello-world http-server diff --git a/test/Makefile.am b/test/Makefile.am index 97682fb4..b9fb8d04 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -45,7 +45,7 @@ if BUILD_WIN32 regress_SOURCES += regress_iocp.c endif -regress_LDADD = ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS) +regress_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS) regress_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat \ -I$(top_srcdir)/include -I../include $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS) regress_LDFLAGS = $(PTHREAD_CFLAGS) @@ -56,13 +56,13 @@ regress_LDADD += ../libevent_openssl.la -lcrypto -lssl endif bench_SOURCES = bench.c -bench_LDADD = ../libevent.la +bench_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la bench_cascade_SOURCES = bench_cascade.c -bench_cascade_LDADD = ../libevent.la +bench_cascade_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la bench_http_SOURCES = bench_http.c -bench_http_LDADD = ../libevent.la +bench_http_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la bench_httpclient_SOURCES = bench_httpclient.c -bench_httpclient_LDADD = ../libevent_core.la +bench_httpclient_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent_core.la regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py $(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc || echo "No Python installed" From 0b334799d6c48a5830774ee1f62fc2540810051e Mon Sep 17 00:00:00 2001 From: Harlan Stenn Date: Sun, 13 Feb 2011 02:00:10 -0500 Subject: [PATCH 10/17] Add -D_OSF_SOURCE to fix hpux builds --- configure.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configure.in b/configure.in index c00abd20..3c76cfa3 100644 --- a/configure.in +++ b/configure.in @@ -14,6 +14,18 @@ if test "$prefix" = "NONE"; then prefix="/usr/local" fi +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +dnl the 'build' machine is where we run configure and compile +dnl the 'host' machine is where the resulting stuff runs. + +case "$host_os" in + + osf5*) + CFLAGS="$CFLAGS -D_OSF_SOURCE" + ;; +esac + dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL From 49e9bb7fb014a84de677f265cedac58f4d8a8ad5 Mon Sep 17 00:00:00 2001 From: Dave Hart Date: Sun, 13 Feb 2011 02:05:04 -0500 Subject: [PATCH 11/17] Add configure options to disable installation, regression tests The main reason for disabling installation is if you're building libevent as a subpackage for embedding: you want to have your main package's "make all" build libevent, but you don't want your main package's "make install" to install libevent. --- Makefile.am | 19 +++++++++++++------ configure.in | 19 +++++++++++++++++++ test/Makefile.am | 9 +++++++-- test/test.sh | 1 + 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index 46f6d34e..3a7bc2b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,7 +72,7 @@ VERSION_INFO = 5:1:0 dist_bin_SCRIPTS = event_rpcgen.py pkgconfigdir=$(libdir)/pkgconfig -pkgconfig_DATA=libevent.pc +LIBEVENT_PKGCONFIG=libevent.pc # These sources are conditionally added by configure.in or conditionally # included from other files. @@ -89,14 +89,21 @@ EXTRA_DIST = \ Makefile.nmake test/Makefile.nmake \ $(PLATFORM_DEPENDENT_SRC) -lib_LTLIBRARIES = libevent.la libevent_core.la libevent_extra.la +LIBEVENT_LIBS_LA = libevent.la libevent_core.la libevent_extra.la if PTHREADS -lib_LTLIBRARIES += libevent_pthreads.la -pkgconfig_DATA += libevent_pthreads.pc +LIBEVENT_LIBS_LA += libevent_pthreads.la +LIBEVENT_PKGCONFIG += libevent_pthreads.pc endif if OPENSSL -lib_LTLIBRARIES += libevent_openssl.la -pkgconfig_DATA += libevent_openssl.pc +LIBEVENT_LIBS_LA += libevent_openssl.la +LIBEVENT_PKGCONFIG += libevent_openssl.pc +endif + +if INSTALL_LIBEVENT +lib_LTLIBRARIES = $(LIBEVENT_LIBS_LA) +pkgconfig_DATA = $(LIBEVENT_PKGCONFIG) +else +noinst_LTLIBRARIES = $(LIBEVENT_LIBS_LA) endif SUBDIRS = . include sample test diff --git a/configure.in b/configure.in index 3c76cfa3..d924016d 100644 --- a/configure.in +++ b/configure.in @@ -42,6 +42,9 @@ if test "$GCC" = "yes" ; then CFLAGS="$CFLAGS -fno-strict-aliasing" fi +enable_libevent_install_def=yes +enable_libevent_regress_def=yes + AC_ARG_ENABLE(gcc-warnings, AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings with GCC)) AC_ARG_ENABLE(thread-support, @@ -56,6 +59,12 @@ AC_ARG_ENABLE(openssl, AC_ARG_ENABLE(debug-mode, AS_HELP_STRING(--disable-debug-mode, disable support for running in debug mode), [], [enable_debug_mode=yes]) +AC_ARG_ENABLE([libevent-install], + AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]), + [], [enable_libevent_install=$enable_libevent_install_def]) +AC_ARG_ENABLE([libevent-regress], + AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), + [], [enable_libevent_regress=$enable_libevent_regress_def]) AC_PROG_LIBTOOL @@ -65,6 +74,14 @@ dnl the command line with --enable-shared and --disable-shared. dnl AC_DISABLE_SHARED AC_SUBST(LIBTOOL_DEPS) +AM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"]) +if test "$enable_libevent_regress" = "yes" ; then + CHECK_REGRESS=regress +else + CHECK_REGRESS= +fi +AC_SUBST([CHECK_REGRESS]) + dnl Checks for libraries. AC_SEARCH_LIBS([inet_ntoa], [nsl]) AC_SEARCH_LIBS([socket], [socket]) @@ -672,5 +689,7 @@ if test "$GCC" = yes ; then fi AC_SUBST([LIBEVENT_GC_SECTIONS]) +AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"]) + AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc] ) AC_OUTPUT(Makefile include/Makefile test/Makefile sample/Makefile) diff --git a/test/Makefile.am b/test/Makefile.am index b9fb8d04..6d8bf5e7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,14 +4,19 @@ AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../ EXTRA_DIST = regress.rpc regress.gen.h regress.gen.c test.sh -noinst_PROGRAMS = test-init test-eof test-weof test-time regress \ +noinst_PROGRAMS = test-init test-eof test-weof test-time @CHECK_REGRESS@ \ bench bench_cascade bench_http bench_httpclient test-ratelim \ test-changelist +EXTRA_PROGRAMS = regress noinst_HEADERS = tinytest.h tinytest_macros.h regress.h tinytest_local.h TESTS = $(top_srcdir)/test/test.sh -BUILT_SOURCES = regress.gen.c regress.gen.h +BUILT_SOURCES = +if BUILD_REGRESS +BUILT_SOURCES += regress.gen.c regress.gen.h +endif + test_init_SOURCES = test-init.c test_init_LDADD = ../libevent_core.la test_eof_SOURCES = test-eof.c diff --git a/test/test.sh b/test/test.sh index 0054faee..6460306f 100755 --- a/test/test.sh +++ b/test/test.sh @@ -97,6 +97,7 @@ run_tests () { announce FAILED ; FAILED=yes fi + test -x $TEST_DIR/regress || return announce_n " regress: " if test "$TEST_OUTPUT_FILE" = "/dev/null" ; then From 9c469db300e1b270a93c6b04c1709ac0f7751136 Mon Sep 17 00:00:00 2001 From: Dave Hart Date: Sun, 13 Feb 2011 02:27:42 -0500 Subject: [PATCH 12/17] Correct an AM_CFLAGS to an AM_CPPFLAGS in test/Makefile.am --- test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 6d8bf5e7..abcb18ce 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = foreign -AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include -DTINYTEST_LOCAL +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include -DTINYTEST_LOCAL EXTRA_DIST = regress.rpc regress.gen.h regress.gen.c test.sh From 039b9bd0e3ab6e02cd9709d213f1abf32dbd13f0 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 22 Feb 2011 00:31:56 -0500 Subject: [PATCH 13/17] Use %s with printf in test.sh --- test/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.sh b/test/test.sh index 6460306f..08a4cddb 100755 --- a/test/test.sh +++ b/test/test.sh @@ -9,9 +9,9 @@ fi # /bin/echo is a little more likely to support -n than sh's builtin echo, # printf is even more likely -if test "`printf hello 2>&1`" = "hello" +if test "`printf %s hello 2>&1`" = "hello" then - ECHO_N="printf" + ECHO_N="printf %s" else if test -x /bin/echo then From f95bafb60854d07dd8af5033d55656bc371c43f7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 22 Feb 2011 00:34:49 -0500 Subject: [PATCH 14/17] Be explicit about how long event loops run in event.h documentation --- include/event2/event.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/event2/event.h b/include/event2/event.h index 5a3bbf32..09502fd6 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -107,6 +107,10 @@ int event_reinit(struct event_base *base); /** Threadsafe event dispatching loop. + This loop will run the event base until either there are no more added + events, or until something calls event_base_loopbreak() or + evenet_base_loopexit(). + @param eb the event_base structure returned by event_init() @see event_init(), event_dispatch() */ @@ -322,7 +326,7 @@ void event_set_fatal_callback(event_fatal_cb cb); int event_base_set(struct event_base *, struct event *); /** - event_loop() flags + event_base_loop() flags */ /*@{*/ /** Block until we have an active event, then exit once all active events @@ -338,6 +342,11 @@ int event_base_set(struct event_base *, struct event *); This is a more flexible version of event_base_dispatch(). + By default, this loop will run the event base until either there are no more + added events, or until something calls event_base_loopbreak() or + evenet_base_loopexit(). You can override this behavior with the 'flags' + argument. + @param eb the event_base structure returned by event_init() @param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK @return 0 if successful, -1 if an error occurred, or 1 if no events were From 15b2408c9bc4f2b307df8fdecf3ef5a7401f60d2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 22 Feb 2011 16:13:49 -0500 Subject: [PATCH 15/17] Use $(), not @@, for LIBEVENT_GC_SECTIONS --- sample/Makefile.am | 2 +- test/Makefile.am | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sample/Makefile.am b/sample/Makefile.am index 2d616f9e..86f4811d 100644 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = foreign no-dependencies -LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la +LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include noinst_PROGRAMS = event-test time-test signal-test dns-example hello-world http-server diff --git a/test/Makefile.am b/test/Makefile.am index abcb18ce..60dd4972 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -50,7 +50,7 @@ if BUILD_WIN32 regress_SOURCES += regress_iocp.c endif -regress_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS) +regress_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS) regress_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat \ -I$(top_srcdir)/include -I../include $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS) regress_LDFLAGS = $(PTHREAD_CFLAGS) @@ -61,13 +61,13 @@ regress_LDADD += ../libevent_openssl.la -lcrypto -lssl endif bench_SOURCES = bench.c -bench_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la +bench_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la bench_cascade_SOURCES = bench_cascade.c -bench_cascade_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la +bench_cascade_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la bench_http_SOURCES = bench_http.c -bench_http_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la +bench_http_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la bench_httpclient_SOURCES = bench_httpclient.c -bench_httpclient_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent_core.la +bench_httpclient_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent_core.la regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py $(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc || echo "No Python installed" From 7d913f4c8e98a22e75ab2ddea6587f00ef050dbf Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 22 Feb 2011 16:14:16 -0500 Subject: [PATCH 16/17] Remove nonfunctional enable_libevent_(install|regress)_def variables --- configure.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index d924016d..66816b2e 100644 --- a/configure.in +++ b/configure.in @@ -42,9 +42,6 @@ if test "$GCC" = "yes" ; then CFLAGS="$CFLAGS -fno-strict-aliasing" fi -enable_libevent_install_def=yes -enable_libevent_regress_def=yes - AC_ARG_ENABLE(gcc-warnings, AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings with GCC)) AC_ARG_ENABLE(thread-support, @@ -61,10 +58,10 @@ AC_ARG_ENABLE(debug-mode, [], [enable_debug_mode=yes]) AC_ARG_ENABLE([libevent-install], AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]), - [], [enable_libevent_install=$enable_libevent_install_def]) + [], [enable_libevent_install=yes]) AC_ARG_ENABLE([libevent-regress], AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), - [], [enable_libevent_regress=$enable_libevent_regress_def]) + [], [enable_libevent_regress=yes]) AC_PROG_LIBTOOL From 2fba21d8676f941b0b7d61850f440b12f0fb61cc Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 22 Feb 2011 16:20:42 -0500 Subject: [PATCH 17/17] Make -ffunction-sections off-by-default in 2.0.x I don't see how this can burn anybody, but I don't want to take chances: new build options are something that should be done in an alpha. To turn -ffunction-sections on, pass --enable-function-sections to configure. --- configure.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 66816b2e..3b7d1a58 100644 --- a/configure.in +++ b/configure.in @@ -60,8 +60,12 @@ AC_ARG_ENABLE([libevent-install], AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]), [], [enable_libevent_install=yes]) AC_ARG_ENABLE([libevent-regress], - AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), + AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), [], [enable_libevent_regress=yes]) +AC_ARG_ENABLE([function-sections], + AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]), + [], [enable_function_sections=no]) + AC_PROG_LIBTOOL @@ -655,7 +659,7 @@ if test x$enable_gcc_warnings = xyes && test "$GCC" = "yes"; then fi LIBEVENT_GC_SECTIONS= -if test "$GCC" = yes ; then +if test "$GCC" = yes && test "$enable_function_sections" = yes ; then AC_CACHE_CHECK( [if linker supports omitting unused code and data], [libevent_cv_gc_sections_works],