]> granicus.if.org Git - sudo/commitdiff
Backward ABI compatibility for even functions that use a timeval.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Sun, 26 Aug 2018 03:02:07 +0000 (21:02 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Sun, 26 Aug 2018 03:02:07 +0000 (21:02 -0600)
include/sudo_event.h
lib/util/event.c
lib/util/util.exp.in

index 20df2be48c242540ca3e92db9c33ef2c69570a06..9797d58cd65e3a98782aee6ed653527428954bf4 100644 (file)
@@ -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);
index 203c18f338bfd647d874eedec284a92cb4ce4477..cf9e4d7e674d82656098b11a51a8da967d2a017b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017 Todd C. Miller <Todd.Miller@sudo.ws>
+ * Copyright (c) 2013-2018 Todd C. Miller <Todd.Miller@sudo.ws>
  *
  * 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 <config.h>
 
 #include <sys/types.h>
+#include <sys/time.h>
 #include <stdio.h>
 #include <stdlib.h>
 #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)
index 7cf84467d0931fbe6393ec9252c44c94d47ce7b9..a12df15ba270f3994fcbb8839a2c0e43d3cdc39b 100644 (file)
@@ -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