darling-cocotron/QuartzCore/CABase.m
2020-05-12 17:04:15 -04:00

22 lines
551 B
Objective-C

#import <Foundation/NSString.h>
#import <QuartzCore/CABase.h>
#import <mach/mach_time.h>
static double conversionFactor() {
struct mach_timebase_info timebase;
kern_return_t error;
if ((mach_timebase_info(&timebase)) != KERN_SUCCESS) {
NSLog(@"mach_timebase_info returned %d", error);
return 1;
}
return 0.000000001 * ((double) timebase.numer / (double) timebase.denom);
}
CFTimeInterval CACurrentMediaTime(void) {
uint64_t value = mach_absolute_time();
return ((double) value) * conversionFactor();
}