X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=os_win32.cpp;h=57a7fbca452bf3090766870098b3861629fefcb6;hb=448d423ce3dc6eea8af166b366687c24825b6e2b;hp=e96cc93d63431f9a74b5f5057313b113422986af;hpb=a9e80d06b649c0b0ec191c8c56a390688b5d73c1;p=apitrace diff --git a/os_win32.cpp b/os_win32.cpp old mode 100755 new mode 100644 index e96cc93..57a7fbc --- a/os_win32.cpp +++ b/os_win32.cpp @@ -28,7 +28,6 @@ #include #include "os.hpp" -#include "log.hpp" namespace OS { @@ -46,14 +45,14 @@ CriticalSection = { void AcquireMutex(void) { - //EnterCriticalSection(&CriticalSection); + EnterCriticalSection(&CriticalSection); } void ReleaseMutex(void) { - //LeaveCriticalSection(&CriticalSection); + LeaveCriticalSection(&CriticalSection); } @@ -89,14 +88,32 @@ GetCurrentDir(char *str, size_t size) } void -DebugMessage(const char *message) +DebugMessage(const char *format, ...) { - OutputDebugStringA(message); - if (!IsDebuggerPresent()) { - fflush(stdout); - fputs(message, stderr); - fflush(stderr); - } + char buf[4096]; + + va_list ap; + va_start(ap, format); + fflush(stdout); + vsnprintf(buf, sizeof buf, format, ap); + va_end(ap); + + OutputDebugStringA(buf); + if (!IsDebuggerPresent()) { + fflush(stdout); + fputs(buf, stderr); + fflush(stderr); + } +} + +long long GetTime(void) +{ + static LARGE_INTEGER frequency; + LARGE_INTEGER counter; + if(!frequency.QuadPart) + QueryPerformanceFrequency(&frequency); + QueryPerformanceCounter(&counter); + return counter.QuadPart*1000000LL/frequency.QuadPart; } void @@ -109,25 +126,4 @@ Abort(void) #endif } - - } /* namespace OS */ - - -#if 0 -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - switch(fdwReason) { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - return TRUE; - case DLL_THREAD_DETACH: - return TRUE; - case DLL_PROCESS_DETACH: - Log::Close(); - return TRUE; - } - (void)hinstDLL; - (void)lpvReserved; - return TRUE; -} -#endif