Home » U++ Library support » U++ Core » Problem with GetTickCount on Linux
Re: Problem with GetTickCount on Linux [message #36468 is a reply to message #36466] |
Wed, 30 May 2012 12:36 |
|
Hi Mirek,
Thank you for the fast reponse. I see you changed the argument name in SetSysTime from ATime to time, could you please also run a search and replace to correct all the references?
Zbych,
My first version actually was calling the gettimeofday part if the call to CLOCK_MONOTONIC was failing, but I don't know if that was correct and I could not test it on any of my systems.
With the macros you found it would be safe to do something like this:
#ifdef PLATFORM_POSIX
dword GetTickCount() {
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
struct timespec tp;
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
{
return (dword)((tp.tv_sec * 1000) + (tp.tv_nsec / 1000000));
}
#endif
struct timeval tv[1];
struct timezone tz[1];
memset(tz, 0, sizeof(tz));
gettimeofday(tv, tz);
return (dword)tv->tv_sec * 1000 + tv->tv_usec / 1000;
}
#endif
|
|
|
Goto Forum:
Current Time: Thu May 09 07:05:51 CEST 2024
Total time taken to generate the page: 0.01753 seconds
|