Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
steffen is currently offline  steffen
Messages: 38
Registered: May 2007
Location: Denmark
Member

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? Wink


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

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Serialize of derived classes
Next Topic: A warning in Diag.h
Goto Forum:
  


Current Time: Thu May 09 07:05:51 CEST 2024

Total time taken to generate the page: 0.01753 seconds