Skip to content
Closed
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
4 changes: 2 additions & 2 deletions core/libs/prx/libc/src/RuntimeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ void APS5_VABI _Unlockfilelock_nid_postfix(FileStream* stream) {
#endif
}

unsigned long APS5_VABI _Stoul_nid_postfix(const char* str, char** endptr, int base) {
return std::strtoul(str, endptr, base);
unsigned long long APS5_VABI _Stoul_nid_postfix(const char* str, char** endptr, int base) {
return std::strtoull(str, endptr, base);
}

void APS5_VABI _Locksyslock_nid_postfix() {
Expand Down
12 changes: 12 additions & 0 deletions core/libs/tests/GuestMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ float APS5_VABI strtof_nid_postfix(const char*, char**);
long double APS5_VABI strtold_nid_postfix(const char*, char**);
std::int64_t APS5_VABI strtol_nid_postfix(const char*, char**, int);
std::uint64_t APS5_VABI strtoul_nid_postfix(const char*, char**, int);
unsigned long long APS5_VABI _Stoul_nid_postfix(const char*, char**, int);
std::intmax_t APS5_VABI strtoimax_nid_postfix(const char*, char**, int);
int* APS5_VABI __error_nid_postfix();
struct LibcFloatConstant { std::uint32_t bits[4]; };
Expand Down Expand Up @@ -132,11 +133,22 @@ static void CheckIntegerConversions() {
std::abort();
}
}
for (const auto& test : unsignedCases) {
char* end = nullptr;
*__error_nid_postfix() = 0;
const auto value = _Stoul_nid_postfix(test.text, &end, test.base);
if (value != test.value || end != test.text + test.consumed || *__error_nid_postfix() != test.error) {
std::fprintf(stderr, "Guest _Stoul failed for '%s' in base %d\n", test.text, test.base);
std::abort();
}
}
*__error_nid_postfix() = 13;
Require(strtol_nid_postfix("-4294967296", nullptr, 10) == -INT64_C(4294967296));
Require(*__error_nid_postfix() == 13);
Require(strtoul_nid_postfix("4294967296", nullptr, 10) == UINT64_C(4294967296));
Require(*__error_nid_postfix() == 13);
Require(_Stoul_nid_postfix("4294967296", nullptr, 10) == UINT64_C(4294967296));
Require(*__error_nid_postfix() == 13);
*__error_nid_postfix() = 0;
}

Expand Down
Loading