Revision: 14016
          http://edk2.svn.sourceforge.net/edk2/?rev=14016&view=rev
Author:   andrewfish
Date:     2012-12-22 00:47:17 +0000 (Sat, 22 Dec 2012)
Log Message:
-----------
Update to build with 10.8 OS X Frameworks. This is a Mac only change.

Modified Paths:
--------------
    trunk/edk2/EmulatorPkg/Unix/Host/EmuThunk.c

Modified: trunk/edk2/EmulatorPkg/Unix/Host/EmuThunk.c
===================================================================
--- trunk/edk2/EmulatorPkg/Unix/Host/EmuThunk.c 2012-12-22 00:45:55 UTC (rev 
14015)
+++ trunk/edk2/EmulatorPkg/Unix/Host/EmuThunk.c 2012-12-22 00:47:17 UTC (rev 
14016)
@@ -259,18 +259,26 @@
 {
 #if __APPLE__
   UINT64          Start;
-  Nanoseconds     elapsedNano;
+  static mach_timebase_info_data_t    sTimebaseInfo;
 
+
   Start = mach_absolute_time ();
 
   // Convert to nanoseconds.
 
-  // Have to do some pointer fun because AbsoluteToNanoseconds
-  // works in terms of UnsignedWide, which is a structure rather
-    // than a proper 64-bit integer.
-  elapsedNano = AbsoluteToNanoseconds (*(AbsoluteTime *) &Start);
+  // If this is the first time we've run, get the timebase.
+  // We can use denom == 0 to indicate that sTimebaseInfo is 
+  // uninitialised because it makes no sense to have a zero 
+  // denominator is a fraction.
 
-  return *(uint64_t *) &elapsedNano;
+  if ( sTimebaseInfo.denom == 0 ) {
+      (void) mach_timebase_info(&sTimebaseInfo);
+  }
+
+  // Do the maths. We hope that the multiplication doesn't 
+  // overflow; the price you pay for working in fixed point.
+
+  return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom;
 #else
   // Need to figure out what to do for Linux?
   return 0;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to