mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-12-05 17:11:09 +00:00
The two exports are Microsoft STL's std::bitset::to_string helpers. Each writes one character per bit, the most significant bit first, picking the zero or the one character, and writes no terminator; _2 writes 16-bit elements, the guest wchar_t. A null destination or bitset with a nonzero size throws, as the recovered extrema helpers do for invalid ranges. The functions leave the recovered-inventory placeholders for BitsetToString.cpp, and the technical debt records that the PS5 ABI and results are unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
978 B
C++
27 lines
978 B
C++
#include "prx/libSceLibcInternal/include/RecoveredInventory.hpp"
|
|
#include "prx/libc/include/General.hpp"
|
|
|
|
namespace {
|
|
|
|
template <typename TElement>
|
|
void BitsetToString(TElement* destination, const void* source, std::size_t bits, TElement zero, TElement one) {
|
|
if (bits == 0) return;
|
|
if (!destination || !source) APS5_INVALID_ARG_EX;
|
|
const auto* bytes = static_cast<const std::uint8_t*>(source);
|
|
for (std::size_t bit = 0; bit < bits; ++bit) destination[bits - 1 - bit] = ((bytes[bit >> 3] >> (bit & 7)) & 1u) != 0 ? one : zero;
|
|
}
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
void APS5_VABI __std_bitset_to_string_1_nid_postfix(char* destination, const void* source, std::size_t bits, char zero, char one) {
|
|
BitsetToString(destination, source, bits, zero, one);
|
|
}
|
|
|
|
void APS5_VABI __std_bitset_to_string_2_nid_postfix(std::uint16_t* destination, const void* source, std::size_t bits, std::uint16_t zero, std::uint16_t one) {
|
|
BitsetToString(destination, source, bits, zero, one);
|
|
}
|
|
|
|
}
|