summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-12-30 15:36:56 +0000
committerpeter <peter@FreeBSD.org>1996-12-30 15:36:56 +0000
commit76162281a2cdd31a9af75ec13601530bbeadb55e (patch)
treea8186b437d73248ef504204cba8934dd42a6a48f
parent2a7e4d562f4977127aa5f5a0abb201656a252dde (diff)
downloadFreeBSD-src-76162281a2cdd31a9af75ec13601530bbeadb55e.zip
FreeBSD-src-76162281a2cdd31a9af75ec13601530bbeadb55e.tar.gz
Add NetBSD/OpenBSD compatable timeradd()/timersub() user-space macros.
These are deliberately not visible to the kernel since we have timevaladd() and timevalsub() functions there. Obtained from: NetBSD/OpenBSD
-rw-r--r--sys/sys/time.h23
-rw-r--r--sys/sys/timetc.h23
2 files changed, 44 insertions, 2 deletions
diff --git a/sys/sys/time.h b/sys/sys/time.h
index f68c5cc..ef2f222 100644
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
- * $Id: time.h,v 1.7 1996/03/11 02:11:25 hsu Exp $
+ * $Id: time.h,v 1.8 1996/09/19 18:21:20 nate Exp $
*/
#ifndef _SYS_TIME_H_
@@ -84,6 +84,27 @@ struct timezone {
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
+#ifndef KERNEL /* use timevaladd/timevalsub in kernel */
+/* NetBSD/OpenBSD compatable interfaces */
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
/*
* Names of the interval timers, and structure
diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h
index f68c5cc..ef2f222 100644
--- a/sys/sys/timetc.h
+++ b/sys/sys/timetc.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
- * $Id: time.h,v 1.7 1996/03/11 02:11:25 hsu Exp $
+ * $Id: time.h,v 1.8 1996/09/19 18:21:20 nate Exp $
*/
#ifndef _SYS_TIME_H_
@@ -84,6 +84,27 @@ struct timezone {
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
+#ifndef KERNEL /* use timevaladd/timevalsub in kernel */
+/* NetBSD/OpenBSD compatable interfaces */
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
/*
* Names of the interval timers, and structure
OpenPOWER on IntegriCloud