Fixes for iOS
replace AbsoluteToNanoseconds to alternate implementation in uv_hrtime when target OS is iOS which does not have CoreServices.framework Fixes #243
This commit is contained in:
parent
cb70db1240
commit
3cbe7c3f79
1
AUTHORS
1
AUTHORS
@ -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,7 +28,12 @@
|
||||
#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 */
|
||||
@ -36,10 +41,26 @@
|
||||
#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;
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user