X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos.hpp;h=741d345bf18b30d1c702a1770db3e245f7276611;hb=0ae84f58eee1c239d5bc2cc148a1d007b328d2e1;hp=cc72a0ea5b288184ffeb1759894344d2f5f5de3a;hpb=e7cb2b98575d5ff3801bd3527a648e0dbfdebdad;p=apitrace diff --git a/common/os.hpp b/common/os.hpp index cc72a0e..741d345 100644 --- a/common/os.hpp +++ b/common/os.hpp @@ -42,6 +42,9 @@ #ifndef vsnprintf #define vsnprintf _vsnprintf #endif +#ifndef strcasecmp +#define strcasecmp stricmp +#endif #endif /* !_WIN32 */ namespace os { @@ -70,11 +73,29 @@ void log(const char *format, ...) #endif #endif +/** + * Exit immediately. + * + * This should be called only from the wrappers, when there is no safe way of + * failing gracefully. + */ void abort(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 */ #endif /* _OS_HPP_ */