]> granicus.if.org Git - libevent/commitdiff
Remove compat/sys/_time.h
authorNick Mathewson <nickm@torproject.org>
Tue, 3 Nov 2009 19:54:56 +0000 (19:54 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 3 Nov 2009 19:54:56 +0000 (19:54 +0000)
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

14 files changed:
ChangeLog
Makefile.am
compat/sys/_time.h [deleted file]
devpoll.c
epoll.c
event.c
evmap.c
kqueue.c
log.c
poll.c
select.c
test/bench_cascade.c
test/regress.c
test/regress_http.c

index 9f2922a3039b17c11551c701c3224cc7c97dd262..e62e195ac35497779372927519eecdf09a901b9e 100644 (file)
--- 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:
index fd5179a7711a8464f33cef2d49ba578114600579..e9383edd20f0f08205b7f2bed3eee715a9fcac25 100644 (file)
@@ -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 (file)
index 8cabb0d..0000000
+++ /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 <sys/types.h>
-
-/*
- * 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_ */
index 7adc91bfa310b83ab189c040f5ef8a9c50759ace..25664fa7955e6d53493d99df91c9c100ff610943 100644 (file)
--- a/devpoll.c
+++ b/devpoll.c
@@ -31,8 +31,6 @@
 #include <sys/resource.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
-#include <sys/_time.h>
 #endif
 #include <sys/queue.h>
 #include <sys/devpoll.h>
diff --git a/epoll.c b/epoll.c
index 171feb06048d7e50d41cc40f2fd9c4e15415cedb..70e8eb3e6ce1aa8304e43280433e8626893a3690 100644 (file)
--- a/epoll.c
+++ b/epoll.c
@@ -33,8 +33,6 @@
 #include <sys/resource.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
-#include <sys/_time.h>
 #endif
 #include <sys/queue.h>
 #include <sys/epoll.h>
diff --git a/event.c b/event.c
index af202a635c7ae3354167fdce4c549a932d335aac..d59fe5bbfb320f01a75e0b952509cb9ba090a236 100644 (file)
--- a/event.c
+++ b/event.c
 #undef WIN32_LEAN_AND_MEAN
 #endif
 #include <sys/types.h>
-#ifndef WIN32
-#ifdef _EVENT_HAVE_SYS_TIME_H
+#if !defined(WIN32) && defined(_EVENT_HAVE_SYS_TIME_H)
 #include <sys/time.h>
-#else
-#include <sys/_time.h>
-#endif
 #endif
 #include <sys/queue.h>
 #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 46b79181ccda4ecc09f9b3773a1433154fe7ef13..32443472273f4e0803357ce256d05a077b998a4e 100644 (file)
--- a/evmap.c
+++ b/evmap.c
 #undef WIN32_LEAN_AND_MEAN
 #endif
 #include <sys/types.h>
-#ifdef _EVENT_HAVE_SYS_TIME_H
+#if !defined(WIN32) && defined(_EVENT_HAVE_SYS_TIME_H)
 #include <sys/time.h>
-#elif !defined(WIN32)
-#include <sys/_time.h>
 #endif
 #include <sys/queue.h>
 #include <stdio.h>
index 335208d382e94111d8ac9102268140aea4351299..cbcbb41a6ef67c89b21bbafeec8559dae051acfd 100644 (file)
--- a/kqueue.c
+++ b/kqueue.c
@@ -33,8 +33,6 @@
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
-#include <sys/_time.h>
 #endif
 #include <sys/queue.h>
 #include <sys/event.h>
diff --git a/log.c b/log.c
index 8aa1d428a219dbab606876266e0488912064ad82..4bf22d04f1b57399fb5cbb34723ed63d2ae325da 100644 (file)
--- a/log.c
+++ b/log.c
 #undef WIN32_LEAN_AND_MEAN
 #endif
 #include <sys/types.h>
-#ifdef _EVENT_HAVE_SYS_TIME_H
-#include <sys/time.h>
-#elif !defined(WIN32)
-#include <sys/_time.h>
-#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/poll.c b/poll.c
index c8879d649c1a1fee5f88223fab2d58cfe73b6310..e11699ce877b472991bfdb5fb6833f7ed8118327 100644 (file)
--- a/poll.c
+++ b/poll.c
@@ -33,8 +33,6 @@
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
-#include <sys/_time.h>
 #endif
 #include <sys/queue.h>
 #include <poll.h>
index fcc4669f83e1ecaadeff0a81181f75da3f562adc..4ec21e5791af315df6c32c5df9d6e1c770d0db35 100644 (file)
--- a/select.c
+++ b/select.c
@@ -33,8 +33,6 @@
 #include <sys/types.h>
 #ifdef _EVENT_HAVE_SYS_TIME_H
 #include <sys/time.h>
-#else
-#include <sys/_time.h>
 #endif
 #ifdef _EVENT_HAVE_SYS_SELECT_H
 #include <sys/select.h>
index d06076455d9eb642008673be4f45c96fc13de16d..59cbc50ff4024dc80772c24c58e0d9455b7b50f7 100644 (file)
@@ -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) {
index c5927b70879f6b1b5b1d2246ac56014718d45258..8a984b34b36a873dd79459d4e3adc08bddb2f598 100644 (file)
@@ -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,
index 1fb20aec00c971e9a92b894ab9e1d8c7c735834e..1ca02f0c7387d8b103cde421d6409601da7119cd 100644 (file)
@@ -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);