shadPS4/src/core/libraries/random/random.cpp
Lizardy 59b651be07
[Libs] Error Codes (#612)
* ngs2: all errors w/ official names

* ajm errors

* gnm errors

* random errors

* clang

* random error

* linux

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-27 15:53:38 +03:00

30 lines
797 B
C++

// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "random.h"
#include "random_error.h"
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
namespace Libraries::Random {
s32 PS4_SYSV_ABI sceRandomGetRandomNumber(u8* buf, std::size_t size) {
LOG_TRACE(Lib_Random, "called");
if (size > SCE_RANDOM_MAX_SIZE) {
return SCE_RANDOM_ERROR_INVALID;
}
for (auto i = 0; i < size; ++i) {
buf[i] = std::rand() & 0xFF;
}
return ORBIS_OK;
}
void RegisterlibSceRandom(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("PI7jIZj4pcE", "libSceRandom", 1, "libSceRandom", 1, 1, sceRandomGetRandomNumber);
};
} // namespace Libraries::Random