fix(libc): match FreeBSD asinf errno
asinf returned 0xffc00000 (errno 33) for 2.0 (0x40000000), where FreeBSD lib/msun/src/math.h returns 0xffc00000 (errno 0). It now returns the FreeBSD result for that case. A guest test covers it and fails on main. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a11c8f7f70
commit
1a6f6a9f13
|
|
@ -36,7 +36,12 @@ std::lldiv_t APS5_VABI ldiv_nid_postfix(std::int64_t numerator, std::int64_t den
|
|||
}
|
||||
|
||||
float APS5_VABI fmodf_nid_postfix(float x, float y) { return std::fmod(x, y); }
|
||||
float APS5_VABI asinf_nid_postfix(float x) { return std::asin(x); }
|
||||
float APS5_VABI asinf_nid_postfix(float x) {
|
||||
const int saved_errno = errno;
|
||||
const float result = std::asin(x);
|
||||
errno = saved_errno;
|
||||
return result;
|
||||
}
|
||||
float APS5_VABI acosf_nid_postfix(float x) { return std::acos(x); }
|
||||
float APS5_VABI atan2f_nid_postfix(float y, float x) { return std::atan2(y, x); }
|
||||
float APS5_VABI hypotf_nid_postfix(float x, float y) { return static_cast<float>(std::hypot(static_cast<double>(x), static_cast<double>(y))); }
|
||||
|
|
|
|||
|
|
@ -128,6 +128,12 @@ static void CheckHypotSpecialValue() {
|
|||
Require(std::bit_cast<std::uint64_t>(hypot_nid_postfix(std::bit_cast<double>(0x7ff0000000000001ull), -INFINITY)) == 0x7ff0000000000000ull);
|
||||
}
|
||||
|
||||
static void CheckAsinfErrno() {
|
||||
errno = 0;
|
||||
(void)asinf_nid_postfix(2.0f);
|
||||
Require(errno == 0);
|
||||
}
|
||||
|
||||
static void CheckLongDouble() {
|
||||
Require(ExtendedBits(acosl_nid_postfix(-1.0L), 0xc90fdaa22168c235ull, 0x4000));
|
||||
Require(ExtendedBits(acosl_nid_postfix(0.0L), 0xc90fdaa22168c235ull, 0x3fff));
|
||||
|
|
@ -479,6 +485,7 @@ int main() {
|
|||
Require(__isnormal_nid_postfix(1.) == 1 && __isnormal_nid_postfix(0.) == 0);
|
||||
Require(__isnormal_nid_postfix(std::numeric_limits<double>::denorm_min()) == 0);
|
||||
const auto quotient = div_nid_postfix(7, 2);
|
||||
CheckAsinfErrno();
|
||||
Require(quotient.quot == 3 && quotient.rem == 1);
|
||||
const auto negativeNumerator = div_nid_postfix(-7, 2);
|
||||
Require(negativeNumerator.quot == -3 && negativeNumerator.rem == -1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue