diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-12-22 00:47:17 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-12-22 00:47:17 +0000 |
commit | 5b484a25f744b123093a49bbb0188b78e7c7d99d (patch) | |
tree | c59413b81a1cb2a97fcd0582e3ecbf230ea8a03a /EmulatorPkg | |
parent | 171bb2e53c6d701b13496eb72d57cd716586423d (diff) | |
download | edk2-platforms-5b484a25f744b123093a49bbb0188b78e7c7d99d.tar.xz |
Update to build with 10.8 OS X Frameworks. This is a Mac only change.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14016 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmulatorPkg')
-rw-r--r-- | EmulatorPkg/Unix/Host/EmuThunk.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c b/EmulatorPkg/Unix/Host/EmuThunk.c index 52875c3bce..a7b12b14e5 100644 --- a/EmulatorPkg/Unix/Host/EmuThunk.c +++ b/EmulatorPkg/Unix/Host/EmuThunk.c @@ -259,18 +259,26 @@ QueryPerformanceCounter ( { #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. + + 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 *(uint64_t *) &elapsedNano; + return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom; #else // Need to figure out what to do for Linux? return 0; |