]> git.saurik.com Git - apple/libc.git/blame - mach.subproj/mach_absolute_time.c
Libc-186.tar.gz
[apple/libc.git] / mach.subproj / mach_absolute_time.c
CommitLineData
e9ce8d39
A
1#include <stdint.h>
2#include <mach/clock.h>
3
4extern mach_port_t clock_port;
5
6uint64_t mach_absolute_time(void) {
7#if defined(__ppc__)
8 __asm__ volatile("0: mftbu r3");
9 __asm__ volatile("mftb r4");
10 __asm__ volatile("mftbu r0");
11 __asm__ volatile("cmpw r0,r3");
12 __asm__ volatile("bne- 0b");
13#else
14 mach_timespec_t now;
15 (void)clock_get_time(clock_port, &now);
16 return (uint64_t)now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
17#endif
18}
19