Merge pull request #3688 from CouchRiv/fix-libc-acosf-errno
fix(libc): keep the acosf result and leave errno unchanged
This commit is contained in:
commit
f56d638a5a
|
|
@ -182,7 +182,12 @@ float APS5_VABI asinf_nid_postfix(float x) {
|
|||
errno = saved_errno;
|
||||
return result;
|
||||
}
|
||||
float APS5_VABI acosf_nid_postfix(float x) { return std::acos(x); }
|
||||
float APS5_VABI acosf_nid_postfix(float x) {
|
||||
const int saved_errno = errno;
|
||||
const float result = std::acos(x);
|
||||
errno = saved_errno;
|
||||
return result;
|
||||
}
|
||||
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))); }
|
||||
double APS5_VABI hypot_nid_postfix(double x, double y) {
|
||||
|
|
|
|||
|
|
@ -214,6 +214,16 @@ static void CheckPowfSpecialValue() {
|
|||
Require(std::bit_cast<std::uint32_t>(powf_nid_postfix(1.0f, std::bit_cast<float>(0x7f800001u))) == 0x3f800000u);
|
||||
}
|
||||
|
||||
static void CheckAcosfErrno() {
|
||||
errno = 0;
|
||||
Require(std::bit_cast<std::uint32_t>(acosf_nid_postfix(2.0f)) == 0xffc00000u);
|
||||
Require(errno == 0);
|
||||
Require(std::bit_cast<std::uint32_t>(acosf_nid_postfix(-2.0f)) == 0xffc00000u);
|
||||
Require(errno == 0);
|
||||
Require(std::bit_cast<std::uint32_t>(acosf_nid_postfix(0.5f)) == 0x3f860a92u);
|
||||
Require(errno == 0);
|
||||
}
|
||||
|
||||
static void CheckLongDouble() {
|
||||
Require(ExtendedBits(acosl_nid_postfix(-1.0L), 0xc90fdaa22168c235ull, 0x4000));
|
||||
Require(ExtendedBits(acosl_nid_postfix(0.0L), 0xc90fdaa22168c235ull, 0x3fff));
|
||||
|
|
@ -839,6 +849,7 @@ int main() {
|
|||
Require(minimum.quot == -214748364 && minimum.rem == -8);
|
||||
CheckPowfSpecialValue();
|
||||
Require(abs_nid_postfix(0) == 0);
|
||||
CheckAcosfErrno();
|
||||
Require(abs_nid_postfix(42) == 42);
|
||||
Require(abs_nid_postfix(-42) == 42);
|
||||
Require(abs_nid_postfix(std::numeric_limits<int>::max()) == std::numeric_limits<int>::max());
|
||||
|
|
|
|||
Loading…
Reference in New Issue