[quoted lines by Dave Mielke on 2012/04/06 at 12:08 -0400]
>What do you think about the following code to get a fairly accurate actual
>time
>in milliseconds? I'm thinking of adding it to the Grub part of our
>timing.c:getCurrentTime() function.
Here's what I think is a better version, especially as I suspect that time()
could possibly delay.
static time_t baseSeconds = 0;
static uint64_t baseMilliseconds;
if (!baseSeconds) {
baseSeconds = time(NULL);
baseMilliseconds = grub_get_time_ms();
}
{
uint64_t milliseconds = grub_get_time_ms() - baseMilliseconds;
now->seconds = baseSeconds + (milliseconds / MSECS_PER_SEC);
now->nanoseconds = (milliseconds % MSECS_PER_SEC) * NSECS_PER_MSEC;
}
--
Dave Mielke | 2213 Fox Crescent | The Bible is the very Word of God.
Phone: 1-613-726-0014 | Ottawa, Ontario | 2011 May 21 is the End of Salvation.
EMail: [email protected] | Canada K2A 1H7 | http://Mielke.cc/now.html
http://FamilyRadio.com/ | http://Mielke.cc/bible/
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty