Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions core/libs/prx/libSceLibcInternal/BasicString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,31 @@ void TidyWide(String* string) {
SetWideSize(string, 0);
}

std::size_t CapacityFor(const String* string, std::size_t size) {
if (size > MaxSize) _ZNKSs5_XlenEv_nid_postfix(string);
const std::size_t rounded = size | GuestLocale::StringCapacityMask;
if (rounded < size || rounded > MaxSize) return size;
std::size_t capacity = rounded;
if (string->capacity > GuestLocale::StringInlineCapacity && string->capacity / 2 > rounded / 3) {
if (string->capacity > MaxSize - string->capacity / 2) _ZSt11_Xbad_allocv_nid_postfix();
capacity = string->capacity + string->capacity / 2;
}
return capacity;
}

char* Allocate(const String* string, std::size_t capacity) {
if (capacity > MaxSize) _ZNKSs5_XlenEv_nid_postfix(string);
const std::size_t bytes = capacity + 1;
if (bytes >= GuestStringStorage::LargeAllocation && bytes > NoPosition - GuestStringStorage::AllocationPadding) _ZSt11_Xbad_allocv_nid_postfix();
return static_cast<char*>(GuestStringStorage::Allocate(bytes));
}

void Tidy(String* string) {
if (string->capacity > GuestLocale::StringInlineCapacity) GuestStringStorage::Deallocate(string->pointer, string->capacity + 1);
string->capacity = GuestLocale::StringInlineCapacity;
SetSize(string, 0);
}

