Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cf0a305
feat(libc): implement libc++ ios_base::failure and iostream_category
kiansaeidnia Nov 26, 2026
30e2197
Merge commit 'refs/tmp/pr27582' into feat/libc-libcxx-ostream-core
LeandroLP23 Dec 3, 2026
c89eaca
Merge commit 'refs/tmp/pr28741' into feat/libc-libcxx-ostream-core
LeandroLP23 Dec 3, 2026
7b30dd2
refactor(libc): share the libc++ ios_base layout
LeandroLP23 Dec 3, 2026
aa4027e
feat(libc): implement libc++ basic_ostream<char> core members
LeandroLP23 Dec 3, 2026
e9369a2
test(libc): build the ostream fixtures in place and describe null str…
LeandroLP23 Dec 3, 2026
a1b2a04
feat(libc): add the libc++ num_put<char> facet
LeandroLP23 Dec 3, 2026
8ebbd09
feat(libc): implement the libc++ basic_ostream<char> arithmetic inser…
LeandroLP23 Dec 3, 2026
442d064
feat(libc): hold the libc++ num_put<char> facet in the classic locale
LeandroLP23 Dec 3, 2026
0bbb9a1
Merge remote-tracking branch 'origin/main' into feat/libc-libcxx-ostr…
LeandroLP23 Dec 4, 2026
320ab80
Merge branch 'feat/libc-libcxx-ostream-core' into feat/libc-libcxx-os…
LeandroLP23 Dec 4, 2026
1e12559
docs(debt): note the classic num_put<char> facet and the exported ins…
LeandroLP23 Dec 4, 2026
0790d04
fix(libc): use classic numeric values per placeholder facet slot
LeandroLP23 Dec 4, 2026
3143f32
fix(libc): hold the stream locale while numeric formatting uses its f…
LeandroLP23 Dec 4, 2026
ed4f8f1
fix(libc): free a long numpunct string outside a destructor
LeandroLP23 Dec 4, 2026
3e91f9b
Merge commit 'ed4f8f163c401a781426567714f5e332087cfdb1' into codex/li…
cmsierrave-coder Dec 5, 2026
5f3b5cf
feat(libc): implement libc++ time_put range formatting
cmsierrave-coder Dec 5, 2026
e484038
fix(libc): correct classic facet RTTI and ostream dispatch
cmsierrave-coder Dec 5, 2026
32f2f29
fix(libc): preserve overlapping time_put format output
cmsierrave-coder Dec 5, 2026
2b291da
fix(libc): preserve time conversions and boolalpha padding
cmsierrave-coder Dec 6, 2026
c970834
test(libc): verify boolalpha padding through the stream buffer
cmsierrave-coder Dec 6, 2026
d6d187c
test(libc): check boolalpha short writes through xsputn
cmsierrave-coder Dec 6, 2026
aa2e03a
chore(libc): merge origin/main into codex/libcxx-time-put
cmsierrave-coder Dec 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/libs/prx/libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ target_sources(libc PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/AtomicWait.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/LibcxxMutex.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/LibcxxIosInit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/LibcxxOstream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Rename.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Errors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Syslog.cpp
Expand Down
11 changes: 11 additions & 0 deletions core/libs/prx/libc/include/Api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,13 @@ void APS5_VABI _ZNSt3__112system_errorC1ENS_10error_codeERKNS_12basic_stringIcNS
void APS5_VABI _ZNSt3__112system_errorD1Ev_nid_postfix(LibcException::LibcxxSystemErrorObject* self) noexcept;
void APS5_VABI _ZNSt3__112system_errorD2Ev_nid_postfix(LibcException::LibcxxSystemErrorObject* self) noexcept;
[[noreturn]] void APS5_VABI _ZNSt3__120__throw_system_errorEiPKc_nid_postfix(int value, const char* what);
const LibcException::CategoryObject* APS5_VABI _ZNSt3__117iostream_categoryEv_nid_postfix() noexcept;
extern const LibcException::TypeRecord _ZTINSt3__18ios_base7failureE_nid_postfix;
extern const LibcException::ExceptionVtable _ZTVNSt3__18ios_base7failureE_nid_postfix;
void APS5_VABI _ZNSt3__18ios_base7failureC1EPKcRKNS_10error_codeE_nid_postfix(LibcException::LibcxxSystemErrorObject* self, const char* what, const LibcException::LibcxxErrorCode* code);
void APS5_VABI _ZNSt3__18ios_base7failureC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKNS_10error_codeE_nid_postfix(LibcException::LibcxxSystemErrorObject* self, const void* what, const LibcException::LibcxxErrorCode* code);
void APS5_VABI _ZNSt3__18ios_base7failureD1Ev_nid_postfix(LibcException::LibcxxSystemErrorObject* self) noexcept;
void APS5_VABI _ZNSt3__18ios_base7failureD2Ev_nid_postfix(LibcException::LibcxxSystemErrorObject* self) noexcept;
void APS5_VABI _ZNSt11range_errorD1Ev_nid_postfix(LibcException::ExceptionObject* self);
void APS5_VABI _ZNSt11range_errorD2Ev_nid_postfix(LibcException::ExceptionObject* self);
void APS5_VABI _ZNSt11range_errorD0Ev_nid_postfix(LibcException::ExceptionObject* self);
Expand Down Expand Up @@ -2176,6 +2183,10 @@ extern GuestLocale::LibcxxLocaleId _ZNSt3__18messagesIcE2idE_nid_postfix;
extern GuestLocale::LibcxxLocaleId _ZNSt3__18numpunctIcE2idE_nid_postfix;
extern GuestLocale::LibcxxLocaleId _ZNSt3__18numpunctIwE2idE_nid_postfix;
extern GuestLocale::LibcxxLocaleId _ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE_nid_postfix;
extern GuestLocale::LibcxxLocaleId _ZNSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE_nid_postfix;
void* APS5_VABI _ZNKSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE3putES4_RNS_8ios_baseEcPK2tmPKcSC__nid_postfix(
const GuestLocale::LibcxxFacet* self, void* output, void* stream, char fill, const GuestTm* time,
const char* first, const char* last);
void APS5_VABI _ZNSt3__16localeC1Ev_nid_postfix(GuestLocale::LibcxxLocale* self);
void APS5_VABI _ZNSt3__16localeC1ERKS0__nid_postfix(GuestLocale::LibcxxLocale* self, const GuestLocale::LibcxxLocale* other);
void APS5_VABI _ZNSt3__16localeD1Ev_nid_postfix(GuestLocale::LibcxxLocale* self);
Expand Down
86 changes: 86 additions & 0 deletions core/libs/prx/libc/include/GuestLocale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <string>
#include "general/VabiMacros.hpp"

struct GuestTm;

namespace GuestLocale {

std::string FormatTimeConversion(const GuestTm& time, const char* format, char conversion);

struct LocinfoStorage {
alignas(std::uint64_t) unsigned char bytes[64];
};
Expand Down Expand Up @@ -65,6 +68,87 @@ struct LibcxxLocale {

static_assert(sizeof(LibcxxLocale) == 0x8);

using LibcxxIosCallback = void (APS5_VABI*)(int event, void* stream, int index);

struct LibcxxIosBase {
const void* vtable;
std::uint32_t flags;
std::int64_t precision;
std::int64_t width;
std::uint32_t state;
std::uint32_t exceptions;
void* buffer;
LibcxxLocale locale;
const LibcxxIosCallback* callbacks;
const int* callbackIndexes;
std::uint64_t callbackCount;
std::uint64_t callbackCapacity;
void* integers;
std::uint64_t integerCount;
std::uint64_t integerCapacity;
void* pointers;
std::uint64_t pointerCount;
std::uint64_t pointerCapacity;
};

static_assert(offsetof(LibcxxIosBase, precision) == 0x10);
static_assert(offsetof(LibcxxIosBase, state) == 0x20);
static_assert(offsetof(LibcxxIosBase, buffer) == 0x28);
static_assert(offsetof(LibcxxIosBase, locale) == 0x30);
static_assert(offsetof(LibcxxIosBase, callbackCount) == 0x48);
static_assert(offsetof(LibcxxIosBase, integers) == 0x58);
static_assert(offsetof(LibcxxIosBase, pointers) == 0x70);
static_assert(sizeof(LibcxxIosBase) == 0x88);

struct LibcxxStreambuf;

struct LibcxxStreambufVtable {
std::uintptr_t beforeSync[6];
int (APS5_VABI* sync)(LibcxxStreambuf*);
std::uintptr_t beforeXsputn[5];
std::int64_t (APS5_VABI* xsputn)(LibcxxStreambuf*, const char*, std::int64_t);
int (APS5_VABI* overflow)(LibcxxStreambuf*, int);
};

static_assert(offsetof(LibcxxStreambufVtable, sync) == 0x30);
static_assert(offsetof(LibcxxStreambufVtable, xsputn) == 0x60);
static_assert(offsetof(LibcxxStreambufVtable, overflow) == 0x68);

struct LibcxxStreambuf {
const LibcxxStreambufVtable* vtable;
LibcxxLocale locale;
char* getStart;
char* getCurrent;
char* getEnd;
char* putStart;
char* putCurrent;
char* putEnd;
};

static_assert(offsetof(LibcxxStreambuf, putCurrent) == 0x30);
static_assert(offsetof(LibcxxStreambuf, putEnd) == 0x38);
static_assert(sizeof(LibcxxStreambuf) == 0x40);

template <typename TValue>
using LibcxxPutMethod = LibcxxStreambuf* (APS5_VABI*)(const LibcxxFacet*, LibcxxStreambuf*, LibcxxIosBase*, char, TValue);

struct LibcxxNumPutVtable {
LibcxxFacetVtable facet;
LibcxxPutMethod<bool> putBool;
LibcxxPutMethod<std::int64_t> putLong;
LibcxxPutMethod<std::int64_t> putLongLong;
LibcxxPutMethod<std::uint64_t> putUnsignedLong;
LibcxxPutMethod<std::uint64_t> putUnsignedLongLong;
LibcxxPutMethod<double> putDouble;
LibcxxPutMethod<long double> putLongDouble;
LibcxxPutMethod<const void*> putPointer;
};

static_assert(offsetof(LibcxxNumPutVtable, putBool) == 0x18);
static_assert(offsetof(LibcxxNumPutVtable, putUnsignedLong) == 0x30);
static_assert(offsetof(LibcxxNumPutVtable, putPointer) == 0x50);
static_assert(sizeof(LibcxxNumPutVtable) == 0x58);

struct CtypeFacet {
Facet base;
const std::int16_t* classification;
Expand Down Expand Up @@ -458,6 +542,8 @@ extern "C" GuestLocale::OutputIterator LibcPutWideElements_nid_no_patch(GuestLoc
extern "C" GuestLocale::OutputIterator LibcRepeatWideElement_nid_no_patch(GuestLocale::OutputIterator out, std::uint16_t element, std::size_t count);
extern "C" GuestLocale::OutputIterator LibcNumPutInteger_nid_no_patch(GuestLocale::OutputIterator out, GuestLocale::IosBase* stream, char fill, const char* digits, std::size_t count);
extern "C" GuestLocale::OutputIterator LibcTimePutDoPut_nid_no_patch(const GuestLocale::Facet* self, GuestLocale::OutputIterator out, GuestLocale::IosBase* stream, char fill, const GuestTm* time, char format, char modifier);
extern "C" GuestLocale::LibcxxFacet* LibcxxNumPutFacet_nid_no_patch();
extern "C" GuestLocale::LibcxxFacet* LibcxxProvidedFacet_nid_no_patch(const GuestLocale::LibcxxLocale* locale, GuestLocale::LibcxxLocaleId* id);
extern "C" GuestLocale::String* LibcAssignCString_nid_no_patch(GuestLocale::String* result, const char* source);
extern "C" GuestLocale::String* LibcAssignWideCString_nid_no_patch(GuestLocale::String* result, const std::uint16_t* source);
extern "C" void LibcReleaseStringStorage_nid_no_patch(GuestLocale::String* value);
Expand Down
18 changes: 18 additions & 0 deletions core/libs/prx/libc/include/LibcxxIosInit.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
#pragma once

#include "general/VabiMacros.hpp"
#include <cstdint>

extern "C" {

void APS5_VABI _ZNSt3__18ios_base4initEPv_nid_postfix(void* self, void* buffer);
void* APS5_VABI _ZNKSt3__18ios_base6getlocEv_nid_postfix(void* result, const void* self);
void* APS5_VABI _ZNSt3__18ios_base5imbueERKNS_6localeE_nid_postfix(void* result, void* self, const void* locale);
void APS5_VABI _ZNSt3__19basic_iosIcNS_11char_traitsIcEEED2Ev_nid_postfix(void* self);
void APS5_VABI _ZNSt3__18ios_base5clearEj_nid_postfix(void* self, std::uint32_t state);
void APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3__nid_postfix(void* self, void* stream);
void APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev_nid_postfix(void* self);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc_nid_postfix(void* self, char value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5writeEPKcl_nid_postfix(void* self, const char* data, std::int64_t count);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv_nid_postfix(void* self);
void APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev_nid_postfix(void* self);
void APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED2Ev_nid_postfix(void* self, const void* const* vtt);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEb_nid_postfix(void* self, bool value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEs_nid_postfix(void* self, short value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEt_nid_postfix(void* self, unsigned short value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEi_nid_postfix(void* self, int value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEj_nid_postfix(void* self, unsigned int value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEl_nid_postfix(void* self, std::int64_t value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEm_nid_postfix(void* self, std::uint64_t value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEf_nid_postfix(void* self, float value);
void* APS5_VABI _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEd_nid_postfix(void* self, double value);

}
33 changes: 2 additions & 31 deletions core/libs/prx/libc/src/LibcxxIosInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,8 @@ constexpr std::uint32_t SkipWhitespace = 0x1000;
constexpr int EraseEvent = 0;
constexpr int ImbueEvent = 1;

using Callback = void (APS5_VABI*)(int event, void* stream, int index);

struct IosBase {
const void* vtable;
std::uint32_t flags;
std::int64_t precision;
std::int64_t width;
std::uint32_t state;
std::uint32_t exceptions;
void* buffer;
LibcxxLocale locale;
const Callback* callbacks;
const int* callbackIndexes;
std::uint64_t callbackCount;
std::uint64_t callbackCapacity;
void* integers;
std::uint64_t integerCount;
std::uint64_t integerCapacity;
void* pointers;
std::uint64_t pointerCount;
std::uint64_t pointerCapacity;
};

static_assert(offsetof(IosBase, precision) == 0x10);
static_assert(offsetof(IosBase, state) == 0x20);
static_assert(offsetof(IosBase, buffer) == 0x28);
static_assert(offsetof(IosBase, locale) == 0x30);
static_assert(offsetof(IosBase, callbackCount) == 0x48);
static_assert(offsetof(IosBase, integers) == 0x58);
static_assert(offsetof(IosBase, pointers) == 0x70);
static_assert(sizeof(IosBase) == 0x88);
using Callback = GuestLocale::LibcxxIosCallback;
using IosBase = GuestLocale::LibcxxIosBase;

[[noreturn]] void Inaccessible() {
throw std::invalid_argument("libc++ ios_base: inaccessible guest object");
Expand Down
Loading