mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 08:33:12 -05:00
PPSA21703's Unity PSN plugin imports sceNpWebApi2GetMemoryPoolStats (Xweb+naPZ8Y), so the title did not start. sceNpWebApi2Initialize now records the pool size of each context and sceNpWebApi2Terminate forgets it. The statistics report that size with no peak or current use, as sceHttp2GetMemoryPoolStats does, since nothing is allocated from the pool. A null output or an unknown context throws. The signature and layout follow the Http2 statistics and are recorded in TechnicalDebt. The library gets its own CMakeLists.txt, equivalent to the generic rule, to register its test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include "SceTypes.hpp"
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <stdexcept>
|
|
|
|
struct NpWebApi2MemoryPoolStats {
|
|
std::size_t pool_size;
|
|
std::size_t max_inuse_size;
|
|
std::size_t current_inuse_size;
|
|
std::int32_t reserved;
|
|
};
|
|
|
|
extern "C" {
|
|
int APS5_VABI sceNpWebApi2Initialize(int, std::size_t);
|
|
int APS5_VABI sceNpWebApi2Terminate(int);
|
|
int APS5_VABI sceNpWebApi2GetMemoryPoolStats(int, NpWebApi2MemoryPoolStats*);
|
|
}
|
|
|
|
static void Require(bool value) { if (!value) std::abort(); }
|
|
|
|
template <typename TCall>
|
|
static bool Throws(TCall call) {
|
|
try {
|
|
call();
|
|
} catch (const std::exception&) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int main() {
|
|
const int context = sceNpWebApi2Initialize(1, 0x20000);
|
|
const int other = sceNpWebApi2Initialize(1, 0x8000);
|
|
Require(context > 0 && other > 0 && context != other);
|
|
NpWebApi2MemoryPoolStats stats{1, 1, 1, 1};
|
|
Require(sceNpWebApi2GetMemoryPoolStats(context, &stats) == 0);
|
|
Require(stats.pool_size == 0x20000 && stats.max_inuse_size == 0 && stats.current_inuse_size == 0 && stats.reserved == 0);
|
|
Require(sceNpWebApi2GetMemoryPoolStats(other, &stats) == 0 && stats.pool_size == 0x8000);
|
|
Require(Throws([&] { sceNpWebApi2GetMemoryPoolStats(context, nullptr); }));
|
|
Require(sceNpWebApi2Terminate(context) == 0);
|
|
Require(Throws([&] { sceNpWebApi2GetMemoryPoolStats(context, &stats); }));
|
|
Require(sceNpWebApi2Terminate(other) == 0);
|
|
return 0;
|
|
}
|