#ifdef _WIN32
#include <windows.h>
-
+
#define sleep_ms(x) Sleep(x)
#else
#include <unistd.h>
#include <stdint.h> //for uintptr_t
-
+
#if (defined(linux) || defined(__linux)) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif
#endif
#define sleep_ms(x) usleep(x*1000)
-
+
#define THREAD_PRIORITY_LOWEST 0
#define THREAD_PRIORITY_BELOW_NORMAL 1
#define THREAD_PRIORITY_NORMAL 2
#define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
-
+
inline u32 getTimeS()
{
return GetTickCount() / 1000;
}
-
+
inline u32 getTimeMs()
{
return GetTickCount();
}
-
+
inline u32 getTimeUs()
{
LARGE_INTEGER freq, t;
QueryPerformanceCounter(&t);
return (double)(t.QuadPart) / ((double)(freq.QuadPart) / 1000000.0);
}
-
+
inline u32 getTimeNs()
{
LARGE_INTEGER freq, t;
QueryPerformanceCounter(&t);
return (double)(t.QuadPart) / ((double)(freq.QuadPart) / 1000000000.0);
}
-
+
#else // Posix
#include <sys/time.h>
#include <time.h>
gettimeofday(&tv, NULL);
return tv.tv_sec;
}
-
+
inline u32 getTimeMs()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
-
+
inline u32 getTimeUs()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000 + tv.tv_usec;
}
-
+
inline u32 getTimeNs()
{
struct timespec ts;
#endif
return ts.tv_sec * 1000000000 + ts.tv_nsec;
}
-
+
/*#include <sys/timeb.h>
inline u32 getTimeMs()
{
} // namespace porting
+#ifdef __ANDROID__
+#include "porting_android.h"
+#endif
+
#endif // PORTING_HEADER