core: Library cleanup (#1631)

* core: Split error codes into separate files

* Reduces build times and is cleaner

* core: Bring structs and enums to codebase style

* core: More style changes
This commit is contained in:
TheTurtle 2024-11-30 22:37:36 +02:00 committed by GitHub
parent 3d0aacd43d
commit 5b6e0ab238
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
114 changed files with 2158 additions and 2509 deletions

View file

@ -4,8 +4,8 @@
#include "common/assert.h"
#include "common/debug.h"
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/equeue.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/libs.h"
namespace Libraries::Kernel {
@ -77,9 +77,8 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
bool has_found = false;
{
std::scoped_lock lock{m_mutex};
for (auto& event : m_events) {
if ((event.event.ident == ident) && (event.event.filter == filter)) {
if (event.event.ident == ident && event.event.filter == filter) {
event.Trigger(trigger_data);
has_found = true;
}
@ -91,7 +90,6 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
int EqueueInternal::GetTriggeredEvents(SceKernelEvent* ev, int num) {
int count = 0;
for (auto& event : m_events) {
if (event.IsTriggered()) {
if (event.event.flags & SceKernelEvent::Flags::Clear) {

View file

@ -6,8 +6,8 @@
#include "common/scope_exit.h"
#include "common/singleton.h"
#include "core/file_sys/fs.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/file_system.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/libs.h"
#include "kernel.h"
@ -128,12 +128,12 @@ int PS4_SYSV_ABI sceKernelClose(int d) {
return ORBIS_KERNEL_ERROR_EPERM;
}
if (d == 2003) { // dev/urandom case
return SCE_OK;
return ORBIS_OK;
}
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(d);
if (file == nullptr) {
return SCE_KERNEL_ERROR_EBADF;
return ORBIS_KERNEL_ERROR_EBADF;
}
if (!file->is_directory) {
file->f.Close();
@ -141,7 +141,7 @@ int PS4_SYSV_ABI sceKernelClose(int d) {
file->is_opened = false;
LOG_INFO(Kernel_Fs, "Closing {}", file->m_guest_name);
h->DeleteHandle(d);
return SCE_OK;
return ORBIS_OK;
}
int PS4_SYSV_ABI posix_close(int d) {
@ -166,7 +166,7 @@ size_t PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) {
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(d);
if (file == nullptr) {
return SCE_KERNEL_ERROR_EBADF;
return ORBIS_KERNEL_ERROR_EBADF;
}
std::scoped_lock lk{file->m_mutex};
@ -175,7 +175,7 @@ size_t PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) {
int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
if (path == nullptr) {
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
@ -184,15 +184,15 @@ int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
bool ro = false;
const auto host_path = mnt->GetHostPath(path, &ro);
if (host_path.empty()) {
return SCE_KERNEL_ERROR_EACCES;
return ORBIS_KERNEL_ERROR_EACCES;
}
if (ro) {
return SCE_KERNEL_ERROR_EROFS;
return ORBIS_KERNEL_ERROR_EROFS;
}
if (std::filesystem::is_directory(host_path)) {
return SCE_KERNEL_ERROR_EPERM;
return ORBIS_KERNEL_ERROR_EPERM;
}
auto* file = h->GetFile(host_path);
@ -201,7 +201,7 @@ int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
}
LOG_INFO(Kernel_Fs, "Unlinked {}", path);
return SCE_OK;
return ORBIS_OK;
}
size_t PS4_SYSV_ABI _readv(int d, const SceKernelIovec* iov, int iovcnt) {
@ -231,7 +231,7 @@ s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) {
std::scoped_lock lk{file->m_mutex};
if (!file->f.Seek(offset, origin)) {
LOG_CRITICAL(Kernel_Fs, "sceKernelLseek: failed to seek");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
return file->f.Tell();
}
@ -257,7 +257,7 @@ s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) {
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(d);
if (file == nullptr) {
return SCE_KERNEL_ERROR_EBADF;
return ORBIS_KERNEL_ERROR_EBADF;
}
std::scoped_lock lk{file->m_mutex};
@ -277,7 +277,7 @@ int PS4_SYSV_ABI posix_read(int d, void* buf, size_t nbytes) {
int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
LOG_INFO(Kernel_Fs, "path = {} mode = {}", path, mode);
if (path == nullptr) {
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
@ -285,21 +285,21 @@ int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
const auto dir_name = mnt->GetHostPath(path, &ro);
if (std::filesystem::exists(dir_name)) {
return SCE_KERNEL_ERROR_EEXIST;
return ORBIS_KERNEL_ERROR_EEXIST;
}
if (ro) {
return SCE_KERNEL_ERROR_EROFS;
return ORBIS_KERNEL_ERROR_EROFS;
}
// CUSA02456: path = /aotl after sceSaveDataMount(mode = 1)
std::error_code ec;
if (dir_name.empty() || !std::filesystem::create_directory(dir_name, ec)) {
return SCE_KERNEL_ERROR_EIO;
return ORBIS_KERNEL_ERROR_EIO;
}
if (!std::filesystem::exists(dir_name)) {
return SCE_KERNEL_ERROR_ENOENT;
return ORBIS_KERNEL_ERROR_ENOENT;
}
return ORBIS_OK;
}
@ -323,13 +323,13 @@ int PS4_SYSV_ABI sceKernelRmdir(const char* path) {
if (dir_name.empty()) {
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, permission denied",
fmt::UTF(dir_name.u8string()));
return SCE_KERNEL_ERROR_EACCES;
return ORBIS_KERNEL_ERROR_EACCES;
}
if (ro) {
LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, directory is read only",
fmt::UTF(dir_name.u8string()));
return SCE_KERNEL_ERROR_EROFS;
return ORBIS_KERNEL_ERROR_EROFS;
}
if (!std::filesystem::is_directory(dir_name)) {
@ -411,7 +411,7 @@ int PS4_SYSV_ABI sceKernelCheckReachability(const char* path) {
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
const auto path_name = mnt->GetHostPath(path);
if (!std::filesystem::exists(path_name)) {
return SCE_KERNEL_ERROR_ENOENT;
return ORBIS_KERNEL_ERROR_ENOENT;
}
return ORBIS_OK;
}
@ -514,15 +514,15 @@ int PS4_SYSV_ABI sceKernelFtruncate(int fd, s64 length) {
auto* file = h->GetFile(fd);
if (file == nullptr) {
return SCE_KERNEL_ERROR_EBADF;
return ORBIS_KERNEL_ERROR_EBADF;
}
if (file->m_host_name.empty()) {
return SCE_KERNEL_ERROR_EACCES;
return ORBIS_KERNEL_ERROR_EACCES;
}
file->f.SetSize(length);
return SCE_OK;
return ORBIS_OK;
}
static int GetDents(int fd, char* buf, int nbytes, s64* basep) {
@ -605,11 +605,11 @@ s32 PS4_SYSV_ABI sceKernelRename(const char* from, const char* to) {
return ORBIS_KERNEL_ERROR_ENOENT;
}
if (ro) {
return SCE_KERNEL_ERROR_EROFS;
return ORBIS_KERNEL_ERROR_EROFS;
}
const auto dst_path = mnt->GetHostPath(to, &ro);
if (ro) {
return SCE_KERNEL_ERROR_EROFS;
return ORBIS_KERNEL_ERROR_EROFS;
}
const bool src_is_dir = std::filesystem::is_directory(src_path);
const bool dst_is_dir = std::filesystem::is_directory(dst_path);

View file

@ -37,8 +37,8 @@ struct OrbisKernelStat {
u32 st_gen;
s32 st_lspare;
OrbisKernelTimespec st_birthtim;
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
u32 : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
u32 : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
};
struct OrbisKernelDirent {

View file

@ -2,36 +2,27 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <thread>
#include <boost/asio/io_context.hpp>
#include "common/assert.h"
#include "common/debug.h"
#include "common/logging/log.h"
#include "common/polyfill_thread.h"
#include "common/singleton.h"
#include "common/thread.h"
#include "core/file_sys/fs.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/equeue.h"
#include "core/libraries/kernel/file_system.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/memory.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/process.h"
#include "core/libraries/kernel/threads.h"
#include "core/libraries/kernel/threads/exception.h"
#include "core/libraries/kernel/time.h"
#include "core/libraries/libs.h"
#include "core/linker.h"
#ifdef _WIN64
#include <io.h>
#include <objbase.h>
#include <windows.h>
#else
#ifdef __APPLE__
#include <date/tz.h>
#endif
#include <Rpc.h>
#endif
namespace Libraries::Kernel {
@ -39,10 +30,10 @@ namespace Libraries::Kernel {
static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; // dummy return
boost::asio::io_context io_context;
std::mutex m_asio_req;
std::condition_variable_any cv_asio_req;
std::atomic<u32> asio_requests;
std::jthread service_thread;
static std::mutex m_asio_req;
static std::condition_variable_any cv_asio_req;
static std::atomic<u32> asio_requests;
static std::jthread service_thread;
void KernelSignalRequest() {
std::unique_lock lock{m_asio_req};
@ -93,16 +84,12 @@ int* PS4_SYSV_ABI __Error() {
return &g_posix_errno;
}
void ErrSceToPosix(int result) {
const int rt = result > SCE_KERNEL_ERROR_UNKNOWN && result <= SCE_KERNEL_ERROR_ESTOP
? result + -SCE_KERNEL_ERROR_UNKNOWN
: POSIX_EOTHER;
g_posix_errno = rt;
void ErrSceToPosix(int error) {
g_posix_errno = error - ORBIS_KERNEL_ERROR_UNKNOWN;
}
int ErrnoToSceKernelError(int e) {
const auto res = SCE_KERNEL_ERROR_UNKNOWN + e;
return res > SCE_KERNEL_ERROR_ESTOP ? SCE_KERNEL_ERROR_UNKNOWN : res;
int ErrnoToSceKernelError(int error) {
return error + ORBIS_KERNEL_ERROR_UNKNOWN;
}
void SetPosixErrno(int e) {

View file

@ -5,9 +5,8 @@
#include <algorithm>
#include <fmt/core.h>
#include "common/logging/log.h"
#include "common/types.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/orbis_error.h"
namespace Core::Loader {
class SymbolsResolver;
@ -38,7 +37,7 @@ struct WrapperImpl<name, PS4_SYSV_ABI R (*)(Args...), f> {
u32 ret = f(args...);
if (ret != 0) {
// LOG_ERROR(Lib_Kernel, "Function {} returned {}", std::string_view{name.value}, ret);
ret += SCE_KERNEL_ERROR_UNKNOWN;
ret += ORBIS_KERNEL_ERROR_UNKNOWN;
}
return ret;
}

View file

@ -9,9 +9,9 @@
#include "common/scope_exit.h"
#include "common/singleton.h"
#include "core/file_sys/fs.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/memory.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/libs.h"
#include "core/linker.h"
#include "core/memory.h"
@ -28,20 +28,20 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
u64 alignment, int memoryType, s64* physAddrOut) {
if (searchStart < 0 || searchEnd <= searchStart) {
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
const bool is_in_range = searchEnd - searchStart >= len;
if (len <= 0 || !Common::Is16KBAligned(len) || !is_in_range) {
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (alignment != 0 && !Common::Is16KBAligned(alignment)) {
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (physAddrOut == nullptr) {
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* memory = Core::Memory::Instance();
@ -53,7 +53,7 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
"alignment = {:#x}, memoryType = {:#x}, physAddrOut = {:#x}",
searchStart, searchEnd, len, alignment, memoryType, phys_addr);
return SCE_OK;
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment, int memoryType,
@ -111,7 +111,7 @@ s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, int flags, OrbisVirtual
size_t infoSize) {
LOG_INFO(Kernel_Vmm, "called addr = {}, flags = {:#x}", fmt::ptr(addr), flags);
if (!addr) {
return SCE_KERNEL_ERROR_EACCES;
return ORBIS_KERNEL_ERROR_EACCES;
}
auto* memory = Core::Memory::Instance();
return memory->VirtualQuery(std::bit_cast<VAddr>(addr), flags, info);
@ -123,16 +123,16 @@ s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u
if (addr == nullptr) {
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (len == 0 || !Common::Is16KBAligned(len)) {
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 16KB aligned!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (alignment != 0) {
if ((!std::has_single_bit(alignment) && !Common::Is16KBAligned(alignment))) {
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
}
@ -141,7 +141,7 @@ s32 PS4_SYSV_ABI sceKernelReserveVirtualRange(void** addr, u64 len, int flags, u
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
memory->Reserve(addr, in_addr, len, map_flags, alignment);
return SCE_OK;
return ORBIS_OK;
}
int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, int flags,
@ -149,16 +149,16 @@ int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, i
const char* name) {
if (len == 0 || !Common::Is16KBAligned(len)) {
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 16KB aligned!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (!Common::Is16KBAligned(directMemoryStart)) {
LOG_ERROR(Kernel_Vmm, "Start address is not 16KB aligned!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (alignment != 0) {
if ((!std::has_single_bit(alignment) && !Common::Is16KBAligned(alignment))) {
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
}
@ -357,20 +357,20 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolExpand(u64 searchStart, u64 searchEnd, size_
size_t alignment, u64* physAddrOut) {
if (searchStart < 0 || searchEnd <= searchStart) {
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
const bool is_in_range = searchEnd - searchStart >= len;
if (len <= 0 || !Common::Is64KBAligned(len) || !is_in_range) {
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (alignment != 0 && !Common::Is64KBAligned(alignment)) {
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (physAddrOut == nullptr) {
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* memory = Core::Memory::Instance();
@ -391,16 +391,16 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t ali
if (addrIn == nullptr) {
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (len == 0 || !Common::Is2MBAligned(len)) {
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 2MB aligned!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (alignment != 0) {
if ((!std::has_single_bit(alignment) && !Common::Is2MBAligned(alignment))) {
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
}
@ -415,11 +415,11 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t ali
s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int prot, int flags) {
if (addr == nullptr) {
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (len == 0 || !Common::Is64KBAligned(len)) {
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 64KB aligned!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, type = {:#x}, prot = {:#x}, flags = {:#x}",
@ -434,11 +434,11 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolCommit(void* addr, size_t len, int type, int
s32 PS4_SYSV_ABI sceKernelMemoryPoolDecommit(void* addr, size_t len, int flags) {
if (addr == nullptr) {
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (len == 0 || !Common::Is64KBAligned(len)) {
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 64KB aligned!");
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}, flags = {:#x}", fmt::ptr(addr), len, flags);
@ -493,7 +493,7 @@ int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) {
}
auto* memory = Core::Memory::Instance();
memory->UnmapMemory(std::bit_cast<VAddr>(addr), len);
return SCE_OK;
return ORBIS_OK;
}
int PS4_SYSV_ABI posix_munmap(void* addr, size_t len) {

View file

@ -0,0 +1,108 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/libraries/error_codes.h"
// Libkernel library
constexpr int ORBIS_KERNEL_ERROR_UNKNOWN = 0x80020000;
constexpr int ORBIS_KERNEL_ERROR_EPERM = 0x80020001;
constexpr int ORBIS_KERNEL_ERROR_ENOENT = 0x80020002;
constexpr int ORBIS_KERNEL_ERROR_ESRCH = 0x80020003;
constexpr int ORBIS_KERNEL_ERROR_EINTR = 0x80020004;
constexpr int ORBIS_KERNEL_ERROR_EIO = 0x80020005;
constexpr int ORBIS_KERNEL_ERROR_ENXIO = 0x80020006;
constexpr int ORBIS_KERNEL_ERROR_E2BIG = 0x80020007;
constexpr int ORBIS_KERNEL_ERROR_ENOEXEC = 0x80020008;
constexpr int ORBIS_KERNEL_ERROR_EBADF = 0x80020009;
constexpr int ORBIS_KERNEL_ERROR_ECHILD = 0x8002000A;
constexpr int ORBIS_KERNEL_ERROR_EDEADLK = 0x8002000B;
constexpr int ORBIS_KERNEL_ERROR_ENOMEM = 0x8002000C;
constexpr int ORBIS_KERNEL_ERROR_EACCES = 0x8002000D;
constexpr int ORBIS_KERNEL_ERROR_EFAULT = 0x8002000E;
constexpr int ORBIS_KERNEL_ERROR_ENOTBLK = 0x8002000F;
constexpr int ORBIS_KERNEL_ERROR_EBUSY = 0x80020010;
constexpr int ORBIS_KERNEL_ERROR_EEXIST = 0x80020011;
constexpr int ORBIS_KERNEL_ERROR_EXDEV = 0x80020012;
constexpr int ORBIS_KERNEL_ERROR_ENODEV = 0x80020013;
constexpr int ORBIS_KERNEL_ERROR_ENOTDIR = 0x80020014;
constexpr int ORBIS_KERNEL_ERROR_EISDIR = 0x80020015;
constexpr int ORBIS_KERNEL_ERROR_EINVAL = 0x80020016;
constexpr int ORBIS_KERNEL_ERROR_ENFILE = 0x80020017;
constexpr int ORBIS_KERNEL_ERROR_EMFILE = 0x80020018;
constexpr int ORBIS_KERNEL_ERROR_ENOTTY = 0x80020019;
constexpr int ORBIS_KERNEL_ERROR_ETXTBSY = 0x8002001A;
constexpr int ORBIS_KERNEL_ERROR_EFBIG = 0x8002001B;
constexpr int ORBIS_KERNEL_ERROR_ENOSPC = 0x8002001C;
constexpr int ORBIS_KERNEL_ERROR_ESPIPE = 0x8002001D;
constexpr int ORBIS_KERNEL_ERROR_EROFS = 0x8002001E;
constexpr int ORBIS_KERNEL_ERROR_EMLINK = 0x8002001F;
constexpr int ORBIS_KERNEL_ERROR_EPIPE = 0x80020020;
constexpr int ORBIS_KERNEL_ERROR_EDOM = 0x80020021;
constexpr int ORBIS_KERNEL_ERROR_ERANGE = 0x80020022;
constexpr int ORBIS_KERNEL_ERROR_EAGAIN = 0x80020023;
constexpr int ORBIS_KERNEL_ERROR_EWOULDBLOCK = 0x80020023;
constexpr int ORBIS_KERNEL_ERROR_EINPROGRESS = 0x80020024;
constexpr int ORBIS_KERNEL_ERROR_EALREADY = 0x80020025;
constexpr int ORBIS_KERNEL_ERROR_ENOTSOCK = 0x80020026;
constexpr int ORBIS_KERNEL_ERROR_EDESTADDRREQ = 0x80020027;
constexpr int ORBIS_KERNEL_ERROR_EMSGSIZE = 0x80020028;
constexpr int ORBIS_KERNEL_ERROR_EPROTOTYPE = 0x80020029;
constexpr int ORBIS_KERNEL_ERROR_ENOPROTOOPT = 0x8002002A;
constexpr int ORBIS_KERNEL_ERROR_EPROTONOSUPPORT = 0x8002002B;
constexpr int ORBIS_KERNEL_ERROR_ESOCKTNOSUPPORT = 0x8002002C;
constexpr int ORBIS_KERNEL_ERROR_ENOTSUP = 0x8002002D;
constexpr int ORBIS_KERNEL_ERROR_EOPNOTSUPP = 0x8002002D;
constexpr int ORBIS_KERNEL_ERROR_EPFNOSUPPORT = 0x8002002E;
constexpr int ORBIS_KERNEL_ERROR_EAFNOSUPPORT = 0x8002002F;
constexpr int ORBIS_KERNEL_ERROR_EADDRINUSE = 0x80020030;
constexpr int ORBIS_KERNEL_ERROR_EADDRNOTAVAIL = 0x80020031;
constexpr int ORBIS_KERNEL_ERROR_ENETDOWN = 0x80020032;
constexpr int ORBIS_KERNEL_ERROR_ENETUNREACH = 0x80020033;
constexpr int ORBIS_KERNEL_ERROR_ENETRESET = 0x80020034;
constexpr int ORBIS_KERNEL_ERROR_ECONNABORTED = 0x80020035;
constexpr int ORBIS_KERNEL_ERROR_ECONNRESET = 0x80020036;
constexpr int ORBIS_KERNEL_ERROR_ENOBUFS = 0x80020037;
constexpr int ORBIS_KERNEL_ERROR_EISCONN = 0x80020038;
constexpr int ORBIS_KERNEL_ERROR_ENOTCONN = 0x80020039;
constexpr int ORBIS_KERNEL_ERROR_ESHUTDOWN = 0x8002003A;
constexpr int ORBIS_KERNEL_ERROR_ETOOMANYREFS = 0x8002003B;
constexpr int ORBIS_KERNEL_ERROR_ETIMEDOUT = 0x8002003C;
constexpr int ORBIS_KERNEL_ERROR_ECONNREFUSED = 0x8002003D;
constexpr int ORBIS_KERNEL_ERROR_ELOOP = 0x8002003E;
constexpr int ORBIS_KERNEL_ERROR_ENAMETOOLONG = 0x8002003F;
constexpr int ORBIS_KERNEL_ERROR_EHOSTDOWN = 0x80020040;
constexpr int ORBIS_KERNEL_ERROR_EHOSTUNREACH = 0x80020041;
constexpr int ORBIS_KERNEL_ERROR_ENOTEMPTY = 0x80020042;
constexpr int ORBIS_KERNEL_ERROR_EPROCLIM = 0x80020043;
constexpr int ORBIS_KERNEL_ERROR_EUSERS = 0x80020044;
constexpr int ORBIS_KERNEL_ERROR_EDQUOT = 0x80020045;
constexpr int ORBIS_KERNEL_ERROR_ESTALE = 0x80020046;
constexpr int ORBIS_KERNEL_ERROR_EREMOTE = 0x80020047;
constexpr int ORBIS_KERNEL_ERROR_EBADRPC = 0x80020048;
constexpr int ORBIS_KERNEL_ERROR_ERPCMISMATCH = 0x80020049;
constexpr int ORBIS_KERNEL_ERROR_EPROGUNAVAIL = 0x8002004A;
constexpr int ORBIS_KERNEL_ERROR_EPROGMISMATCH = 0x8002004B;
constexpr int ORBIS_KERNEL_ERROR_EPROCUNAVAIL = 0x8002004C;
constexpr int ORBIS_KERNEL_ERROR_ENOLCK = 0x8002004D;
constexpr int ORBIS_KERNEL_ERROR_ENOSYS = 0x8002004E;
constexpr int ORBIS_KERNEL_ERROR_EFTYPE = 0x8002004F;
constexpr int ORBIS_KERNEL_ERROR_EAUTH = 0x80020050;
constexpr int ORBIS_KERNEL_ERROR_ENEEDAUTH = 0x80020051;
constexpr int ORBIS_KERNEL_ERROR_EIDRM = 0x80020052;
constexpr int ORBIS_KERNEL_ERROR_ENOMSG = 0x80020053;
constexpr int ORBIS_KERNEL_ERROR_EOVERFLOW = 0x80020054;
constexpr int ORBIS_KERNEL_ERROR_ECANCELED = 0x80020055;
constexpr int ORBIS_KERNEL_ERROR_EILSEQ = 0x80020056;
constexpr int ORBIS_KERNEL_ERROR_ENOATTR = 0x80020057;
constexpr int ORBIS_KERNEL_ERROR_EDOOFUS = 0x80020058;
constexpr int ORBIS_KERNEL_ERROR_EBADMSG = 0x80020059;
constexpr int ORBIS_KERNEL_ERROR_EMULTIHOP = 0x8002005A;
constexpr int ORBIS_KERNEL_ERROR_ENOLINK = 0x8002005B;
constexpr int ORBIS_KERNEL_ERROR_EPROTO = 0x8002005C;
constexpr int ORBIS_KERNEL_ERROR_ENOTCAPABLE = 0x8002005D;
constexpr int ORBIS_KERNEL_ERROR_ECAPMODE = 0x8002005E;
constexpr int ORBIS_KERNEL_ERROR_ENOBLK = 0x8002005F;
constexpr int ORBIS_KERNEL_ERROR_EICV = 0x80020060;
constexpr int ORBIS_KERNEL_ERROR_ENOPLAYGOENT = 0x80020061;

View file

@ -0,0 +1,128 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/libraries/error_codes.h"
// Posix error codes
constexpr int POSIX_EPERM = 1;
constexpr int POSIX_ENOENT = 2;
constexpr int POSIX_ESRCH = 3;
constexpr int POSIX_EINTR = 4;
constexpr int POSIX_EIO = 5;
constexpr int POSIX_ENXIO = 6;
constexpr int POSIX_E2BIG = 7;
constexpr int POSIX_ENOEXEC = 8;
constexpr int POSIX_EBADF = 9;
constexpr int POSIX_ECHILD = 10;
constexpr int POSIX_EDEADLK = 11;
constexpr int POSIX_ENOMEM = 12;
constexpr int POSIX_EACCES = 13;
constexpr int POSIX_EFAULT = 14;
constexpr int POSIX_ENOTBLK = 15;
constexpr int POSIX_EBUSY = 16;
constexpr int POSIX_EEXIST = 17;
constexpr int POSIX_EXDEV = 18;
constexpr int POSIX_ENODEV = 19;
constexpr int POSIX_ENOTDIR = 20;
constexpr int POSIX_EISDIR = 21;
constexpr int POSIX_EINVAL = 22;
constexpr int POSIX_ENFILE = 23;
constexpr int POSIX_EMFILE = 24;
constexpr int POSIX_ENOTTY = 25;
constexpr int POSIX_ETXTBSY = 26;
constexpr int POSIX_EFBIG = 27;
constexpr int POSIX_ENOSPC = 28;
constexpr int POSIX_ESPIPE = 29;
constexpr int POSIX_EROFS = 30;
constexpr int POSIX_EMLINK = 31;
constexpr int POSIX_EPIPE = 32;
constexpr int POSIX_EDOM = 33;
constexpr int POSIX_ERANGE = 34;
constexpr int POSIX_EAGAIN = 35;
constexpr int POSIX_EWOULDBLOCK = 35;
constexpr int POSIX_EINPROGRESS = 36;
constexpr int POSIX_EALREADY = 37;
constexpr int POSIX_ENOTSOCK = 38;
constexpr int POSIX_EDESTADDRREQ = 39;
constexpr int POSIX_EMSGSIZE = 40;
constexpr int POSIX_EPROTOTYPE = 41;
constexpr int POSIX_ENOPROTOOPT = 42;
constexpr int POSIX_EPROTONOSUPPORT = 43;
constexpr int POSIX_ESOCKTNOSUPPORT = 44;
constexpr int POSIX_EOPNOTSUPP = 45;
constexpr int POSIX_ENOTSUP = 45;
constexpr int POSIX_EPFNOSUPPORT = 46;
constexpr int POSIX_EAFNOSUPPORT = 47;
constexpr int POSIX_EADDRINUSE = 48;
constexpr int POSIX_EADDRNOTAVAIL = 49;
constexpr int POSIX_ENETDOWN = 50;
constexpr int POSIX_ENETUNREACH = 51;
constexpr int POSIX_ENETRESET = 52;
constexpr int POSIX_ECONNABORTED = 53;
constexpr int POSIX_ECONNRESET = 54;
constexpr int POSIX_ENOBUFS = 55;
constexpr int POSIX_EISCONN = 56;
constexpr int POSIX_ENOTCONN = 57;
constexpr int POSIX_ESHUTDOWN = 58;
constexpr int POSIX_ETOOMANYREFS = 59;
constexpr int POSIX_ETIMEDOUT = 60;
constexpr int POSIX_ECONNREFUSED = 61;
constexpr int POSIX_ELOOP = 62;
constexpr int POSIX_ENAMETOOLONG = 63;
constexpr int POSIX_EHOSTDOWN = 64;
constexpr int POSIX_EHOSTUNREACH = 65;
constexpr int POSIX_ENOTEMPTY = 66;
constexpr int POSIX_EPROCLIM = 67;
constexpr int POSIX_EUSERS = 68;
constexpr int POSIX_EDQUOT = 69;
constexpr int POSIX_ESTALE = 70;
constexpr int POSIX_EREMOTE = 71;
constexpr int POSIX_EBADRPC = 72;
constexpr int POSIX_ERPCMISMATCH = 73;
constexpr int POSIX_EPROGUNAVAIL = 74;
constexpr int POSIX_EPROGMISMATCH = 75;
constexpr int POSIX_EPROCUNAVAIL = 76;
constexpr int POSIX_ENOLCK = 77;
constexpr int POSIX_ENOSYS = 78;
constexpr int POSIX_EFTYPE = 79;
constexpr int POSIX_EAUTH = 80;
constexpr int POSIX_ENEEDAUTH = 81;
constexpr int POSIX_EIDRM = 82;
constexpr int POSIX_ENOMSG = 83;
constexpr int POSIX_EOVERFLOW = 84;
constexpr int POSIX_ECANCELED = 85;
constexpr int POSIX_EILSEQ = 86;
constexpr int POSIX_ENOATTR = 87;
constexpr int POSIX_EDOOFUS = 88;
constexpr int POSIX_EBADMSG = 89;
constexpr int POSIX_EMULTIHOP = 90;
constexpr int POSIX_ENOLINK = 91;
constexpr int POSIX_EPROTO = 92;
constexpr int POSIX_ENOTCAPABLE = 93;
constexpr int POSIX_ECAPMODE = 94;
constexpr int POSIX_ENOBLK = 95;
constexpr int POSIX_EICV = 96;
constexpr int POSIX_ENOPLAYGOENT = 97;
constexpr int POSIX_EREVOKE = 98;
constexpr int POSIX_ESDKVERSION = 99;
constexpr int POSIX_ESTART = 100;
constexpr int POSIX_ESTOP = 101;
constexpr int POSIX_EINVALID2MB = 102;
constexpr int POSIX_ELAST = 102;
constexpr int POSIX_EADHOC = 160;
constexpr int POSIX_EINACTIVEDISABLED = 163;
constexpr int POSIX_ENETNODATA = 164;
constexpr int POSIX_ENETDESC = 165;
constexpr int POSIX_ENETDESCTIMEDOUT = 166;
constexpr int POSIX_ENETINTR = 167;
constexpr int POSIX_ERETURN = 205;
constexpr int POSIX_EFPOS = 152;
constexpr int POSIX_ENODATA = 1040;
constexpr int POSIX_ENOSR = 1050;
constexpr int POSIX_ENOSTR = 1051;
constexpr int POSIX_ENOTRECOVERABLE = 1056;
constexpr int POSIX_EOTHER = 1062;
constexpr int POSIX_EOWNERDEAD = 1064;
constexpr int POSIX_ETIME = 1074;

View file

@ -5,7 +5,7 @@
#include "common/elf_info.h"
#include "common/logging/log.h"
#include "core/file_sys/fs.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/kernel/process.h"
#include "core/libraries/libs.h"
#include "core/linker.h"
@ -91,7 +91,7 @@ s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, int flags,
OrbisModuleInfoForUnwind* info) {
if (flags >= 3) {
std::memset(info, 0, sizeof(OrbisModuleInfoForUnwind));
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
if (!info) {
return ORBIS_KERNEL_ERROR_EFAULT;

View file

@ -3,8 +3,8 @@
#include <cstring>
#include "common/assert.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/kernel/threads/sleepq.h"
#include "core/libraries/libs.h"

View file

@ -7,7 +7,7 @@
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/libs.h"
namespace Libraries::Kernel {

View file

@ -3,10 +3,9 @@
#include <thread>
#include "common/assert.h"
#include "common/scope_exit.h"
#include "common/types.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/libs.h"

View file

@ -4,8 +4,8 @@
#include "common/assert.h"
#include "common/thread.h"
#include "core/debug_state.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/kernel/threads/thread_state.h"
#include "core/libraries/libs.h"
@ -380,7 +380,7 @@ int PS4_SYSV_ABI posix_sched_get_priority_min() {
int PS4_SYSV_ABI posix_pthread_rename_np(PthreadT thread, const char* name) {
LOG_INFO(Kernel_Pthread, "name = {}", name);
thread->name = name;
return SCE_OK;
return ORBIS_OK;
}
int PS4_SYSV_ABI posix_pthread_getschedparam(PthreadT pthread, SchedPolicy* policy,

View file

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/kernel/threads/thread_state.h"
#include "core/libraries/libs.h"

View file

@ -1,9 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/assert.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/libs.h"

View file

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/libs.h"

View file

@ -5,9 +5,11 @@
#include <list>
#include <mutex>
#include <semaphore>
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/kernel/time.h"
#include "core/libraries/libs.h"
@ -41,7 +43,7 @@ public:
}
if (timeout && *timeout == 0) {
return SCE_KERNEL_ERROR_ETIMEDOUT;
return ORBIS_KERNEL_ERROR_ETIMEDOUT;
}
// Create waiting thread object and add it into the list of waiters.
@ -50,7 +52,7 @@ public:
// Perform the wait.
const s32 result = waiter.Wait(lk, timeout);
if (result == SCE_KERNEL_ERROR_ETIMEDOUT) {
if (result == ORBIS_KERNEL_ERROR_ETIMEDOUT) {
wait_list.erase(it);
}
return result;
@ -120,15 +122,15 @@ public:
int GetResult(bool timed_out) {
if (timed_out) {
return SCE_KERNEL_ERROR_ETIMEDOUT;
return ORBIS_KERNEL_ERROR_ETIMEDOUT;
}
if (was_deleted) {
return SCE_KERNEL_ERROR_EACCES;
return ORBIS_KERNEL_ERROR_EACCES;
}
if (was_cancled) {
return SCE_KERNEL_ERROR_ECANCELED;
return ORBIS_KERNEL_ERROR_ECANCELED;
}
return SCE_OK;
return ORBIS_OK;
}
int Wait(std::unique_lock<std::mutex>& lk, u32* timeout) {
@ -223,13 +225,13 @@ int PS4_SYSV_ABI sceKernelCancelSema(OrbisKernelSema sem, s32 setCount, s32* pNu
int PS4_SYSV_ABI sceKernelDeleteSema(OrbisKernelSema sem) {
if (!sem) {
return SCE_KERNEL_ERROR_ESRCH;
return ORBIS_KERNEL_ERROR_ESRCH;
}
sem->Delete();
return ORBIS_OK;
}
int PS4_SYSV_ABI posix_sem_init(PthreadSem** sem, int pshared, unsigned int value) {
int PS4_SYSV_ABI posix_sem_init(PthreadSem** sem, int pshared, u32 value) {
if (value > ORBIS_KERNEL_SEM_VALUE_MAX) {
*__Error() = POSIX_EINVAL;
return -1;

View file

@ -2,14 +2,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <forward_list>
#include <list>
#include <boost/intrusive/list.hpp>
#include <boost/intrusive/list_hook.hpp>
#include "common/types.h"
namespace Libraries::Kernel {
struct Pthread;
struct SleepQueue;
using ListBaseHook =
boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::auto_unlink>>;
@ -17,7 +16,7 @@ using ListBaseHook =
using SleepqList = boost::intrusive::list<SleepQueue, boost::intrusive::constant_time_size<false>>;
struct SleepQueue : public ListBaseHook {
std::list<Pthread*> sq_blocked;
std::forward_list<Pthread*> sq_blocked;
SleepqList sq_freeq;
void* sq_wchan;
int sq_type;
@ -35,4 +34,4 @@ int SleepqRemove(SleepQueue* sq, Pthread* td);
void SleepqDrop(SleepQueue* sq, void (*callback)(Pthread*, void*), void* arg);
} // namespace Libraries::Kernel
} // namespace Libraries::Kernel

View file

@ -4,7 +4,7 @@
#include <boost/container/small_vector.hpp>
#include "common/alignment.h"
#include "common/scope_exit.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/posix_error.h"
#include "core/libraries/kernel/threads/pthread.h"
#include "core/libraries/kernel/threads/sleepq.h"
#include "core/libraries/kernel/threads/thread_state.h"

View file

@ -5,7 +5,7 @@
#include "common/assert.h"
#include "common/native_clock.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/orbis_error.h"
#include "core/libraries/kernel/time.h"
#include "core/libraries/libs.h"
@ -80,7 +80,7 @@ u32 PS4_SYSV_ABI sceKernelSleep(u32 seconds) {
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
if (tp == nullptr) {
return SCE_KERNEL_ERROR_EFAULT;
return ORBIS_KERNEL_ERROR_EFAULT;
}
clockid_t pclock_id = CLOCK_REALTIME;
switch (clock_id) {
@ -105,9 +105,9 @@ int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
tp->tv_sec = t.tv_sec;
tp->tv_nsec = t.tv_nsec;
if (result == 0) {
return SCE_OK;
return ORBIS_OK;
}
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
int PS4_SYSV_ABI posix_clock_gettime(s32 clock_id, OrbisKernelTimespec* time) {
@ -126,11 +126,11 @@ int PS4_SYSV_ABI posix_nanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTim
int PS4_SYSV_ABI sceKernelNanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTimespec* rmtp) {
if (!rqtp || !rmtp) {
return SCE_KERNEL_ERROR_EFAULT;
return ORBIS_KERNEL_ERROR_EFAULT;
}
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0) {
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
return posix_nanosleep(rqtp, rmtp);
@ -197,7 +197,7 @@ s32 PS4_SYSV_ABI sceKernelGettimezone(OrbisKernelTimezone* tz) {
int PS4_SYSV_ABI posix_clock_getres(u32 clock_id, OrbisKernelTimespec* res) {
if (res == nullptr) {
return SCE_KERNEL_ERROR_EFAULT;
return ORBIS_KERNEL_ERROR_EFAULT;
}
clockid_t pclock_id = CLOCK_REALTIME;
switch (clock_id) {
@ -221,9 +221,9 @@ int PS4_SYSV_ABI posix_clock_getres(u32 clock_id, OrbisKernelTimespec* res) {
res->tv_sec = t.tv_sec;
res->tv_nsec = t.tv_nsec;
if (result == 0) {
return SCE_OK;
return ORBIS_OK;
}
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2, time_t* seconds,
@ -237,9 +237,9 @@ int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2,
if (dst_seconds)
*dst_seconds = timezone->tz_dsttime * 60;
} else {
return SCE_KERNEL_ERROR_EINVAL;
return ORBIS_KERNEL_ERROR_EINVAL;
}
return SCE_OK;
return ORBIS_OK;
}
namespace Dev {
@ -254,7 +254,7 @@ Common::NativeClock* GetClock() {
} // namespace Dev
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
struct OrbisTimesec* st, unsigned long* dst_sec) {
struct OrbisTimesec* st, u64* dst_sec) {
LOG_TRACE(Kernel, "Called");
#ifdef __APPLE__
// std::chrono::current_zone() not available yet.

View file

@ -81,7 +81,7 @@ int PS4_SYSV_ABI sceKernelConvertLocaltimeToUtc(time_t param_1, int64_t param_2,
OrbisKernelTimezone* timezone, int* dst_seconds);
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time, OrbisTimesec* st,
unsigned long* dst_sec);
u64* dst_sec);
void RegisterTime(Core::Loader::SymbolsResolver* sym);