X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos.hpp;h=741d345bf18b30d1c702a1770db3e245f7276611;hb=c037ae2b4f749aed15ede635a6b517534bc5a901;hp=caf9dc3d2cc66e4243d819571beaf1082c7bd723;hpb=48412ffde3dd4710c96d5e8d9cfdf1789e4d703a;p=apitrace diff --git a/common/os.hpp b/common/os.hpp index caf9dc3..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 { @@ -71,15 +74,28 @@ void log(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 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_ */