From: tholo Date: Sun, 20 Apr 1997 20:47:33 +0000 (+0000) Subject: Add macros and types needed for POSIX 1003.1b timers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e375aa517761a018836d3d00dce2f1400e4b79bb;p=openbsd Add macros and types needed for POSIX 1003.1b timers --- diff --git a/sys/sys/time.h b/sys/sys/time.h index b95e8b0659c..0b9cdcc01cc 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -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)); diff --git a/sys/sys/types.h b/sys/sys/types.h index c2a4cf8e377..1dd72e61c82 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -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 */