changeset 4941:384a97a92e86 draft

eloop: header is now the single source of truth for SEC_PER_SEC Saves duplication
author Roy Marples <roy@marples.name>
date Wed, 08 Jan 2020 00:43:11 +0000
parents a0d2d9dd08f3
children fc102732fa9c
files src/common.h src/eloop.c src/eloop.h
diffstat 3 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/common.h	Sat Jan 04 07:44:10 2020 +0000
+++ b/src/common.h	Wed Jan 08 00:43:11 2020 +0000
@@ -51,11 +51,6 @@
 #define ROUNDUP4(a)		(1 + (((a) - 1) |  3))
 #define ROUNDUP8(a)		(1 + (((a) - 1) |  7))
 
-#define NSEC_PER_SEC		1000000000L
-#define MSEC_PER_SEC		1000
-#define CSEC_PER_SEC		100L
-#define NSEC_PER_CSEC		10000000L
-
 /* Some systems don't define timespec macros */
 #ifndef timespecclear
 #define timespecclear(tsp)      (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L)
--- a/src/eloop.c	Sat Jan 04 07:44:10 2020 +0000
+++ b/src/eloop.c	Wed Jan 08 00:43:11 2020 +0000
@@ -95,12 +95,6 @@
 #endif
 #endif
 
-#ifndef MSEC_PER_SEC
-#define MSEC_PER_SEC	1000
-#define NSEC_PER_MSEC	1000000L
-#define NSEC_PER_SEC	1000000000U
-#endif
-
 #if defined(HAVE_KQUEUE)
 #include <sys/event.h>
 #include <fcntl.h>
--- a/src/eloop.h	Sat Jan 04 07:44:10 2020 +0000
+++ b/src/eloop.h	Wed Jan 08 00:43:11 2020 +0000
@@ -31,6 +31,13 @@
 
 #include <time.h>
 
+/* Handy macros to create subsecond timeouts */
+#define	CSEC_PER_SEC		100
+#define	MSEC_PER_SEC		1000
+#define	NSEC_PER_CSEC		10000000
+#define	NSEC_PER_MSEC		1000000
+#define	NSEC_PER_SEC		1000000000
+
 /* eloop queues are really only for deleting timeouts registered
  * for a function or object.
  * The idea being that one interface has different timeouts for