Add macros and types needed for POSIX 1003.1b timers
authortholo <tholo@openbsd.org>
Sun, 20 Apr 1997 20:47:33 +0000 (20:47 +0000)
committertholo <tholo@openbsd.org>
Sun, 20 Apr 1997 20:47:33 +0000 (20:47 +0000)
sys/sys/time.h
sys/sys/types.h

index b95e8b0..0b9cdcc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: time.h,v 1.3 1996/05/02 13:14:04 deraadt Exp $        */
+/*     $OpenBSD: time.h,v 1.4 1997/04/20 20:47:34 tholo Exp $  */
 /*     $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $        */
 
 /*
@@ -105,6 +105,32 @@ struct timezone {
                }                                                       \
        } while (0)
 
+/* Operations on timespecs. */
+#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)
+
 /*
  * Names of the interval timers, and structure
  * defining a timer setting.
@@ -129,6 +155,13 @@ struct clockinfo {
        int     profhz;         /* profiling clock frequency */
 };
 
+#define CLOCK_REALTIME 0
+#define CLOCK_VIRTUAL  1
+#define CLOCK_PROF     2
+
+#define TIMER_RELTIME  0x0     /* relative timer */
+#define TIMER_ABSTIME  0x1     /* absolute timer */
+
 #ifdef _KERNEL
 int    itimerfix __P((struct timeval *tv));
 int    itimerdecr __P((struct itimerval *itp, int usec));
index c2a4cf8..1dd72e6 100644 (file)
@@ -1,5 +1,5 @@
-/*     $OpenBSD: types.h,v 1.9 1996/05/28 12:16:28 deraadt Exp $       */
-/*     $NetBSD: types.h,v 1.26 1996/04/09 20:55:47 cgd Exp $   */
+/*     $OpenBSD: types.h,v 1.10 1997/04/20 20:47:33 tholo Exp $        */
+/*     $NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $   */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -125,6 +125,16 @@ typedef    _BSD_TIME_T_    time_t;
 #undef _BSD_TIME_T_
 #endif
 
+#ifdef _BSD_CLOCKID_T_
+typedef        _BSD_CLOCKID_T_ clockid_t;
+#undef _BSD_CLOCKID_T_
+#endif
+
+#ifdef _BSD_TIMER_T_
+typedef        _BSD_TIMER_T_   timer_t;
+#undef _BSD_TIMER_T_
+#endif
+
 #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
 #define        NBBY    8               /* number of bits in a byte */