mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-18 00:36:49 -04:00
make it compile on windows; gettimeofday -> evutil_gettimeofday; snprintf -> evutil_snprintf
svn:r876
This commit is contained in:
parent
e0b38edc9d
commit
1efa70aba0
@ -44,10 +44,10 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -61,7 +61,9 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include "regress.h"
|
#include "regress.h"
|
||||||
|
#ifndef WIN32
|
||||||
#include "regress.gen.h"
|
#include "regress.gen.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int pair[2];
|
int pair[2];
|
||||||
int test_ok;
|
int test_ok;
|
||||||
@ -179,7 +181,7 @@ timeout_cb(int fd, short event, void *arg)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
gettimeofday(&tcalled, NULL);
|
evutil_gettimeofday(&tcalled, NULL);
|
||||||
if (evutil_timercmp(&tcalled, &tset, >))
|
if (evutil_timercmp(&tcalled, &tset, >))
|
||||||
evutil_timersub(&tcalled, &tset, &tv);
|
evutil_timersub(&tcalled, &tset, &tv);
|
||||||
else
|
else
|
||||||
@ -442,7 +444,7 @@ test_simpletimeout(void)
|
|||||||
evtimer_set(&ev, timeout_cb, NULL);
|
evtimer_set(&ev, timeout_cb, NULL);
|
||||||
evtimer_add(&ev, &tv);
|
evtimer_add(&ev, &tv);
|
||||||
|
|
||||||
gettimeofday(&tset, NULL);
|
evutil_gettimeofday(&tset, NULL);
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
cleanup_test();
|
cleanup_test();
|
||||||
@ -760,9 +762,9 @@ test_loopexit(void)
|
|||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
event_loopexit(&tv);
|
event_loopexit(&tv);
|
||||||
|
|
||||||
gettimeofday(&tv_start, NULL);
|
evutil_gettimeofday(&tv_start, NULL);
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
gettimeofday(&tv_end, NULL);
|
evutil_gettimeofday(&tv_end, NULL);
|
||||||
evutil_timersub(&tv_end, &tv_start, &tv_end);
|
evutil_timersub(&tv_end, &tv_start, &tv_end);
|
||||||
|
|
||||||
evtimer_del(&ev);
|
evtimer_del(&ev);
|
||||||
@ -1062,7 +1064,7 @@ test_priorities(int npriorities)
|
|||||||
struct test_pri_event one, two;
|
struct test_pri_event one, two;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "Testing Priorities %d: ", npriorities);
|
evutil_snprintf(buf, sizeof(buf), "Testing Priorities %d: ", npriorities);
|
||||||
setup_test(buf);
|
setup_test(buf);
|
||||||
|
|
||||||
event_base_priority_init(global_base, npriorities);
|
event_base_priority_init(global_base, npriorities);
|
||||||
@ -1327,6 +1329,7 @@ evtag_test(void)
|
|||||||
fprintf(stdout, "OK\n");
|
fprintf(stdout, "OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
static void
|
static void
|
||||||
rpc_test(void)
|
rpc_test(void)
|
||||||
{
|
{
|
||||||
@ -1352,7 +1355,7 @@ rpc_test(void)
|
|||||||
EVTAG_ASSIGN(attack, weapon, "feather");
|
EVTAG_ASSIGN(attack, weapon, "feather");
|
||||||
EVTAG_ASSIGN(attack, action, "tickle");
|
EVTAG_ASSIGN(attack, action, "tickle");
|
||||||
|
|
||||||
gettimeofday(&tv_start, NULL);
|
evutil_gettimeofday(&tv_start, NULL);
|
||||||
for (i = 0; i < 1000; ++i) {
|
for (i = 0; i < 1000; ++i) {
|
||||||
run = EVTAG_ADD(msg, run);
|
run = EVTAG_ADD(msg, run);
|
||||||
if (run == NULL) {
|
if (run == NULL) {
|
||||||
@ -1385,7 +1388,7 @@ rpc_test(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&tv_end, NULL);
|
evutil_gettimeofday(&tv_end, NULL);
|
||||||
evutil_timersub(&tv_end, &tv_start, &tv_end);
|
evutil_timersub(&tv_end, &tv_start, &tv_end);
|
||||||
fprintf(stderr, "(%.1f us/add) ",
|
fprintf(stderr, "(%.1f us/add) ",
|
||||||
(float)tv_end.tv_sec/(float)i * 1000000.0 +
|
(float)tv_end.tv_sec/(float)i * 1000000.0 +
|
||||||
@ -1410,6 +1413,7 @@ rpc_test(void)
|
|||||||
|
|
||||||
fprintf(stdout, "OK\n");
|
fprintf(stdout, "OK\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_evutil_strtoll(void)
|
test_evutil_strtoll(void)
|
||||||
@ -1474,7 +1478,9 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
http_suite();
|
http_suite();
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
rpc_suite();
|
rpc_suite();
|
||||||
|
#endif
|
||||||
|
|
||||||
dns_suite();
|
dns_suite();
|
||||||
|
|
||||||
@ -1508,9 +1514,9 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
evtag_test();
|
evtag_test();
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
rpc_test();
|
rpc_test();
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
test_signal_dealloc();
|
test_signal_dealloc();
|
||||||
test_signal_pipeloss();
|
test_signal_pipeloss();
|
||||||
test_signal_switchbase();
|
test_signal_switchbase();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user