mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-18 04:53:06 +01:00
Cleanup.
This commit is contained in:
@@ -384,7 +384,7 @@ namespace bx
|
||||
if (0 < kk && kk <= 21)
|
||||
{
|
||||
// 1234e-2 -> 12.34
|
||||
memmove(&buffer[kk + 1], &buffer[kk], length - kk);
|
||||
memMove(&buffer[kk + 1], &buffer[kk], length - kk);
|
||||
buffer[kk] = '.';
|
||||
buffer[length + 1] = '\0';
|
||||
return length + 1;
|
||||
@@ -394,7 +394,7 @@ namespace bx
|
||||
{
|
||||
// 1234e-6 -> 0.001234
|
||||
const int32_t offset = 2 - kk;
|
||||
memmove(&buffer[offset], &buffer[0], length);
|
||||
memMove(&buffer[offset], &buffer[0], length);
|
||||
buffer[0] = '0';
|
||||
buffer[1] = '.';
|
||||
for (int32_t i = 2; i < offset; i++)
|
||||
@@ -415,7 +415,7 @@ namespace bx
|
||||
}
|
||||
|
||||
// 1234e30 -> 1.234e33
|
||||
memmove(&buffer[2], &buffer[1], length - 1);
|
||||
memMove(&buffer[2], &buffer[1], length - 1);
|
||||
buffer[1] = '.';
|
||||
buffer[length + 1] = 'e';
|
||||
int32_t exp = WriteExponent(kk - 1, &buffer[length + 2]);
|
||||
@@ -520,7 +520,7 @@ namespace bx
|
||||
|
||||
reverse(data, len);
|
||||
|
||||
memcpy(_dst, data, len);
|
||||
memCopy(_dst, data, len);
|
||||
_dst[len] = '\0';
|
||||
return int32_t(len);
|
||||
}
|
||||
|
||||
@@ -406,11 +406,11 @@ namespace bx
|
||||
return (void*)uintptr_t(pid);
|
||||
#elif BX_PLATFORM_WINDOWS
|
||||
STARTUPINFO si;
|
||||
memset(&si, 0, sizeof(STARTUPINFO) );
|
||||
memSet(&si, 0, sizeof(STARTUPINFO) );
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
memset(&pi, 0, sizeof(PROCESS_INFORMATION) );
|
||||
memSet(&pi, 0, sizeof(PROCESS_INFORMATION) );
|
||||
|
||||
int32_t total = 0;
|
||||
for (uint32_t ii = 0; NULL != _argv[ii]; ++ii)
|
||||
|
||||
57
src/timer.cpp
Normal file
57
src/timer.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2010-2017 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
#include <bx/timer.h>
|
||||
|
||||
#if BX_PLATFORM_ANDROID
|
||||
# include <time.h> // clock, clock_gettime
|
||||
#elif BX_PLATFORM_EMSCRIPTEN
|
||||
# include <emscripten.h>
|
||||
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <sys/time.h> // gettimeofday
|
||||
#endif // BX_PLATFORM_
|
||||
|
||||
namespace bx
|
||||
{
|
||||
int64_t getHPCounter()
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
|
||||
LARGE_INTEGER li;
|
||||
// Performance counter value may unexpectedly leap forward
|
||||
// http://support.microsoft.com/kb/274323
|
||||
QueryPerformanceCounter(&li);
|
||||
int64_t i64 = li.QuadPart;
|
||||
#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);
|
||||
int64_t i64 = now.tv_sec*INT64_C(1000000) + now.tv_usec;
|
||||
#endif // BX_PLATFORM_
|
||||
return i64;
|
||||
}
|
||||
|
||||
int64_t getHPFrequency()
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
|
||||
LARGE_INTEGER li;
|
||||
QueryPerformanceFrequency(&li);
|
||||
return li.QuadPart;
|
||||
#elif BX_PLATFORM_ANDROID
|
||||
return INT64_C(1000000000);
|
||||
#elif BX_PLATFORM_EMSCRIPTEN
|
||||
return INT64_C(1000000);
|
||||
#else
|
||||
return INT64_C(1000000);
|
||||
#endif // BX_PLATFORM_
|
||||
}
|
||||
|
||||
} // namespace bx
|
||||
Reference in New Issue
Block a user