From 86090ee198ce45e857c6367d7ec71cca7a953159 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 10:54:06 +0200 Subject: [PATCH 1/8] Link with -lshell32 and -ladvapi32 on Win32. SHGetSpecialFolderPath is in Shell32.dll and the RegOpenKey (et al) and CryptGenRandom (et al) functions are in -ladvapi32.dll. MinGW is "nice" and brings those in automatically, but specify them explicitly for other tool chains. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 08a7cafe..2c902426 100644 --- a/Makefile.am +++ b/Makefile.am @@ -110,7 +110,7 @@ SUBDIRS = . include sample test if BUILD_WIN32 -SYS_LIBS = -lws2_32 +SYS_LIBS = -lws2_32 -lshell32 -ladvapi32 SYS_SRC = win32select.c evthread_win32.c buffer_iocp.c event_iocp.c \ bufferevent_async.c SYS_INCLUDES = -IWIN32-Code From 07c41bead2097de223def8b6975f08a2f65e908c Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 10:55:41 +0200 Subject: [PATCH 2/8] Make the tests build when OpenSSL is not available. Don't #define HAVE_OPENSSL (to zero) when OpenSSL is not available. Code written as #ifdef HAVE_OPENSSL do not expect that. --- configure.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 5085edea..85f92c36 100644 --- a/configure.in +++ b/configure.in @@ -137,8 +137,7 @@ AC_SEARCH_LIBS([SSL_new], [ssl], [have_openssl=yes OPENSSL_LIBS="$LIBS -lcrypto $EV_LIB_GDI $EV_LIB_WS32" AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl])], - [have_openssl=no - AC_DEFINE(HAVE_OPENSSL, 0, [Define if the system lacks openssl])], + [have_openssl=no], [-lcrypto $EV_LIB_GDI $EV_LIB_WS32]) LIBS="$save_LIBS" AC_SUBST(OPENSSL_LIBS) From f3c7a4c165066bafed3da149f5bf2aecee43cd47 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 10:56:32 +0200 Subject: [PATCH 3/8] Bring in the compile script from automake, if needed. --- configure.in | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.in b/configure.in index 85f92c36..cbc0d218 100644 --- a/configure.in +++ b/configure.in @@ -28,6 +28,7 @@ esac dnl Checks for programs. AC_PROG_CC +AM_PROG_CC_C_O AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MKDIR_P From 70be7d17e4467e61eb343ad7eb242afc3a463c66 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 10:57:16 +0200 Subject: [PATCH 4/8] MSVC does not provide S_ISDIR, so provide it manually. --- sample/http-server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sample/http-server.c b/sample/http-server.c index 05dc165e..75caa414 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -19,6 +19,9 @@ #include #include #include +#ifndef S_ISDIR +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif #else #include #include From fe93022a6694ab8d69c96043c10817e23084a318 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 10:58:48 +0200 Subject: [PATCH 5/8] unistd.h and sys/time.h might not exist. --- test/bench.c | 4 ++++ test/bench_cascade.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/bench.c b/test/bench.c index 59cb6df5..c92bee3b 100644 --- a/test/bench.c +++ b/test/bench.c @@ -37,7 +37,9 @@ #include #include +#ifdef _EVENT_HAVE_SYS_TIME_H #include +#endif #ifdef WIN32 #include #else @@ -49,7 +51,9 @@ #include #include #include +#ifdef _EVENT_HAVE_UNISTD_H #include +#endif #include #include diff --git a/test/bench_cascade.c b/test/bench_cascade.c index 6b508ef1..fef174fa 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -29,7 +29,9 @@ #include #include +#ifdef _EVENT_HAVE_SYS_TIME_H #include +#endif #ifdef WIN32 #include #else @@ -41,7 +43,9 @@ #include #include #include +#ifdef _EVENT_HAVE_UNISTD_H #include +#endif #include #include From 8fa030c032d63871b4434333c1d1e1ff98a81052 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Thu, 26 May 2011 00:03:38 +0200 Subject: [PATCH 6/8] Make sure TINYTEST_LOCAL is defined when building tinytest.c --- test/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 01bd203f..b867501f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -54,8 +54,7 @@ regress_SOURCES += regress_iocp.c endif regress_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS) -regress_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat \ - -I$(top_srcdir)/include -I../include $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS) +regress_CPPFLAGS = $(AM_CPPFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS) regress_LDFLAGS = $(PTHREAD_CFLAGS) if OPENSSL From 3d768dc96761e283750e0f0550172d181b04fe31 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 11:04:43 +0200 Subject: [PATCH 7/8] Fix winsock2.h #include issues with MSVC Define WIN32_LEAN_AND_MEAN, so that windows.h does not bring in winsock.h which in turn makes it impossible to #include (at least with MSVC) --- test/bench.c | 1 + test/bench_cascade.c | 1 + 2 files changed, 2 insertions(+) diff --git a/test/bench.c b/test/bench.c index c92bee3b..1d25076e 100644 --- a/test/bench.c +++ b/test/bench.c @@ -41,6 +41,7 @@ #include #endif #ifdef WIN32 +#define WIN32_LEAN_AND_MEAN #include #else #include diff --git a/test/bench_cascade.c b/test/bench_cascade.c index fef174fa..908c6170 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -33,6 +33,7 @@ #include #endif #ifdef WIN32 +#define WIN32_LEAN_AND_MEAN #include #else #include From 0de87fe69c0e1e8499c083a2a02f8d547a0d11db Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 25 May 2011 15:11:01 +0200 Subject: [PATCH 8/8] Use evutil_gettimeofday instead of relying on the system gettimeofday. --- test/bench.c | 4 ++-- test/bench_cascade.c | 4 ++-- test/bench_httpclient.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/bench.c b/test/bench.c index 1d25076e..d0f831b9 100644 --- a/test/bench.c +++ b/test/bench.c @@ -107,12 +107,12 @@ run_once(void) count = 0; writes = num_writes; { int xcount = 0; - gettimeofday(&ts, NULL); + evutil_gettimeofday(&ts, NULL); do { event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK); xcount++; } while (count != fired); - gettimeofday(&te, NULL); + evutil_gettimeofday(&te, NULL); if (xcount != count) fprintf(stderr, "Xcount: %d, Rcount: %d\n", xcount, count); } diff --git a/test/bench_cascade.c b/test/bench_cascade.c index 908c6170..c25255ed 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -97,7 +97,7 @@ run_once(int num_pipes) } /* measurements includes event setup */ - gettimeofday(&ts, NULL); + evutil_gettimeofday(&ts, NULL); /* provide a default timeout for events */ evutil_timerclear(&tv_timeout); @@ -116,7 +116,7 @@ run_once(int num_pipes) event_dispatch(); - gettimeofday(&te, NULL); + evutil_gettimeofday(&te, NULL); evutil_timersub(&te, &ts, &te); for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { diff --git a/test/bench_httpclient.c b/test/bench_httpclient.c index 87103cc8..25db4a7d 100644 --- a/test/bench_httpclient.c +++ b/test/bench_httpclient.c @@ -88,7 +88,7 @@ errorcb(struct bufferevent *b, short what, void *arg) if (what & BEV_EVENT_EOF) { ++total_n_handled; total_n_bytes += ri->n_read; - gettimeofday(&now, NULL); + evutil_gettimeofday(&now, NULL); evutil_timersub(&now, &ri->started, &diff); evutil_timeradd(&diff, &total_time, &total_time); @@ -152,7 +152,7 @@ launch_request(void) ri = malloc(sizeof(*ri)); ri->n_read = 0; - gettimeofday(&ri->started, NULL); + evutil_gettimeofday(&ri->started, NULL); b = bufferevent_socket_new(base, sock, BEV_OPT_CLOSE_ON_FREE); @@ -184,11 +184,11 @@ main(int argc, char **argv) perror("launch"); } - gettimeofday(&start, NULL); + evutil_gettimeofday(&start, NULL); event_base_dispatch(base); - gettimeofday(&end, NULL); + evutil_gettimeofday(&end, NULL); evutil_timersub(&end, &start, &total); usec = total_time.tv_sec * 1000000 + total_time.tv_usec;