From 0fd0255fa4b1e60cd49324f79472657c1f1ed24f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 3 Nov 2009 19:54:56 +0000 Subject: [PATCH] Remove compat/sys/_time.h I've gone through everything that it declared to see where it was used, and it seems that we probably don't need it anywhere. Here's what it declared, and why I think we're okay dropping it. o struct timeval {} (Used all over, and we can't really get away with declaring it ourselves; we need the same definition the system uses. If we can't find struct timeval, we're pretty much sunk.) o struct timespec {} (Used in event.c, evdns.c, kqueue.c, evport.c. Of these, kqueue.c and event.c include sys/_time.h. event.c conditions its use on _EVENT_HAVE_CLOCK_GETTIME, and kqueue() only works if timespec is defined.) o TIMEVAL_TO_TIMESPEC (Used in kqueue.c, but every place with kqueue has sys/time.h) o struct timezone {} (event2/util.h has a forward declaration; only evutil.c references it and doesn't look at its contents.) o timerclear, timerisset, timercmp, timeradd, timersub (Everything now uses the evutil_timer* variants.) o ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, struct itemerval (These are only used in test/regress.c, which does not include _time.h) o CLOCK_REALTIME (Only used in evdns.c, which does not include _time.h) o TIMESPEC_TO_TIMEVAL o DST_* o timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub o struct clockinfo {} o CLOCK_VIRTUAL, CLOCK_PROF o TIMER_RELTIME, TIMER_ABSTIME (unused) svn:r1494 --- ChangeLog | 1 + Makefile.am | 2 +- compat/sys/_time.h | 163 ------------------------------------------- devpoll.c | 2 - epoll.c | 2 - event.c | 8 +-- evmap.c | 4 +- kqueue.c | 2 - log.c | 5 -- poll.c | 2 - select.c | 2 - test/bench_cascade.c | 2 +- test/regress.c | 2 +- test/regress_http.c | 16 ++--- 14 files changed, 15 insertions(+), 198 deletions(-) delete mode 100644 compat/sys/_time.h diff --git a/ChangeLog b/ChangeLog index 9f2922a3..e62e195a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,6 +36,7 @@ Changes in 2.0.3-alpha: o Replace all assert() calls with a variant that is aware of the user-provided logging and panic functions. o Add a return value to event_assign so that it can fail rather than asserting when the user gives it bad input. event_set still dies on bad input. o The event_base_new() and event_base_new_with_config() functions now never call exit() on failure. For backward "compatibility", event_init() still does, but more consistently. + o Remove compat/sys/_time.h. It interfered with system headers on HPUX, and its functionality has been subsumed by event2/util.h and util-internal.h. Changes in 2.0.2-alpha: diff --git a/Makefile.am b/Makefile.am index fd5179a7..e9383edd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,7 @@ EXTRA_DIST = \ test/Makefile.am test/Makefile.in test/bench.c test/regress.c \ test/test-eof.c test/test-weof.c test/test-time.c \ test/test-init.c test/test.sh \ - compat/sys/queue.h compat/sys/_time.h \ + compat/sys/queue.h \ evthread_win32.c \ evthread_pthread.c \ whatsnew-2.0.txt \ diff --git a/compat/sys/_time.h b/compat/sys/_time.h deleted file mode 100644 index 8cabb0d5..00000000 --- a/compat/sys/_time.h +++ /dev/null @@ -1,163 +0,0 @@ -/* $OpenBSD: time.h,v 1.11 2000/10/10 13:36:48 itojun Exp $ */ -/* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)time.h 8.2 (Berkeley) 7/10/94 - */ - -#ifndef _SYS_TIME_H_ -#define _SYS_TIME_H_ - -#include - -/* - * Structure returned by gettimeofday(2) system call, - * and used in other calls. - */ -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; - -/* - * Structure defined by POSIX.1b to be like a timeval. - */ -struct timespec { - time_t tv_sec; /* seconds */ - long tv_nsec; /* and nanoseconds */ -}; - -#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ - (ts)->tv_sec = (tv)->tv_sec; \ - (ts)->tv_nsec = (tv)->tv_usec * 1000; \ -} -#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ - (tv)->tv_sec = (ts)->tv_sec; \ - (tv)->tv_usec = (ts)->tv_nsec / 1000; \ -} - -struct timezone { - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; -#define DST_NONE 0 /* not on dst */ -#define DST_USA 1 /* USA style dst */ -#define DST_AUST 2 /* Australian style dst */ -#define DST_WET 3 /* Western European dst */ -#define DST_MET 4 /* Middle European dst */ -#define DST_EET 5 /* Eastern European dst */ -#define DST_CAN 6 /* Canada */ - -/* Operations on timevals. */ -#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 -#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) -#define timercmp(tvp, uvp, cmp) \ - (((tvp)->tv_sec == (uvp)->tv_sec) ? \ - ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ - ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#define timeradd(tvp, uvp, vvp) \ - do { \ - (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ - (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ - if ((vvp)->tv_usec >= 1000000) { \ - (vvp)->tv_sec++; \ - (vvp)->tv_usec -= 1000000; \ - } \ - } while (0) -#define timersub(tvp, uvp, vvp) \ - do { \ - (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ - (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ - if ((vvp)->tv_usec < 0) { \ - (vvp)->tv_sec--; \ - (vvp)->tv_usec += 1000000; \ - } \ - } while (0) - -/* Operations on timespecs. */ -#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0 -#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) -#define timespeccmp(tsp, usp, cmp) \ - (((tsp)->tv_sec == (usp)->tv_sec) ? \ - ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ - ((tsp)->tv_sec cmp (usp)->tv_sec)) -#define timespecadd(tsp, usp, vsp) \ - do { \ - (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ - (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ - if ((vsp)->tv_nsec >= 1000000000L) { \ - (vsp)->tv_sec++; \ - (vsp)->tv_nsec -= 1000000000L; \ - } \ - } while (0) -#define timespecsub(tsp, usp, vsp) \ - do { \ - (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ - (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ - if ((vsp)->tv_nsec < 0) { \ - (vsp)->tv_sec--; \ - (vsp)->tv_nsec += 1000000000L; \ - } \ - } while (0) - -/* - * Names of the interval timers, and structure - * defining a timer setting. - */ -#define ITIMER_REAL 0 -#define ITIMER_VIRTUAL 1 -#define ITIMER_PROF 2 - -struct itimerval { - struct timeval it_interval; /* timer interval */ - struct timeval it_value; /* current value */ -}; - -/* - * Getkerninfo clock information structure - */ -struct clockinfo { - int hz; /* clock frequency */ - int tick; /* micro-seconds per hz tick */ - int tickadj; /* clock skew rate for adjtime() */ - int stathz; /* statistics clock frequency */ - int profhz; /* profiling clock frequency */ -}; - -#define CLOCK_REALTIME 0 -#define CLOCK_VIRTUAL 1 -#define CLOCK_PROF 2 - -#define TIMER_RELTIME 0x0 /* relative timer */ -#define TIMER_ABSTIME 0x1 /* absolute timer */ - -/* --- stuff got cut here - niels --- */ - -#endif /* !_SYS_TIME_H_ */ diff --git a/devpoll.c b/devpoll.c index 7adc91bf..25664fa7 100644 --- a/devpoll.c +++ b/devpoll.c @@ -31,8 +31,6 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else -#include #endif #include #include diff --git a/epoll.c b/epoll.c index 171feb06..70e8eb3e 100644 --- a/epoll.c +++ b/epoll.c @@ -33,8 +33,6 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else -#include #endif #include #include diff --git a/event.c b/event.c index af202a63..d59fe5bb 100644 --- a/event.c +++ b/event.c @@ -35,12 +35,8 @@ #undef WIN32_LEAN_AND_MEAN #endif #include -#ifndef WIN32 -#ifdef _EVENT_HAVE_SYS_TIME_H +#if !defined(WIN32) && defined(_EVENT_HAVE_SYS_TIME_H) #include -#else -#include -#endif #endif #include #ifdef _EVENT_HAVE_SYS_SOCKET_H @@ -1072,7 +1068,7 @@ event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, shor ev->ev_closure = EV_CLOSURE_SIGNAL; } else { if (events & EV_PERSIST) { - timerclear(&ev->ev_io_timeout); + evutil_timerclear(&ev->ev_io_timeout); ev->ev_closure = EV_CLOSURE_PERSIST; } else { ev->ev_closure = EV_CLOSURE_NONE; diff --git a/evmap.c b/evmap.c index 46b79181..32443472 100644 --- a/evmap.c +++ b/evmap.c @@ -34,10 +34,8 @@ #undef WIN32_LEAN_AND_MEAN #endif #include -#ifdef _EVENT_HAVE_SYS_TIME_H +#if !defined(WIN32) && defined(_EVENT_HAVE_SYS_TIME_H) #include -#elif !defined(WIN32) -#include #endif #include #include diff --git a/kqueue.c b/kqueue.c index 335208d3..cbcbb41a 100644 --- a/kqueue.c +++ b/kqueue.c @@ -33,8 +33,6 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else -#include #endif #include #include diff --git a/log.c b/log.c index 8aa1d428..4bf22d04 100644 --- a/log.c +++ b/log.c @@ -48,11 +48,6 @@ #undef WIN32_LEAN_AND_MEAN #endif #include -#ifdef _EVENT_HAVE_SYS_TIME_H -#include -#elif !defined(WIN32) -#include -#endif #include #include #include diff --git a/poll.c b/poll.c index c8879d64..e11699ce 100644 --- a/poll.c +++ b/poll.c @@ -33,8 +33,6 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else -#include #endif #include #include diff --git a/select.c b/select.c index fcc4669f..4ec21e57 100644 --- a/select.c +++ b/select.c @@ -33,8 +33,6 @@ #include #ifdef _EVENT_HAVE_SYS_TIME_H #include -#else -#include #endif #ifdef _EVENT_HAVE_SYS_SELECT_H #include diff --git a/test/bench_cascade.c b/test/bench_cascade.c index d0607645..59cbc50f 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -97,7 +97,7 @@ run_once(int num_pipes) gettimeofday(&ts, NULL); /* provide a default timeout for events */ - timerclear(&tv_timeout); + evutil_timerclear(&tv_timeout); tv_timeout.tv_sec = 60; for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { diff --git a/test/regress.c b/test/regress.c index c5927b70..8a984b34 100644 --- a/test/regress.c +++ b/test/regress.c @@ -540,7 +540,7 @@ test_persistent_timeout(void) struct event ev; int count = 0; - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_usec = 10000; event_assign(&ev, global_base, -1, EV_TIMEOUT|EV_PERSIST, diff --git a/test/regress_http.c b/test/regress_http.c index 1fb20aec..1ca02f0c 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -352,7 +352,7 @@ http_basic_test(void) "Host: some"; bufferevent_write(bev, http_request, strlen(http_request)); - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_usec = 10000; event_once(-1, EV_TIMEOUT, http_complete_write, bev, &tv); @@ -404,7 +404,7 @@ static void http_delay_cb(struct evhttp_request *req, void *arg) { struct timeval tv; - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 0; tv.tv_usec = 200 * 1000; @@ -417,7 +417,7 @@ static void http_large_delay_cb(struct evhttp_request *req, void *arg) { struct timeval tv; - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 3; event_once(-1, EV_TIMEOUT, http_delay_reply, req, &tv); @@ -593,7 +593,7 @@ http_do_cancel(evutil_socket_t fd, short what, void *arg) { struct evhttp_request *req = arg; struct timeval tv; - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 0; tv.tv_usec = 500 * 1000; @@ -633,7 +633,7 @@ http_cancel_test(void) tt_int_op(evhttp_make_request(evcon, req, EVHTTP_REQ_GET, "/delay"), !=, -1); - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 0; tv.tv_usec = 100 * 1000; @@ -1226,7 +1226,7 @@ close_detect_done(struct evhttp_request *req, void *arg) test_ok = 1; end: - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 3; event_loopexit(&tv); } @@ -1258,7 +1258,7 @@ close_detect_cb(struct evhttp_request *req, void *arg) tt_abort_msg("Failed"); } - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 3; /* longer than the http time out */ /* launch a new request on the persistent connection in 3 seconds */ @@ -2050,7 +2050,7 @@ http_connection_retry_test(void) /* start up a web server one second after the connection tried * to send a request */ - timerclear(&tv); + evutil_timerclear(&tv); tv.tv_sec = 1; event_once(-1, EV_TIMEOUT, http_make_web_server, NULL, &tv);