aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-03-06 19:36:35 +0100
committerDuncaen <mail@duncano.de>2017-03-06 20:34:38 +0100
commit33d564391976f25bdfec00052ac62001c19222a2 (patch)
tree6535822f944ae9661623ed9a7cd37ee88b5a2062
parent85f6574b80f1d6d734da25fa8746a428911a6117 (diff)
downloadlobase-33d564391976f25bdfec00052ac62001c19222a2.tar.gz
include/sys/time.h: define timespec macros in the right header
-rw-r--r--include/sys/time.h34
-rw-r--r--lib/libopenbsd/openbsd.h34
2 files changed, 34 insertions, 34 deletions
diff --git a/include/sys/time.h b/include/sys/time.h
index 11e02d0..b59b27d 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -3,4 +3,38 @@
#ifndef _COMPAT_SYS_TIME_H_
#define _COMPAT_SYS_TIME_H_
#include <time.h>
+
+#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; \
+}
+#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)
+
#endif /* _COMPAT_SYS_TIME_H_ */
diff --git a/lib/libopenbsd/openbsd.h b/lib/libopenbsd/openbsd.h
index e394e67..6064512 100644
--- a/lib/libopenbsd/openbsd.h
+++ b/lib/libopenbsd/openbsd.h
@@ -149,40 +149,6 @@ uintmax_t strtoumax(const char *, char **, int);
/* setproctitle.c */
void setproctitle(const char *, ...);
-/* sys/sys/time.h */
-#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; \
-}
-#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)
-
/* pw_dup.c */
struct passwd *pw_dup(const struct passwd *);