45 SystemTimeToFileTime(&s, &f);
46 t.QuadPart = f.dwHighDateTime;
48 t.QuadPart |= f.dwLowDateTime;
53 clock_gettime(
int X,
struct timespec *tv)
58 static LARGE_INTEGER offset;
59 static double frequencyToMicroseconds;
60 static int initialized = 0;
61 static BOOL usePerformanceCounter = 0;
64 LARGE_INTEGER performanceFrequency;
66 usePerformanceCounter = QueryPerformanceFrequency(&performanceFrequency);
67 if (usePerformanceCounter) {
68 QueryPerformanceCounter(&offset);
69 frequencyToMicroseconds = (double)performanceFrequency.QuadPart / 1000000.;
71 offset = getFILETIMEoffset();
72 frequencyToMicroseconds = 10.;
75 if (usePerformanceCounter) QueryPerformanceCounter(&t);
77 GetSystemTimeAsFileTime(&f);
78 t.QuadPart = f.dwHighDateTime;
80 t.QuadPart |= f.dwLowDateTime;
83 t.QuadPart -= offset.QuadPart;
84 microseconds = (double)t.QuadPart / frequencyToMicroseconds;
85 t.QuadPart = microseconds;
86 tv->tv_sec = t.QuadPart / 1000000;
87 tv->tv_nsec = t.QuadPart % 1000000;
97 unsigned long timeout = va_arg(*params,
unsigned long);
static void timerDtor(void *_this)
TR_CREATE_CLASS(TR_Timer, NULL, NULL, TR_IF(TR_Class))
static int timerCtor(void *_this, va_list *params)
void TR_timerSet(TR_Timer, TR_eTimeoutBase, unsigned long)
TR_INIT_IFACE(TR_Class, timerCtor, timerDtor, NULL)