refactor: strip explanatory comments to match repo conventions

Comments in this codebase may only mark technical debt (per
docs/dev/CONVENTIONS.md), plus the #endif and namespace-close
structural exceptions. Removes the descriptive comments added on
this branch across PreciseWait.hpp, FormattingWide.cpp, the
direct-memory pool query/free-run plumbing, and the module loader
wiring, keeping the two allowed structural markers intact.
This commit is contained in:
OverkillLabs
2026-09-29 04:18:04 +03:00
parent 5387aef3b7
commit d9f8d87c27
7 changed files with 4 additions and 38 deletions
-2
View File
@@ -81,8 +81,6 @@ int APS5_VABI fscanf_nid_postfix() {
return 0;
}
// vswprintf_nid_postfix is implemented in src/FormattingWide.cpp.
APS5_EXPORT("Pu0Ecyk-7FU", libcUnknown_Pu0Ecyk_M7FU);
int APS5_VABI libcUnknown_Pu0Ecyk_M7FU() {
NotImplemented_nid_no_patch(__func__);
+1 -12
View File
@@ -8,17 +8,6 @@
#include <windows.h>
#endif
// std::condition_variable::wait_for on this MinGW toolchain cannot return in under about one system tick,
// whatever the budget says: measured 15.6 ms average for a 0 us wait and for a 1 us wait alike, and raising
// the process timer resolution to 0.5 ms with NtSetTimerResolution does not change it. A high-resolution
// waitable timer honours the same request in about 0.5 ms instead.
//
// This matters for any guest-side poll that requests a sub-tick wait budget: without this helper, such a
// poll runs at the OS tick rate rather than at the requested budget, which can turn a tight wait loop into
// a multi-millisecond stall per iteration.
//
// Callers must hold no lock that the awaited event's producer needs: the point of the helper is to wait
// precisely and cheaply, so the caller re-tests its own condition afterwards.
inline constexpr unsigned long long kSubTickWaitUs = 2000;
inline void PreciseSleepUs(unsigned long long micros) {
@@ -38,7 +27,7 @@ inline void PreciseSleepUs(unsigned long long micros) {
thread_local Timer timer;
if (timer.handle != nullptr) {
LARGE_INTEGER due{};
due.QuadPart = -static_cast<LONGLONG>(micros * 10ULL); // relative, 100 ns units
due.QuadPart = -static_cast<LONGLONG>(micros * 10ULL);
if (SetWaitableTimerEx(timer.handle, &due, 0, nullptr, nullptr, nullptr, 0) != FALSE) {
WaitForSingleObject(timer.handle, INFINITE);
return;
@@ -1,6 +1,3 @@
// Wide-character (UTF-16 guest wchar_t) printf-family support. Upstream's Formatting.cpp implements the
// narrow checked/unchecked printf and scanf families but has no real wide-char formatter; vswprintf and
// wprintf are otherwise left as unimplemented stubs.
#include <cerrno>
#include <cstdint>
#include <cstddef>
@@ -89,7 +86,6 @@ void AppendPadded(std::u16string& out, const std::u16string& text, bool left, in
if (left) out.append(pad, u' ');
}
// Wide printf: %s is a narrow string and %ls a wide one; numeric conversions reuse the host formatter.
std::u16string FormatWide(const char16_t* format, VaList* source) {
if (format == nullptr || source == nullptr) throw std::invalid_argument("Null formatting argument");
LibcDetail::FormatArguments args(source);
@@ -191,7 +187,6 @@ std::u16string FormatWide(const char16_t* format, VaList* source) {
extern "C" {
// Returns the character count, or -1 when the buffer is too small (the output is still terminated).
int APS5_VABI vswprintf_nid_postfix(char16_t* buffer, std::size_t size, const char16_t* format, VaList* args) {
if (buffer == nullptr || size == 0) { errno = 22; return -1; }
try {
@@ -129,8 +129,6 @@ int APS5_VABI sceKernelAvailableDirectMemorySize(int64_t search_start, int64_t s
if (ret != 0) { *phys_addr_out = 0; *size_out = 0; return ret; }
DirectMemoryFree(tmpPhys, PS5_PAGE_SIZE);
*phys_addr_out = tmpPhys;
// The probe only proves one page is free; report the run actually available from there so a
// title cannot plan an allocation that immediately fails.
*size_out = DirectMemoryFreeRun(static_cast<uint64_t>(tmpPhys), static_cast<uint64_t>(search_end));
return 0;
}
@@ -147,8 +145,6 @@ int APS5_VABI sceKernelDirectMemoryQuery(int64_t offset, int flags, void* info,
q->end = static_cast<int64_t>(block.end);
q->memory_type = block.memoryType;
} else {
// Unallocated range: report the containing page as free-form (-1), same as an unregistered
// range has no type to answer with.
q->start = offset & ~static_cast<int64_t>(PS5_PAGE_SIZE - 1);
q->end = q->start + PS5_PAGE_SIZE;
q->memory_type = -1;
@@ -33,8 +33,6 @@ struct PhysicalMemoryPool {
void Free(uint64_t start, size_t len) {
std::lock_guard<std::mutex> lock(_mutex);
_mark(start, len, false);
// A partial release leaves the rest of the block queryable, so the record is split
// rather than dropped.
auto it = _ranges.upper_bound(start);
if (it == _ranges.begin()) return;
--it;
@@ -45,7 +43,6 @@ struct PhysicalMemoryPool {
if (start + len < block.end) _ranges[start + len] = {start + len, block.end, block.memoryType};
}
// Block containing offset, as the guest was given it at allocation time.
bool Query(uint64_t offset, DirectMemoryBlock* block) {
std::lock_guard<std::mutex> lock(_mutex);
auto it = _ranges.upper_bound(offset);
@@ -56,7 +53,6 @@ struct PhysicalMemoryPool {
return true;
}
// Contiguous free bytes from `offset` up to `limit`.
size_t FreeRun(uint64_t offset, uint64_t limit) {
std::lock_guard<std::mutex> lock(_mutex);
uint64_t cur = offset & ~static_cast<uint64_t>(PS5_PAGE_SIZE - 1);
@@ -8,9 +8,6 @@
namespace {
// A pool block is the unit sceKernelMemoryPoolGetBlockStats counts. The pool itself is backed by
// ordinary direct-memory pages: Expand takes them, Reserve hands out an inaccessible virtual
// range, Commit makes part of it accessible and Decommit takes the access away again.
constexpr size_t kPoolBlockSize = 2ULL * 1024 * 1024;
struct PoolState {
@@ -61,7 +58,6 @@ int Guarded(Fn fn) {
extern "C" {
// Batch opcodes: 1 commit, 2 decommit, 3 protect, 4 type-protect. Move (5) is not supported.
int APS5_VABI sceKernelMemoryPoolBatch(const KernelMemoryPoolBatchEntry* entries, int num_entries, int* num_entries_out, int flags) {
(void)flags;
if (!entries || num_entries < 0) return SCE_KERNEL_ERROR_EINVAL;
@@ -109,7 +105,6 @@ int APS5_VABI sceKernelMemoryPoolExpand(int64_t search_start, int64_t search_end
return ret;
}
// Counts in whole pool blocks: expanded but uncommitted blocks are "available", committed ones "allocated".
int APS5_VABI sceKernelMemoryPoolGetBlockStats(KernelMemoryPoolBlockStats* output, size_t output_size) {
if (!output || output_size < sizeof(KernelMemoryPoolBlockStats)) return SCE_KERNEL_ERROR_EINVAL;
PoolState& pool = Pool();
@@ -123,7 +118,6 @@ int APS5_VABI sceKernelMemoryPoolGetBlockStats(KernelMemoryPoolBlockStats* outpu
return 0;
}
// The reservation is an inaccessible virtual range; Commit later gives it access.
int APS5_VABI sceKernelMemoryPoolReserve(void* addr_in, size_t len, size_t alignment, int flags, void** addr_out) {
(void)addr_in;
(void)flags;
@@ -5,7 +5,6 @@
#include "prx/libkernel/DirectMemory/DirectMemory.hpp"
extern "C" {
// DynamicLoader.cpp: host-module loader shared with dlopen/dlsym.
void* APS5_VABI dlopen_nid_postfix(const char* path, int flags);
void* APS5_VABI dlsym_nid_postfix(void* handle, const char* name);
int APS5_VABI dlclose_nid_postfix(void* handle);
@@ -13,11 +12,10 @@ int APS5_VABI dlclose_nid_postfix(void* handle);
extern "C" {
// Module handles are the loader's dlopen handles, so only host-loadable modules resolve here.
int APS5_VABI sceKernelDlsym(KernelModule handle, const char* symbol, void** addr) {
if (!symbol || !addr) return SCE_KERNEL_ERROR_EFAULT;
void* found = dlsym_nid_postfix(reinterpret_cast<void*>(static_cast<intptr_t>(handle)), symbol);
if (!found) return static_cast<int>(0x80020003); // ESRCH: symbol not found
if (!found) return static_cast<int>(0x80020003);
*addr = found;
return 0;
}
@@ -45,8 +43,8 @@ KernelModule APS5_VABI sceKernelLoadStartModule(const char* module_file_name, si
(void)opt;
if (res) *res = 0;
if (!module_file_name) return static_cast<KernelModule>(SCE_KERNEL_ERROR_EFAULT);
void* handle = dlopen_nid_postfix(module_file_name, 2); // RTLD_NOW
if (!handle) return static_cast<KernelModule>(0x80020002); // ENOENT
void* handle = dlopen_nid_postfix(module_file_name, 2);
if (!handle) return static_cast<KernelModule>(0x80020002);
return static_cast<KernelModule>(reinterpret_cast<intptr_t>(handle));
}