aboutsummaryrefslogtreecommitdiff
path: root/src/common/random.cpp
blob: d951881cd2a4dce8e3689ff3eb3e5b792d781b9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#include <optional>
#include <random>
#include "common/random.h"

namespace Common::Random {
    [[nodiscard]] static std::random_device& GetGlobalRandomDevice() noexcept {
        static std::random_device g_random_device{};
        return g_random_device;
    }
    [[nodiscard]] u32 Random32(u32 seed) noexcept {
        return GetGlobalRandomDevice()();
    }
    [[nodiscard]] u64 Random64(u64 seed) noexcept {
        return GetGlobalRandomDevice()();
    }
    [[nodiscard]] std::mt19937 GetMT19937() noexcept {
        return std::mt19937(GetGlobalRandomDevice()());
    }
}