void ReserveForInsert(String* string, std::size_t size) {
if (size > MaxSize) _ZNKSs5_XlenEv_nid_postfix(string);
if (size <= string->capacity) return;
Expand Down Expand Up @@ -355,6 +380,30 @@ void APS5_VABI _ZNSbIwSt11char_traitsIwESaIwEE5_CopyEmm_nid_postfix(String* self
SetWideSize(self, oldLength);
}

void APS5_VABI _ZNSs5_CopyEmm_nid_postfix(String* self, std::size_t newSize, std::size_t oldLength) {
if (self == nullptr) throw std::invalid_argument("basic_string<char>::_Copy: null string");
if (oldLength > self->size || oldLength > newSize || newSize <= GuestLocale::StringInlineCapacity)
throw std::invalid_argument("basic_string<char>::_Copy: the new size must exceed the inline buffer and hold the kept length");
std::size_t capacity = CapacityFor(self, newSize);
char* data = nullptr;
try {
data = Allocate(self, capacity);
} catch (...) {
capacity = newSize;
try {
data = Allocate(self, capacity);
} catch (...) {
Tidy(self);
throw;
}
}
std::memcpy(data, Data(self), oldLength);
if (self->capacity > GuestLocale::StringInlineCapacity) GuestStringStorage::Deallocate(self->pointer, self->capacity + 1);
self->pointer = data;
self->capacity = capacity;
SetSize(self, oldLength);
}

String* APS5_VABI _ZNSs6insertEmmc_nid_postfix(String* self, std::size_t position, std::size_t count, char character) {
if (position > self->size) _ZNKSs5_XranEv_nid_postfix(self);
if (count > MaxSize - self->size) _ZNKSs5_XlenEv_nid_postfix(self);
Expand Down
52 changes: 52 additions & 0 deletions core/libs/prx/libSceLibcInternal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,45 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
endif()
endif()
target_sources(libSceLibcInternal PRIVATE LocaleName.cpp)
if(BUILD_TESTING)
add_test_executable(guest_libc_internal_locale_name_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalLocaleName.cpp)
target_include_directories(guest_libc_internal_locale_name_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_libc_internal_locale_name_tests PRIVATE libSceLibcInternal libkernel libc)
configure_windows_unwind(guest_libc_internal_locale_name_tests)
add_test(NAME guest_libc_internal_locale_name COMMAND guest_libc_internal_locale_name_tests)
set_tests_properties(guest_libc_internal_locale_name PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_libc_internal_locale_name PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
endif()
endif()
target_sources(libSceLibcInternal PRIVATE Punctuation.cpp)
if(BUILD_TESTING)
add_test_executable(guest_libc_internal_punctuation_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalPunctuation.cpp)
target_include_directories(guest_libc_internal_punctuation_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_libc_internal_punctuation_tests PRIVATE libSceLibcInternal libkernel libc)
configure_windows_unwind(guest_libc_internal_punctuation_tests)
add_test(NAME guest_libc_internal_punctuation COMMAND guest_libc_internal_punctuation_tests)
set_tests_properties(guest_libc_internal_punctuation PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_libc_internal_punctuation PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
endif()
endif()
target_sources(libSceLibcInternal PRIVATE StreamRuntime.cpp)
if(BUILD_TESTING)
add_test_executable(guest_libc_internal_stream_runtime_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStreamRuntime.cpp)
target_include_directories(guest_libc_internal_stream_runtime_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_libc_internal_stream_runtime_tests PRIVATE libSceLibcInternal libkernel libc)
configure_windows_unwind(guest_libc_internal_stream_runtime_tests)
add_test(NAME guest_libc_internal_stream_runtime COMMAND guest_libc_internal_stream_runtime_tests)
set_tests_properties(guest_libc_internal_stream_runtime PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_libc_internal_stream_runtime PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
endif()
endif()
target_sources(libSceLibcInternal PRIVATE Stream.cpp)
if(BUILD_TESTING)
add_test_executable(guest_libc_internal_stream_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalStream.cpp)
Expand Down Expand Up @@ -1322,6 +1361,19 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
endif()
endif()
target_sources(libSceLibcInternal PRIVATE FacetConstruction.cpp)
if(BUILD_TESTING)
add_test_executable(guest_libc_internal_facet_construction_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalFacetConstruction.cpp)
target_include_directories(guest_libc_internal_facet_construction_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_libc_internal_facet_construction_tests PRIVATE libSceLibcInternal libkernel libc)
configure_windows_unwind(guest_libc_internal_facet_construction_tests)
add_test(NAME guest_libc_internal_facet_construction COMMAND guest_libc_internal_facet_construction_tests)
set_tests_properties(guest_libc_internal_facet_construction PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_libc_internal_facet_construction PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceLibcInternal>")
endif()
endif()
target_sources(libSceLibcInternal PRIVATE Rint.cpp)
if(BUILD_TESTING)
add_test_executable(guest_libc_internal_rint_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibcInternalRint.cpp)
Expand Down
42 changes: 0 additions & 42 deletions core/libs/prx/libSceLibcInternal/Err.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,60 +321,18 @@ int APS5_VABI sceLibcInternalPending3_066_nid_no_patch() {
}
APS5_EXPORT("VKdXFE7ualw", sceLibcInternalPending3_066_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_067_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("SmtBNDda5qU", sceLibcInternalPending3_067_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_078_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("G9LB1YD5-xc", sceLibcInternalPending3_078_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_079_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("J-0I2PtiZc4", sceLibcInternalPending3_079_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_091_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("BNZq-mRvDS8", sceLibcInternalPending3_091_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_092_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("wEU8oFtBXT8", sceLibcInternalPending3_092_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_103_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("GGqIV4cjzzI", sceLibcInternalPending3_103_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_104_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("bZ0oEGQUKO8", sceLibcInternalPending3_104_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_113_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("k8zgjeBmpVY", sceLibcInternalPending3_113_nid_no_patch);

int APS5_VABI sceLibcInternalPending3_114_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("tCihLs4UJxQ", sceLibcInternalPending3_114_nid_no_patch);

int APS5_VABI _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE5_FputES3_RSt8ios_basecPKcm_nid_postfix() {
NotImplemented_nid_no_patch(__func__);
return 0;
Expand Down
6 changes: 0 additions & 6 deletions core/libs/prx/libSceLibcInternal/Export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ int APS5_VABI sceLibcInternalPending4_106_nid_no_patch() {
}
APS5_EXPORT("nk+0yTWvoRE", sceLibcInternalPending4_106_nid_no_patch);

int APS5_VABI sceLibcInternalPending4_109_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
APS5_EXPORT("9HILqEoh24E", sceLibcInternalPending4_109_nid_no_patch);

int APS5_VABI sceLibcInternalPending4_119_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
return 0;
Expand Down
Loading
Loading