summaryrefslogtreecommitdiff
path: root/Win32Build/mingw/libevent-1.1b-mingw.diff
blob: c7cea5b3262f69bc07073608ff8563b519492364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
=== Makefile.am
==================================================================
--- Makefile.am	(revision 8794)
+++ Makefile.am	(local)
@@ -1,6 +1,5 @@
 AUTOMAKE_OPTIONS = foreign no-dependencies
 
-SUBDIRS = . sample test
 
 EXTRA_DIST = acconfig.h event.h event-internal.h log.h evsignal.h event.3 \
 	kqueue.c epoll_sub.c epoll.c select.c rtsig.c poll.c signal.c \
@@ -20,13 +19,29 @@
 
 lib_LTLIBRARIES = libevent.la
 
-libevent_la_SOURCES = event.c buffer.c evbuffer.c log.c
-libevent_la_LIBADD = @LTLIBOBJS@
+if BUILD_WIN32
+
+SUBDIRS = . sample
+SYS_LIBS = -lws2_32
+SYS_SRC = WIN32-Code/misc.c WIN32-Code/win32.c
+SYS_INCLUDES = -IWIN32-Code
+
+else
+
+SUBDIRS = . sample test
+SYS_LIBS =
+SYS_SRC =
+SYS_INCLUDES =
+
+endif
+
+libevent_la_SOURCES = event.c buffer.c evbuffer.c log.c $(SYS_SRC)
+libevent_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS)
 libevent_la_LDFLAGS = -release @VERSION@ -version-info 1:2:0
 
 include_HEADERS = event.h
 
-INCLUDES = -Icompat
+INCLUDES = -Icompat $(SYS_INCLUDES)
 
 man_MANS = event.3
 
=== WIN32-Code/misc.c
==================================================================
--- WIN32-Code/misc.c	(revision 8794)
+++ WIN32-Code/misc.c	(local)
@@ -4,6 +4,12 @@
 #include <sys/timeb.h>
 #include <time.h>
 
+#ifdef __GNUC__
+/*our prototypes for timeval and timezone are in here, just in case the above
+  headers don't have them*/
+#include "misc.h"
+#endif
+
 /****************************************************************************
  *
  * Function: gettimeofday(struct timeval *, struct timezone *)
@@ -17,6 +23,7 @@
  *
  ****************************************************************************/
 
+#ifndef HAVE_GETTIMEOFDAY
 int gettimeofday(struct timeval *tv, struct timezone *tz) {
   struct _timeb tb;
 
@@ -28,6 +35,7 @@
 	tv->tv_usec = ((int) tb.millitm) * 1000;
 	return 0;
 }
+#endif
 
 int
 win_read(int fd, void *buf, unsigned int length)
=== WIN32-Code/misc.h
==================================================================
--- WIN32-Code/misc.h	(revision 8794)
+++ WIN32-Code/misc.h	(local)
@@ -1,6 +1,11 @@
 #ifndef MISC_H
 #define MISC_H
 
+struct timezone;
+struct timeval;
+
+#ifndef HAVE_GETTIMEOFDAY
 int gettimeofday(struct timeval *,struct timezone *);
+#endif
 
 #endif
=== WIN32-Code/win32.c
==================================================================
--- WIN32-Code/win32.c	(revision 8794)
+++ WIN32-Code/win32.c	(local)
@@ -60,7 +60,8 @@
 /* MSDN says this is required to handle SIGFPE */
 volatile double SIGFPE_REQ = 0.0f;
 
-int signal_handler(int sig);
+static void signal_handler(int sig);
+
 void signal_process(void);
 int signal_recalc(void);
 
@@ -205,8 +206,9 @@
 }
 
 int
-win32_insert(struct win32op *win32op, struct event *ev)
+win32_insert(void *op, struct event *ev)
 {
+	struct win32op *win32op = op;
 	int i;
 
 	if (ev->ev_events & EV_SIGNAL) {
@@ -251,8 +253,9 @@
 }
 
 int
-win32_del(struct win32op *win32op, struct event *ev)
+win32_del(void *op, struct event *ev)
 {
+	struct win32op *win32op = op;
 	int i, found;
 
 	if (ev->ev_events & EV_SIGNAL)
@@ -302,9 +305,10 @@
 */
 
 int
-win32_dispatch(struct event_base *base, struct win32op *win32op,
+win32_dispatch(struct event_base *base, void *op,
 	       struct timeval *tv)
 {
+	struct win32op *win32op = op;
 	int res = 0;
 	int i;
 	int fd_count;
@@ -366,13 +370,11 @@
 }
 
 
-static int
+static void
 signal_handler(int sig)
 {
 	evsigcaught[sig]++;
 	signal_caught = 1;
-
-	return 0;
 }
 
 int
=== buffer.c
==================================================================
--- buffer.c	(revision 8794)
+++ buffer.c	(local)
@@ -197,7 +197,7 @@
 	u_char *data = EVBUFFER_DATA(buffer);
 	size_t len = EVBUFFER_LENGTH(buffer);
 	char *line;
-	u_int i;
+	unsigned int i;
 
 	for (i = 0; i < len; i++) {
 		if (data[i] == '\r' || data[i] == '\n')
=== configure.in
==================================================================
--- configure.in	(revision 8794)
+++ configure.in	(local)
@@ -111,6 +111,21 @@
 )
 fi
 
+dnl - check if the macro WIN32 is defined on this compiler.
+dnl - (this is how we check for a windows version of GCC)
+AC_MSG_CHECKING(for WIN32)
+AC_TRY_COMPILE(,
+	[
+	#ifndef WIN32
+	#error
+	#endif
+	],
+	bwin32=true; AC_MSG_RESULT(yes),
+	bwin32=false; AC_MSG_RESULT(no),
+)
+
+AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue)
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
=== evbuffer.c
==================================================================
--- evbuffer.c	(revision 8794)
+++ evbuffer.c	(local)
@@ -154,12 +154,20 @@
 	if (EVBUFFER_LENGTH(bufev->output)) {
 	    res = evbuffer_write(bufev->output, fd);
 	    if (res == -1) {
+#ifndef WIN32
+/*todo. evbuffer uses WriteFile when WIN32 is set. WIN32 system calls do not
+ *set errno. thus this error checking is not portable*/
 		    if (errno == EAGAIN ||
 			errno == EINTR ||
 			errno == EINPROGRESS)
 			    goto reschedule;
 		    /* error case */
 		    what |= EVBUFFER_ERROR;
+
+#else
+				goto reschedule;
+#endif
+
 	    } else if (res == 0) {
 		    /* eof case */
 		    what |= EVBUFFER_EOF;