summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2021-02-08 18:08:08 -0800
committerGravatar bunnei2021-02-18 16:16:24 -0800
commite7c33d1ad6b464a591279068f07a6b1de82109f6 (patch)
treebaa5a1f9f2f05113c1b377aff3387c32616ee01c /src
parentcommon: Add implementation of TinyMT (Mersenne Twister RNG). (diff)
downloadyuzu-e7c33d1ad6b464a591279068f07a6b1de82109f6.tar.gz
yuzu-e7c33d1ad6b464a591279068f07a6b1de82109f6.tar.xz
yuzu-e7c33d1ad6b464a591279068f07a6b1de82109f6.zip
hle: kernel: system_control: Add function GenerateRandomU64.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/memory/system_control.cpp7
-rw-r--r--src/core/hle/kernel/memory/system_control.h1
2 files changed, 5 insertions, 3 deletions
diff --git a/src/core/hle/kernel/memory/system_control.cpp b/src/core/hle/kernel/memory/system_control.cpp
index 11d204bc2..e855696ad 100644
--- a/src/core/hle/kernel/memory/system_control.cpp
+++ b/src/core/hle/kernel/memory/system_control.cpp
@@ -25,16 +25,17 @@ u64 GenerateUniformRange(u64 min, u64 max, F f) {
25 } 25 }
26} 26}
27 27
28u64 GenerateRandomU64ForInit() { 28} // Anonymous namespace
29
30u64 GenerateRandomU64() {
29 static std::random_device device; 31 static std::random_device device;
30 static std::mt19937 gen(device()); 32 static std::mt19937 gen(device());
31 static std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max()); 33 static std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
32 return distribution(gen); 34 return distribution(gen);
33} 35}
34} // Anonymous namespace
35 36
36u64 GenerateRandomRange(u64 min, u64 max) { 37u64 GenerateRandomRange(u64 min, u64 max) {
37 return GenerateUniformRange(min, max, GenerateRandomU64ForInit); 38 return GenerateUniformRange(min, max, GenerateRandomU64);
38} 39}
39 40
40} // namespace Kernel::Memory::SystemControl 41} // namespace Kernel::Memory::SystemControl
diff --git a/src/core/hle/kernel/memory/system_control.h b/src/core/hle/kernel/memory/system_control.h
index 19cab8cbc..a01b6b014 100644
--- a/src/core/hle/kernel/memory/system_control.h
+++ b/src/core/hle/kernel/memory/system_control.h
@@ -9,5 +9,6 @@
9namespace Kernel::Memory::SystemControl { 9namespace Kernel::Memory::SystemControl {
10 10
11u64 GenerateRandomRange(u64 min, u64 max); 11u64 GenerateRandomRange(u64 min, u64 max);
12u64 GenerateRandomU64();
12 13
13} // namespace Kernel::Memory::SystemControl 14} // namespace Kernel::Memory::SystemControl