mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Fix win32 compilation. Surprisingly, unit tests pass too.
svn:r1002
This commit is contained in:
parent
574d320217
commit
9935d5b01e
@ -48,7 +48,7 @@
|
||||
#include "log-internal.h"
|
||||
#include "event.h"
|
||||
#include "event-internal.h"
|
||||
#include "evmap-inernal.h"
|
||||
#include "evmap-internal.h"
|
||||
|
||||
#define XFREE(ptr) do { if (ptr) mm_free(ptr); } while(0)
|
||||
|
||||
@ -95,7 +95,7 @@ RB_PROTOTYPE(event_map, event_entry, node, compare);
|
||||
RB_GENERATE(event_map, event_entry, node, compare);
|
||||
|
||||
void *win32_init (struct event_base *);
|
||||
int win32_insert(struct event_base *, evutil_socket_t, short old short events);
|
||||
int win32_insert(struct event_base *, evutil_socket_t, short old, short events);
|
||||
int win32_del(struct event_base *, evutil_socket_t, short old, short events);
|
||||
int win32_dispatch (struct event_base *base, struct timeval *);
|
||||
void win32_dealloc (struct event_base *);
|
||||
@ -292,7 +292,7 @@ win32_del(struct event_base *base, evutil_socket_t fd, short old, short events)
|
||||
do_fd_clear(win32op, ent, 1);
|
||||
if (events & EV_WRITE)
|
||||
do_fd_clear(win32op, ent, 0);
|
||||
if ((events & (EV_WRITE|EV_READ) == (EV_WRITE|EV_READ)) {
|
||||
if ((events & (EV_WRITE|EV_READ)) == (EV_WRITE|EV_READ)) {
|
||||
RB_REMOVE(event_map, &win32op->event_root, ent);
|
||||
mm_free(ent);
|
||||
}
|
||||
@ -356,19 +356,16 @@ win32_dispatch(struct event_base *base, struct timeval *tv)
|
||||
}
|
||||
|
||||
for (i=0; i<win32op->readset_out->fd_count; ++i) {
|
||||
struct event_entry *ent;
|
||||
SOCKET s = win32op->readset_out->fd_array[i];
|
||||
evmap_io_active(base, s, EV_READ);
|
||||
}
|
||||
for (i=0; i<win32op->exset_out->fd_count; ++i) {
|
||||
struct event_entry *ent;
|
||||
SOCKET s = win32op->exset_out->fd_array[i];
|
||||
evmap_io_active(base, s, EV_READ, 1);
|
||||
evmap_io_active(base, s, EV_READ);
|
||||
}
|
||||
for (i=0; i<win32op->writeset_out->fd_count; ++i) {
|
||||
struct event_entry *ent;
|
||||
SOCKET s = win32op->writeset_out->fd_array[i];
|
||||
evmap_io_active(base, s, EV_WRITE, 1);
|
||||
evmap_io_active(base, s, EV_WRITE);
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
17
evdns.c
17
evdns.c
@ -109,6 +109,7 @@
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <io.h>
|
||||
#else
|
||||
@ -360,22 +361,6 @@ static void server_port_ready_callback(evutil_socket_t fd, short events, void *a
|
||||
|
||||
static int strtoint(const char *const str);
|
||||
|
||||
#ifdef WIN32
|
||||
static int
|
||||
inet_aton(const char *c, struct in_addr *addr)
|
||||
{
|
||||
ev_uint32_t r;
|
||||
if (strcmp(c, "255.255.255.255") == 0) {
|
||||
addr->s_addr = 0xffffffffu;
|
||||
} else {
|
||||
r = inet_addr(c);
|
||||
if (r == INADDR_NONE)
|
||||
return 0;
|
||||
addr->s_addr = r;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#define CLOSE_SOCKET(s) EVUTIL_CLOSESOCKET(s)
|
||||
|
||||
#define ISSPACE(c) isspace((int)(unsigned char)(c))
|
||||
|
1
evmap.c
1
evmap.c
@ -32,7 +32,6 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include "misc.h"
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
|
9
evutil.c
9
evutil.c
@ -30,6 +30,7 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
@ -465,14 +466,14 @@ evutil_inet_pton(int af, const char *src, void *dst)
|
||||
#else
|
||||
ev_uint32_t r;
|
||||
struct in_addr *out = dst;
|
||||
if (strcmp(c, "255.255.255.255") == 0) {
|
||||
if (strcmp(src, "255.255.255.255") == 0) {
|
||||
out->s_addr = 0xffffffffu;
|
||||
} else {
|
||||
r = inet_addr(c);
|
||||
r = inet_addr(src);
|
||||
if (r == INADDR_NONE)
|
||||
return 0;
|
||||
addr->s_addr = r;
|
||||
}
|
||||
out->s_addr = r;
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
#ifdef AF_INET6
|
||||
|
2
http.c
2
http.c
@ -108,7 +108,7 @@
|
||||
#define NI_NUMERICHOST 1
|
||||
#define NI_NUMERICSERV 2
|
||||
|
||||
int
|
||||
static int
|
||||
fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
|
||||
size_t hostlen, char *serv, size_t servlen, int flags)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ struct in6_addr {
|
||||
#endif
|
||||
|
||||
#ifndef _EVENT_HAVE_SA_FAMILY_T
|
||||
typedef int sa_family_t
|
||||
typedef int sa_family_t;
|
||||
#endif
|
||||
|
||||
#ifndef _EVENT_HAVE_STRUCT_SOCKADDR_IN6
|
||||
|
@ -27,6 +27,7 @@
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -39,7 +39,7 @@ extern "C" {
|
||||
((e) == WSAEWOULDBLOCK || \
|
||||
(e) == WSAEINTR || \
|
||||
(e) == WSAEINPROGRESS || \
|
||||
(e) == WSAEINVAL))
|
||||
(e) == WSAEINVAL)
|
||||
|
||||
#define EVUTIL_ERR_ACCEPT_RETRIABLE(e) \
|
||||
EVUTIL_ERR_RW_RETRIABLE(e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user