home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / h / timeops.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-17  |  1.1 KB  |  31 lines

  1. /* Macros for manipulation of time values (cf. gettimeofday(2)) */
  2. #define timeLess(t1,t2) ( (t1.tv_sec < t2.tv_sec) ? 1 : \
  3.     (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec < t2.tv_usec) : 0)
  4. #define timeLessEq(t1,t2) ( (t1.tv_sec < t2.tv_sec) ? 1 : \
  5.     (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec <= t2.tv_usec) : 0)
  6. #define timeGtr(t1,t2) ( (t1.tv_sec > t2.tv_sec) ? 1 : \
  7.     (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec > t2.tv_usec) : 0)
  8. #define timeGtrEq(t1,t2) ( (t1.tv_sec > t2.tv_sec) ? 1 : \
  9.     (t1.tv_sec == t2.tv_sec) ? (t1.tv_usec >= t2.tv_usec) : 0)
  10. #define timeEq(t1,t2) ( (t1.tv_sec == t2.tv_sec) ? \
  11.     (t1.tv_usec == t2.tv_usec) : 0)
  12.  
  13. #define timeAdd(t1,t2,t3) /* t1 = t2 + t3 */ \
  14.     t1.tv_sec   = t2.tv_sec + t3.tv_sec; \
  15.     if ((t1.tv_usec  = t2.tv_usec + t3.tv_usec) > 1000000) { \
  16.         t1.tv_sec++; \
  17.     t1.tv_usec -= 1000000; \
  18.     }
  19.  
  20. #define timeSub(t1,t2,t3) /* t1 = t2 - t3 */ \
  21.     t1.tv_sec   = t2.tv_sec - t3.tv_sec; \
  22.     if ((t1.tv_usec  = t2.tv_usec - t3.tv_usec) < 0) { \
  23.         t1.tv_sec--; \
  24.     t1.tv_usec += 1000000; \
  25.     }    
  26.  
  27. #define timeBuild(t1,tSec,tUSec) /* Build a time value */ \
  28.     t1.tv_sec   = tSec; \
  29.     t1.tv_usec  = tUSec;
  30.  
  31.