sys/time.h additions
Joel Sherrill
joel.sherrill@OARcorp.com
Fri Dec 1 06:42:00 GMT 2000
We are close to the point where I am going to have to submit a
lump. :)
But for now, this simply adds macros such as "timerisset, timerclear,
timercmp, timeradd, etc. from BSD for RTEMS specific targets.
2000-12-01 Joel Sherrill <joel@OARcorp.com>
* libc/include/sys/time.h: Added BSD timer manipulation macros
used by RTEMS code. These are currently within an RTEMS
conditional.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
Index: newlib/libc/include/sys/time.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/time.h,v
retrieving revision 1.2
diff -u -r1.2 time.h
--- time.h 2000/05/30 17:18:05 1.2
+++ time.h 2000/12/01 13:20:17
@@ -38,6 +38,38 @@
struct timeval it_value;
};
+/* BSD time macros used by RTEMS code */
+#if defined(__rtems__)
+
+/* 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)
+#endif
+
int _EXFUN(gettimeofday, (struct timeval *__p, struct timezone *__z));
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
int _EXFUN(utimes, (const char *__path, struct timeval *__tvp));
More information about the Newlib
mailing list