--- - 2006-05-19 08:37:47.000000000 -0700 +++ posix.cc 2006-05-08 12:11:21.000000000 -0700 @@ -48,6 +48,7 @@ #include #include #include +#include #if (defined(__GLIBC__) && __GLIBC__ >= 2) || defined(__SCO_VERSION__) || defined(__aix__) || defined (__cygwin__) // typedef of struct timeval and gettimeofday(); @@ -266,6 +267,11 @@ static size_t stack_size = 0; #endif +#if defined(__linux__) +static long ticks_per_second = 0; +static long nanos_per_tick = 0; +#endif + // // Initialisation function (gets called before any user code). // @@ -378,6 +384,11 @@ #endif /* PthreadDraftVersion */ #endif /* PthreadSupportThreadPriority */ + +#if defined(__linux__) + ticks_per_second = sysconf(_SC_CLK_TCK); + nanos_per_tick = 1*1000*1000*1000 / ticks_per_second; +#endif } omni_thread::init_t::~init_t(void) @@ -855,10 +866,17 @@ #if defined(__linux__) || defined(__aix__) || defined(__SCO_VERSION__) || defined(__darwin__) || defined(__macos__) +#if defined(__linux__) + struct tms tms; + clock_t ticks = times(&tms); + abs.tv_sec = ticks / ticks_per_second; + abs.tv_nsec = (ticks % ticks_per_second) * nanos_per_tick; +#else /* __linux__ */ struct timeval tv; gettimeofday(&tv, NULL); abs.tv_sec = tv.tv_sec; abs.tv_nsec = tv.tv_usec * 1000; +#endif /* __linux__ */ #else /* __linux__ || __aix__ */