X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos.hpp;h=741d345bf18b30d1c702a1770db3e245f7276611;hb=d6c02fd58feb2b48be13a2405d0eb738ed62925a;hp=91c819fca55f09a516a746d23283bd0ab81766de;hpb=77373c35010d89e5ab3f030e4c60f8f6e3fdbe82;p=apitrace diff --git a/common/os.hpp b/common/os.hpp index 91c819f..741d345 100644 --- a/common/os.hpp +++ b/common/os.hpp @@ -73,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_ */