mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Fix 1.4 compilation on msvc, and add a couple of minimal (not-quite-right) nmakefiles.
svn:r1534
This commit is contained in:
parent
25da0672f7
commit
f76b599d28
48
Makefile.nmake
Normal file
48
Makefile.nmake
Normal file
@ -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 */
|
||||
|
||||
|
7
event.h
7
event.h
@ -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.
|
||||
|
47
test/Makefile.nmake
Normal file
47
test/Makefile.nmake
Normal file
@ -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
|
@ -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
|
||||
@ -20,7 +22,9 @@
|
||||
#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 */
|
||||
|
@ -6,10 +6,15 @@
|
||||
#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
|
||||
@ -17,7 +22,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include <event.h>
|
||||
|
@ -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>
|
||||
|
@ -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,7 +41,7 @@ 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");
|
||||
@ -45,7 +49,7 @@ write_cb(int fd, short event, void *arg)
|
||||
if (len > 0) {
|
||||
if (!called)
|
||||
event_add(arg, NULL);
|
||||
close(pair[0]);
|
||||
EVUTIL_CLOSESOCKET(pair[0]);
|
||||
} else if (called == 1)
|
||||
test_okay = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user