libevent-1.1b-mingw.diff 4.6 KB

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