libevent-1.1b-mingw.diff 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. @@ -17,6 +23,7 @@
  54. *
  55. ****************************************************************************/
  56. +#ifndef HAVE_GETTIMEOFDAY
  57. int gettimeofday(struct timeval *tv, struct timezone *tz) {
  58. struct _timeb tb;
  59. @@ -28,6 +35,7 @@
  60. tv->tv_usec = ((int) tb.millitm) * 1000;
  61. return 0;
  62. }
  63. +#endif
  64. int
  65. win_read(int fd, void *buf, unsigned int length)
  66. === WIN32-Code/misc.h
  67. ==================================================================
  68. --- WIN32-Code/misc.h (revision 8794)
  69. +++ WIN32-Code/misc.h (local)
  70. @@ -1,6 +1,11 @@
  71. #ifndef MISC_H
  72. #define MISC_H
  73. +struct timezone;
  74. +struct timeval;
  75. +
  76. +#ifndef HAVE_GETTIMEOFDAY
  77. int gettimeofday(struct timeval *,struct timezone *);
  78. +#endif
  79. #endif
  80. === WIN32-Code/win32.c
  81. ==================================================================
  82. --- WIN32-Code/win32.c (revision 8794)
  83. +++ WIN32-Code/win32.c (local)
  84. @@ -60,7 +60,8 @@
  85. /* MSDN says this is required to handle SIGFPE */
  86. volatile double SIGFPE_REQ = 0.0f;
  87. -int signal_handler(int sig);
  88. +static void signal_handler(int sig);
  89. +
  90. void signal_process(void);
  91. int signal_recalc(void);
  92. @@ -205,8 +206,9 @@
  93. }
  94. int
  95. -win32_insert(struct win32op *win32op, struct event *ev)
  96. +win32_insert(void *op, struct event *ev)
  97. {
  98. + struct win32op *win32op = op;
  99. int i;
  100. if (ev->ev_events & EV_SIGNAL) {
  101. @@ -251,8 +253,9 @@
  102. }
  103. int
  104. -win32_del(struct win32op *win32op, struct event *ev)
  105. +win32_del(void *op, struct event *ev)
  106. {
  107. + struct win32op *win32op = op;
  108. int i, found;
  109. if (ev->ev_events & EV_SIGNAL)
  110. @@ -302,9 +305,10 @@
  111. */
  112. int
  113. -win32_dispatch(struct event_base *base, struct win32op *win32op,
  114. +win32_dispatch(struct event_base *base, void *op,
  115. struct timeval *tv)
  116. {
  117. + struct win32op *win32op = op;
  118. int res = 0;
  119. int i;
  120. int fd_count;
  121. @@ -366,13 +370,11 @@
  122. }
  123. -static int
  124. +static void
  125. signal_handler(int sig)
  126. {
  127. evsigcaught[sig]++;
  128. signal_caught = 1;
  129. -
  130. - return 0;
  131. }
  132. int
  133. === buffer.c
  134. ==================================================================
  135. --- buffer.c (revision 8794)
  136. +++ buffer.c (local)
  137. @@ -197,7 +197,7 @@
  138. u_char *data = EVBUFFER_DATA(buffer);
  139. size_t len = EVBUFFER_LENGTH(buffer);
  140. char *line;
  141. - u_int i;
  142. + unsigned int i;
  143. for (i = 0; i < len; i++) {
  144. if (data[i] == '\r' || data[i] == '\n')
  145. === configure.in
  146. ==================================================================
  147. --- configure.in (revision 8794)
  148. +++ configure.in (local)
  149. @@ -111,6 +111,21 @@
  150. )
  151. fi
  152. +dnl - check if the macro WIN32 is defined on this compiler.
  153. +dnl - (this is how we check for a windows version of GCC)
  154. +AC_MSG_CHECKING(for WIN32)
  155. +AC_TRY_COMPILE(,
  156. + [
  157. + #ifndef WIN32
  158. + #error
  159. + #endif
  160. + ],
  161. + bwin32=true; AC_MSG_RESULT(yes),
  162. + bwin32=false; AC_MSG_RESULT(no),
  163. +)
  164. +
  165. +AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue)
  166. +
  167. dnl Checks for typedefs, structures, and compiler characteristics.
  168. AC_C_CONST
  169. AC_C_INLINE
  170. === evbuffer.c
  171. ==================================================================
  172. --- evbuffer.c (revision 8794)
  173. +++ evbuffer.c (local)
  174. @@ -154,12 +154,20 @@
  175. if (EVBUFFER_LENGTH(bufev->output)) {
  176. res = evbuffer_write(bufev->output, fd);
  177. if (res == -1) {
  178. +#ifndef WIN32
  179. +/*todo. evbuffer uses WriteFile when WIN32 is set. WIN32 system calls do not
  180. + *set errno. thus this error checking is not portable*/
  181. if (errno == EAGAIN ||
  182. errno == EINTR ||
  183. errno == EINPROGRESS)
  184. goto reschedule;
  185. /* error case */
  186. what |= EVBUFFER_ERROR;
  187. +
  188. +#else
  189. + goto reschedule;
  190. +#endif
  191. +
  192. } else if (res == 0) {
  193. /* eof case */
  194. what |= EVBUFFER_EOF;