aboutsummaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorRanjith Kumaran <ranjith@cygnus.com>2000-05-15 18:30:03 +0000
committerRanjith Kumaran <ranjith@cygnus.com>2000-05-15 18:30:03 +0000
commit75362a768be4a15953e4a30314ec695174049ef2 (patch)
tree0bb1f201bb4f917c731ecede788b54aa0631e483 /newlib
parent4004738117733a2a6f26ac68fb7e0d4dad3520d9 (diff)
downloadnewlib-75362a768be4a15953e4a30314ec695174049ef2.zip
newlib-75362a768be4a15953e4a30314ec695174049ef2.tar.gz
newlib-75362a768be4a15953e4a30314ec695174049ef2.tar.bz2
Mon May 15 14:26:00 2000 Joel Sherrill <joel@oarcorp.com>
* libc/sys/rtems/sys/time.h: Add macros for manipulating timeval structures.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/sys/rtems/sys/time.h27
2 files changed, 32 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 5488955..735c47d 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+Mon May 15 14:26:00 2000 Joel Sherrill <joel@oarcorp.com>
+
+ * libc/sys/rtems/sys/time.h: Add macros for manipulating timeval
+ structures.
+
Wed May 10 19:24:53 2000 Jim Wilson <wilson@cygnus.com>
* libc/include/machine/ieeefp.h: Add ia64 support.
diff --git a/newlib/libc/sys/rtems/sys/time.h b/newlib/libc/sys/rtems/sys/time.h
index 596ec57..ea33257 100644
--- a/newlib/libc/sys/rtems/sys/time.h
+++ b/newlib/libc/sys/rtems/sys/time.h
@@ -65,6 +65,33 @@ int gettimeofday(
struct timezone *tzp
);
+/* Convenience macros for operations on timevals.
+ NOTE: `timercmp' does not work for >= or <=. */
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+#define timercmp(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) ? \
+ ((a)->tv_usec CMP (b)->tv_usec) : \
+ ((a)->tv_sec CMP (b)->tv_sec))
+#define timeradd(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
+ if ((result)->tv_usec >= 1000000) \
+ { \
+ ++(result)->tv_sec; \
+ (result)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
#ifdef __cplusplus
}
#endif