use nrand48 instead of rand_r
rand_r is not supported on Android.
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
diff --git a/src/os.cpp b/src/os.cpp
index 6664c1a..df75c1e 100644
--- a/src/os.cpp
+++ b/src/os.cpp
@@ -763,12 +763,12 @@
bool OsLayer::CpuStressWorkload() {
double float_arr[100];
double sum = 0;
- unsigned int seed = 12345;
+ unsigned short seed = 12345;
// Initialize array with random numbers.
for (int i = 0; i < 100; i++) {
- float_arr[i] = rand_r(&seed);
- if (rand_r(&seed) % 2)
+ float_arr[i] = nrand48(&seed);
+ if (nrand48(&seed) % 2)
float_arr[i] *= -1.0;
}
diff --git a/src/worker.cpp b/src/worker.cpp
index c274c4a..2d61286 100644
--- a/src/worker.cpp
+++ b/src/worker.cpp
@@ -2449,7 +2449,7 @@
uint64 time_start, time_end;
struct timeval tv;
- unsigned int seed = static_cast<unsigned int>(gettid());
+ unsigned short seed = static_cast<unsigned int>(gettid());
gettimeofday(&tv, NULL); // Get the timestamp before increments.
time_start = tv.tv_sec * 1000000ULL + tv.tv_usec;
@@ -2459,7 +2459,7 @@
// Choose a datastructure in random and increment the appropriate
// member in that according to the offset (which is the same as the
// thread number.
- int r = rand_r(&seed);
+ int r = nrand48(&seed);
r = cc_cacheline_count_ * (r / (RAND_MAX + 1.0));
// Increment the member of the randomely selected structure.
(cc_cacheline_data_[r].num[cc_thread_num_])++;