2
0

time.h 774 B

1234567891011121314151617181920212223
  1. #ifndef _BITS_SYS_TIME
  2. #define _BITS_SYS_TIME
  3. #define timeradd(x,y,res) (void) (\
  4. (res)->tv_sec = (x)->tv_sec + (y)->tv_sec + (((x)->tv_usec + (y)->tv_usec) / 1000000), \
  5. (res)->tv_usec = ((x)->tv_usec + (y)->tv_usec) % 1000000 \
  6. )
  7. #define timersub(x,y,res) (void) ( \
  8. (res)->tv_sec = (x)->tv_sec - (y)->tv_sec, \
  9. (res)->tv_usec = ((x)->tv_usec - (y)->tv_usec), \
  10. ((res)->tv_usec < 0) && ((res)->tv_sec -= 1, (res)->tv_usec += 1000000) \
  11. )
  12. #define timerclear(t) (void) ( \
  13. (t)->tv_sec = 0, \
  14. (t)->tv_usec = 0 \
  15. )
  16. #define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
  17. #define timercmp(x,y,op) ((x)->tv_sec == (y)->tv_sec ? \
  18. (x)->tv_usec op (y)->tv_usec \
  19. : \
  20. (x)->tv_sec op (y)->tv_sec)
  21. #endif