Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixes for iOS

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 Nov 10, 2011
1 parent cb70db1 commit 3cbe7c3f7952aa249450438b21cf4f346bb88e22
Showing with 24 additions and 2 deletions.
  1. +1 −0 AUTHORS
  2. +23 −2 src/unix/darwin.c
@@ -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>
@@ -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;

0 comments on commit 3cbe7c3

Please sign in to comment.
You can’t perform that action at this time.