shadPS4/src/core/libraries/kernel/kernel.h
georgemoralis bb59cd81fa
[Libs] sceNet (#2815)
* implemented sceNetGetMacAddress

* added all error codes

* added ORBIS_NET_CTL_INFO_DEVICE , ORBIS_NET_CTL_INFO_MTU

* RE sceNetConnect

* sceNetBind RE

* RE sceNetAccept

* RE sceNetGetpeername ,sceNetGetsockname

* fixup

* RE sceNetListen ,sceNetSetsockopt

* sceNetShutdown,sceNetSocket,sceNetSocketAbort,sceNetSocketClose

* sceSend,sceSendTo,sceSendMsg

* sceNetRecv,sceNetRecvFrom,sceNetRecvMsg RE

* some kernel net calls

* init winsock2

* logging

* sockets interface

* added winsock to SCE* error codes conversion

* implemented net basic calls

* some net calls implementation

* clang fixes

* fixes for linux+macOS

* more fix

* added sys_accept implementation

* more posix net calls

* implemented sys_getsockname

* fixed redirection

* fixed posix socket?

* posix_sendto , recvfrom

* added sys_socketclose

* unsigned error log

* added setsocketoptions

* added more posix net calls

* implement getsocketOptions

* stubbed p2p calls
2025-04-30 17:58:39 +03:00

49 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <algorithm>
#include <fmt/core.h>
#include "common/string_literal.h"
#include "common/types.h"
#include "core/libraries/kernel/orbis_error.h"
namespace Core::Loader {
class SymbolsResolver;
}
namespace Libraries::Kernel {
void ErrSceToPosix(int result);
int ErrnoToSceKernelError(int e);
void SetPosixErrno(int e);
int* PS4_SYSV_ABI __Error();
template <StringLiteral name, class F, F f>
struct WrapperImpl;
template <StringLiteral name, class R, class... Args, PS4_SYSV_ABI R (*f)(Args...)>
struct WrapperImpl<name, PS4_SYSV_ABI R (*)(Args...), f> {
static constexpr StringLiteral Name{name};
static R PS4_SYSV_ABI wrap(Args... args) {
u32 ret = f(args...);
if (ret != 0) {
// LOG_ERROR(Lib_Kernel, "Function {} returned {}", std::string_view{name.value}, ret);
ret += ORBIS_KERNEL_ERROR_UNKNOWN;
}
return ret;
}
};
template <StringLiteral name, class F, F f>
constexpr auto OrbisWrapper = WrapperImpl<name, F, f>::wrap;
#define ORBIS(func) WrapperImpl<#func, decltype(&func), func>::wrap
int* PS4_SYSV_ABI __Error();
void RegisterKernel(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Kernel