mirror of
https://github.com/mihawk-99/PS5_RetroArch.git
synced 2026-10-23 00:52:29 -05:00
Beetle PSX HW, Mupen64Plus-Next, Beetle Saturn, VICE x64sc, MAME 0.289, DeSmuME and Azahar, each built from my fork of it at a pinned revision (tools/core-fork.sh, tools/build-<core>.sh), with the PS5 defaults at the most each offers that holds full speed. The loader grew to fit them. A core's file and image come from direct memory, up to 1 GiB (MAME's image is 413 MB), and each image is zeroed when it is reserved: direct memory is not, and a reloaded core's .bss held its predecessor's bytes, which faulted every core on a reload. Each image's .eh_frame is registered with the title's unwinder, for the cores that throw. Initializers are capped at 65,536 (Azahar has 2,476). A load that misses imports lists all of them. Aligned operator new comes from the core heap, a core's atexit belongs to the core, and the imports the new cores need are bound to the platform layer's getcwd, tmpfile, mkstemp and the rest (SDK fork ebd0fe2).
79 lines
2.6 KiB
C++
79 lines
2.6 KiB
C++
/*
|
|
* PS5 RetroArch - libc entry points LRPS2's core calls and the console lacks.
|
|
*
|
|
* Copyright (C) 2026 Mihawk
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* Each function here is referenced by LRPS2 or by a library it vendors, and
|
|
* cannot come from the title's import table: the payload SDK exports no symbol
|
|
* for it, or its stub lists one the console does not provide at runtime. They
|
|
* are defined in the core so the reference resolves where it is made. The
|
|
* pattern is the Dolphin port's (tooling/dolphin/ps5-libc-shims.cpp).
|
|
*
|
|
* atexit, which glslang calls for its finalizer, comes from the destructor
|
|
* registry every core links (tooling/native/core_cxx_runtime.cpp).
|
|
*
|
|
* A real implementation, because the core depends on the answer:
|
|
*
|
|
* clock_nanosleep
|
|
* Granite's timer (paraLLEl-GS) sleeps to an absolute deadline.
|
|
* The console has clock_gettime and nanosleep, so the deadline is
|
|
* turned into the interval still to go.
|
|
*
|
|
* Refusals the callers already handle, for features a console core never uses:
|
|
*
|
|
* getaddrinfo, freeaddrinfo DEV9's network adapter (name lookups)
|
|
* if_nameindex, if_freenameindex DEV9's adapter enumeration
|
|
*/
|
|
#include <cerrno>
|
|
#include <cstddef>
|
|
#include <ctime>
|
|
|
|
#include <net/if.h>
|
|
#include <netdb.h>
|
|
|
|
extern "C"
|
|
{
|
|
int clock_nanosleep(clockid_t clock, int flags, const struct timespec *request,
|
|
struct timespec *remaining)
|
|
{
|
|
struct timespec wait = *request;
|
|
if (flags & TIMER_ABSTIME)
|
|
{
|
|
struct timespec now;
|
|
if (clock_gettime(clock, &now) != 0)
|
|
return errno;
|
|
const long long left = (static_cast<long long>(request->tv_sec) - now.tv_sec) * 1000000000LL +
|
|
(request->tv_nsec - now.tv_nsec);
|
|
if (left <= 0)
|
|
return 0;
|
|
wait.tv_sec = static_cast<time_t>(left / 1000000000LL);
|
|
wait.tv_nsec = static_cast<long>(left % 1000000000LL);
|
|
/* An absolute sleep reports no remainder: the deadline is unchanged. */
|
|
remaining = nullptr;
|
|
}
|
|
return nanosleep(&wait, remaining) == 0 ? 0 : errno;
|
|
}
|
|
|
|
int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **result)
|
|
{
|
|
if (result)
|
|
*result = nullptr;
|
|
return EAI_FAIL;
|
|
}
|
|
|
|
void freeaddrinfo(struct addrinfo *)
|
|
{
|
|
}
|
|
|
|
struct if_nameindex *if_nameindex()
|
|
{
|
|
errno = ENOSYS;
|
|
return nullptr;
|
|
}
|
|
|
|
void if_freenameindex(struct if_nameindex *)
|
|
{
|
|
}
|
|
}
|