[BRLTTY] BRLTTY in GRUB2

Dave Mielke dave at mielke.cc
Fri Apr 6 13:09:07 EDT 2012


[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: dave at mielke.cc | Canada  K2A 1H7   | http://Mielke.cc/now.html
http://FamilyRadio.com/                   | http://Mielke.cc/bible/


More information about the BRLTTY mailing list