From: Todd C. Miller Date: Sun, 26 Aug 2018 03:02:07 +0000 (-0600) Subject: Backward ABI compatibility for even functions that use a timeval. X-Git-Tag: SUDO_1_8_25^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63f7aa8fcfb170509dd0bc33922b4cd4aba8194d;p=sudo Backward ABI compatibility for even functions that use a timeval. --- diff --git a/include/sudo_event.h b/include/sudo_event.h index 20df2be48..9797d58cd 100644 --- a/include/sudo_event.h +++ b/include/sudo_event.h @@ -124,8 +124,9 @@ __dso_public void sudo_ev_free_v1(struct sudo_event *ev); #define sudo_ev_free(_a) sudo_ev_free_v1((_a)) /* Add an event, returns 0 on success, -1 on error */ -__dso_public int sudo_ev_add_v1(struct sudo_event_base *head, struct sudo_event *ev, struct timespec *timo, bool tohead); -#define sudo_ev_add(_a, _b, _c, _d) sudo_ev_add_v1((_a), (_b), (_c), (_d)) +__dso_public int sudo_ev_add_v1(struct sudo_event_base *head, struct sudo_event *ev, struct timeval *timo, bool tohead); +__dso_public int sudo_ev_add_v2(struct sudo_event_base *head, struct sudo_event *ev, struct timespec *timo, bool tohead); +#define sudo_ev_add(_a, _b, _c, _d) sudo_ev_add_v2((_a), (_b), (_c), (_d)) /* Delete an event, returns 0 on success, -1 on error */ __dso_public int sudo_ev_del_v1(struct sudo_event_base *head, struct sudo_event *ev); @@ -140,8 +141,9 @@ __dso_public int sudo_ev_loop_v1(struct sudo_event_base *head, int flags); #define sudo_ev_loop(_a, _b) sudo_ev_loop_v1((_a), (_b)) /* Return the remaining timeout associated with an event. */ -__dso_public int sudo_ev_get_timeleft_v1(struct sudo_event *ev, struct timespec *tv); -#define sudo_ev_get_timeleft(_a, _b) sudo_ev_get_timeleft_v1((_a), (_b)) +__dso_public int sudo_ev_get_timeleft_v1(struct sudo_event *ev, struct timeval *tv); +__dso_public int sudo_ev_get_timeleft_v2(struct sudo_event *ev, struct timespec *tv); +#define sudo_ev_get_timeleft(_a, _b) sudo_ev_get_timeleft_v2((_a), (_b)) /* Cause the event loop to exit after one run through. */ __dso_public void sudo_ev_loopexit_v1(struct sudo_event_base *base); diff --git a/lib/util/event.c b/lib/util/event.c index 203c18f33..cf9e4d7e6 100644 --- a/lib/util/event.c +++ b/lib/util/event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 Todd C. Miller + * Copyright (c) 2013-2018 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -17,6 +17,7 @@ #include #include +#include #include #include #ifdef HAVE_STDBOOL_H @@ -429,6 +430,20 @@ sudo_ev_add_signal(struct sudo_event_base *base, struct sudo_event *ev, int sudo_ev_add_v1(struct sudo_event_base *base, struct sudo_event *ev, + struct timeval *timo, bool tohead) +{ + struct timespec tsbuf, *ts = NULL; + + if (timo != NULL) { + TIMEVAL_TO_TIMESPEC(timo, &tsbuf); + ts = &tsbuf; + } + + return sudo_ev_add_v2(base, ev, ts, tohead); +} + +int +sudo_ev_add_v2(struct sudo_event_base *base, struct sudo_event *ev, struct timespec *timo, bool tohead) { debug_decl(sudo_ev_add, SUDO_DEBUG_EVENT) @@ -748,7 +763,19 @@ sudo_ev_got_break_v1(struct sudo_event_base *base) } int -sudo_ev_get_timeleft_v1(struct sudo_event *ev, struct timespec *ts) +sudo_ev_get_timeleft_v1(struct sudo_event *ev, struct timeval *tv) +{ + struct timespec ts; + int ret; + + ret = sudo_ev_get_timeleft_v2(ev, &ts); + TIMESPEC_TO_TIMEVAL(tv, &ts); + + return ret; +} + +int +sudo_ev_get_timeleft_v2(struct sudo_event *ev, struct timespec *ts) { struct timespec now; debug_decl(sudo_ev_get_timeleft, SUDO_DEBUG_EVENT) diff --git a/lib/util/util.exp.in b/lib/util/util.exp.in index 7cf84467d..a12df15ba 100644 --- a/lib/util/util.exp.in +++ b/lib/util/util.exp.in @@ -50,6 +50,7 @@ sudo_dso_preload_table_v1 sudo_dso_strerror_v1 sudo_dso_unload_v1 sudo_ev_add_v1 +sudo_ev_add_v2 sudo_ev_alloc_v1 sudo_ev_base_alloc_v1 sudo_ev_base_free_v1 @@ -58,6 +59,7 @@ sudo_ev_del_v1 sudo_ev_dispatch_v1 sudo_ev_free_v1 sudo_ev_get_timeleft_v1 +sudo_ev_get_timeleft_v2 sudo_ev_got_break_v1 sudo_ev_got_exit_v1 sudo_ev_loop_v1