home *** CD-ROM | disk | FTP | other *** search
- /* Macros for manipulation of time values (cf. gettimeofday(2)) */
- #define timeLess(t1,t2) ( (t1.tv_sec < t2.tv_sec) ? 1 : \
- (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec < t2.tv_usec) : 0)
- #define timeLessEq(t1,t2) ( (t1.tv_sec < t2.tv_sec) ? 1 : \
- (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec <= t2.tv_usec) : 0)
- #define timeGtr(t1,t2) ( (t1.tv_sec > t2.tv_sec) ? 1 : \
- (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec > t2.tv_usec) : 0)
- #define timeGtrEq(t1,t2) ( (t1.tv_sec > t2.tv_sec) ? 1 : \
- (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec >= t2.tv_usec) : 0)
- #define timeEq(t1,t2) ( (t1.tv_sec == t2.tv_sec) ? \
- (t1.tv_usec == t2.tv_usec) : 0)
-
- #define timeAdd(t1,t2,t3) /* t1 = t2 + t3 */ \
- t1.tv_sec = t2.tv_sec + t3.tv_sec; \
- if ((t1.tv_usec = t2.tv_usec + t3.tv_usec) > 1000000) { \
- t1.tv_sec++; \
- t1.tv_usec -= 1000000; \
- }
-
- #define timeSub(t1,t2,t3) /* t1 = t2 - t3 */ \
- t1.tv_sec = t2.tv_sec - t3.tv_sec; \
- if ((t1.tv_usec = t2.tv_usec - t3.tv_usec) < 0) { \
- t1.tv_sec--; \
- t1.tv_usec += 1000000; \
- }
-
- #define timeBuild(t1,tSec,tUSec) /* Build a time value */ \
- t1.tv_sec = tSec; \
- t1.tv_usec = tUSec;
-
-