diff -r -u -8 -N libevent-2.0.2-alpha/CMakeLists.txt libevent-2.0.2-alpha-brodie/CMakeLists.txt
--- libevent-2.0.2-alpha/CMakeLists.txt	1970-01-01 09:00:00.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/CMakeLists.txt	2009-07-26 23:11:25.734375000 +0900
@@ -0,0 +1,66 @@
+# -----------------------------------------------------------------------------
+# Copyright (c) 2009 Cross Language Inc., All Rights Reserved.
+#
+# vendor/event2
+# -----------------------------------------------------------------------------
+cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
+
+project(event2)
+
+# Put the libaries and binaries that get built into directories at the
+# top of the build tree rather than in hard-to-find leaf directories. 
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
+SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
+SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
+
+# -----------------------------------------------------------------------------
+
+include_directories(include)
+include_directories(BEFORE WIN32-Code compat .)
+add_definitions(/DHAVE_CONFIG_H /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS)
+set(EXTRA_FILES WIN32-Code/win32.c evthread_win32.c buffer_iocp.c event_iocp.c bufferevent_async.c)
+
+add_library(event2 STATIC
+    event.c 
+    buffer.c 
+    bufferevent.c 
+    bufferevent_sock.c 
+    bufferevent_filter.c 
+    bufferevent_pair.c 
+    listener.c 
+    evmap.c
+    log.c 
+    evutil.c 
+    signal.c
+    strlcpy.c 
+    event_tagging.c 
+    http.c 
+    evdns.c 
+    evrpc.c
+    bufferevent-internal.h
+    defer-internal.h
+    evbuffer-internal.h
+    evdns.h
+    event-internal.h
+    event.h
+    evhttp.h
+    evmap-internal.h
+    evrpc-internal.h
+    evrpc.h
+    evsignal-internal.h
+    evthread-internal.h
+    evutil.h
+    ht-internal.h
+    http-internal.h
+    iocp-internal.h
+    ipv6-internal.h
+    log-internal.h
+    minheap-internal.h
+    mm-internal.h
+    strlcpy-internal.h
+    util-internal.h
+    ${EXTRA_FILES}
+    )
+
+add_subdirectory(test)
+add_subdirectory(sample)
diff -r -u -8 -N libevent-2.0.2-alpha/WIN32-Code/event-config.h libevent-2.0.2-alpha-brodie/WIN32-Code/event-config.h
--- libevent-2.0.2-alpha/WIN32-Code/event-config.h	2009-05-15 15:40:58.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/WIN32-Code/event-config.h	2009-07-26 22:49:18.421875000 +0900
@@ -329,9 +329,11 @@
 /* #undef _EVENT_size_t */
 
 /* Define to unsigned int if you dont have it */
 #define _EVENT_socklen_t unsigned int
 
 /* Define to `int' if <sys/types.h> does not define. */
 #define _EVENT_ssize_t intptr_t
 
+#define ssize_t SSIZE_T
+
 #endif
diff -r -u -8 -N libevent-2.0.2-alpha/WIN32-Code/win32.c libevent-2.0.2-alpha-brodie/WIN32-Code/win32.c
--- libevent-2.0.2-alpha/WIN32-Code/win32.c	2009-05-29 07:50:42.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/WIN32-Code/win32.c	2009-07-26 22:31:56.484375000 +0900
@@ -329,21 +329,22 @@
 		for (j=0; j<win32op->exset_out->fd_count; ++j) {
 			if (++i >= win32op->exset_out->fd_count)
 				i = 0;
 			s = win32op->exset_out->fd_array[i];
 			evmap_io_active(base, s, EV_READ);
 		}
 	}
 	if (win32op->writeset_out->fd_count) {
+        SOCKET s;
 		i = rand() % win32op->writeset_out->fd_count;
 		for (j=0; j<win32op->writeset_out->fd_count; ++j) {
 			if (++i >= win32op->writeset_out->fd_count)
 				i = 0;
-			SOCKET s = win32op->writeset_out->fd_array[i];
+			s = win32op->writeset_out->fd_array[i];
 			evmap_io_active(base, s, EV_WRITE);
 		}
 	}
 	return (0);
 }
 
 void
 win32_dealloc(struct event_base *_base)
