From: José Fonseca Date: Sun, 16 Jun 2013 08:42:51 +0000 (+0100) Subject: Use rand() on windows. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=9882c5f08f337ce494e040e01a6f79816f92170e;p=apitrace Use rand() on windows. --- diff --git a/common/os.hpp b/common/os.hpp index 985ff6b..741d345 100644 --- a/common/os.hpp +++ b/common/os.hpp @@ -84,6 +84,18 @@ 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_ */ diff --git a/common/trace_fast_callset.cpp b/common/trace_fast_callset.cpp index 3b5c570..5aebfd2 100644 --- a/common/trace_fast_callset.cpp +++ b/common/trace_fast_callset.cpp @@ -31,6 +31,7 @@ #include #include +#include "os.hpp" #include "trace_fast_callset.hpp" using namespace trace; @@ -79,7 +80,7 @@ static int random_level (void) { /* tricky bit -- each bit is '1' 75% of the time */ - long int bits = random() | random(); + long int bits = os::random() | os::random(); int level = 1; while (level < MAX_LEVEL)