Merge main into PR #9844

Additive conflicts with main's newer libc math changes: the debt list keeps
both sides' entries (per entry), the GuestMath.cpp test functions and calls
from both sides are kept, and Math.cpp keeps both sides' independent changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
JJenkxandClaude Opus 5.5 committed 2026-10-24 03:19:24 -04:00
commit 7488308bb9
200 files changed
+9063 -524

No files matched your search

+69
View File
@@ -97,6 +97,7 @@ float APS5_VABI remquof_nid_postfix(float, float, int*);
float APS5_VABI fmaf_nid_postfix(float, float, float);
long double APS5_VABI ceill_nid_postfix(long double);
long double APS5_VABI floorl_nid_postfix(long double);
float APS5_VABI cbrtf_nid_postfix(float);
float APS5_VABI tanf_nid_postfix(float);
int APS5_VABI rand_nid_postfix();
void APS5_VABI srand_nid_postfix(unsigned int);
@@ -126,6 +127,7 @@ float APS5_VABI nextafterf_nid_postfix(float, float);
double APS5_VABI nextafter_nid_postfix(double, double);
double APS5_VABI frexp_nid_postfix(double, int*);
float APS5_VABI frexpf_nid_postfix(float, int*);
float APS5_VABI logf_nid_postfix(float);
std::int64_t APS5_VABI lround_nid_postfix(double);
std::div_t APS5_VABI div_nid_postfix(int, int);
double APS5_VABI sinh_nid_postfix(double);
@@ -682,6 +684,35 @@ static long double MakeExtended(std::uint64_t mantissa, std::uint16_t signExpone
return value;
}
static void CheckExpm1ConsoleBits() {
constexpr struct {
std::uint64_t input;
std::uint64_t expected;
int error;
} cases[] = {
{0x0000000000000000ull, 0x0000000000000000ull, 0}, {0x8000000000000000ull, 0x8000000000000000ull, 0},
{0x3c8fffffffffffffull, 0x3c8fffffffffffffull, 0}, {0x3c90000000000000ull, 0x3c90000000000000ull, 0},
{0x3fd62e42fefa39efull, 0x3fda827999fcef32ull, 0}, {0x3fd62e4300000000ull, 0x3fda82799b6f2366ull, 0},
{0x3ff0a2b1ffffffffull, 0x3ffd413c1a24d411ull, 0}, {0x3ff0a2b200000000ull, 0x3ffd413c1a24d414ull, 0},
{0xbfd0000000000000ull, 0xbfcc5041854df7d4ull, 0}, {0xbfe0000000000000ull, 0xbfd92e9a0720d3ecull, 0},
{0x3ff0000000000000ull, 0x3ffb7e151628aed2ull, 0}, {0xbff0000000000000ull, 0xbfe43a54e4e98864ull, 0},
{0x4043687a00000000ull, 0x436fffd8395c0c41ull, 0}, {0xc043687a00000000ull, 0xbff0000000000000ull, 0},
{0x4049000000000000ull, 0x44719103e4080b45ull, 0}, {0x40862e42fefa39efull, 0x7fefffffffffff2aull, 0},
{0x40862e42fefa39f0ull, 0x7ff0000000000000ull, ERANGE}, {0xc08f400000000000ull, 0xbff0000000000000ull, 0},
{0x7fefffffffffffffull, 0x7ff0000000000000ull, ERANGE}, {0xffefffffffffffffull, 0xbff0000000000000ull, 0},
{0x7ff0000000000000ull, 0x7ff0000000000000ull, 0}, {0xfff0000000000000ull, 0xbff0000000000000ull, 0},
{0x7ff8000000000001ull, 0x7ff8000000000001ull, 0}, {0xfff8000000000002ull, 0xfff8000000000002ull, 0},
{0x3fc78b9e474afed8ull, 0x3fc9d99e60806b35ull, 0}, {0xbf887a99bea50fb1ull, 0xbf88554c5b9d0cbbull, 0},
{0x3ff790fb0ae85390ull, 0x400ae5103402894bull, 0}, {0xbf840fe48e07e54dull, 0xbf83f6d1bcda4943ull, 0},
{0xbfbb1276066a31c7ull, 0xbfb9b098289dab68ull, 0}, {0x3fc07bc20a0c887eull, 0x3fc197828317c86cull, 0},
};
for (const auto& item : cases) {
errno = 1234;
Require(std::bit_cast<std::uint64_t>(expm1_nid_postfix(std::bit_cast<double>(item.input))) == item.expected);
Require(errno == (item.error != 0 ? item.error : 1234));
}
}
static void CheckAsinl() {
const struct { std::uint64_t inputMantissa; std::uint16_t inputSignExponent; std::uint64_t outputMantissa; std::uint16_t outputSignExponent; } cases[] = {
{0, 0x0000, 0, 0x0000}, {0, 0x8000, 0, 0x8000},
@@ -716,6 +747,21 @@ static void CheckAsinl() {
*__error_nid_postfix() = 0;
}
static void CheckCbrtfConsoleBits() {
constexpr std::uint32_t cases[][2] = {
{0x00000123u, 0x28059605u}, {0x00400327u, 0x2a4b334bu}, {0x3f000555u, 0x3f4b32c7u}, {0x3fc00778u, 0x3f9287e5u},
{0x42000999u, 0x404b3509u}, {0x7e000bbcu, 0x544b362au}, {0xbf400dddu, 0xbf689d01u}, {0x80201002u, 0xaa215ff8u},
{0x00000000u, 0x00000000u}, {0x80000000u, 0x80000000u}, {0x00000001u, 0x26a14518u}, {0x007fffffu, 0x2a7fffffu},
{0x00800000u, 0x2a800000u}, {0x3f800000u, 0x3f800000u}, {0x41000000u, 0x40000000u}, {0xc1000000u, 0xc0000000u},
{0x7f7fffffu, 0x54cb2ff5u}, {0x7f800000u, 0x7f800000u}, {0xff800000u, 0xff800000u}, {0x7fc00001u, 0x7fc00001u},
{0xffc00002u, 0xffc00002u},
};
for (const auto& [input, expected] : cases) {
errno = 1234;
Require(std::bit_cast<std::uint32_t>(cbrtf_nid_postfix(std::bit_cast<float>(input))) == expected && errno == 1234);
}
}
static void CheckIntegerConversions() {
for (const long long numerator : {4294967301LL, -4294967301LL}) {
for (const long long denominator : {3LL, -3LL}) {
@@ -1202,6 +1248,26 @@ static void RequireBytes(const void* constant, std::initializer_list<unsigned ch
while (index < 16) Require(bytes[index++] == 0);
}
static void CheckLogfConsoleBits() {
constexpr struct {
std::uint32_t input;
std::uint32_t expected;
int error;
} cases[] = {
{0x00000983u, 0xc2bef664u, 0}, {0x3e003791u, 0xc004f9cfu, 0}, {0x3f7f0a10u, 0xbb76666fu, 0}, {0x3f81086bu, 0x3c03adacu, 0},
{0x40400de0u, 0x3f8ca894u, 0}, {0x5f00a041u, 0x422eb14eu, 0}, {0x3f800000u, 0x00000000u, 0}, {0x40000000u, 0x3f317218u, 0},
{0x00000001u, 0xc2ce8ed0u, 0}, {0x00800000u, 0xc2aeac50u, 0}, {0x7f7fffffu, 0x42b17218u, 0}, {0x7f800000u, 0x7f800000u, 0},
{0x3f800001u, 0x33ffffffu, 0}, {0x3f7fffffu, 0xb3800000u, 0}, {0x7fc00001u, 0x7fc00001u, 0},
{0x00000000u, 0xff800000u, ERANGE}, {0x80000000u, 0xff800000u, ERANGE}, {0x80000001u, 0xffc00000u, EDOM},
{0xbf800000u, 0xffc00000u, EDOM}, {0xff800000u, 0xffc00000u, EDOM}, {0xffc00002u, 0xffc00002u, EDOM},
};
for (const auto& item : cases) {
errno = 1234;
Require(std::bit_cast<std::uint32_t>(logf_nid_postfix(std::bit_cast<float>(item.input))) == item.expected);
Require(errno == (item.error != 0 ? item.error : 1234));
}
}
static void CheckDinkumwareConstants() {
RequireBytes(&_Inf_nid_postfix, {0, 0, 0, 0, 0, 0, 0xf0, 0x7f});
RequireBytes(&_Denorm_nid_postfix, {1});
@@ -1467,6 +1533,7 @@ int main() {
CheckMissingClassificationExports();
CheckFloatMathExports();
CheckIntegerConversions();
CheckCbrtfConsoleBits();
CheckExtendedMath();
Require(atof_nid_postfix(" -12.5tail") == -12.5);
char* end = nullptr;
@@ -1622,6 +1689,7 @@ int main() {
CheckFegetenv();
CheckLongDouble();
CheckNearbyintl();
CheckExpm1ConsoleBits();
CheckAsinl();
Require(scalbn_nid_postfix(0.75, -2) == 0.1875);
Require(scalbnf_nid_postfix(0.75f, 4) == 12.f);
@@ -1749,6 +1817,7 @@ int main() {
CheckScaledHyperbolic();
CheckSinhf();
CheckAtanhf();
CheckLogfConsoleBits();
CheckHypotSpecialValue();
CheckAtanfConsoleBits();
CheckFloatUnderflowErrno();