1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:52:07 +00:00

Userland: Replace arc4random() with get_random<u32>()

This commit is contained in:
Jean-Baptiste Boric 2021-05-14 17:27:38 +02:00 committed by Andreas Kling
parent 5a0468c21f
commit 090936e424
8 changed files with 19 additions and 12 deletions

View file

@ -6,6 +6,7 @@
*/
#include <AK/Function.h>
#include <AK/Random.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/MathObject.h>
#include <math.h>
@ -86,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::abs)
JS_DEFINE_NATIVE_FUNCTION(MathObject::random)
{
#ifdef __serenity__
double r = (double)arc4random() / (double)UINT32_MAX;
double r = (double)get_random<u32>() / (double)UINT32_MAX;
#else
double r = (double)rand() / (double)RAND_MAX;
#endif