diff -r -u -8 -N libevent-2.0.2-alpha/buffer_iocp.c libevent-2.0.2-alpha-brodie/buffer_iocp.c
--- libevent-2.0.2-alpha/buffer_iocp.c	2009-05-29 07:50:42.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/buffer_iocp.c	2009-07-26 22:43:09.000000000 +0900
@@ -37,16 +37,17 @@
 #include "event2/thread.h"
 #include "event-config.h"
 #include "util-internal.h"
 #include "evthread-internal.h"
 #include "evbuffer-internal.h"
 #include "iocp-internal.h"
 #include "mm-internal.h"
 
+#include <winsock2.h>
 #include <windows.h>
 #include <assert.h>
 #include <stdio.h>
 
 #define MAX_WSABUFS 16
 
 /** Wrapper for an OVERLAPPED that holds the necessary info to notice
     when an overlapped read or write is done on an evbuffer.
diff -r -u -8 -N libevent-2.0.2-alpha/cross_build.cmd libevent-2.0.2-alpha-brodie/cross_build.cmd
--- libevent-2.0.2-alpha/cross_build.cmd	1970-01-01 09:00:00.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/cross_build.cmd	2009-07-26 23:05:25.046875000 +0900
@@ -0,0 +1,47 @@
+REM 1. run the vcvars.bat for visual studio
+REM 2. cross_build.cmd <toolset> 
+
+set PROJECT=event2
+
+set CROSS_TOOLSET=%1
+if %CROSS_TOOLSET%.==. goto usage
+
+call cross_clean.cmd %CROSS_TOOLSET%
+
+mkdir %CROSS_TOOLSET%
+pushd %CROSS_TOOLSET%
+
+set GENERATOR=NMake Makefiles
+if %CROSS_TOOLSET%.==msvc-6.0.    set GENERATOR=Visual Studio 6
+if %CROSS_TOOLSET%.==msvc-7.0.    set GENERATOR=Visual Studio 7
+if %CROSS_TOOLSET%.==msvc-7.1.    set GENERATOR=Visual Studio 7 .NET 2003
+if %CROSS_TOOLSET%.==msvc-8.0.    set GENERATOR=Visual Studio 8 2005
+if %CROSS_TOOLSET%.==msvc-8.0-64. set GENERATOR=Visual Studio 8 2005 Win64
+if %CROSS_TOOLSET%.==msvc-9.0.    set GENERATOR=Visual Studio 9 2008
+if %CROSS_TOOLSET%.==msvc-9.0-64. set GENERATOR=Visual Studio 9 2008 Win64
+
+cmake -G "%GENERATOR%" ..
+if errorlevel 1 goto error
+
+devenv %PROJECT%.sln /build Debug
+if errorlevel 1 goto error
+
+devenv %PROJECT%.sln /build Release
+if errorlevel 1 goto error
+
+devenv %PROJECT%.sln /build MinSizeRel
+if errorlevel 1 goto error
+
+devenv %PROJECT%.sln /build RelWithDebInfo
+if errorlevel 1 goto error
+
+popd
+exit /b 0
+
+:error
+popd
+exit /b 1
+
+:usage
+echo Usage: cross_build {toolset}
+exit /b 1
diff -r -u -8 -N libevent-2.0.2-alpha/cross_clean.cmd libevent-2.0.2-alpha-brodie/cross_clean.cmd
--- libevent-2.0.2-alpha/cross_clean.cmd	1970-01-01 09:00:00.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/cross_clean.cmd	2009-07-23 14:38:48.000000000 +0900
@@ -0,0 +1,16 @@
+set CROSS_TOOLSET=%1
+if %CROSS_TOOLSET%.==. goto all
+
+:toolset
+rd /q /s %CROSS_TOOLSET%
+goto exit
+
+:all
+rd /q /s msvc-6.5
+rd /q /s msvc-7.0
+rd /q /s msvc-7.1
+rd /q /s msvc-8.0
+rd /q /s msvc-9.0
+goto exit
+
+:exit
diff -r -u -8 -N libevent-2.0.2-alpha/evdns.c libevent-2.0.2-alpha-brodie/evdns.c
--- libevent-2.0.2-alpha/evdns.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/evdns.c	2009-07-26 22:54:02.203125000 +0900
@@ -116,16 +116,17 @@
 #include "log-internal.h"
 #include "mm-internal.h"
 #include "strlcpy-internal.h"
 #include "ipv6-internal.h"
 #include "util-internal.h"
 #include "evthread-internal.h"
 #ifdef WIN32
 #include <ctype.h>
+#include <winsock2.h>
 #include <windows.h>
 #include <iphlpapi.h>
 #include <io.h>
 #else
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #endif
diff -r -u -8 -N libevent-2.0.2-alpha/event.h libevent-2.0.2-alpha-brodie/event.h
--- libevent-2.0.2-alpha/event.h	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/event.h	2009-07-26 22:41:23.593750000 +0900
@@ -174,16 +174,17 @@
 #endif
 #include <stdarg.h>
 
 /* For int types. */
 #include <evutil.h>
 
 #ifdef WIN32
 #define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 typedef unsigned char u_char;
 typedef unsigned short u_short;
 #endif
 
 #include <event2/event_struct.h>
 #include <event2/event.h>
diff -r -u -8 -N libevent-2.0.2-alpha/event_iocp.c libevent-2.0.2-alpha-brodie/event_iocp.c
--- libevent-2.0.2-alpha/event_iocp.c	2009-05-29 07:50:42.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/event_iocp.c	2009-07-26 22:43:09.000000000 +0900
@@ -19,16 +19,17 @@
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <winsock2.h>
 #include <windows.h>
 #include <process.h>
 #include <stdio.h>
 
 #include "event2/util.h"
 #include "util-internal.h"
 #include "iocp-internal.h"
 #include "log-internal.h"
diff -r -u -8 -N libevent-2.0.2-alpha/evmap.c libevent-2.0.2-alpha-brodie/evmap.c
--- libevent-2.0.2-alpha/evmap.c	2009-04-18 00:59:48.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/evmap.c	2009-07-26 22:46:58.312500000 +0900
@@ -23,24 +23,25 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #ifdef HAVE_CONFIG_H
 #include "event-config.h"
 #endif
 
 #ifdef WIN32
+#include <winsock2.h>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 #endif
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
+#elif !defined(WIN32)
 #include <sys/_time.h>
 #endif
 #include <sys/queue.h>
 #include <stdio.h>
 #include <stdlib.h>
 #ifndef WIN32
 #include <unistd.h>
 #endif
diff -r -u -8 -N libevent-2.0.2-alpha/include/event2/event_struct.h libevent-2.0.2-alpha-brodie/include/event2/event_struct.h
--- libevent-2.0.2-alpha/include/event2/event_struct.h	2009-05-29 07:50:38.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/include/event2/event_struct.h	2009-07-26 23:00:59.312500000 +0900
@@ -45,16 +45,17 @@
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 
 /* For int types. */
 #include <event2/util.h>
 
 #ifdef WIN32
+#include <winsock2.h>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 #endif
 
 #define EVLIST_TIMEOUT	0x01
 #define EVLIST_INSERTED	0x02
 #define EVLIST_SIGNAL	0x04
diff -r -u -8 -N libevent-2.0.2-alpha/log.c libevent-2.0.2-alpha-brodie/log.c
--- libevent-2.0.2-alpha/log.c	2009-02-16 04:46:54.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/log.c	2009-07-26 22:46:41.812500000 +0900
@@ -37,24 +37,25 @@
  * SUCH DAMAGE.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "event-config.h"
 #endif
 
 #ifdef WIN32
+#include <winsock2.h>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 #endif
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
+#elif !defined(WIN32)
 #include <sys/_time.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <errno.h>
 #include "event2/event.h"
