Permalink
Browse files

Fix 1.4 compilation on msvc, and add a couple of minimal (not-quite-r…

…ight) nmakefiles.

svn:r1534
  • Loading branch information...
Nick Mathewson
Nick Mathewson committed Nov 16, 2009
1 parent 25da067 commit f76b599d28cc72f0f4790195ab7528e711620a6a
Showing with 129 additions and 5 deletions.
  1. +48 −0 Makefile.nmake
  2. +2 −0 WIN32-Code/event-config.h
  3. +6 −1 event.h
  4. +47 −0 test/Makefile.nmake
  5. +6 −2 test/test-eof.c
  6. +7 −0 test/test-init.c
  7. +7 −0 test/test-time.c
  8. +6 −2 test/test-weof.c
View
@@ -0,0 +1,48 @@
+# WATCH OUT! This makefile is a work in progress. It is probably missing
+# tons of important things. DO NOT RELY ON IT TO BUILD A GOOD LIBEVENT.
+
+# Needed for correctness
+CFLAGS=/Iinclude /Icompat /IWIN32-Code /DWIN32 /DHAVE_CONFIG_H /I.
+
+# For optimization and warnings
+CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo
+
+# XXXX have a debug mode
+
+LIBFLAGS=/nologo
+
+
+CORE_OBJS=event.obj buffer.obj evbuffer.obj \
+ log.obj evutil.obj \
+ strlcpy.obj signal.obj win32.obj
+EXTRA_OBJS=event_tagging.obj http.obj evdns.obj evrpc.obj
+
+ALL_OBJS=$(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS)
+STATIC_LIBS=libevent_core.lib libevent_extras.lib libevent.lib
+
+
+all: static_libs tests
+
+static_libs: $(STATIC_LIBS)
+
+win32.obj: WIN32-Code\win32.c
+ $(CC) $(CFLAGS) /c WIN32-Code\win32.c
+
+libevent_core.lib: $(CORE_OBJS)
+ lib $(LIBFLAGS) $(CORE_OBJS) /out:libevent_core.lib
+
+libevent_extras.lib: $(EXTRA_OBJS)
+ lib $(LIBFLAGS) $(EXTRA_OBJS) /out:libevent_extras.lib
+
+libevent.lib: $(CORE_OBJ) $(EXTRA_OBJS)
+ lib $(LIBFLAGS) $(CORE_OBJS) $(EXTRA_OBJS) /out:libevent.lib
+
+clean:
+ del $(ALL_OBJS)
+ del $(STATIC_LIBS)
+ cd test
+ $(MAKE) /F Makefile.nmake clean
+
+tests:
+ cd test
+ $(MAKE) /F Makefile.nmake
@@ -221,6 +221,8 @@
#define _EVENT_inline __inline
#endif
+#define _EVENT___func__ __FUNCTION__
+
/* Define to `int' if <sys/types.h> does not define. */
/* #undef _EVENT_pid_t */
View
@@ -209,6 +209,7 @@ struct { \
#endif /* !TAILQ_ENTRY */
struct event_base;
+#ifndef EVENT_NO_STRUCT
struct event {
TAILQ_ENTRY (event) ev_next;
TAILQ_ENTRY (event) ev_active_next;
@@ -232,6 +233,9 @@ struct event {
int ev_res; /* result passed to event callback */
int ev_flags;
};
+#else
+struct event;
+#endif
#define EVENT_SIGNAL(ev) (int)(ev)->ev_fd
#define EVENT_FD(ev) (int)(ev)->ev_fd
@@ -747,6 +751,7 @@ struct event_watermark {
size_t high;
};
+#ifndef EVENT_NO_STRUCT
struct bufferevent {
struct event_base *ev_base;
@@ -769,7 +774,7 @@ struct bufferevent {
short enabled; /* events that are currently enabled */
};
-
+#endif
/**
Create a new bufferevent.
View
@@ -0,0 +1,47 @@
+
+CFLAGS=/I.. /I../include /I../WIN32-Code /I../compat /DWIN32 /DHAVE_CONFIG_H
+
+CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo
+
+REGRESS_OBJS=regress.obj regress_http.obj regress_dns.obj \
+ regress_rpc.obj regress.gen.obj \
+
+OTHER_OBJS=test-init.obj test-eof.obj test-weof.obj test-time.obj \
+ bench.obj bench_cascade.obj bench_http.obj bench_httpclient.obj
+
+PROGRAMS=regress.exe \
+ test-init.exe test-eof.exe test-weof.exe test-time.exe
+
+# Disabled for now:
+# bench.exe bench_cascade.exe bench_http.exe bench_httpclient.exe
+
+
+LIBS=..\libevent.lib ws2_32.lib advapi32.lib
+
+all: $(PROGRAMS)
+
+regress.exe: $(REGRESS_OBJS)
+ $(CC) $(CFLAGS) $(LIBS) $(REGRESS_OBJS)
+
+test-init.exe: test-init.obj
+ $(CC) $(CFLAGS) $(LIBS) test-init.obj
+test-eof.exe: test-eof.obj
+ $(CC) $(CFLAGS) $(LIBS) test-eof.obj
+test-weof.exe: test-weof.obj
+ $(CC) $(CFLAGS) $(LIBS) test-weof.obj
+test-time.exe: test-time.obj
+ $(CC) $(CFLAGS) $(LIBS) test-time.obj
+
+bench.exe: bench.obj
+ $(CC) $(CFLAGS) $(LIBS) bench.obj
+bench_cascade.exe: bench_cascade.obj
+ $(CC) $(CFLAGS) $(LIBS) bench_cascade.obj
+bench_http.exe: bench_http.obj
+ $(CC) $(CFLAGS) $(LIBS) bench_http.obj
+bench_httpclient.exe: bench_httpclient.obj
+ $(CC) $(CFLAGS) $(LIBS) bench_httpclient.obj
+
+clean:
+ -del $(REGRESS_OBJS)
+ -del $(OTHER_OBJS)
+ -del regress.exe
View
@@ -12,15 +12,19 @@
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include <event.h>
@@ -35,7 +39,7 @@ read_cb(int fd, short event, void *arg)
char buf[256];
int len;
- len = read(fd, buf, sizeof(buf));
+ len = recv(fd, buf, sizeof(buf), 0);
printf("%s: read %d%s\n", __func__,
len, len ? "" : " - means EOF");
@@ -64,7 +68,7 @@ main (int argc, char **argv)
return (1);
- write(pair[0], test, strlen(test)+1);
+ send(pair[0], test, strlen(test)+1, 0);
shutdown(pair[0], SHUT_WR);
/* Initalize the event library */
View
@@ -6,18 +6,25 @@
#include "config.h"
#endif
+#ifdef WIN32
+#include <winsock2.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include <event.h>
View
@@ -6,15 +6,22 @@
#include "config.h"
#endif
+#ifdef WIN32
+#include <winsock2.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include <event.h>
View
@@ -12,7 +12,9 @@
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@ -21,7 +23,9 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include <event.h>
@@ -37,15 +41,15 @@ write_cb(int fd, short event, void *arg)
const char *test = "test string";
int len;
- len = write(fd, test, strlen(test) + 1);
+ len = send(fd, test, strlen(test) + 1, 0);
printf("%s: write %d%s\n", __func__,
len, len ? "" : " - means EOF");
if (len > 0) {
if (!called)
event_add(arg, NULL);
- close(pair[0]);
+ EVUTIL_CLOSESOCKET(pair[0]);
} else if (called == 1)
test_okay = 0;

0 comments on commit f76b599

Please sign in to comment.