mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-07 13:39:55 +00:00
feat(libc): export the remaining Dinkumware floating-point constants
Add _Denorm, _Hugeval, _Nan, _Snan, _FDenorm, _FSnan, _LDenorm, _LInf, _LNan and _LSnan with the 16 bytes the console's libc.prx exports. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
d0852defa2
commit
91c401db5e
2 files changed
+53
No files matched your search
@@ -706,4 +706,14 @@ union SonyDconst {
|
||||
|
||||
static_assert(std::endian::native == std::endian::little);
|
||||
SonyDconst _Inf_nid_postfix {{0, 0, 0, 0x7ff0, 0, 0, 0, 0}};
|
||||
SonyDconst _Denorm_nid_postfix {{1, 0, 0, 0, 0, 0, 0, 0}};
|
||||
SonyDconst _Hugeval_nid_postfix {{0, 0, 0, 0x7ff0, 0, 0, 0, 0}};
|
||||
SonyDconst _Nan_nid_postfix {{0, 0, 0, 0x7ff8, 0, 0, 0, 0}};
|
||||
SonyDconst _Snan_nid_postfix {{1, 0, 0, 0x7ff0, 0, 0, 0, 0}};
|
||||
LibcFloatConstant _FDenorm_nid_postfix {{0x00000001u, 0, 0, 0}};
|
||||
LibcFloatConstant _FSnan_nid_postfix {{0x7f800001u, 0, 0, 0}};
|
||||
SonyDconst _LDenorm_nid_postfix {{1, 0, 0, 0, 0, 0, 0, 0}};
|
||||
SonyDconst _LInf_nid_postfix {{0, 0, 0, 0x8000, 0x7fff, 0, 0, 0}};
|
||||
SonyDconst _LNan_nid_postfix {{0, 0, 0, 0xc000, 0x7fff, 0, 0, 0}};
|
||||
SonyDconst _LSnan_nid_postfix {{1, 0, 0, 0x8000, 0x7fff, 0, 0, 0}};
|
||||
}
|
||||
@@ -57,6 +57,18 @@ long double APS5_VABI frexpl_nid_postfix(long double, int*);
|
||||
struct LibcFloatConstant { std::uint32_t bits[4]; };
|
||||
extern LibcFloatConstant _FInf_nid_postfix;
|
||||
extern LibcFloatConstant _FNan_nid_postfix;
|
||||
extern LibcFloatConstant _FDenorm_nid_postfix;
|
||||
extern LibcFloatConstant _FSnan_nid_postfix;
|
||||
union SonyDconst { unsigned short _Word[8]; float _Float; double _Double; long double _Long_double; };
|
||||
extern SonyDconst _Inf_nid_postfix;
|
||||
extern SonyDconst _Denorm_nid_postfix;
|
||||
extern SonyDconst _Hugeval_nid_postfix;
|
||||
extern SonyDconst _Nan_nid_postfix;
|
||||
extern SonyDconst _Snan_nid_postfix;
|
||||
extern SonyDconst _LDenorm_nid_postfix;
|
||||
extern SonyDconst _LInf_nid_postfix;
|
||||
extern SonyDconst _LNan_nid_postfix;
|
||||
extern SonyDconst _LSnan_nid_postfix;
|
||||
short APS5_VABI _FDtest_nid_postfix(const float*);
|
||||
short APS5_VABI _Dtest_nid_postfix(const double*);
|
||||
int APS5_VABI __fpclassifyf_nid_postfix(float);
|
||||
@@ -881,6 +893,36 @@ static void CheckFloatClassification() {
|
||||
Require(_FDtest_nid_postfix(reinterpret_cast<const float*>(&_FNan_nid_postfix)) == 2);
|
||||
}
|
||||
|
||||
static void RequireBytes(const void* constant, std::initializer_list<unsigned char> expected) {
|
||||
unsigned char bytes[16];
|
||||
std::memcpy(bytes, constant, sizeof(bytes));
|
||||
int index = 0;
|
||||
for (const unsigned char byte : expected) Require(bytes[index++] == byte);
|
||||
while (index < 16) Require(bytes[index++] == 0);
|
||||
}
|
||||
|
||||
static void CheckDinkumwareConstants() {
|
||||
RequireBytes(&_Inf_nid_postfix, {0, 0, 0, 0, 0, 0, 0xf0, 0x7f});
|
||||
RequireBytes(&_Denorm_nid_postfix, {1});
|
||||
RequireBytes(&_Hugeval_nid_postfix, {0, 0, 0, 0, 0, 0, 0xf0, 0x7f});
|
||||
RequireBytes(&_Nan_nid_postfix, {0, 0, 0, 0, 0, 0, 0xf8, 0x7f});
|
||||
RequireBytes(&_Snan_nid_postfix, {1, 0, 0, 0, 0, 0, 0xf0, 0x7f});
|
||||
RequireBytes(&_FDenorm_nid_postfix, {1});
|
||||
RequireBytes(&_FSnan_nid_postfix, {1, 0, 0x80, 0x7f});
|
||||
RequireBytes(&_LDenorm_nid_postfix, {1});
|
||||
RequireBytes(&_LInf_nid_postfix, {0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f});
|
||||
RequireBytes(&_LNan_nid_postfix, {0, 0, 0, 0, 0, 0, 0, 0xc0, 0xff, 0x7f});
|
||||
RequireBytes(&_LSnan_nid_postfix, {1, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f});
|
||||
Require(_Dtest_nid_postfix(&_Denorm_nid_postfix._Double) == -2 && _Denorm_nid_postfix._Double == std::numeric_limits<double>::denorm_min());
|
||||
Require(_Dtest_nid_postfix(&_Hugeval_nid_postfix._Double) == 1 && _Hugeval_nid_postfix._Double == HUGE_VAL);
|
||||
Require(_Dtest_nid_postfix(&_Nan_nid_postfix._Double) == 2 && _Dtest_nid_postfix(&_Snan_nid_postfix._Double) == 2);
|
||||
Require(_FDtest_nid_postfix(reinterpret_cast<const float*>(&_FDenorm_nid_postfix)) == -2);
|
||||
Require(_FDtest_nid_postfix(reinterpret_cast<const float*>(&_FSnan_nid_postfix)) == 2);
|
||||
Require(_LDenorm_nid_postfix._Long_double == std::numeric_limits<long double>::denorm_min());
|
||||
Require(_LInf_nid_postfix._Long_double == std::numeric_limits<long double>::infinity());
|
||||
Require(std::isnan(_LNan_nid_postfix._Long_double) && std::isnan(_LSnan_nid_postfix._Long_double));
|
||||
}
|
||||
|
||||
static void CheckMissingClassificationExports() {
|
||||
const float infinity = std::numeric_limits<float>::infinity();
|
||||
const float nan = std::numeric_limits<float>::quiet_NaN();
|
||||
@@ -1074,6 +1116,7 @@ static void CheckNoConversionIsPositiveZero() {
|
||||
|
||||
int main() {
|
||||
CheckFloatClassification();
|
||||
CheckDinkumwareConstants();
|
||||
CheckNoConversionIsPositiveZero();
|
||||
CheckMissingClassificationExports();
|
||||
CheckFloatMathExports();
|
||||
|
||||
Reference in new issue
Block a user