diff --git a/AUTHORS b/AUTHORS index 6a95ce31..dd40b7af 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,3 +38,4 @@ Ryan Emery Bruce Mitchener Maciej MaƂecki Yasuhiro Matsumoto +Daisuke Murase diff --git a/src/unix/darwin.c b/src/unix/darwin.c index 47104be8..e6deb301 100644 --- a/src/unix/darwin.c +++ b/src/unix/darwin.c @@ -28,7 +28,12 @@ #include #include +#include + +#if !TARGET_OS_IPHONE #include +#endif + #include #include #include /* _NSGetExecutablePath */ @@ -36,10 +41,26 @@ #include #include /* sysconf */ - static char *process_title; +#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; @@ -47,7 +68,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;