diff options
| author | 2023-11-23 16:55:56 +0200 | |
|---|---|---|
| committer | 2023-11-25 00:47:43 -0500 | |
| commit | 5a9ffa81a6452f9f0af6f5b288f302cbaf0475b2 (patch) | |
| tree | 2dd459df7b2687871fa9d86df2bb63408505c949 /src/common/host_memory.cpp | |
| parent | Address more review comments (diff) | |
| download | yuzu-5a9ffa81a6452f9f0af6f5b288f302cbaf0475b2.tar.gz yuzu-5a9ffa81a6452f9f0af6f5b288f302cbaf0475b2.tar.xz yuzu-5a9ffa81a6452f9f0af6f5b288f302cbaf0475b2.zip | |
host_memory: Simplify randomness generation
Diffstat (limited to '')
| -rw-r--r-- | src/common/host_memory.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index f14077750..4cbc22b85 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp | |||
| @@ -363,21 +363,12 @@ private: | |||
| 363 | 363 | ||
| 364 | #ifdef ARCHITECTURE_arm64 | 364 | #ifdef ARCHITECTURE_arm64 |
| 365 | 365 | ||
| 366 | static uint64_t GetRandomU64() { | ||
| 367 | uint64_t ret; | ||
| 368 | ASSERT(getrandom(&ret, sizeof(ret), 0) == 0); | ||
| 369 | return ret; | ||
| 370 | } | ||
| 371 | |||
| 372 | static void* ChooseVirtualBase(size_t virtual_size) { | 366 | static void* ChooseVirtualBase(size_t virtual_size) { |
| 373 | constexpr uintptr_t Map39BitSize = (1ULL << 39); | 367 | constexpr uintptr_t Map39BitSize = (1ULL << 39); |
| 374 | constexpr uintptr_t Map36BitSize = (1ULL << 36); | 368 | constexpr uintptr_t Map36BitSize = (1ULL << 36); |
| 375 | 369 | ||
| 376 | // Seed the MT with some initial strong randomness. | 370 | // This is not a cryptographic application, we just want something random. |
| 377 | // | 371 | std::mt19937_64 rng; |
| 378 | // This is not a cryptographic application, we just want something more | ||
| 379 | // random than the current time. | ||
| 380 | std::mt19937_64 rng(GetRandomU64()); | ||
| 381 | 372 | ||
| 382 | // We want to ensure we are allocating at an address aligned to the L2 block size. | 373 | // We want to ensure we are allocating at an address aligned to the L2 block size. |
| 383 | // For Qualcomm devices, we must also allocate memory above 36 bits. | 374 | // For Qualcomm devices, we must also allocate memory above 36 bits. |