Created
November 10, 2011 10:16
-
-
Save typester/1354552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/unix/darwin.c b/src/unix/darwin.c | |
| index 675e0ad..be2683a 100644 | |
| --- a/src/unix/darwin.c | |
| +++ b/src/unix/darwin.c | |
| @@ -25,7 +25,12 @@ | |
| #include <stdint.h> | |
| #include <errno.h> | |
| +#include <TargetConditionals.h> | |
| + | |
| +#if !TARGET_OS_IPHONE | |
| #include <CoreServices/CoreServices.h> | |
| +#endif | |
| + | |
| #include <mach/mach.h> | |
| #include <mach/mach_time.h> | |
| #include <mach-o/dyld.h> /* _NSGetExecutablePath */ | |
| @@ -33,7 +38,24 @@ | |
| #include <sys/sysctl.h> | |
| #include <unistd.h> /* sysconf */ | |
| +#if TARGET_OS_IPHONE | |
| +/* see: http://developer.apple.com/library/mac/#qa/qa1398/_index.html */ | |
| +uint64_t uv_hrtime() { | |
| + uint64_t time; | |
| + uint64_t enano; | |
| + static mach_timebase_info_data_t sTimebaseInfo; | |
| + | |
| + time = mach_absolute_time(); | |
| + if (0 == sTimebaseInfo.denom) { | |
| + (void)mach_timebase_info(&sTimebaseInfo); | |
| + } | |
| + | |
| + enano = time * sTimebaseInfo.numer / sTimebaseInfo.denom; | |
| + | |
| + return enano; | |
| +} | |
| +#else | |
| uint64_t uv_hrtime() { | |
| uint64_t time; | |
| Nanoseconds enano; | |
| @@ -41,7 +63,7 @@ uint64_t uv_hrtime() { | |
| enano = AbsoluteToNanoseconds(*(AbsoluteTime *)&time); | |
| return (*(uint64_t *)&enano); | |
| } | |
| - | |
| +#endif | |
| int uv_exepath(char* buffer, size_t* size) { | |
| uint32_t usize; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment