double now() { #ifdef WIN32 FILETIME ft; GetSystemTimeAsFileTime(&ft); double t = (4294967296.0 * ft.dwHighDateTime + ft.dwLowDateTime); /* Converts from 100ns units in 1601 epoch to unix epoch in sec */ return (t * 1e-7) - 11644473600.0; #else time_t t; struct timeval td; do { t = time(0); gettimeofday(&td, 0); } while(t != time(0)); return t + 1e-6 * td.tv_usec; #endif }