From 9882c5f08f337ce494e040e01a6f79816f92170e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 16 Jun 2013 09:42:51 +0100 Subject: [PATCH] Use rand() on windows. --- common/os.hpp | 12 ++++++++++++ common/trace_fast_callset.cpp | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) 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) -- 2.45.2