[libc-commits] [libc] 31c3943 - [libc][math] Switch math functions to use libc_errno and fix some errno and floating point exceptions.
Tue Ly via libc-commits
libc-commits at lists.llvm.org
Mon Mar 6 21:51:29 PST 2023
Author: Tue Ly
Date: 2023-03-07T00:51:16-05:00
New Revision: 31c39439a894f6cc46cdcdc6d2f45da004184f6a
URL: https://github.com/llvm/llvm-project/commit/31c39439a894f6cc46cdcdc6d2f45da004184f6a
DIFF: https://github.com/llvm/llvm-project/commit/31c39439a894f6cc46cdcdc6d2f45da004184f6a.diff
LOG: [libc][math] Switch math functions to use libc_errno and fix some errno and floating point exceptions.
Switch math functions to use libc_errno and fix some errno and
floating point exceptions
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D145349
Added:
Modified:
libc/src/__support/FPUtil/CMakeLists.txt
libc/src/__support/FPUtil/FEnvImpl.h
libc/src/__support/FPUtil/NearestIntegerOperations.h
libc/src/math/generic/CMakeLists.txt
libc/src/math/generic/acosf.cpp
libc/src/math/generic/acoshf.cpp
libc/src/math/generic/atanhf.cpp
libc/src/math/generic/cosf.cpp
libc/src/math/generic/log10.cpp
libc/src/math/generic/log10f.cpp
libc/src/math/generic/log1pf.cpp
libc/src/math/generic/log2f.cpp
libc/src/math/generic/logf.cpp
libc/src/math/generic/sinf.cpp
libc/src/math/generic/tanf.cpp
libc/test/UnitTest/FPMatcher.h
libc/test/src/math/CMakeLists.txt
libc/test/src/math/RoundToIntegerTest.h
libc/test/src/math/acosf_test.cpp
libc/test/src/math/acoshf_test.cpp
libc/test/src/math/asin_test.cpp
libc/test/src/math/asinf_test.cpp
libc/test/src/math/asinhf_test.cpp
libc/test/src/math/atanf_test.cpp
libc/test/src/math/atanhf_test.cpp
libc/test/src/math/cosf_test.cpp
libc/test/src/math/coshf_test.cpp
libc/test/src/math/exp10f_test.cpp
libc/test/src/math/exp2f_test.cpp
libc/test/src/math/expf_test.cpp
libc/test/src/math/expm1f_test.cpp
libc/test/src/math/log10_test.cpp
libc/test/src/math/log1pf_test.cpp
libc/test/src/math/log2f_test.cpp
libc/test/src/math/pow_test.cpp
libc/test/src/math/sincosf_test.cpp
libc/test/src/math/sinf_test.cpp
libc/test/src/math/sinhf_test.cpp
libc/test/src/math/tanf_test.cpp
libc/test/src/math/tanhf_test.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 6ccb3ba511c37..b737aad1093d0 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -3,7 +3,6 @@ add_header_library(
HDRS
FEnvImpl.h
DEPENDS
- libc.include.errno
libc.include.fenv
libc.include.math
libc.src.__support.macros.attributes
@@ -52,7 +51,6 @@ add_header_library(
libc.src.__support.CPP.type_traits
libc.src.__support.common
libc.include.math
- libc.include.errno
libc.src.errno.errno
)
@@ -80,7 +78,6 @@ add_header_library(
libc.src.__support.common
libc.src.__support.macros.optimization
libc.include.math
- libc.include.errno
libc.src.errno.errno
)
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 5041b3e911693..ec21555071c86 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -11,8 +11,8 @@
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/properties/architectures.h"
+#include "src/errno/libc_errno.h"
-#include <errno.h>
#include <fenv.h>
#include <math.h>
@@ -71,7 +71,7 @@ LIBC_INLINE int raise_except_if_required(int excepts) {
LIBC_INLINE void set_errno_if_required(int err) {
if (math_errhandling & MATH_ERRNO)
- errno = err;
+ libc_errno = err;
}
} // namespace __llvm_libc::fputil
diff --git a/libc/src/__support/FPUtil/NearestIntegerOperations.h b/libc/src/__support/FPUtil/NearestIntegerOperations.h
index 968e7d499ae27..8265ea1cbb3e5 100644
--- a/libc/src/__support/FPUtil/NearestIntegerOperations.h
+++ b/libc/src/__support/FPUtil/NearestIntegerOperations.h
@@ -15,7 +15,6 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
-#include <errno.h>
#include <math.h>
namespace __llvm_libc {
@@ -238,10 +237,8 @@ LIBC_INLINE I rounded_float_to_signed_integer(F x) {
constexpr I INTEGER_MAX = -(INTEGER_MIN + 1);
FPBits<F> bits(x);
auto set_domain_error_and_raise_invalid = []() {
- if (math_errhandling & MATH_ERRNO)
- errno = EDOM;
- if (math_errhandling & MATH_ERREXCEPT)
- raise_except(FE_INVALID);
+ set_errno_if_required(EDOM);
+ raise_except_if_required(FE_INVALID);
};
if (bits.is_inf_or_nan()) {
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 922e16f4c05e6..09aefc67d1b51 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -774,6 +774,7 @@ add_entrypoint_object(
HDRS
../log10.h
DEPENDS
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.double_double
diff --git a/libc/src/math/generic/acosf.cpp b/libc/src/math/generic/acosf.cpp
index d75e36209a4a7..5835dfa617056 100644
--- a/libc/src/math/generic/acosf.cpp
+++ b/libc/src/math/generic/acosf.cpp
@@ -79,8 +79,7 @@ LLVM_LIBC_FUNCTION(float, acosf, (float x)) {
fputil::set_errno_if_required(EDOM);
fputil::raise_except_if_required(FE_INVALID);
}
- return x +
- FPBits::build_nan(1 << (fputil::MantissaWidth<float>::VALUE - 1));
+ return x + FPBits::build_quiet_nan(0);
}
// When 0.5 < |x| <= 1, we perform range reduction as follow:
diff --git a/libc/src/math/generic/acoshf.cpp b/libc/src/math/generic/acoshf.cpp
index 12e0796c91301..ac225fe5a808f 100644
--- a/libc/src/math/generic/acoshf.cpp
+++ b/libc/src/math/generic/acoshf.cpp
@@ -25,7 +25,8 @@ LLVM_LIBC_FUNCTION(float, acoshf, (float x)) {
if (LIBC_UNLIKELY(x < 1.0f)) {
// x < 1.
- fputil::set_except(FE_INVALID);
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
return FPBits_t::build_quiet_nan(0);
}
diff --git a/libc/src/math/generic/atanhf.cpp b/libc/src/math/generic/atanhf.cpp
index 0a077007de784..b0c92fa8de87d 100644
--- a/libc/src/math/generic/atanhf.cpp
+++ b/libc/src/math/generic/atanhf.cpp
@@ -24,15 +24,15 @@ LLVM_LIBC_FUNCTION(float, atanhf, (float x)) {
if (xbits.is_nan()) {
return x;
}
- // |x| == 0
+ // |x| == 1.0
if (x_abs == 0x3F80'0000U) {
- fputil::set_except(FE_DIVBYZERO);
- return with_errno(FPBits::inf(sign).get_val(), ERANGE);
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_DIVBYZERO);
+ return FPBits::inf(sign).get_val();
} else {
- fputil::set_except(FE_INVALID);
- return with_errno(
- FPBits::build_nan(1 << (fputil::MantissaWidth<float>::VALUE - 1)),
- EDOM);
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
+ return FPBits::build_quiet_nan(0);
}
}
diff --git a/libc/src/math/generic/cosf.cpp b/libc/src/math/generic/cosf.cpp
index 89b7d63b9e8c1..ef94804bda60d 100644
--- a/libc/src/math/generic/cosf.cpp
+++ b/libc/src/math/generic/cosf.cpp
@@ -117,8 +117,7 @@ LLVM_LIBC_FUNCTION(float, cosf, (float x)) {
fputil::set_errno_if_required(EDOM);
fputil::raise_except_if_required(FE_INVALID);
}
- return x +
- FPBits::build_nan(1 << (fputil::MantissaWidth<float>::VALUE - 1));
+ return x + FPBits::build_quiet_nan(0);
}
// Combine the results with the sine of sum formula:
diff --git a/libc/src/math/generic/log10.cpp b/libc/src/math/generic/log10.cpp
index 10d57a8f30861..8eca77379c5e9 100644
--- a/libc/src/math/generic/log10.cpp
+++ b/libc/src/math/generic/log10.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/math/log10.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/double_double.h"
#include "src/__support/FPUtil/dyadic_float.h"
@@ -953,9 +954,13 @@ LLVM_LIBC_FUNCTION(double, log10, (double x)) {
xbits.uintval() > FPBits_t::MAX_NORMAL)) {
if (xbits.is_zero()) {
// return -Inf and raise FE_DIVBYZERO.
- return -1.0 / 0.0;
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_DIVBYZERO);
+ return static_cast<double>(FPBits_t::neg_inf());
}
if (xbits.get_sign() && !xbits.is_nan()) {
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
return FPBits_t::build_quiet_nan(0);
}
if (xbits.is_inf_or_nan()) {
diff --git a/libc/src/math/generic/log10f.cpp b/libc/src/math/generic/log10f.cpp
index ba2f01601ec65..bcf17c672a638 100644
--- a/libc/src/math/generic/log10f.cpp
+++ b/libc/src/math/generic/log10f.cpp
@@ -152,12 +152,14 @@ LLVM_LIBC_FUNCTION(float, log10f, (float x)) {
if (LIBC_UNLIKELY(x_u < FPBits::MIN_NORMAL || x_u > FPBits::MAX_NORMAL)) {
if (xbits.is_zero()) {
// Return -inf and raise FE_DIVBYZERO
- fputil::raise_except(FE_DIVBYZERO);
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_DIVBYZERO);
return static_cast<float>(FPBits::neg_inf());
}
if (xbits.get_sign() && !xbits.is_nan()) {
// Return NaN and raise FE_INVALID
- fputil::raise_except(FE_INVALID);
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
return FPBits::build_quiet_nan(0);
}
if (xbits.is_inf_or_nan()) {
diff --git a/libc/src/math/generic/log1pf.cpp b/libc/src/math/generic/log1pf.cpp
index 1a18e0cd6861f..bf6a91a5fc466 100644
--- a/libc/src/math/generic/log1pf.cpp
+++ b/libc/src/math/generic/log1pf.cpp
@@ -45,7 +45,8 @@ LIBC_INLINE float log(double x) {
if (LIBC_UNLIKELY(x_u > FPBits::MAX_NORMAL)) {
if (xbits.get_sign() && !xbits.is_nan()) {
- fputil::raise_except(FE_INVALID);
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
return fputil::FPBits<float>::build_quiet_nan(0);
}
return static_cast<float>(x);
@@ -103,7 +104,8 @@ LLVM_LIBC_FUNCTION(float, log1pf, (float x)) {
case 0xbd1d20afU: // x = -0x1.3a415ep-5f
return fputil::round_result_slightly_up(-0x1.407112p-5f);
case 0xbf800000U: // x = -1.0
- fputil::raise_except(FE_DIVBYZERO);
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_DIVBYZERO);
return static_cast<float>(fputil::FPBits<float>::neg_inf());
#ifndef LIBC_TARGET_CPU_HAS_FMA
case 0x4cc1c80bU: // x = 0x1.839016p+26f
diff --git a/libc/src/math/generic/log2f.cpp b/libc/src/math/generic/log2f.cpp
index 47abcf8d1f772..ae3c67a770aa6 100644
--- a/libc/src/math/generic/log2f.cpp
+++ b/libc/src/math/generic/log2f.cpp
@@ -121,10 +121,12 @@ LLVM_LIBC_FUNCTION(float, log2f, (float x)) {
// Exceptional inputs.
if (LIBC_UNLIKELY(x_u < FPBits::MIN_NORMAL || x_u > FPBits::MAX_NORMAL)) {
if (xbits.is_zero()) {
- fputil::raise_except(FE_DIVBYZERO);
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_DIVBYZERO);
return static_cast<float>(FPBits::neg_inf());
}
if (xbits.get_sign() && !xbits.is_nan()) {
+ fputil::set_errno_if_required(EDOM);
fputil::raise_except(FE_INVALID);
return FPBits::build_quiet_nan(0);
}
diff --git a/libc/src/math/generic/logf.cpp b/libc/src/math/generic/logf.cpp
index b579b5b7e863f..f2c1fa33309bf 100644
--- a/libc/src/math/generic/logf.cpp
+++ b/libc/src/math/generic/logf.cpp
@@ -96,12 +96,14 @@ LLVM_LIBC_FUNCTION(float, logf, (float x)) {
if (LIBC_UNLIKELY(x_u < FPBits::MIN_NORMAL || x_u > FPBits::MAX_NORMAL)) {
if (xbits.is_zero()) {
// Return -inf and raise FE_DIVBYZERO
- fputil::raise_except(FE_DIVBYZERO);
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_DIVBYZERO);
return static_cast<float>(FPBits::neg_inf());
}
if (xbits.get_sign() && !xbits.is_nan()) {
// Return NaN and raise FE_INVALID
- fputil::raise_except(FE_INVALID);
+ fputil::set_errno_if_required(EDOM);
+ fputil::raise_except_if_required(FE_INVALID);
return FPBits::build_quiet_nan(0);
}
if (xbits.is_inf_or_nan()) {
diff --git a/libc/src/math/generic/sinf.cpp b/libc/src/math/generic/sinf.cpp
index 86f47ace2cc8e..1641c44e9fc00 100644
--- a/libc/src/math/generic/sinf.cpp
+++ b/libc/src/math/generic/sinf.cpp
@@ -138,8 +138,7 @@ LLVM_LIBC_FUNCTION(float, sinf, (float x)) {
fputil::set_errno_if_required(EDOM);
fputil::raise_except_if_required(FE_INVALID);
}
- return x +
- FPBits::build_nan(1 << (fputil::MantissaWidth<float>::VALUE - 1));
+ return x + FPBits::build_quiet_nan(0);
}
// Combine the results with the sine of sum formula:
diff --git a/libc/src/math/generic/tanf.cpp b/libc/src/math/generic/tanf.cpp
index e2208203a2e8a..217664f8b2acb 100644
--- a/libc/src/math/generic/tanf.cpp
+++ b/libc/src/math/generic/tanf.cpp
@@ -114,8 +114,7 @@ LLVM_LIBC_FUNCTION(float, tanf, (float x)) {
fputil::set_errno_if_required(EDOM);
fputil::raise_except_if_required(FE_INVALID);
}
- return x +
- FPBits::build_nan(1 << (fputil::MantissaWidth<float>::VALUE - 1));
+ return x + FPBits::build_quiet_nan(0);
}
// Other large exceptional values
if (auto r = TANF_EXCEPTS.lookup_odd(x_abs, x_sign);
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index f804b652f2759..89ccf1a874e39 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -14,7 +14,6 @@
#include "test/UnitTest/Test.h"
#include "utils/testutils/RoundingModeUtils.h"
-#include <errno.h>
#include <math.h>
namespace __llvm_libc {
@@ -106,8 +105,8 @@ FPMatcher<T, C> getMatcher(T expectedValue) {
#define EXPECT_MATH_ERRNO(expected) \
do { \
if (math_errhandling & MATH_ERRNO) { \
- int actual = errno; \
- errno = 0; \
+ int actual = libc_errno; \
+ libc_errno = 0; \
EXPECT_EQ(actual, expected); \
} \
} while (0)
@@ -115,8 +114,8 @@ FPMatcher<T, C> getMatcher(T expectedValue) {
#define ASSERT_MATH_ERRNO(expected) \
do { \
if (math_errhandling & MATH_ERRNO) { \
- int actual = errno; \
- errno = 0; \
+ int actual = libc_errno; \
+ libc_errno = 0; \
ASSERT_EQ(actual, expected); \
} \
} while (0)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 54cabf89c87ab..0a929ff56d292 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -10,7 +10,6 @@ add_fp_unittest(
HDRS
sdcomp26094.h
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.cosf
libc.src.__support.CPP.array
@@ -39,7 +38,6 @@ add_fp_unittest(
HDRS
sdcomp26094.h
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.sinf
libc.src.__support.CPP.array
@@ -68,7 +66,6 @@ add_fp_unittest(
HDRS
sdcomp26094.h
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.sincosf
libc.src.__support.CPP.array
@@ -85,7 +82,6 @@ add_fp_unittest(
HDRS
sdcomp26094.h
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.tanf
libc.src.__support.CPP.array
@@ -327,7 +323,6 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
- libc.include.errno
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
@@ -347,7 +342,6 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
- libc.include.errno
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
@@ -367,7 +361,6 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
- libc.include.errno
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
@@ -387,7 +380,6 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
- libc.include.errno
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
@@ -407,7 +399,6 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
- libc.include.errno
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
@@ -427,7 +418,6 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
- libc.include.errno
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
@@ -589,7 +579,6 @@ add_fp_unittest(
SRCS
expf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.expf
@@ -604,7 +593,6 @@ add_fp_unittest(
SRCS
exp2f_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.exp2f
@@ -619,7 +607,6 @@ add_fp_unittest(
SRCS
exp10f_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.exp10f
@@ -1268,7 +1255,6 @@ add_fp_unittest(
SRCS
expm1f_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.expm1f
@@ -1295,7 +1281,6 @@ add_fp_unittest(
SRCS
logf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.logf
@@ -1310,7 +1295,6 @@ add_fp_unittest(
SRCS
log2f_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.log2f
@@ -1325,7 +1309,6 @@ add_fp_unittest(
SRCS
log10_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.log10
@@ -1342,7 +1325,6 @@ add_fp_unittest(
SRCS
log10f_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.log10f
@@ -1357,7 +1339,6 @@ add_fp_unittest(
SRCS
log1pf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.include.math
libc.src.math.log1pf
@@ -1419,7 +1400,6 @@ add_fp_unittest(
HDRS
sdcomp26094.h
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.coshf
libc.src.__support.CPP.array
@@ -1436,7 +1416,6 @@ add_fp_unittest(
HDRS
sdcomp26094.h
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.sinhf
libc.src.__support.CPP.array
@@ -1463,7 +1442,6 @@ add_fp_unittest(
SRCS
atanhf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.atanhf
libc.src.__support.FPUtil.fp_bits
@@ -1477,7 +1455,6 @@ add_fp_unittest(
SRCS
asinhf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.asinhf
libc.src.__support.FPUtil.fp_bits
@@ -1491,7 +1468,6 @@ add_fp_unittest(
SRCS
acoshf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.acoshf
libc.src.__support.FPUtil.fp_bits
@@ -1505,7 +1481,6 @@ add_fp_unittest(
SRCS
asinf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.asinf
libc.src.__support.FPUtil.fp_bits
@@ -1519,7 +1494,6 @@ add_fp_unittest(
SRCS
asin_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.asin
)
@@ -1532,7 +1506,6 @@ add_fp_unittest(
SRCS
acosf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.acosf
libc.src.__support.FPUtil.fp_bits
@@ -1546,7 +1519,6 @@ add_fp_unittest(
SRCS
atanf_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.atanf
libc.src.__support.FPUtil.fp_bits
@@ -1574,7 +1546,6 @@ add_fp_unittest(
SRCS
pow_test.cpp
DEPENDS
- libc.include.errno
libc.src.errno.errno
libc.src.math.pow
)
diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index 823ec8deaf27e..a8be9481d3c6e 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -42,7 +42,7 @@ class RoundToIntegerTestTemplate : public __llvm_libc::testing::Test {
void test_one_input(RoundToIntegerFunc func, F input, I expected,
bool expectError) {
- errno = 0;
+ libc_errno = 0;
__llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);
ASSERT_EQ(func(input), expected);
diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp
index ea79aff37304e..0d2db1275d123 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/acosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -23,7 +24,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcAcosfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::acosf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp
index 4ac01b7fcb94c..03f3a30c4ab07 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/acoshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -23,13 +24,13 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcAcoshfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::acoshf(aNaN));
EXPECT_MATH_ERRNO(0);
EXPECT_FP_EQ(aNaN, __llvm_libc::acoshf(0.0f));
- EXPECT_MATH_ERRNO(0);
+ EXPECT_MATH_ERRNO(EDOM);
EXPECT_FP_EQ(0.0f, __llvm_libc::acoshf(1.0f));
EXPECT_MATH_ERRNO(0);
@@ -38,7 +39,7 @@ TEST(LlvmLibcAcoshfTest, SpecialNumbers) {
EXPECT_MATH_ERRNO(0);
EXPECT_FP_EQ(aNaN, __llvm_libc::acoshf(neg_inf));
- EXPECT_MATH_ERRNO(0);
+ EXPECT_MATH_ERRNO(EDOM);
}
TEST(LlvmLibcAcoshfTest, InFloatRange) {
diff --git a/libc/test/src/math/asin_test.cpp b/libc/test/src/math/asin_test.cpp
index d1b8483b8824e..2ccbebfdb22bf 100644
--- a/libc/test/src/math/asin_test.cpp
+++ b/libc/test/src/math/asin_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "src/errno/libc_errno.h"
#include "src/math/asin.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -22,7 +23,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(double)
TEST(LlvmLibcAsinTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::asin(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index 890f21f51612e..439d23c8d1b58 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/asinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -24,7 +25,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcAsinfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::asinf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index d2c6584454abe..906f834a78b22 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/asinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -23,7 +24,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcAsinhfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::asinhf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp
index 7601ffb00dd5e..dbe1d485295ac 100644
--- a/libc/test/src/math/atanf_test.cpp
+++ b/libc/test/src/math/atanf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/atanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -25,7 +26,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcAtanfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
__llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);
EXPECT_FP_EQ(aNaN, __llvm_libc::atanf(aNaN));
EXPECT_FP_EXCEPTION(0);
diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp
index d4b884894a9e4..b11a9dfe1e2b0 100644
--- a/libc/test/src/math/atanhf_test.cpp
+++ b/libc/test/src/math/atanhf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/atanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -23,7 +24,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcAtanhfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
__llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);
EXPECT_FP_EQ(aNaN, __llvm_libc::atanhf(aNaN));
EXPECT_FP_EXCEPTION(0);
diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index dae3c9336cfe9..721ca32068485 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/cosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -25,7 +26,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcCosfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::cosf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp
index c151fbaff4b28..88354a100a533 100644
--- a/libc/test/src/math/coshf_test.cpp
+++ b/libc/test/src/math/coshf_test.cpp
@@ -8,6 +8,7 @@
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/coshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -24,7 +25,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcCoshfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::coshf(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -43,7 +44,7 @@ TEST(LlvmLibcCoshfTest, SpecialNumbers) {
}
TEST(LlvmLibcCoshfTest, Overflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, __llvm_libc::coshf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp
index 1ea7b80087b35..684aa017479c1 100644
--- a/libc/test/src/math/exp10f_test.cpp
+++ b/libc/test/src/math/exp10f_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/exp10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -21,7 +22,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcExp10fTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::exp10f(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -40,7 +41,7 @@ TEST(LlvmLibcExp10fTest, SpecialNumbers) {
}
TEST(LlvmLibcExp10fTest, Overflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, __llvm_libc::exp10f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -55,7 +56,7 @@ TEST(LlvmLibcExp10fTest, Overflow) {
}
TEST(LlvmLibcExp10fTest, Underflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, __llvm_libc::exp10f(float(FPBits(0xff7fffffU))), FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -96,7 +97,7 @@ TEST(LlvmLibcExp10fTest, TrickyInputs) {
0x41200000, // x = 10.0f
};
for (int i = 0; i < N; ++i) {
- errno = 0;
+ libc_errno = 0;
float x = float(FPBits(INPUTS[i]));
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
__llvm_libc::exp10f(x), 0.5);
@@ -112,7 +113,7 @@ TEST(LlvmLibcExp10fTest, InFloatRange) {
float x = float(FPBits(v));
if (isnan(x) || isinf(x))
continue;
- errno = 0;
+ libc_errno = 0;
float result = __llvm_libc::exp10f(x);
// If the computation resulted in an error or did not produce valid result
diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp
index b38c4d43ed535..22abd23d8155e 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -8,6 +8,7 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
+#include "src/errno/libc_errno.h"
#include "src/math/exp2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -22,7 +23,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcExp2fTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::exp2f(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -41,7 +42,7 @@ TEST(LlvmLibcExp2fTest, SpecialNumbers) {
}
TEST(LlvmLibcExp2fTest, Overflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, __llvm_libc::exp2f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -72,7 +73,7 @@ TEST(LlvmLibcExp2fTest, TrickyInputs) {
0xc3150000U, /*-0x1.2ap+7f*/
};
for (int i = 0; i < N; ++i) {
- errno = 0;
+ libc_errno = 0;
float x = float(FPBits(INPUTS[i]));
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
__llvm_libc::exp2f(x), 0.5);
@@ -81,7 +82,7 @@ TEST(LlvmLibcExp2fTest, TrickyInputs) {
}
TEST(LlvmLibcExp2fTest, Underflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, __llvm_libc::exp2f(float(FPBits(0xff7fffffU))), FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -109,7 +110,7 @@ TEST(LlvmLibcExp2fTest, InFloatRange) {
float x = float(FPBits(v));
if (isnan(x) || isinf(x))
continue;
- errno = 0;
+ libc_errno = 0;
float result = __llvm_libc::exp2f(x);
// If the computation resulted in an error or did not produce valid result
diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp
index bcd1dcdb8b6e1..a38bcbd01dd56 100644
--- a/libc/test/src/math/expf_test.cpp
+++ b/libc/test/src/math/expf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/expf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -21,7 +22,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcExpfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::expf(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -40,7 +41,7 @@ TEST(LlvmLibcExpfTest, SpecialNumbers) {
}
TEST(LlvmLibcExpfTest, Overflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, __llvm_libc::expf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -55,7 +56,7 @@ TEST(LlvmLibcExpfTest, Overflow) {
}
TEST(LlvmLibcExpfTest, Underflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, __llvm_libc::expf(float(FPBits(0xff7fffffU))), FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -76,7 +77,7 @@ TEST(LlvmLibcExpfTest, Underflow) {
TEST(LlvmLibcExpfTest, Borderline) {
float x;
- errno = 0;
+ libc_errno = 0;
x = float(FPBits(0x42affff8U));
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x),
0.5);
@@ -110,7 +111,7 @@ TEST(LlvmLibcExpfTest, InFloatRange) {
float x = float(FPBits(v));
if (isnan(x) || isinf(x))
continue;
- errno = 0;
+ libc_errno = 0;
float result = __llvm_libc::expf(x);
// If the computation resulted in an error or did not produce valid result
diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp
index 74df79fe7a390..8ea85f7915c5b 100644
--- a/libc/test/src/math/expm1f_test.cpp
+++ b/libc/test/src/math/expm1f_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/expm1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -21,7 +22,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcExpm1fTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::expm1f(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -40,7 +41,7 @@ TEST(LlvmLibcExpm1fTest, SpecialNumbers) {
}
TEST(LlvmLibcExpm1fTest, Overflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, __llvm_libc::expm1f(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -55,7 +56,7 @@ TEST(LlvmLibcExpm1fTest, Overflow) {
}
TEST(LlvmLibcExpm1fTest, Underflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(-1.0f, __llvm_libc::expm1f(float(FPBits(0xff7fffffU))));
float x = float(FPBits(0xc2cffff8U));
@@ -70,7 +71,7 @@ TEST(LlvmLibcExpm1fTest, Underflow) {
TEST(LlvmLibcExpm1fTest, Borderline) {
float x;
- errno = 0;
+ libc_errno = 0;
x = float(FPBits(0x42affff8U));
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
__llvm_libc::expm1f(x), 0.5);
@@ -119,7 +120,7 @@ TEST(LlvmLibcExpm1fTest, InFloatRange) {
float x = float(FPBits(v));
if (isnan(x) || isinf(x))
continue;
- errno = 0;
+ libc_errno = 0;
float result = __llvm_libc::expm1f(x);
// If the computation resulted in an error or did not produce valid result
diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp
index edefa4cf02a5d..15e5ee6ae918a 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/log10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -84,7 +85,7 @@ TEST(LlvmLibcLog10Test, InDoubleRange) {
double x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x < 0.0)
continue;
- errno = 0;
+ libc_errno = 0;
double result = __llvm_libc::log10(x);
++cc;
if (isnan(result))
diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp
index 973c71945055e..e5137e62ce0a1 100644
--- a/libc/test/src/math/log1pf_test.cpp
+++ b/libc/test/src/math/log1pf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/log1pf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -75,7 +76,7 @@ TEST(LlvmLibclog1pfTest, InFloatRange) {
float x = float(FPBits(v));
if (isnan(x) || isinf(x))
continue;
- errno = 0;
+ libc_errno = 0;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
__llvm_libc::log1pf(x), 0.5);
}
diff --git a/libc/test/src/math/log2f_test.cpp b/libc/test/src/math/log2f_test.cpp
index 08619efb5203f..bef2ffdada7e7 100644
--- a/libc/test/src/math/log2f_test.cpp
+++ b/libc/test/src/math/log2f_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/log2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -50,7 +51,7 @@ TEST(LlvmLibcLog2fTest, InFloatRange) {
float x = float(FPBits(v));
if (isnan(x) || isinf(x))
continue;
- errno = 0;
+ libc_errno = 0;
float result = __llvm_libc::log2f(x);
// If the computation resulted in an error or did not produce valid result
// in the single-precision floating point range, then ignore comparing with
diff --git a/libc/test/src/math/pow_test.cpp b/libc/test/src/math/pow_test.cpp
index 2be8b87500a4b..eff578ae9e380 100644
--- a/libc/test/src/math/pow_test.cpp
+++ b/libc/test/src/math/pow_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "src/errno/libc_errno.h"
#include "src/math/pow.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -22,7 +23,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(double)
TEST(LlvmLibcAsinTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::pow(aNaN, aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index 1fd89190c34d2..8f580c9243ab1 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/sincosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -25,7 +26,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcSinCosfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
float sin, cos;
__llvm_libc::sincosf(aNaN, &sin, &cos);
diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp
index 3559515c80a55..a4a2eda7fd376 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/sinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -25,7 +26,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcSinfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::sinf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp
index 6bec6426d1d51..c0a07756f17c1 100644
--- a/libc/test/src/math/sinhf_test.cpp
+++ b/libc/test/src/math/sinhf_test.cpp
@@ -8,6 +8,7 @@
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/sinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -24,7 +25,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcSinhfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::sinhf(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -67,7 +68,7 @@ TEST(LlvmLibcSinhfTest, SmallValues) {
}
TEST(LlvmLibcSinhfTest, Overflow) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, __llvm_libc::sinhf(float(FPBits(0x7f7fffffU))), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp
index cfe1762ecb58d..a513a036aea16 100644
--- a/libc/test/src/math/tanf_test.cpp
+++ b/libc/test/src/math/tanf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/tanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -25,7 +26,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcTanfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::tanf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp
index dc8af63f2b9e8..6e7a1b472a611 100644
--- a/libc/test/src/math/tanhf_test.cpp
+++ b/libc/test/src/math/tanhf_test.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/errno/libc_errno.h"
#include "src/math/tanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
@@ -23,7 +24,7 @@ namespace mpfr = __llvm_libc::testing::mpfr;
DECLARE_SPECIAL_CONSTANTS(float)
TEST(LlvmLibcTanhfTest, SpecialNumbers) {
- errno = 0;
+ libc_errno = 0;
EXPECT_FP_EQ(aNaN, __llvm_libc::tanhf(aNaN));
EXPECT_MATH_ERRNO(0);
More information about the libc-commits
mailing list