From f4bd1afb45ecf4caf48bd98ad1b401ea709684bc Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Mon, 25 Jun 2012 18:50:26 -0700 Subject: [PATCH] OSX port, thanks @MatthewEndsley. --- include/bx/mutex.h | 2 +- include/bx/os.h | 2 +- include/bx/timer.h | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/bx/mutex.h b/include/bx/mutex.h index 7c1e906..b20bb9a 100644 --- a/include/bx/mutex.h +++ b/include/bx/mutex.h @@ -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 #elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 # include diff --git a/include/bx/os.h b/include/bx/os.h index ed0ced4..57e8e78 100644 --- a/include/bx/os.h +++ b/include/bx/os.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_yield # if BX_PLATFORM_NACL # include // nanosleep diff --git a/include/bx/timer.h b/include/bx/timer.h index dd335f8..ff260d1 100644 --- a/include/bx/timer.h +++ b/include/bx/timer.h @@ -12,6 +12,8 @@ # include // clock, clock_gettime #elif BX_PLATFORM_NACL | BX_PLATFORM_LINUX # include // gettimeofday +#elif BX_PLATFORM_OSX +# include // 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_