From ee72372d0f06cbb4b01bbd23e83b593d4d9e7687 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 16 Mar 2014 18:57:55 -0700 Subject: [PATCH] Fixed asm.js/Emscripten timer. --- include/bx/timer.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/bx/timer.h b/include/bx/timer.h index a12dae0..ae52038 100644 --- a/include/bx/timer.h +++ b/include/bx/timer.h @@ -8,8 +8,10 @@ #include "bx.h" -#if BX_PLATFORM_ANDROID || BX_PLATFORM_EMSCRIPTEN +#if BX_PLATFORM_ANDROID # include // clock, clock_gettime +#elif BX_PLATFORM_EMSCRIPTEN +# include #elif BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_OSX || BX_PLATFORM_IOS || BX_PLATFORM_QNX # include // gettimeofday #elif BX_PLATFORM_WINDOWS @@ -26,10 +28,12 @@ namespace bx // http://support.microsoft.com/kb/274323 QueryPerformanceCounter(&li); int64_t i64 = li.QuadPart; -#elif BX_PLATFORM_ANDROID || BX_PLATFORM_EMSCRIPTEN +#elif BX_PLATFORM_ANDROID struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); int64_t i64 = now.tv_sec*INT64_C(1000000000) + now.tv_nsec; +#elif BX_PLATFORM_EMSCRIPTEN + int64_t i64 = int64_t(1000.0f * emscripten_get_now() ); #else struct timeval now; gettimeofday(&now, 0); @@ -44,8 +48,10 @@ namespace bx LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.QuadPart; -#elif BX_PLATFORM_ANDROID || BX_PLATFORM_EMSCRIPTEN +#elif BX_PLATFORM_ANDROID return INT64_C(1000000000); +#elif BX_PLATFORM_EMSCRIPTEN + return INT64_C(1000000); #else return INT64_C(1000000); #endif // BX_PLATFORM_