From 9626a421de2e3b4e2eed34bfdffdd0d417655c78 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 29 Apr 2008 18:11:23 +0000 Subject: [PATCH] r15341@tombo: nickm | 2008-04-29 14:09:50 -0400 Use internal implementation for evutil_timercmp() everywhere, to avoid bugs when the platform timercmp() has never heard of <= or >=. Also, replace timercmp() usage in min_heap.c with call to evutil_timercmp(). svn:r744 --- ChangeLog | 2 ++ include/event2/util.h | 4 ---- min_heap.h | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index db680364..384a2786 100644 --- a/ChangeLog +++ b/ChangeLog @@ -77,6 +77,8 @@ Changes in current version: o provide bufferevent_input and bufferevent_output without requiring knowledge of the structure o introduce bufferevent_setcb and bufferevent_setfd to allow better manipulation of bufferevents o convert evhttp_connection to use bufferevents. + o use libevent's internal timercmp on all platforms, to avoid bugs on old platforms where timercmp(a,b,<=) is buggy. + Changes in 1.4.0: o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. diff --git a/include/event2/util.h b/include/event2/util.h index 88778767..e88654c9 100644 --- a/include/event2/util.h +++ b/include/event2/util.h @@ -159,14 +159,10 @@ int evutil_make_socket_nonblocking(evutil_socket_t sock); #define evutil_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 #endif -#ifdef _EVENT_HAVE_TIMERCMP -#define evutil_timercmp(tvp, uvp, cmp) timercmp((tvp), (uvp), cmp) -#else #define evutil_timercmp(tvp, uvp, cmp) \ (((tvp)->tv_sec == (uvp)->tv_sec) ? \ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#endif #ifdef _EVENT_HAVE_TIMERISSET #define evutil_timerisset(tvp) timerisset(tvp) diff --git a/min_heap.h b/min_heap.h index e6fb6b34..ac0ea674 100644 --- a/min_heap.h +++ b/min_heap.h @@ -28,6 +28,7 @@ #define _MIN_HEAP_H_ #include "event2/event.h" +#include "event2/util.h" typedef struct min_heap { @@ -51,7 +52,7 @@ static inline void min_heap_shift_down_(min_heap_t* s, unsigned hole_i int min_heap_elem_greater(struct event *a, struct event *b) { - return timercmp(&a->ev_timeout, &b->ev_timeout, >); + return evutil_timercmp(&a->ev_timeout, &b->ev_timeout, >); } void min_heap_ctor(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; } -- 2.40.0