Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Fixes for iOS
Browse files Browse the repository at this point in the history
replace AbsoluteToNanoseconds to alternate implementation in uv_hrtime when
target OS is iOS which does not have CoreServices.framework

Fixes #243
  • Loading branch information
typester authored and ry committed Dec 20, 2011
1 parent cb70db1 commit 3cbe7c3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -38,3 +38,4 @@ Ryan Emery <seebees@gmail.com>
Bruce Mitchener <bruce.mitchener@gmail.com>
Maciej Małecki <maciej.malecki@notimplemented.org>
Yasuhiro Matsumoto <mattn.jp@gmail.com>
Daisuke Murase <typester@cpan.org>
25 changes: 23 additions & 2 deletions src/unix/darwin.c
Expand Up @@ -28,26 +28,47 @@
#include <ifaddrs.h>
#include <net/if.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 */
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <unistd.h> /* 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;
time = mach_absolute_time();
enano = AbsoluteToNanoseconds(*(AbsoluteTime *)&time);
return (*(uint64_t *)&enano);
}

#endif

int uv_exepath(char* buffer, size_t* size) {
uint32_t usize;
Expand Down

0 comments on commit 3cbe7c3

Please sign in to comment.