diff --git a/src/platform.h b/src/platform.h index 151c882a..2248fd1d 100644 --- a/src/platform.h +++ b/src/platform.h @@ -20,27 +20,7 @@ #ifndef PLATFORM_H_INCLUDED #define PLATFORM_H_INCLUDED -#ifdef _MSC_VER - -// Disable some silly and noisy warnings from MSVC compiler -#pragma warning(disable: 4127) // Conditional expression is constant -#pragma warning(disable: 4146) // Unary minus operator applied to unsigned type -#pragma warning(disable: 4800) // Forcing value to bool 'true' or 'false' -#pragma warning(disable: 4996) // Function _ftime() may be unsafe - -// MSVC does not support -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - -#else -# include -#endif +#include #ifndef _WIN32 // Linux - Unix @@ -71,46 +51,6 @@ typedef void*(*pt_start_fn)(void*); # define thread_join(x) pthread_join(x, NULL) #else // Windows and MinGW - -# include - -inline int64_t system_time_to_msec() { - _timeb t; - _ftime(&t); - return t.time * 1000LL + t.millitm; -} - -#ifndef NOMINMAX -# define NOMINMAX // disable macros min() and max() -#endif - -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#undef NOMINMAX - -// We use critical sections on Windows to support Windows XP and older versions. -// Unfortunately, cond_wait() is racy between lock_release() and WaitForSingleObject() -// but apart from this they have the same speed performance of SRW locks. -typedef CRITICAL_SECTION Lock; -typedef HANDLE WaitCondition; -typedef HANDLE NativeHandle; - -// On Windows 95 and 98 parameter lpThreadId may not be null -inline DWORD* dwWin9xKludge() { static DWORD dw; return &dw; } - -# define lock_init(x) InitializeCriticalSection(&(x)) -# define lock_grab(x) EnterCriticalSection(&(x)) -# define lock_release(x) LeaveCriticalSection(&(x)) -# define lock_destroy(x) DeleteCriticalSection(&(x)) -# define cond_init(x) { x = CreateEvent(0, FALSE, FALSE, 0); } -# define cond_destroy(x) CloseHandle(x) -# define cond_signal(x) SetEvent(x) -# define cond_wait(x,y) { lock_release(y); WaitForSingleObject(x, INFINITE); lock_grab(y); } -# define cond_timedwait(x,y,z) { lock_release(y); WaitForSingleObject(x,z); lock_grab(y); } -# define thread_create(x,f,t) (x = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)f,t,0,dwWin9xKludge())) -# define thread_join(x) { WaitForSingleObject(x, INFINITE); CloseHandle(x); } - #endif #endif // #ifndef PLATFORM_H_INCLUDED