Show
Ignore:
Timestamp:
04/09/08 15:37:35 (9 months ago)
Author:
aturner
Message:

switch to timespec (nanosecond precision) for sleeping. OS X's AbsoluteTime?
methods are really damn accurate! refs #41

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • features/performance/src/defines.h.in

    r1970 r1971  
    218218#define MILLISEC_TO_TIMEVAL(x, tv)          \ 
    219219    do {                                    \ 
    220         (tv)->tv_sec = x / 1000;            \ 
     220        (tv)->tv_sec = (x) / 1000;            \ 
    221221        (tv)->tv_usec = (x * 1000) - ((tv)->tv_sec * 1000000);   \ 
    222222    } while(0) 
     
    224224#define MICROSEC_TO_TIMEVAL(x, tv)          \ 
    225225    do {                                    \ 
    226         (tv)->tv_sec = x / 1000000;         \ 
    227         (tv)->tv_usec = x - ((tv)->tv_sec * 1000000);   \ 
     226        (tv)->tv_sec = (x) / 1000000;         \ 
     227        (tv)->tv_usec = (x) - ((tv)->tv_sec * 1000000);   \ 
    228228    } while(0) 
    229229 
    230230#define NANOSEC_TO_TIMEVAL(x, tv)           \ 
    231231    do {                                    \ 
    232         (tv)->tv_sec = x / 1000000000;      \ 
     232        (tv)->tv_sec = (x) / 1000000000;      \ 
    233233        (tv)->tv_usec = (x / 1000) - (tv)->tv_sec * 1000000);   \ 
    234234    } while(0) 
    235235 
     236#define NANOSEC_TO_TIMESPEC(x, ts)          \ 
     237    do {                                    \ 
     238        (ts)->tv_sec = (x) / 1000000000;      \ 
     239        (ts)->tv_nsec = (x) - ((ts)->tv_sec * 1000000000);   \ 
     240    } while(0) 
     241 
     242#define TIMESPEC_TO_MILLISEC(x)  (((x)->tv_sec * 1000) + ((x)->tv_nsec / 1000000)) 
     243#define TIMESPEC_TO_MICROSEC(x)  (((x)->tv_sec * 1000000) + (x)->tv_nsec / 1000) 
     244#define TIMESPEC_TO_NANOSEC(x) ((u_int64_t)((x)->tv_sec * 1000000000) + ((u_int64_t)(x)->tv_nsec)) 
     245 
     246 
     247 
    236248#endif /* DEFINES */