13
0

Fallback to gettimeofday for access time in FileManager

This commit is contained in:
Paul Davis 2013-07-11 12:39:24 -04:00
parent acc13d37a7
commit 38ebf63961

View File

@ -116,10 +116,14 @@ FileManager::allocate (FileDescriptor* d)
#ifdef __APPLE__ #ifdef __APPLE__
d->_last_used = mach_absolute_time(); d->_last_used = mach_absolute_time();
#else #elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
struct timespec t; struct timespec t;
clock_gettime (CLOCK_MONOTONIC, &t); clock_gettime (CLOCK_MONOTONIC, &t);
d->_last_used = t.tv_sec + (double) t.tv_nsec / 10e9; d->_last_used = t.tv_sec + (double) t.tv_nsec / 10e9;
#else
struct timeval now;
gettimeofday (&now, NULL);
d->_last_used = now.tv_sec + (double) now.tv_usec / 10e6;
#endif #endif
d->_refcount++; d->_refcount++;