1.1 --- a/DateUtils.m Sat May 24 13:24:33 2008 -0700
1.2 +++ b/DateUtils.m Wed Apr 08 16:31:19 2009 -0700
1.3 @@ -33,13 +33,17 @@
1.4
1.5 NSTimeInterval TimeIntervalSinceBoot(void)
1.6 {
1.7 - // From http://developer.apple.com/qa/qa2004/qa1398.html
1.8 - uint64_t abstime = mach_absolute_time();
1.9 - // Have to do some pointer fun because AbsoluteToNanoseconds
1.10 + // Adapted from http://developer.apple.com/qa/qa2004/qa1398.html
1.11 + // Have to do some union tricks because AbsoluteToNanoseconds
1.12 // works in terms of UnsignedWide, which is a structure rather
1.13 // than a proper 64-bit integer.
1.14 - Nanoseconds elapsedNano = AbsoluteToNanoseconds( *(AbsoluteTime *) &abstime );
1.15 - return *(uint64_t*)&elapsedNano / 1.0e9;
1.16 + union {
1.17 + uint64_t asUInt64;
1.18 + UnsignedWide asUWide;
1.19 + } t;
1.20 + t.asUInt64 = mach_absolute_time();
1.21 + t.asUWide = AbsoluteToNanoseconds(t.asUWide);
1.22 + return t.asUInt64 / 1.0e9;
1.23 }
1.24
1.25