mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 12:42:34 +01:00
OSX port, thanks @MatthewEndsley.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include "cpu.h"
|
||||
#include "sem.h"
|
||||
|
||||
#if BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_ANDROID
|
||||
#if BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_ANDROID || BX_PLATFORM_OSX
|
||||
# include <pthread.h>
|
||||
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
|
||||
# include <errno.h>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "bx.h"
|
||||
|
||||
#if BX_PLATFORM_NACL || BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX
|
||||
#if BX_PLATFORM_NACL || BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
# include <sched.h> // sched_yield
|
||||
# if BX_PLATFORM_NACL
|
||||
# include <sys/nacl_syscalls.h> // nanosleep
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
# include <time.h> // clock, clock_gettime
|
||||
#elif BX_PLATFORM_NACL | BX_PLATFORM_LINUX
|
||||
# include <sys/time.h> // gettimeofday
|
||||
#elif BX_PLATFORM_OSX
|
||||
# include <mach/mach_time.h> // mach_absolute_time/mach_timebase_info
|
||||
#endif // BX_PLATFORM_
|
||||
|
||||
namespace bx
|
||||
@@ -26,6 +28,8 @@ namespace bx
|
||||
int64_t i64 = li.QuadPart;
|
||||
#elif BX_PLATFORM_ANDROID
|
||||
int64_t i64 = clock();
|
||||
#elif BX_PLATFORM_OSX
|
||||
int64_t i64 = mach_absolute_time();
|
||||
#else
|
||||
struct timeval now;
|
||||
gettimeofday(&now, 0);
|
||||
@@ -43,6 +47,10 @@ namespace bx
|
||||
return li.QuadPart;
|
||||
#elif BX_PLATFORM_ANDROID
|
||||
return CLOCKS_PER_SEC;
|
||||
#elif BX_PLATFORM_OSX
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
return (int64_t)(info.denom * 1000000) / info.numer;
|
||||
#else
|
||||
return 1000000;
|
||||
#endif // BNET_PLATFORM_
|
||||
|
||||
Reference in New Issue
Block a user