make it compile on windows; gettimeofday -> evutil_gettimeofday; snprintf -> evutil_snprintf

svn:r876
This commit is contained in:
Niels Provos 2008-06-25 15:46:33 +00:00
parent e0b38edc9d
commit 1efa70aba0

View File

@ -44,10 +44,10 @@
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/signal.h>
#include <assert.h>
#include <unistd.h>
#include <netdb.h>
#endif
#include <assert.h>
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
@ -61,7 +61,9 @@
#include "log.h"
#include "regress.h"
#ifndef WIN32
#include "regress.gen.h"
#endif
int pair[2];
int test_ok;
@ -179,7 +181,7 @@ timeout_cb(int fd, short event, void *arg)
struct timeval tv;
int diff;
gettimeofday(&tcalled, NULL);
evutil_gettimeofday(&tcalled, NULL);
if (evutil_timercmp(&tcalled, &tset, >))
evutil_timersub(&tcalled, &tset, &tv);
else
@ -442,7 +444,7 @@ test_simpletimeout(void)
evtimer_set(&ev, timeout_cb, NULL);
evtimer_add(&ev, &tv);
gettimeofday(&tset, NULL);
evutil_gettimeofday(&tset, NULL);
event_dispatch();
cleanup_test();
@ -760,9 +762,9 @@ test_loopexit(void)
tv.tv_sec = 1;
event_loopexit(&tv);
gettimeofday(&tv_start, NULL);
evutil_gettimeofday(&tv_start, NULL);
event_dispatch();
gettimeofday(&tv_end, NULL);
evutil_gettimeofday(&tv_end, NULL);
evutil_timersub(&tv_end, &tv_start, &tv_end);
evtimer_del(&ev);
@ -1062,7 +1064,7 @@ test_priorities(int npriorities)
struct test_pri_event one, two;
struct timeval tv;
snprintf(buf, sizeof(buf), "Testing Priorities %d: ", npriorities);
evutil_snprintf(buf, sizeof(buf), "Testing Priorities %d: ", npriorities);
setup_test(buf);
event_base_priority_init(global_base, npriorities);
@ -1327,6 +1329,7 @@ evtag_test(void)
fprintf(stdout, "OK\n");
}
#ifndef WIN32
static void
rpc_test(void)
{
@ -1352,7 +1355,7 @@ rpc_test(void)
EVTAG_ASSIGN(attack, weapon, "feather");
EVTAG_ASSIGN(attack, action, "tickle");
gettimeofday(&tv_start, NULL);
evutil_gettimeofday(&tv_start, NULL);
for (i = 0; i < 1000; ++i) {
run = EVTAG_ADD(msg, run);
if (run == NULL) {
@ -1385,7 +1388,7 @@ rpc_test(void)
exit(1);
}
gettimeofday(&tv_end, NULL);
evutil_gettimeofday(&tv_end, NULL);
evutil_timersub(&tv_end, &tv_start, &tv_end);
fprintf(stderr, "(%.1f us/add) ",
(float)tv_end.tv_sec/(float)i * 1000000.0 +
@ -1410,6 +1413,7 @@ rpc_test(void)
fprintf(stdout, "OK\n");
}
#endif
static void
test_evutil_strtoll(void)
@ -1474,7 +1478,9 @@ main (int argc, char **argv)
http_suite();
#ifndef WIN32
rpc_suite();
#endif
dns_suite();
@ -1508,9 +1514,9 @@ main (int argc, char **argv)
evtag_test();
#ifndef WIN32
rpc_test();
#ifndef WIN32
test_signal_dealloc();
test_signal_pipeloss();
test_signal_switchbase();