mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
make it compile with mingw; from Nick
svn:r235
This commit is contained in:
parent
64c76fbea4
commit
9f7d28bb81
23
Makefile.am
23
Makefile.am
@ -1,6 +1,5 @@
|
|||||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||||
|
|
||||||
SUBDIRS = . sample test
|
|
||||||
|
|
||||||
bin_SCRIPTS = event_rpcgen.py
|
bin_SCRIPTS = event_rpcgen.py
|
||||||
|
|
||||||
@ -22,14 +21,30 @@ EXTRA_DIST = acconfig.h event.h event-internal.h log.h evsignal.h event.3 \
|
|||||||
|
|
||||||
lib_LTLIBRARIES = libevent.la
|
lib_LTLIBRARIES = libevent.la
|
||||||
|
|
||||||
|
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 event_tagging.c \
|
libevent_la_SOURCES = event.c buffer.c evbuffer.c log.c event_tagging.c \
|
||||||
http.c evhttp.h http-internal.h evdns.c evdns.h
|
http.c evhttp.h http-internal.h evdns.c evdns.h $(SYS_SRC)
|
||||||
libevent_la_LIBADD = @LTLIBOBJS@
|
libevent_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS)
|
||||||
libevent_la_LDFLAGS = -release @VERSION@ -version-info 1:3:0
|
libevent_la_LDFLAGS = -release @VERSION@ -version-info 1:3:0
|
||||||
|
|
||||||
include_HEADERS = event.h evhttp.h evdns.h
|
include_HEADERS = event.h evhttp.h evdns.h
|
||||||
|
|
||||||
INCLUDES = -Icompat
|
INCLUDES = -Icompat $(SYS_INCLUDES)
|
||||||
|
|
||||||
man_MANS = event.3
|
man_MANS = event.3
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#include <time.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 *)
|
* Function: gettimeofday(struct timeval *, struct timezone *)
|
||||||
@ -17,6 +23,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
||||||
struct _timeb tb;
|
struct _timeb tb;
|
||||||
|
|
||||||
@ -28,6 +35,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
|||||||
tv->tv_usec = ((int) tb.millitm) * 1000;
|
tv->tv_usec = ((int) tb.millitm) * 1000;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
win_read(int fd, void *buf, unsigned int length)
|
win_read(int fd, void *buf, unsigned int length)
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#ifndef MISC_H
|
#ifndef MISC_H
|
||||||
#define MISC_H
|
#define MISC_H
|
||||||
|
|
||||||
|
struct timezone;
|
||||||
|
struct timeval;
|
||||||
|
|
||||||
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
int gettimeofday(struct timeval *,struct timezone *);
|
int gettimeofday(struct timeval *,struct timezone *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,7 +60,8 @@ volatile sig_atomic_t signal_caught = 0;
|
|||||||
/* MSDN says this is required to handle SIGFPE */
|
/* MSDN says this is required to handle SIGFPE */
|
||||||
volatile double SIGFPE_REQ = 0.0f;
|
volatile double SIGFPE_REQ = 0.0f;
|
||||||
|
|
||||||
int signal_handler(int sig);
|
static void signal_handler(int sig);
|
||||||
|
|
||||||
void signal_process(void);
|
void signal_process(void);
|
||||||
int signal_recalc(void);
|
int signal_recalc(void);
|
||||||
|
|
||||||
@ -207,8 +208,9 @@ win32_recalc(struct event_base *base, void *arg, int max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
win32_insert(struct win32op *win32op, struct event *ev)
|
win32_insert(void *op, struct event *ev)
|
||||||
{
|
{
|
||||||
|
struct win32op *win32op = op;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (ev->ev_events & EV_SIGNAL) {
|
if (ev->ev_events & EV_SIGNAL) {
|
||||||
@ -253,8 +255,9 @@ win32_insert(struct win32op *win32op, struct event *ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
win32_del(struct win32op *win32op, struct event *ev)
|
win32_del(void *op, struct event *ev)
|
||||||
{
|
{
|
||||||
|
struct win32op *win32op = op;
|
||||||
int i, found;
|
int i, found;
|
||||||
|
|
||||||
if (ev->ev_events & EV_SIGNAL)
|
if (ev->ev_events & EV_SIGNAL)
|
||||||
@ -304,9 +307,10 @@ fd_set_copy(struct win_fd_set *out, const struct win_fd_set *in)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
win32_dispatch(struct event_base *base, struct win32op *win32op,
|
win32_dispatch(struct event_base *base, void *op,
|
||||||
struct timeval *tv)
|
struct timeval *tv)
|
||||||
{
|
{
|
||||||
|
struct win32op *win32op = op;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int i;
|
int i;
|
||||||
int fd_count;
|
int fd_count;
|
||||||
@ -389,13 +393,11 @@ win32_dealloc(void *arg)
|
|||||||
free(win32op);
|
free(win32op);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
signal_handler(int sig)
|
signal_handler(int sig)
|
||||||
{
|
{
|
||||||
evsigcaught[sig]++;
|
evsigcaught[sig]++;
|
||||||
signal_caught = 1;
|
signal_caught = 1;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
2
buffer.c
2
buffer.c
@ -197,7 +197,7 @@ evbuffer_readline(struct evbuffer *buffer)
|
|||||||
u_char *data = EVBUFFER_DATA(buffer);
|
u_char *data = EVBUFFER_DATA(buffer);
|
||||||
size_t len = EVBUFFER_LENGTH(buffer);
|
size_t len = EVBUFFER_LENGTH(buffer);
|
||||||
char *line;
|
char *line;
|
||||||
u_int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (data[i] == '\r' || data[i] == '\n')
|
if (data[i] == '\r' || data[i] == '\n')
|
||||||
|
15
configure.in
15
configure.in
@ -111,6 +111,21 @@ if test "x$ac_cv_header_sys_time_h" = "xyes"; then
|
|||||||
)
|
)
|
||||||
fi
|
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.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
|
@ -163,12 +163,20 @@ bufferevent_writecb(int fd, short event, void *arg)
|
|||||||
if (EVBUFFER_LENGTH(bufev->output)) {
|
if (EVBUFFER_LENGTH(bufev->output)) {
|
||||||
res = evbuffer_write(bufev->output, fd);
|
res = evbuffer_write(bufev->output, fd);
|
||||||
if (res == -1) {
|
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 ||
|
if (errno == EAGAIN ||
|
||||||
errno == EINTR ||
|
errno == EINTR ||
|
||||||
errno == EINPROGRESS)
|
errno == EINPROGRESS)
|
||||||
goto reschedule;
|
goto reschedule;
|
||||||
/* error case */
|
/* error case */
|
||||||
what |= EVBUFFER_ERROR;
|
what |= EVBUFFER_ERROR;
|
||||||
|
|
||||||
|
#else
|
||||||
|
goto reschedule;
|
||||||
|
#endif
|
||||||
|
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
/* eof case */
|
/* eof case */
|
||||||
what |= EVBUFFER_EOF;
|
what |= EVBUFFER_EOF;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user