diff --git a/headers/private/kernel/util/Random.h b/headers/private/kernel/util/Random.h index 7ca4f05312..26d1ee0059 100644 --- a/headers/private/kernel/util/Random.h +++ b/headers/private/kernel/util/Random.h @@ -16,8 +16,8 @@ #define MAX_FAST_RANDOM_VALUE 0x7fff #define MAX_RANDOM_VALUE 0x7fffffffu -const int kFastRandomShift = 15; -const int kRandomShift = 31; +static const int kFastRandomShift = 15; +static const int kRandomShift = 31; #ifdef __cplusplus extern "C" { diff --git a/src/system/kernel/util/Random.cpp b/src/system/kernel/util/Random.cpp index 417abe7324..57c724de4f 100644 --- a/src/system/kernel/util/Random.cpp +++ b/src/system/kernel/util/Random.cpp @@ -12,8 +12,8 @@ #include -static uint32 fast_last = 0; -static uint32 last = 0; +static uint32 sFastLast = 0; +static uint32 sLast = 0; // In the following functions there are race conditions when many threads // attempt to update static variable last. However, since such conflicts @@ -24,11 +24,11 @@ static uint32 last = 0; unsigned int fast_random_value() { - if (fast_last == 0) - fast_last = system_time(); + if (sFastLast == 0) + sFastLast = system_time(); - uint32 random = fast_last * 1103515245 + 12345; - fast_last = random; + uint32 random = sFastLast * 1103515245 + 12345; + sFastLast = random; return (random >> 16) & 0x7fff; } @@ -39,16 +39,16 @@ fast_random_value() unsigned int random_value() { - if (last == 0) - last = system_time(); + if (sLast == 0) + sLast = system_time(); - uint32 hi = last / 127773; - uint32 lo = last % 127773; + uint32 hi = sLast / 127773; + uint32 lo = sLast % 127773; int32 random = 16807 * lo - 2836 * hi; if (random <= 0) random += MAX_RANDOM_VALUE; - last = random; + sLast = random; return random % (MAX_RANDOM_VALUE + 1); }