10.6 compatibility: Fix some new compiler warnings, and work around apparent regressions in NSTask and -stringByStandardizingPath.
5 // Created by Jens Alfke on 3/25/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
12 #include <CoreServices/CoreServices.h>
13 #include <mach/mach.h>
14 #include <mach/mach_time.h>
18 /** Absolute time (since 'reference date') to NSDate. 0.0 -> nil. */
19 NSDate* $date( CFAbsoluteTime time )
21 CAssert(time>=0.0 && time < 1.0e15, @"Bogus timestamp %g",time);
22 return time ?[NSDate dateWithTimeIntervalSinceReferenceDate: time] :nil;
26 /** NSDate to absolute time (since 'reference date'). nil -> 0.0 */
27 CFAbsoluteTime $time( NSDate* date )
29 return date ?[date timeIntervalSinceReferenceDate] :0.0;
34 NSTimeInterval TimeIntervalSinceBoot(void)
36 // Adapted from http://developer.apple.com/qa/qa2004/qa1398.html
37 // Have to do some union tricks because AbsoluteToNanoseconds
38 // works in terms of UnsignedWide, which is a structure rather
39 // than a proper 64-bit integer.
44 t.asUInt64 = mach_absolute_time();
45 t.asUWide = AbsoluteToNanoseconds(t.asUWide);
46 return t.asUInt64 / 1.0e9;
52 Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
54 Redistribution and use in source and binary forms, with or without modification, are permitted
55 provided that the following conditions are met:
57 * Redistributions of source code must retain the above copyright notice, this list of conditions
58 and the following disclaimer.
59 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
60 and the following disclaimer in the documentation and/or other materials provided with the
63 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
64 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
65 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
66 BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
67 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
68 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
69 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
70 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.