In article <90319dc1-1978-46f1-81f5-
>,
says...
>
> Is there any simple library that can return a systemtime in a
> resolution of max. 10ms, working on both Windows XP and modern Linux?
> time() works on both but has a resolution of 1s. There is
> GetSystsmTime on Windows with 10ms resolution, there are probably also
> some functions for Linux - but maybe there is some library works on
> both these OSes?
This is (undoubtably) the most famous portable time library:
ftp://elsie.nci.nih.gov/pub/
Here is Bernstein's libtai (be aware that Posix IGNORES leap seconds):
http://cr.yp.to/libtai.html
Here is a Windows flavored gettimeofday():
#include <windows.h>
/* FILETIME of Jan 1 1970 00:00:00. */
static const unsigned long long epoch = 116444736000000000ULL;
/*
* timezone information is stored outside the kernel so tzp isn't used
anymore.
*
* Note: this function is not for Win32 high precision timing purpose.
See
* elapsed_time().
*/
int
gettimeofday(struct timeval * tp, struct timezone * tzp)
{
FILETIME file_time;
SYSTEMTIME system_time;
ULARGE_INTEGER ularge;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
ularge.LowPart = file_time.dwLowDateTime;
ularge.HighPart = file_time.dwHighDateTime;
tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
return 0;
}
HTH