Hi, I want to submit a more complete patch for VC6.
This one makes all elements of the code compilable and this code is being used on a production-level project at work. The patch is in attachment. Compiles and works under VC6. * signal_test works. * timer_test works. * event_test fails due to the reason that win32 select() can't work on anything but network sockets. Most importantly, my code that runs perfectly well on unix (linux & freebsd) now runs on windows with little modification. But: * Didn't try to run any other tests since there are no project files for them. * Didn't test how mingw32 copes with these changes either. The main changes are: * INPUT and OUTPUT are defined in platform SDK, so I had to redefine them as EVRPC_INPUT and EVRPC_OUTPUT. * uint64_t on MSVC must be defined as unsigned __int64 * int64_t on MSVC is to be defined as signed __int64 * MSVC6 doesn't know about __func__ and the #ifdefs weren't guarding against them good enough. * winsock2.h sometimes was included after windows.h, that lead to compiler errors in libevent. * select.c can be painlessly excluded from compilation in win32, but I still fixed it's compilation. * Winsock library needs to be initialized and freed explicitly on win32. * http.c was using sockaddr_storage. There isn't one in MSVC. Using sockaddr is good enough for MSVC. * There are tons of compiler warnings regarding "do {} while(0);" * I took the liberty to add #pragma to the WIN32-section of the event.h so that there's no need to put ws2_32 library into the linker explicitly. * There's no NFDBITS in msvc. * vsnprintf() is _vsnprintf() for some weird reason on win32. * I've had to bump tv->tv_usec to 1000 to prevent eating 100% of the cpu core in win32 dispatch when using timers with events each 10ms or so. * Also I've provided a gettimeofday() wrapper that uses timeGetTime() instead of much slower _ftime(). Also, I would like to ask the maintainer of the project to change svn:eol-style property of .dsw and .dsp files on SVN repository toto CRLF, since project loader handles these files properly only when line endings are in windows style. -- - Eugene 'HMage' Bujak.
diff -ur libevent-1.4.3-stable/WIN32-Code/config.h libevent-1.4.3-stable-win32/WIN32-Code/config.h --- libevent-1.4.3-stable/WIN32-Code/config.h Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Code/config.h Wed Apr 23 17:31:03 2008 @@ -205,8 +205,8 @@ /* Version number of package */ #define VERSION "1.3.99-trunk" -/* Define to appropriate substitue if compiler doesnt have __func__ */ -#if defined(_MSC_VER) && _MSC_VER < 1300 +/* Define to appropriate substitute if compiler doesn't have __func__ */ +#ifdef _MSC_VER #define __func__ "??" #else #define __func__ __FUNCTION__ diff -ur libevent-1.4.3-stable/WIN32-Code/misc.c libevent-1.4.3-stable-win32/WIN32-Code/misc.c --- libevent-1.4.3-stable/WIN32-Code/misc.c Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Code/misc.c Wed Apr 23 17:31:03 2008 @@ -1,9 +1,14 @@ #include <stdio.h> #include <string.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #include <sys/timeb.h> #include <time.h> +#ifdef _MSC_VER +#pragma comment(lib,"winmm") +#endif + #ifdef __GNUC__ /*our prototypes for timeval and timezone are in here, just in case the above headers don't have them*/ @@ -16,7 +21,7 @@ * * Purpose: Get current time of day. * - * Arguments: tv => Place to store the curent time of day. + * Arguments: tv => Place to store the current time of day. * tz => Ignored. * * Returns: 0 => Success. @@ -24,6 +29,7 @@ ****************************************************************************/ #ifndef HAVE_GETTIMEOFDAY +#ifndef _WIN32 int gettimeofday(struct timeval *tv, struct timezone *tz) { struct _timeb tb; @@ -35,6 +41,21 @@ tv->tv_usec = ((int) tb.millitm) * 1000; return 0; } +#else +struct timezone; +int gettimeofday(struct timeval *tv, struct timezone *tz) { + DWORD ms; + tz; + if(tv == NULL) + return -1; + + ms = timeGetTime(); + tv->tv_sec = ms / 1000;//(long)floor(ms * 0.001); + tv->tv_usec = (ms - (tv->tv_sec*1000))*1000; + + return 0; +} +#endif #endif #if 0 diff -ur libevent-1.4.3-stable/WIN32-Code/win32.c libevent-1.4.3-stable-win32/WIN32-Code/win32.c --- libevent-1.4.3-stable/WIN32-Code/win32.c Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Code/win32.c Wed Apr 23 17:32:04 2008 @@ -32,7 +32,7 @@ #include "../config.h" #endif -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #include <sys/types.h> #include <sys/queue.h> @@ -234,6 +234,27 @@ { struct win32op *winop; size_t size; + +#ifdef _WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int retval; + + wVersionRequested = MAKEWORD( 2, 2 ); + + retval = WSAStartup( wVersionRequested, &wsaData ); + if (retval != 0) { + event_err(1, "Couldn't initialize WinSock library.\n"); + return NULL; + } + + if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { + event_err(1, "WinSock library is not acceptable version.\n"); + return NULL; + } + +#endif + if (!(winop = calloc(1, sizeof(struct win32op)))) return NULL; winop->fd_setsz = NEVENT; @@ -360,11 +381,17 @@ if (!fd_count) { /* Windows doesn't like you to call select() with no sockets */ - Sleep(timeval_to_ms(tv)); + int sleep_ms = timeval_to_ms(tv); + if (sleep_ms <= 0) sleep_ms = 1; + Sleep(sleep_ms); evsignal_process(base); return (0); } + if ((tv) && (tv->tv_usec == 0) && (tv->tv_sec == 0)) { + tv->tv_usec = 1000; + } + res = select(fd_count, (struct fd_set*)win32op->readset_out, (struct fd_set*)win32op->writeset_out, @@ -423,6 +450,8 @@ if (win32op->exset_out) free(win32op->exset_out); /* XXXXX free the tree. */ + + WSACleanup(); memset(win32op, 0, sizeof(win32op)); free(win32op); diff -ur libevent-1.4.3-stable/WIN32-Prj/event_test/event_test.dsp libevent-1.4.3-stable-win32/WIN32-Prj/event_test/event_test.dsp --- libevent-1.4.3-stable/WIN32-Prj/event_test/event_test.dsp Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Prj/event_test/event_test.dsp Wed Apr 23 17:31:03 2008 @@ -39,6 +39,7 @@ # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -49,7 +50,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "event_test - Win32 Debug" @@ -62,6 +63,7 @@ # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c @@ -72,7 +74,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff -ur libevent-1.4.3-stable/WIN32-Prj/libevent.dsp libevent-1.4.3-stable-win32/WIN32-Prj/libevent.dsp --- libevent-1.4.3-stable/WIN32-Prj/libevent.dsp Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Prj/libevent.dsp Wed Apr 23 17:31:03 2008 @@ -41,7 +41,7 @@ # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "..\\" /I "..\WIN32-Code" /I "..\compat" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\\" /I "..\WIN32-Code" /I "..\compat" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -64,7 +64,7 @@ # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\\" /I "..\WIN32-Code" /I "..\compat" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\\" /I "..\WIN32-Code" /I "..\compat" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -85,7 +85,11 @@ # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\log.c +SOURCE=..\buffer.c +# End Source File +# Begin Source File + +SOURCE=..\evbuffer.c # End Source File # Begin Source File @@ -93,10 +97,38 @@ # End Source File # Begin Source File +SOURCE=..\event_tagging.c +# End Source File +# Begin Source File + +SOURCE=..\evrpc.c +# End Source File +# Begin Source File + +SOURCE=..\evutil.c +# End Source File +# Begin Source File + +SOURCE=..\log.c +# End Source File +# Begin Source File + SOURCE="..\WIN32-Code\misc.c" # End Source File # Begin Source File +SOURCE=..\select.c +# End Source File +# Begin Source File + +SOURCE=..\signal.c +# End Source File +# Begin Source File + +SOURCE=..\strlcpy.c +# End Source File +# Begin Source File + SOURCE="..\WIN32-Code\win32.c" # End Source File # End Group @@ -117,11 +149,59 @@ # End Source File # Begin Source File +SOURCE=..\evdns.h +# End Source File +# Begin Source File + +SOURCE="..\event-config.h" +# End Source File +# Begin Source File + +SOURCE="..\event-internal.h" +# End Source File +# Begin Source File + SOURCE=..\event.h # End Source File # Begin Source File +SOURCE=..\evhttp.h +# End Source File +# Begin Source File + +SOURCE="..\evrpc-internal.h" +# End Source File +# Begin Source File + +SOURCE=..\evrpc.h +# End Source File +# Begin Source File + +SOURCE=..\evsignal.h +# End Source File +# Begin Source File + +SOURCE=..\evutil.h +# End Source File +# Begin Source File + +SOURCE="..\http-internal.h" +# End Source File +# Begin Source File + +SOURCE=..\log.h +# End Source File +# Begin Source File + +SOURCE=..\min_heap.h +# End Source File +# Begin Source File + SOURCE="..\WIN32-Code\misc.h" +# End Source File +# Begin Source File + +SOURCE="..\strlcpy-internal.h" # End Source File # End Group # End Target diff -ur libevent-1.4.3-stable/WIN32-Prj/signal_test/signal_test.dsp libevent-1.4.3-stable-win32/WIN32-Prj/signal_test/signal_test.dsp --- libevent-1.4.3-stable/WIN32-Prj/signal_test/signal_test.dsp Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Prj/signal_test/signal_test.dsp Wed Apr 23 17:31:03 2008 @@ -39,17 +39,18 @@ # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "signal_test - Win32 Debug" @@ -62,17 +63,18 @@ # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff -ur libevent-1.4.3-stable/WIN32-Prj/time_test/time_test.dsp libevent-1.4.3-stable-win32/WIN32-Prj/time_test/time_test.dsp --- libevent-1.4.3-stable/WIN32-Prj/time_test/time_test.dsp Wed Apr 23 17:31:16 2008 +++ libevent-1.4.3-stable-win32/WIN32-Prj/time_test/time_test.dsp Wed Apr 23 17:31:03 2008 @@ -39,17 +39,18 @@ # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "time_test - Win32 Debug" @@ -62,17 +63,18 @@ # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff -ur libevent-1.4.3-stable/buffer.c libevent-1.4.3-stable-win32/buffer.c --- libevent-1.4.3-stable/buffer.c Wed Apr 23 17:31:13 2008 +++ libevent-1.4.3-stable-win32/buffer.c Wed Apr 23 17:31:00 2008 @@ -30,7 +30,7 @@ #endif #ifdef WIN32 -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif @@ -155,7 +155,7 @@ va_copy(aq, ap); #ifdef WIN32 - sz = vsnprintf(buffer, space - 1, fmt, aq); + sz = _vsnprintf(buffer, space - 1, fmt, aq); buffer[space - 1] = '\0'; #else sz = vsnprintf(buffer, space, fmt, aq); diff -ur libevent-1.4.3-stable/compat/sys/_time.h libevent-1.4.3-stable-win32/compat/sys/_time.h --- libevent-1.4.3-stable/compat/sys/_time.h Wed Apr 23 17:31:13 2008 +++ libevent-1.4.3-stable-win32/compat/sys/_time.h Wed Apr 23 17:31:01 2008 @@ -41,10 +41,12 @@ * Structure returned by gettimeofday(2) system call, * and used in other calls. */ +#ifndef _MSC_VER // MSVC defines this in winsock2.h struct timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; +#endif /* * Structure defined by POSIX.1b to be like a timeval. @@ -78,10 +80,12 @@ /* Operations on timevals. */ #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#ifndef _MSC_VER // MSVC defines this in winsock2.h #define timercmp(tvp, uvp, cmp) \ (((tvp)->tv_sec == (uvp)->tv_sec) ? \ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#endif #define timeradd(tvp, uvp, vvp) \ do { \ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ diff -ur libevent-1.4.3-stable/evdns.c libevent-1.4.3-stable-win32/evdns.c --- libevent-1.4.3-stable/evdns.c Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/evdns.c Wed Apr 23 17:31:01 2008 @@ -105,7 +105,7 @@ #include "evutil.h" #include "log.h" #ifdef WIN32 -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #include <iphlpapi.h> #include <io.h> diff -ur libevent-1.4.3-stable/event-config.h libevent-1.4.3-stable-win32/event-config.h --- libevent-1.4.3-stable/event-config.h Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/event-config.h Wed Apr 23 17:31:01 2008 @@ -51,7 +51,9 @@ #define _EVENT_HAVE_INET_NTOP 1 /* Define to 1 if you have the <inttypes.h> header file. */ +#ifndef _MSC_VER // MSVC doesn't have that #define _EVENT_HAVE_INTTYPES_H 1 +#endif /* Define to 1 if you have the `kqueue' function. */ #define _EVENT_HAVE_KQUEUE 1 @@ -105,7 +107,9 @@ #define _EVENT_HAVE_STDARG_H 1 /* Define to 1 if you have the <stdint.h> header file. */ +#ifndef _MSC_VER // MSVC doesn't have that #define _EVENT_HAVE_STDINT_H 1 +#endif /* Define to 1 if you have the <stdlib.h> header file. */ #define _EVENT_HAVE_STDLIB_H 1 @@ -159,7 +163,9 @@ #define _EVENT_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ +#ifndef _MSC_VER // MSVC doesn't have that #define _EVENT_HAVE_SYS_TIME_H 1 +#endif /* Define to 1 if you have the <sys/types.h> header file. */ #define _EVENT_HAVE_SYS_TYPES_H 1 @@ -183,10 +189,14 @@ #define _EVENT_HAVE_UINT16_T 1 /* Define to 1 if the system has the type `uint32_t'. */ +#ifndef _MSC_VER // MSVC doesn't have that #define _EVENT_HAVE_UINT32_T 1 +#endif /* Define to 1 if the system has the type `uint64_t'. */ +#ifndef _MSC_VER // MSVC doesn't have that #define _EVENT_HAVE_UINT64_T 1 +#endif /* Define to 1 if the system has the type `uint8_t'. */ #define _EVENT_HAVE_UINT8_T 1 diff -ur libevent-1.4.3-stable/event-internal.h libevent-1.4.3-stable-win32/event-internal.h --- libevent-1.4.3-stable/event-internal.h Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/event-internal.h Wed Apr 23 17:31:01 2008 @@ -31,6 +31,13 @@ extern "C" { #endif +#ifdef _WIN32 // MSVC doesn't have that +#ifndef NFDBITS +typedef long int fd_mask; +#define NFDBITS (8 * sizeof(fd_mask)) +#endif +#endif + #include "config.h" #include "min_heap.h" #include "evsignal.h" diff -ur libevent-1.4.3-stable/event.c libevent-1.4.3-stable-win32/event.c --- libevent-1.4.3-stable/event.c Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/event.c Wed Apr 23 17:31:01 2008 @@ -30,6 +30,7 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #undef WIN32_LEAN_AND_MEAN #include "misc.h" diff -ur libevent-1.4.3-stable/event.h libevent-1.4.3-stable-win32/event.h --- libevent-1.4.3-stable/event.h Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/event.h Wed Apr 23 17:31:01 2008 @@ -176,7 +176,9 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> +#pragma comment(lib,"ws2_32") // automatically link ws2_32 library on Win32 #undef WIN32_LEAN_AND_MEAN typedef unsigned char u_char; typedef unsigned short u_short; diff -ur libevent-1.4.3-stable/event_tagging.c libevent-1.4.3-stable-win32/event_tagging.c --- libevent-1.4.3-stable/event_tagging.c Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/event_tagging.c Wed Apr 23 17:31:01 2008 @@ -38,7 +38,7 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #undef WIN32_LEAN_AND_MEAN #else diff -ur libevent-1.4.3-stable/evhttp.h libevent-1.4.3-stable-win32/evhttp.h --- libevent-1.4.3-stable/evhttp.h Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/evhttp.h Wed Apr 23 17:31:01 2008 @@ -35,8 +35,8 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> -#include <winsock2.h> #undef WIN32_LEAN_AND_MEAN #endif diff -ur libevent-1.4.3-stable/evrpc.c libevent-1.4.3-stable-win32/evrpc.c --- libevent-1.4.3-stable/evrpc.c Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/evrpc.c Wed Apr 23 17:31:01 2008 @@ -30,8 +30,8 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> -#include <winsock2.h> #undef WIN32_LEAN_AND_MEAN #include "misc.h" #endif @@ -89,10 +89,10 @@ assert(evrpc_unregister_rpc(base, rpc->uri)); } while ((hook = TAILQ_FIRST(&base->input_hooks)) != NULL) { - assert(evrpc_remove_hook(base, INPUT, hook)); + assert(evrpc_remove_hook(base, EVRPC_INPUT, hook)); } while ((hook = TAILQ_FIRST(&base->output_hooks)) != NULL) { - assert(evrpc_remove_hook(base, OUTPUT, hook)); + assert(evrpc_remove_hook(base, EVRPC_OUTPUT, hook)); } free(base); } @@ -107,14 +107,14 @@ struct evrpc_hook_list *head = NULL; struct evrpc_hook *hook = NULL; switch (hook_type) { - case INPUT: + case EVRPC_INPUT: head = &base->in_hooks; break; - case OUTPUT: + case EVRPC_OUTPUT: head = &base->out_hooks; break; default: - assert(hook_type == INPUT || hook_type == OUTPUT); + assert(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT); } hook = calloc(1, sizeof(struct evrpc_hook)); @@ -152,14 +152,14 @@ struct _evrpc_hooks *base = vbase; struct evrpc_hook_list *head = NULL; switch (hook_type) { - case INPUT: + case EVRPC_INPUT: head = &base->in_hooks; break; - case OUTPUT: + case EVRPC_OUTPUT: head = &base->out_hooks; break; default: - assert(hook_type == INPUT || hook_type == OUTPUT); + assert(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT); } return (evrpc_remove_hook_internal(head, handle)); @@ -425,11 +425,11 @@ } while ((hook = TAILQ_FIRST(&pool->input_hooks)) != NULL) { - assert(evrpc_remove_hook(pool, INPUT, hook)); + assert(evrpc_remove_hook(pool, EVRPC_INPUT, hook)); } while ((hook = TAILQ_FIRST(&pool->output_hooks)) != NULL) { - assert(evrpc_remove_hook(pool, OUTPUT, hook)); + assert(evrpc_remove_hook(pool, EVRPC_OUTPUT, hook)); } free(pool); diff -ur libevent-1.4.3-stable/evrpc.h libevent-1.4.3-stable-win32/evrpc.h --- libevent-1.4.3-stable/evrpc.h Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/evrpc.h Wed Apr 23 17:31:01 2008 @@ -436,8 +436,8 @@ */ enum EVRPC_HOOK_TYPE { - INPUT, /**< apply the function to an input hook */ - OUTPUT /**< apply the function to an output hook */ + EVRPC_INPUT, /**< apply the function to an input hook */ + EVRPC_OUTPUT /**< apply the function to an output hook */ }; /** adds a processing hook to either an rpc base or rpc pool diff -ur libevent-1.4.3-stable/evutil.c libevent-1.4.3-stable-win32/evutil.c --- libevent-1.4.3-stable/evutil.c Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/evutil.c Wed Apr 23 17:31:01 2008 @@ -30,9 +30,10 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> +#include <stdlib.h> // for _atoi64() #undef WIN32_LEAN_AND_MEAN -#include <winsock2.h> #include "misc.h" #endif diff -ur libevent-1.4.3-stable/evutil.h libevent-1.4.3-stable-win32/evutil.h --- libevent-1.4.3-stable/evutil.h Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/evutil.h Wed Apr 23 17:31:01 2008 @@ -55,8 +55,8 @@ #define ev_uint64_t uint64_t #define ev_int64_t int64_t #elif defined(WIN32) -#define ev_uint64_t __uint64_t -#define ev_int64_t __int64_t +#define ev_uint64_t unsigned __int64 +#define ev_int64_t signed __int64 #elif _EVENT_SIZEOF_LONG_LONG == 8 #define ev_uint64_t unsigned long long #define ev_int64_t long long diff -ur libevent-1.4.3-stable/http.c libevent-1.4.3-stable-win32/http.c --- libevent-1.4.3-stable/http.c Wed Apr 23 17:31:14 2008 +++ libevent-1.4.3-stable-win32/http.c Wed Apr 23 17:31:02 2008 @@ -1982,7 +1982,12 @@ accept_socket(int fd, short what, void *arg) { struct evhttp *http = arg; +#ifndef _MSC_VER struct sockaddr_storage ss; +#else + // MSVC doesn't have sockaddr_storage + struct sockaddr ss; +#endif socklen_t addrlen = sizeof(ss); int nfd; diff -ur libevent-1.4.3-stable/log.c libevent-1.4.3-stable-win32/log.c --- libevent-1.4.3-stable/log.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/log.c Wed Apr 23 17:31:02 2008 @@ -43,6 +43,7 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #undef WIN32_LEAN_AND_MEAN #include "misc.h" diff -ur libevent-1.4.3-stable/sample/event-test.c libevent-1.4.3-stable-win32/sample/event-test.c --- libevent-1.4.3-stable/sample/event-test.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/sample/event-test.c Wed Apr 23 17:31:02 2008 @@ -14,6 +14,7 @@ #include <unistd.h> #include <sys/time.h> #else +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif #include <fcntl.h> diff -ur libevent-1.4.3-stable/sample/signal-test.c libevent-1.4.3-stable-win32/sample/signal-test.c --- libevent-1.4.3-stable/sample/signal-test.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/sample/signal-test.c Wed Apr 23 17:31:02 2008 @@ -15,6 +15,7 @@ #include <unistd.h> #include <sys/time.h> #else +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif #include <signal.h> @@ -33,7 +34,7 @@ { struct event *signal = arg; - printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal)); + printf("%s: got signal %d\n", "signal_cb", EVENT_SIGNAL(signal)); if (called >= 2) event_del(signal); diff -ur libevent-1.4.3-stable/sample/time-test.c libevent-1.4.3-stable-win32/sample/time-test.c --- libevent-1.4.3-stable/sample/time-test.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/sample/time-test.c Wed Apr 23 17:31:02 2008 @@ -36,7 +36,7 @@ struct event *timeout = arg; int newtime = time(NULL); - printf("%s: called at %d: %d\n", __func__, newtime, + printf("%s: called at %d: %d\n", "timeout_cb", newtime, newtime - lasttime); lasttime = newtime; @@ -51,7 +51,7 @@ struct event timeout; struct timeval tv; - /* Initalize the event library */ + /* Initialize the event library */ event_init(); /* Initalize one event */ diff -ur libevent-1.4.3-stable/select.c libevent-1.4.3-stable-win32/select.c --- libevent-1.4.3-stable/select.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/select.c Wed Apr 23 17:31:02 2008 @@ -30,6 +30,12 @@ #include "config.h" #endif +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <winsock2.h> +#include <windows.h> +#endif // _WIN32 + #include <sys/types.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> @@ -44,7 +50,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifndef _MSC_VER // MSVC doesn't have this #include <unistd.h> +#endif #include <errno.h> #ifdef CHECK_INVARIANTS #include <assert.h> diff -ur libevent-1.4.3-stable/signal.c libevent-1.4.3-stable-win32/signal.c --- libevent-1.4.3-stable/signal.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/signal.c Wed Apr 23 17:31:02 2008 @@ -32,8 +32,8 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> -#include <winsock2.h> #undef WIN32_LEAN_AND_MEAN #endif #include <sys/types.h> diff -ur libevent-1.4.3-stable/test/bench.c libevent-1.4.3-stable-win32/test/bench.c --- libevent-1.4.3-stable/test/bench.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/test/bench.c Wed Apr 23 17:31:02 2008 @@ -41,6 +41,7 @@ #include <sys/stat.h> #include <sys/time.h> #ifdef WIN32 +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #else #include <sys/socket.h> diff -ur libevent-1.4.3-stable/test/regress.c libevent-1.4.3-stable-win32/test/regress.c --- libevent-1.4.3-stable/test/regress.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/test/regress.c Wed Apr 23 17:31:02 2008 @@ -26,7 +26,7 @@ */ #ifdef WIN32 -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif diff -ur libevent-1.4.3-stable/test/regress_dns.c libevent-1.4.3-stable-win32/test/regress_dns.c --- libevent-1.4.3-stable/test/regress_dns.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/test/regress_dns.c Wed Apr 23 17:31:02 2008 @@ -26,7 +26,7 @@ */ #ifdef WIN32 -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif diff -ur libevent-1.4.3-stable/test/regress_http.c libevent-1.4.3-stable-win32/test/regress_http.c --- libevent-1.4.3-stable/test/regress_http.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/test/regress_http.c Wed Apr 23 17:31:02 2008 @@ -26,7 +26,7 @@ */ #ifdef WIN32 -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif diff -ur libevent-1.4.3-stable/test/regress_rpc.c libevent-1.4.3-stable-win32/test/regress_rpc.c --- libevent-1.4.3-stable/test/regress_rpc.c Wed Apr 23 17:31:15 2008 +++ libevent-1.4.3-stable-win32/test/regress_rpc.c Wed Apr 23 17:31:02 2008 @@ -26,7 +26,7 @@ */ #ifdef WIN32 -#include <winsock2.h> +#include <winsock2.h> // winsock2.h must be before windows.h to have any effect #include <windows.h> #endif @@ -450,14 +450,14 @@ need_input_hook = 1; need_output_hook = 1; - assert(evrpc_add_hook(base, INPUT, rpc_hook_add_header, (void*)"input") + assert(evrpc_add_hook(base, EVRPC_INPUT, rpc_hook_add_header, (void*)"input") != NULL); - assert(evrpc_add_hook(base, OUTPUT, rpc_hook_add_header, (void*)"output") + assert(evrpc_add_hook(base, EVRPC_OUTPUT, rpc_hook_add_header, (void*)"output") != NULL); pool = rpc_pool_with_connection(port); - assert(evrpc_add_hook(pool, INPUT, rpc_hook_remove_header, (void*)"output")); + assert(evrpc_add_hook(pool, EVRPC_INPUT, rpc_hook_remove_header, (void*)"output")); /* set up the basic message */ msg = msg_new();
_______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users