| 112 | |
| 113 | |
| 114 | void timestamp_current( timestamp * const t ) |
| 115 | { |
| 116 | #ifdef OS_NT |
| 117 | /* GetSystemTimeAsFileTime()'s resolution seems to be about 15 ms on Windows |
| 118 | * XP and under a millisecond on Windows 7. |
| 119 | */ |
| 120 | FILETIME ft; |
| 121 | GetSystemTimeAsFileTime( &ft ); |
| 122 | timestamp_from_filetime( t, &ft ); |
| 123 | #elif defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME) && \ |
| 124 | (!defined(__GLIBC__) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17)) |
| 125 | /* Some older versions of XCode define _POSIX_TIMERS, but don't actually |
| 126 | * have clock_gettime. Check CLOCK_REALTIME as well. Prior to glibc 2.17, |
| 127 | * clock_gettime requires -lrt. This is a non-critical feature, so |
| 128 | * we just disable it to keep bootstrapping simple. |
| 129 | */ |
| 130 | struct timespec ts; |
| 131 | clock_gettime( CLOCK_REALTIME, &ts ); |
| 132 | timestamp_init( t, ts.tv_sec, ts.tv_nsec ); |
| 133 | #else /* OS_NT */ |
| 134 | timestamp_init( t, time( 0 ), 0 ); |
| 135 | #endif /* OS_NT */ |
| 136 | } |
| 137 | |
| 138 | |
| 139 | int timestamp_empty( timestamp const * const time ) |