[BRLTTY] BRLTTY in GRUB2

Dave Mielke dave at mielke.cc
Fri Apr 6 12:08:43 EDT 2012


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.

  static time_t baseSeconds = 0;
  static uint64_t baseMilliseconds = 0;
  uint64_t milliseconds = grub_get_time_ms();
  if (!baseSeconds) baseSeconds = time(NULL);
  if (!baseMilliseconds) baseMilliseconds = milliseconds;
  milliseconds -= 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