diff -r -u -8 -N libevent-2.0.2-alpha/sample/CMakeLists.txt libevent-2.0.2-alpha-brodie/sample/CMakeLists.txt
--- libevent-2.0.2-alpha/sample/CMakeLists.txt	1970-01-01 09:00:00.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/sample/CMakeLists.txt	2009-07-26 23:11:25.765625000 +0900
@@ -0,0 +1,18 @@
+# -----------------------------------------------------------------------------
+# Copyright (c) 2009 Cross Language Inc., All Rights Reserved.
+#
+# vendor/event2/sample
+# -----------------------------------------------------------------------------
+
+add_definitions(/DHAVE_CONFIG_H /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS)
+
+add_executable(event-test event-test.c)
+target_link_libraries(event-test ws2_32 event2)
+
+add_executable(signal-test signal-test.c)
+target_link_libraries(signal-test ws2_32 event2)
+
+if(NOT WIN32)
+    add_executable(time-test time-test.c)
+    target_link_libraries(time-test event2)
+endif()
diff -r -u -8 -N libevent-2.0.2-alpha/sample/event-test.c libevent-2.0.2-alpha-brodie/sample/event-test.c
--- libevent-2.0.2-alpha/sample/event-test.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/sample/event-test.c	2009-07-26 22:43:09.000000000 +0900
@@ -9,16 +9,17 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #ifndef WIN32
 #include <sys/queue.h>
 #include <unistd.h>
 #include <sys/time.h>
 #else
+#include <winsock2.h>
 #include <windows.h>
 #endif
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 
diff -r -u -8 -N libevent-2.0.2-alpha/sample/signal-test.c libevent-2.0.2-alpha-brodie/sample/signal-test.c
--- libevent-2.0.2-alpha/sample/signal-test.c	2009-05-29 07:50:38.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/sample/signal-test.c	2009-07-26 22:43:08.921875000 +0900
@@ -11,16 +11,17 @@
 #endif
 
 #include <sys/stat.h>
 #ifndef WIN32
 #include <sys/queue.h>
 #include <unistd.h>
 #include <sys/time.h>
 #else
+#include <winsock2.h>
 #include <windows.h>
 #endif
 #include <signal.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
diff -r -u -8 -N libevent-2.0.2-alpha/test/CMakeLists.txt libevent-2.0.2-alpha-brodie/test/CMakeLists.txt
--- libevent-2.0.2-alpha/test/CMakeLists.txt	1970-01-01 09:00:00.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/CMakeLists.txt	2009-07-26 23:11:25.796875000 +0900
@@ -0,0 +1,57 @@
+# -----------------------------------------------------------------------------
+# Copyright (c) 2009 Cross Language Inc., All Rights Reserved.
+#
+# vendor/event2/test
+# -----------------------------------------------------------------------------
+
+if(NOT WIN32)
+    find_package(PythonInterp REQUIRED)
+
+    file(TO_NATIVE_PATH ../event_rpcgen.py EVENT_RPCGEN_PY)
+    add_custom_command(
+        DEPENDS regress.rpc ../event_rpcgen.py
+        OUTPUT  regress.gen.c regress.gen.h
+        COMMAND ${PYTHON_EXECUTABLE} ${EVENT_RPCGEN_PY} regress.rpc
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+        )
+    set(REGRESS_EXTRA regress_rpc.c regress.gen.c regress.gen.h)
+endif()
+
+add_definitions(/DHAVE_CONFIG_H /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS)
+
+add_executable(regress 
+    regress.c 
+    regress_buffer.c 
+    regress_http.c 
+    regress_dns.c 
+    regress_rpc.c 
+    regress.gen.c 
+    regress.gen.h 
+    regress_et.c 
+    regress_bufferevent.c 
+    regress_util.c 
+    tinytest.c 
+    regress_main.c 
+    regress_minheap.c 
+    regress_iocp.c
+    ${REGRESS_EXTRA}
+    )
+target_link_libraries(regress ws2_32 event2)
+
+
+if(NOT WIN32)
+    add_executable(test_init test-init.c)
+    target_link_libraries(test_init ws2_32 event2)
+        
+    add_executable(test_eof test-eof.c)
+    target_link_libraries(test_eof ws2_32 event2)
+
+    add_executable(test_weof test-weof.c)
+    target_link_libraries(test_weof ws2_32 event2)
+
+    add_executable(test_time test-time.c)
+    target_link_libraries(test_time ws2_32 event2)
+
+    add_executable(bench bench.c)
+    target_link_libraries(bench ws2_32 event2)
+endif()
diff -r -u -8 -N libevent-2.0.2-alpha/test/regress.gen.c libevent-2.0.2-alpha-brodie/test/regress.gen.c
--- libevent-2.0.2-alpha/test/regress.gen.c	2009-07-25 12:46:00.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/regress.gen.c	2009-07-26 22:50:01.718750000 +0900
@@ -1,13 +1,17 @@
 /*
  * Automatically generated from ./regress.rpc
  * by event_rpcgen.py/0.1.  DO NOT EDIT THIS FILE.
  */
 
