X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=os_win32.cpp;h=57a7fbca452bf3090766870098b3861629fefcb6;hb=52eaaa2f3749692d587a41145da900f9014e9002;hp=2e28ec8695967b15e9f636f0dfc0eaaef8c7b0f5;hpb=1630be10e241e2741af716988da3e51dded481a6;p=apitrace diff --git a/os_win32.cpp b/os_win32.cpp index 2e28ec8..57a7fbc 100644 --- a/os_win32.cpp +++ b/os_win32.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "os.hpp" @@ -37,7 +38,7 @@ namespace OS { */ static CRITICAL_SECTION CriticalSection = { - (_CRITICAL_SECTION_DEBUG *)-1, -1, 0, 0, 0, 0 + (PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0 }; @@ -69,7 +70,7 @@ GetProcessName(char *str, size_t size) lpProcessExt = strrchr(lpProcessName, '.'); if (lpProcessExt) { - *lpProcessExt = '\0'; + *lpProcessExt = '\0'; } strncpy(str, lpProcessName, size); @@ -77,5 +78,52 @@ GetProcessName(char *str, size_t size) return true; } +bool +GetCurrentDir(char *str, size_t size) +{ + DWORD ret; + ret = GetCurrentDirectoryA(size, str); + str[size - 1] = 0; + return ret == 0 ? false : true; +} + +void +DebugMessage(const char *format, ...) +{ + 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 +Abort(void) +{ +#ifndef NDEBUG + DebugBreak(); +#else + ExitProcess(0); +#endif +} } /* namespace OS */