X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos.hpp;h=741d345bf18b30d1c702a1770db3e245f7276611;hb=refs%2Fheads%2Fglx-copy-sub-buffer;hp=8e487b502937f02c5e80ae0a292c9c7fd0e7d7d0;hpb=a8c164caecc408462d3e4c1626c87ab9974f6a48;p=apitrace diff --git a/common/os.hpp b/common/os.hpp index 8e487b5..741d345 100644 --- a/common/os.hpp +++ b/common/os.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef _WIN32 #ifndef snprintf @@ -41,25 +42,14 @@ #ifndef vsnprintf #define vsnprintf _vsnprintf #endif -#define PATH_SEP '\\' -#else /* !_WIN32 */ -#define PATH_SEP '/' -#endif /* !_WIN32 */ - -#ifndef PATH_MAX -#define PATH_MAX 1024 +#ifndef strcasecmp +#define strcasecmp stricmp #endif +#endif /* !_WIN32 */ -namespace OS { - -void AcquireMutex(void); - -void ReleaseMutex(void); - -bool GetProcessName(char *str, size_t size); -bool GetCurrentDir(char *str, size_t size); +namespace os { -void DebugMessage(const char *format, ...) +void log(const char *format, ...) #ifdef __GNUC__ __attribute__ ((format (printf, 1, 2))) #endif @@ -84,15 +74,28 @@ void DebugMessage(const char *format, ...) #endif /** - * Get the current time in microseconds from an unknown base. + * Exit immediately. + * + * This should be called only from the wrappers, when there is no safe way of + * failing gracefully. */ -long long GetTime(void); +void abort(void); -void Abort(void); +void setExceptionCallback(void (*callback)(void)); +void resetExceptionCallback(void); -void SetExceptionCallback(void (*callback)(void)); -void ResetExceptionCallback(void); +/** + * Returns a pseudo-random integer in the range 0 to RAND_MAX. + */ +static inline int +random(void) { +#ifdef _WIN32 + return ::rand(); +#else + return ::random(); +#endif +} -} /* namespace OS */ +} /* namespace os */ #endif /* _OS_HPP_ */