Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRanjith Kumaran <ranjith@cygnus.com>2000-05-15 22:30:03 +0400
committerRanjith Kumaran <ranjith@cygnus.com>2000-05-15 22:30:03 +0400
commit75362a768be4a15953e4a30314ec695174049ef2 (patch)
tree0bb1f201bb4f917c731ecede788b54aa0631e483 /newlib/libc
parent4004738117733a2a6f26ac68fb7e0d4dad3520d9 (diff)
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/libc')
-rw-r--r--newlib/libc/sys/rtems/sys/time.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/newlib/libc/sys/rtems/sys/time.h b/newlib/libc/sys/rtems/sys/time.h
index 596ec5730..ea3325772 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