libevent-svn-mingw.diff 4.7 KB

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