+#ifdef WIN32
+# define __func__ __FUNCTION__
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 #include <event2/event.h>
 #include <event2/buffer.h>
 #include <event2/tag.h>
 
 
diff -r -u -8 -N libevent-2.0.2-alpha/test/regress_dns.c libevent-2.0.2-alpha-brodie/test/regress_dns.c
--- libevent-2.0.2-alpha/test/regress_dns.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/regress_dns.c	2009-07-26 22:54:50.609375000 +0900
@@ -56,16 +56,17 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 
 #include "event2/event.h"
 #include "event2/event_compat.h"
+#include <event2/util.h>
 #include "evdns.h"
 #include "log-internal.h"
 #include "regress.h"
 
 static int dns_ok = 0;
 static int dns_got_cancel = 0;
 static int dns_err = 0;
 
@@ -217,42 +218,42 @@
 {
 	int i, r;
 	const char TEST_ARPA[] = "11.11.168.192.in-addr.arpa";
 	for (i = 0; i < req->nquestions; ++i) {
 		struct in_addr ans;
 		ans.s_addr = htonl(0xc0a80b0bUL); /* 192.168.11.11 */
 		if (req->questions[i]->type == EVDNS_TYPE_A &&
 			req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-			!strcasecmp(req->questions[i]->name, "zz.example.com")) {
+			!evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) {
 			r = evdns_server_request_add_a_reply(req,
 												 req->questions[i]->name,
 												 1, &ans.s_addr, 12345);
 			if (r<0)
 				dns_ok = 0;
 		} else if (req->questions[i]->type == EVDNS_TYPE_AAAA &&
 				   req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-				   !strcasecmp(req->questions[i]->name, "zz.example.com")) {
+				   !evutil_strcasecmp(req->questions[i]->name, "zz.example.com")) {
 			char addr6[17] = "abcdefghijklmnop";
 			r = evdns_server_request_add_aaaa_reply(req,
 													req->questions[i]->name,
 												 1, addr6, 123);
 			if (r<0)
 				dns_ok = 0;
 		} else if (req->questions[i]->type == EVDNS_TYPE_PTR &&
 				   req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-				   !strcasecmp(req->questions[i]->name, TEST_ARPA)) {
+				   !evutil_strcasecmp(req->questions[i]->name, TEST_ARPA)) {
 			r = evdns_server_request_add_ptr_reply(req, NULL,
 												   req->questions[i]->name,
 												   "ZZ.EXAMPLE.COM", 54321);
 			if (r<0)
 				dns_ok = 0;
                 } else if (req->questions[i]->type == EVDNS_TYPE_A &&
 		    req->questions[i]->dns_question_class == EVDNS_CLASS_INET &&
-		    !strcasecmp(req->questions[i]->name, "drop.example.com")) {
+		    !evutil_strcasecmp(req->questions[i]->name, "drop.example.com")) {
 			if (evdns_server_request_drop(req)<0)
 				dns_ok = 0;
 			return;
 		} else {
 			fprintf(stdout, "Unexpected question %d %d \"%s\" ",
 					req->questions[i]->type,
 					req->questions[i]->dns_question_class,
 					req->questions[i]->name);
diff -r -u -8 -N libevent-2.0.2-alpha/test/regress_et.c libevent-2.0.2-alpha-brodie/test/regress_et.c
--- libevent-2.0.2-alpha/test/regress_et.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/regress_et.c	2009-07-26 22:51:01.859375000 +0900
@@ -26,25 +26,27 @@
 
 #include <event-config.h>
 
 #ifdef WIN32
 #include <winsock2.h>
 #endif
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #ifdef _EVENT_HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifndef WIN32
+#include <sys/time.h>
 #include <unistd.h>
+#endif
 #include <errno.h>
 
 #include <event2/event.h>
 #include <event2/util.h>
 
 #include "regress.h"
 
 static int was_et = 0;
diff -r -u -8 -N libevent-2.0.2-alpha/test/regress_http.c libevent-2.0.2-alpha-brodie/test/regress_http.c
--- libevent-2.0.2-alpha/test/regress_http.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/regress_http.c	2009-07-26 23:15:33.140625000 +0900
@@ -2097,17 +2097,17 @@
 	if (escaped)
 		free(escaped);
 }
 
 static void
 http_multi_line_header_test(void)
 {
 	struct bufferevent *bev= NULL;
-	int fd = -1;
+	evutil_socket_t fd = -1;
 	const char *http_start_request;
 	short port = -1;
 
 	test_ok = 0;
 
 	http = http_setup(&port, NULL);
 
 	fd = http_connect("127.0.0.1", port);
@@ -2130,17 +2130,17 @@
 
 	event_dispatch();
 
 	tt_int_op(test_ok, ==, 4);
  end:
 	if (bev)
 		bufferevent_free(bev);
 	if (fd >= 0)
-		close(fd);
+		EVUTIL_CLOSESOCKET(fd);
 	if (http)
 		evhttp_free(http);
 }
 
 static void
 http_request_bad(struct evhttp_request *req, void *arg)
 {
 	if (req != NULL) {
diff -r -u -8 -N libevent-2.0.2-alpha/test/regress_main.c libevent-2.0.2-alpha-brodie/test/regress_main.c
--- libevent-2.0.2-alpha/test/regress_main.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/regress_main.c	2009-07-26 22:49:42.015625000 +0900
@@ -23,16 +23,17 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifdef WIN32
 #include <winsock2.h>
 #include <windows.h>
+#define __func__    __FUNCTION__
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "event-config.h"
 #endif
 
 #if 0
 #include <sys/types.h>
diff -r -u -8 -N libevent-2.0.2-alpha/test/tinytest.c libevent-2.0.2-alpha-brodie/test/tinytest.c
--- libevent-2.0.2-alpha/test/tinytest.c	2009-07-25 12:42:30.000000000 +0900
+++ libevent-2.0.2-alpha-brodie/test/tinytest.c	2009-07-26 22:55:53.000000000 +0900
@@ -24,23 +24,26 @@
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
 #ifdef WIN32
+#include <winsock2.h>
 #include <windows.h>
 #else
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #endif
 
+#include <event2/util.h>
+
 #include "tinytest.h"
 #include "tinytest_macros.h"
 
 #define LONGEST_TEST_NAME 16384
 
 static int in_tinytest_main = 0; /**< true if we're in tinytest_main().*/
 static int n_ok = 0; /**< Number of tests that have passed */
 static int n_bad = 0; /**< Number of tests that have failed. */
@@ -111,17 +114,17 @@
 	if (!in_tinytest_main) {
 		printf("\nERROR.  On Windows, _testcase_run_forked must be"
 		       " called from within tinytest_main.\n");
 		abort();
 	}
 	if (opt_verbosity>0)
 		printf("[forking] ");
 
-	snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s",
+	evutil_snprintf(buffer, sizeof(buffer), "%s --RUNNING-FORKED %s %s%s",
 		 commandname, verbosity_flag, group->prefix, testcase->name);
 
 	memset(&si, 0, sizeof(si));
 	memset(&info, 0, sizeof(info));
 	si.cb = sizeof(si);
 
 	ok = CreateProcess(commandname, buffer, NULL, NULL, 0,
 			   0, NULL, NULL, &si, &info);
@@ -240,17 +243,17 @@
 	int i, j;
 	int length = LONGEST_TEST_NAME;
 	char fullname[LONGEST_TEST_NAME];
 	int found=0;
 	if (strstr(arg, ".."))
 		length = strstr(arg,"..")-arg;
 	for (i=0; groups[i].prefix; ++i) {
 		for (j=0; groups[i].cases[j].name; ++j) {
-			snprintf(fullname, sizeof(fullname), "%s%s",
+			evutil_snprintf(fullname, sizeof(fullname), "%s%s",
 				 groups[i].prefix, groups[i].cases[j].name);
 			if (!flag) /* Hack! */
 				printf("    %s\n", fullname);
 			if (!strncmp(fullname, arg, length)) {
 				groups[i].cases[j].flags |= flag;
 				++found;
 			}
 		}
