[libc-commits] [libc] [libc] Move libc_errno inside of LIBC_NAMESPACE (PR #80774)
via libc-commits
libc-commits at lists.llvm.org
Mon Feb 5 16:54:03 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (michaelrj-google)
<details>
<summary>Changes</summary>
Having libc_errno outside of the namespace causes versioning issues when
trying to link the tests against LLVM-libc. Most of this patch is just
moving libc_errno inside the namespace in tests. This isn't necessary in
the function implementations since those are already inside the
namespace.
---
Patch is 118.72 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/80774.diff
123 Files Affected:
- (modified) libc/src/errno/libc_errno.cpp (+2)
- (modified) libc/src/errno/libc_errno.h (+2-1)
- (modified) libc/test/IntegrationTest/test.h (+6-3)
- (modified) libc/test/UnitTest/ErrnoSetterMatcher.h (+2-2)
- (modified) libc/test/UnitTest/FPMatcher.h (+4-4)
- (modified) libc/test/UnitTest/FuchsiaTest.h (+6-3)
- (modified) libc/test/UnitTest/LibcTest.h (+6-3)
- (modified) libc/test/integration/src/pthread/pthread_create_test.cpp (+1-1)
- (modified) libc/test/integration/src/pthread/pthread_join_test.cpp (+1-1)
- (modified) libc/test/integration/src/unistd/getcwd_test.cpp (+2-2)
- (modified) libc/test/src/__support/str_to_double_test.cpp (+1-1)
- (modified) libc/test/src/__support/str_to_float_test.cpp (+1-1)
- (modified) libc/test/src/__support/str_to_fp_test.h (+1-1)
- (modified) libc/test/src/dirent/dirent_test.cpp (+4-4)
- (modified) libc/test/src/errno/errno_test.cpp (+1-1)
- (modified) libc/test/src/math/RoundToIntegerTest.h (+1-1)
- (modified) libc/test/src/math/acosf_test.cpp (+1-1)
- (modified) libc/test/src/math/acoshf_test.cpp (+1-1)
- (modified) libc/test/src/math/asinf_test.cpp (+1-1)
- (modified) libc/test/src/math/asinhf_test.cpp (+1-1)
- (modified) libc/test/src/math/atanf_test.cpp (+1-1)
- (modified) libc/test/src/math/atanhf_test.cpp (+1-1)
- (modified) libc/test/src/math/cosf_test.cpp (+1-1)
- (modified) libc/test/src/math/coshf_test.cpp (+2-2)
- (modified) libc/test/src/math/exp10_test.cpp (+1-1)
- (modified) libc/test/src/math/exp10f_test.cpp (+6-6)
- (modified) libc/test/src/math/exp2_test.cpp (+1-1)
- (modified) libc/test/src/math/exp2f_test.cpp (+6-6)
- (modified) libc/test/src/math/exp_test.cpp (+1-1)
- (modified) libc/test/src/math/expf_test.cpp (+6-6)
- (modified) libc/test/src/math/expm1_test.cpp (+1-1)
- (modified) libc/test/src/math/expm1f_test.cpp (+6-6)
- (modified) libc/test/src/math/log10_test.cpp (+1-1)
- (modified) libc/test/src/math/log1p_test.cpp (+1-1)
- (modified) libc/test/src/math/log1pf_test.cpp (+1-1)
- (modified) libc/test/src/math/log2_test.cpp (+1-1)
- (modified) libc/test/src/math/log2f_test.cpp (+2-2)
- (modified) libc/test/src/math/log_test.cpp (+1-1)
- (modified) libc/test/src/math/powf_test.cpp (+1-1)
- (modified) libc/test/src/math/sincosf_test.cpp (+1-1)
- (modified) libc/test/src/math/sinf_test.cpp (+1-1)
- (modified) libc/test/src/math/sinhf_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/RoundToIntegerTest.h (+1-1)
- (modified) libc/test/src/math/smoke/acosf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/acoshf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/asinf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/asinhf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/atanf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/atanhf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/cosf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/coshf_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/exp10f_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/exp2f_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/expf_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/expm1f_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/sincosf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/sinf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/sinhf_test.cpp (+2-2)
- (modified) libc/test/src/math/smoke/tanf_test.cpp (+1-1)
- (modified) libc/test/src/math/smoke/tanhf_test.cpp (+1-1)
- (modified) libc/test/src/math/tanf_test.cpp (+1-1)
- (modified) libc/test/src/math/tanhf_test.cpp (+1-1)
- (modified) libc/test/src/sched/affinity_test.cpp (+4-4)
- (modified) libc/test/src/sched/cpu_count_test.cpp (+1-1)
- (modified) libc/test/src/sched/get_priority_test.cpp (+1-1)
- (modified) libc/test/src/sched/param_and_scheduler_test.cpp (+24-21)
- (modified) libc/test/src/sched/sched_rr_get_interval_test.cpp (+4-4)
- (modified) libc/test/src/sched/yield_test.cpp (+1-1)
- (modified) libc/test/src/signal/sigaltstack_test.cpp (+1-1)
- (modified) libc/test/src/signal/signal_test.cpp (+1-1)
- (modified) libc/test/src/signal/sigprocmask_test.cpp (+1-1)
- (modified) libc/test/src/stdio/fgetc_test.cpp (+1-1)
- (modified) libc/test/src/stdio/fgetc_unlocked_test.cpp (+1-1)
- (modified) libc/test/src/stdio/fgets_test.cpp (+1-1)
- (modified) libc/test/src/stdio/fileop_test.cpp (+11-11)
- (modified) libc/test/src/stdio/fopencookie_test.cpp (+4-4)
- (modified) libc/test/src/stdio/remove_test.cpp (+2-2)
- (modified) libc/test/src/stdio/setvbuf_test.cpp (+1-1)
- (modified) libc/test/src/stdio/unlocked_fileop_test.cpp (+2-2)
- (modified) libc/test/src/stdlib/StrtolTest.h (+56-56)
- (modified) libc/test/src/stdlib/atof_test.cpp (+2-2)
- (modified) libc/test/src/stdlib/strtod_test.cpp (+1-1)
- (modified) libc/test/src/stdlib/strtof_test.cpp (+1-1)
- (modified) libc/test/src/stdlib/strtoint32_test.cpp (+2-2)
- (modified) libc/test/src/stdlib/strtoint64_test.cpp (+2-2)
- (modified) libc/test/src/stdlib/strtold_test.cpp (+1-1)
- (modified) libc/test/src/string/strdup_test.cpp (+3-3)
- (modified) libc/test/src/sys/mman/linux/madvise_test.cpp (+2-2)
- (modified) libc/test/src/sys/mman/linux/mincore_test.cpp (+7-7)
- (modified) libc/test/src/sys/mman/linux/mlock_test.cpp (+10-7)
- (modified) libc/test/src/sys/mman/linux/mmap_test.cpp (+2-2)
- (modified) libc/test/src/sys/mman/linux/mprotect_test.cpp (+1-1)
- (modified) libc/test/src/sys/mman/linux/posix_madvise_test.cpp (+2-2)
- (modified) libc/test/src/sys/prctl/linux/prctl_test.cpp (+1-1)
- (modified) libc/test/src/sys/random/linux/getrandom_test.cpp (+2-2)
- (modified) libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp (+3-3)
- (modified) libc/test/src/sys/select/select_ui_test.cpp (+1-1)
- (modified) libc/test/src/sys/sendfile/sendfile_test.cpp (+1-1)
- (modified) libc/test/src/sys/stat/chmod_test.cpp (+4-4)
- (modified) libc/test/src/sys/stat/fchmod_test.cpp (+4-4)
- (modified) libc/test/src/sys/stat/fchmodat_test.cpp (+4-4)
- (modified) libc/test/src/sys/stat/fstat_test.cpp (+3-3)
- (modified) libc/test/src/sys/stat/lstat_test.cpp (+3-3)
- (modified) libc/test/src/sys/stat/stat_test.cpp (+3-3)
- (modified) libc/test/src/termios/termios_test.cpp (+5-5)
- (modified) libc/test/src/time/gmtime_test.cpp (+1-1)
- (modified) libc/test/src/time/nanosleep_test.cpp (+1-1)
- (modified) libc/test/src/unistd/access_test.cpp (+3-3)
- (modified) libc/test/src/unistd/chdir_test.cpp (+3-3)
- (modified) libc/test/src/unistd/dup2_test.cpp (+1-1)
- (modified) libc/test/src/unistd/dup3_test.cpp (+1-1)
- (modified) libc/test/src/unistd/dup_test.cpp (+1-1)
- (modified) libc/test/src/unistd/fchdir_test.cpp (+3-3)
- (modified) libc/test/src/unistd/ftruncate_test.cpp (+1-1)
- (modified) libc/test/src/unistd/isatty_test.cpp (+4-4)
- (modified) libc/test/src/unistd/link_test.cpp (+1-1)
- (modified) libc/test/src/unistd/linkat_test.cpp (+1-1)
- (modified) libc/test/src/unistd/readlink_test.cpp (+1-1)
- (modified) libc/test/src/unistd/readlinkat_test.cpp (+1-1)
- (modified) libc/test/src/unistd/symlink_test.cpp (+1-1)
- (modified) libc/test/src/unistd/symlinkat_test.cpp (+1-1)
- (modified) libc/test/src/unistd/syscall_test.cpp (+1-1)
- (modified) libc/test/src/unistd/truncate_test.cpp (+1-1)
``````````diff
diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp
index e54bdd156d6bc..4af21dccc1564 100644
--- a/libc/src/errno/libc_errno.cpp
+++ b/libc/src/errno/libc_errno.cpp
@@ -44,5 +44,7 @@ LIBC_NAMESPACE::Errno::operator int() { return errno; }
#endif // LIBC_FULL_BUILD
+namespace LIBC_NAMESPACE {
// Define the global `libc_errno` instance.
LIBC_NAMESPACE::Errno libc_errno;
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/errno/libc_errno.h b/libc/src/errno/libc_errno.h
index 632faeaaeff66..6a6ddbc3a9c05 100644
--- a/libc/src/errno/libc_errno.h
+++ b/libc/src/errno/libc_errno.h
@@ -39,8 +39,9 @@ struct Errno {
void operator=(int);
operator int();
};
-} // namespace LIBC_NAMESPACE
extern LIBC_NAMESPACE::Errno libc_errno;
+} // namespace LIBC_NAMESPACE
+
#endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
diff --git a/libc/test/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index c015bb44586ff..64906ef179391 100644
--- a/libc/test/IntegrationTest/test.h
+++ b/libc/test/IntegrationTest/test.h
@@ -68,9 +68,12 @@
////////////////////////////////////////////////////////////////////////////////
// Errno checks.
-#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
-#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
-#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_EQ(VAL) \
+ ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno))
+#define ASSERT_ERRNO_SUCCESS() \
+ ASSERT_EQ(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
+#define ASSERT_ERRNO_FAILURE() \
+ ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
// Integration tests are compiled with -ffreestanding which stops treating
// the main function as a non-overloadable special function. Hence, we use a
diff --git a/libc/test/UnitTest/ErrnoSetterMatcher.h b/libc/test/UnitTest/ErrnoSetterMatcher.h
index 6b15bd4e9b79a..745ba4182023e 100644
--- a/libc/test/UnitTest/ErrnoSetterMatcher.h
+++ b/libc/test/UnitTest/ErrnoSetterMatcher.h
@@ -109,8 +109,8 @@ template <typename T> class ErrnoSetterMatcher : public Matcher<T> {
bool match(T got) {
actual_return = got;
- actual_errno = libc_errno;
- libc_errno = 0;
+ actual_errno = LIBC_NAMESPACE::libc_errno;
+ LIBC_NAMESPACE::libc_errno = 0;
if constexpr (ignore_errno())
return return_cmp.compare(actual_return);
else
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index 210690a9c6ece..c4a1cfa1bc1d4 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -132,8 +132,8 @@ template <typename T> struct FPTest : public Test {
#define EXPECT_MATH_ERRNO(expected) \
do { \
if (math_errhandling & MATH_ERRNO) { \
- int actual = libc_errno; \
- libc_errno = 0; \
+ int actual = LIBC_NAMESPACE::libc_errno; \
+ LIBC_NAMESPACE::libc_errno = 0; \
EXPECT_EQ(actual, expected); \
} \
} while (0)
@@ -141,8 +141,8 @@ template <typename T> struct FPTest : public Test {
#define ASSERT_MATH_ERRNO(expected) \
do { \
if (math_errhandling & MATH_ERRNO) { \
- int actual = libc_errno; \
- libc_errno = 0; \
+ int actual = LIBC_NAMESPACE::libc_errno; \
+ LIBC_NAMESPACE::libc_errno = 0; \
ASSERT_EQ(actual, expected); \
} \
} while (0)
diff --git a/libc/test/UnitTest/FuchsiaTest.h b/libc/test/UnitTest/FuchsiaTest.h
index 1b75379658139..e9e8348ee5ddb 100644
--- a/libc/test/UnitTest/FuchsiaTest.h
+++ b/libc/test/UnitTest/FuchsiaTest.h
@@ -14,9 +14,12 @@
#define WITH_SIGNAL(X) #X
// These macros are used in string unittests.
-#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
-#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
-#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_EQ(VAL) \
+ ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno))
+#define ASSERT_ERRNO_SUCCESS() \
+ ASSERT_EQ(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
+#define ASSERT_ERRNO_FAILURE() \
+ ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
#ifndef EXPECT_DEATH
// Since zxtest has ASSERT_DEATH but not EXPECT_DEATH, wrap calling it
diff --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h
index 1a90d10d7ec01..047f18036b0ac 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -446,9 +446,12 @@ CString libc_make_test_file_path_func(const char *file_name);
////////////////////////////////////////////////////////////////////////////////
// Errno checks.
-#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
-#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
-#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_EQ(VAL) \
+ ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno))
+#define ASSERT_ERRNO_SUCCESS() \
+ ASSERT_EQ(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
+#define ASSERT_ERRNO_FAILURE() \
+ ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
////////////////////////////////////////////////////////////////////////////////
// Subprocess checks.
diff --git a/libc/test/integration/src/pthread/pthread_create_test.cpp b/libc/test/integration/src/pthread/pthread_create_test.cpp
index 5da91c6ec9a7d..29da4d5c3c8d7 100644
--- a/libc/test/integration/src/pthread/pthread_create_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_create_test.cpp
@@ -332,7 +332,7 @@ static void run_failure_tests() {
}
TEST_MAIN() {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
run_success_tests();
run_failure_tests();
return 0;
diff --git a/libc/test/integration/src/pthread/pthread_join_test.cpp b/libc/test/integration/src/pthread/pthread_join_test.cpp
index da1a968aa47d3..994fa57a6b337 100644
--- a/libc/test/integration/src/pthread/pthread_join_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_join_test.cpp
@@ -25,7 +25,7 @@ static void nullJoinTest() {
}
TEST_MAIN() {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
nullJoinTest();
return 0;
}
diff --git a/libc/test/integration/src/unistd/getcwd_test.cpp b/libc/test/integration/src/unistd/getcwd_test.cpp
index 87687d09b9e7a..551768187bf01 100644
--- a/libc/test/integration/src/unistd/getcwd_test.cpp
+++ b/libc/test/integration/src/unistd/getcwd_test.cpp
@@ -31,12 +31,12 @@ TEST_MAIN(int argc, char **argv, char **envp) {
cwd = LIBC_NAMESPACE::getcwd(buffer, 0);
ASSERT_TRUE(cwd == nullptr);
ASSERT_ERRNO_EQ(EINVAL);
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
// Insufficient size
cwd = LIBC_NAMESPACE::getcwd(buffer, 2);
ASSERT_TRUE(cwd == nullptr);
- int err = libc_errno;
+ int err = LIBC_NAMESPACE::libc_errno;
ASSERT_EQ(err, ERANGE);
return 0;
diff --git a/libc/test/src/__support/str_to_double_test.cpp b/libc/test/src/__support/str_to_double_test.cpp
index b66935f0988e0..3c6d03978803b 100644
--- a/libc/test/src/__support/str_to_double_test.cpp
+++ b/libc/test/src/__support/str_to_double_test.cpp
@@ -90,7 +90,7 @@ TEST(LlvmLibcStrToDblTest, SimpleDecimalConversionExtraTypes) {
uint64_t double_output_mantissa = 0;
uint32_t output_exp2 = 0;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
auto double_result =
internal::simple_decimal_conversion<double>("123456789012345678900");
diff --git a/libc/test/src/__support/str_to_float_test.cpp b/libc/test/src/__support/str_to_float_test.cpp
index 3102fa7aa91ec..f23d8706d77da 100644
--- a/libc/test/src/__support/str_to_float_test.cpp
+++ b/libc/test/src/__support/str_to_float_test.cpp
@@ -46,7 +46,7 @@ TEST(LlvmLibcStrToFltTest, SimpleDecimalConversionExtraTypes) {
uint32_t float_output_mantissa = 0;
uint32_t output_exp2 = 0;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
auto float_result =
internal::simple_decimal_conversion<float>("123456789012345678900");
float_output_mantissa = float_result.num.mantissa;
diff --git a/libc/test/src/__support/str_to_fp_test.h b/libc/test/src/__support/str_to_fp_test.h
index 32a3133093929..bddff035fdd16 100644
--- a/libc/test/src/__support/str_to_fp_test.h
+++ b/libc/test/src/__support/str_to_fp_test.h
@@ -66,7 +66,7 @@ template <typename T> struct LlvmLibcStrToFloatTest : public testing::Test {
const int expectedErrno = 0) {
StorageType actual_output_mantissa = 0;
uint32_t actual_output_exp2 = 0;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
auto result = internal::simple_decimal_conversion<T>(numStart);
diff --git a/libc/test/src/dirent/dirent_test.cpp b/libc/test/src/dirent/dirent_test.cpp
index e2e0399673be6..41f522a6a75fb 100644
--- a/libc/test/src/dirent/dirent_test.cpp
+++ b/libc/test/src/dirent/dirent_test.cpp
@@ -55,17 +55,17 @@ TEST(LlvmLibcDirentTest, SimpleOpenAndRead) {
}
TEST(LlvmLibcDirentTest, OpenNonExistentDir) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
::DIR *dir = LIBC_NAMESPACE::opendir("___xyz123__.non_existent__");
ASSERT_TRUE(dir == nullptr);
ASSERT_ERRNO_EQ(ENOENT);
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
}
TEST(LlvmLibcDirentTest, OpenFile) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
::DIR *dir = LIBC_NAMESPACE::opendir("testdata/file1.txt");
ASSERT_TRUE(dir == nullptr);
ASSERT_ERRNO_EQ(ENOTDIR);
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
}
diff --git a/libc/test/src/errno/errno_test.cpp b/libc/test/src/errno/errno_test.cpp
index 876ebfc0ac269..b0db22a85f3bc 100644
--- a/libc/test/src/errno/errno_test.cpp
+++ b/libc/test/src/errno/errno_test.cpp
@@ -11,6 +11,6 @@
TEST(LlvmLibcErrnoTest, Basic) {
int test_val = 123;
- libc_errno = test_val;
+ LIBC_NAMESPACE::libc_errno = test_val;
ASSERT_ERRNO_EQ(test_val);
}
diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index 5239528c9246e..9bd4ba52f61ba 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -51,7 +51,7 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
void test_one_input(RoundToIntegerFunc func, F input, I expected,
bool expectError) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
LIBC_NAMESPACE::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 81f697c315a28..c273184d58f3e 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -22,7 +22,7 @@ namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
using LlvmLibcAcosfTest = LIBC_NAMESPACE::testing::FPTest<float>;
TEST_F(LlvmLibcAcosfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::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 6d43105c83c28..a0e845b2b247e 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -22,7 +22,7 @@ using LlvmLibcAcoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcAcoshfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::acoshf(aNaN));
EXPECT_MATH_ERRNO(0);
diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index 77ac2bc216f77..a24fdcc36e140 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -23,7 +23,7 @@ using LlvmLibcAsinfTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcAsinfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::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 9b925bf254a93..3127861c9a1be 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -22,7 +22,7 @@ using LlvmLibcAsinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcAsinhfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::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 b5d30fbd5679e..1fa7165805c7d 100644
--- a/libc/test/src/math/atanf_test.cpp
+++ b/libc/test/src/math/atanf_test.cpp
@@ -22,7 +22,7 @@ using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcAtanfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::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 9dea65dccd8fd..1b45436094da4 100644
--- a/libc/test/src/math/atanhf_test.cpp
+++ b/libc/test/src/math/atanhf_test.cpp
@@ -23,7 +23,7 @@ namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) {
using Sign = LIBC_NAMESPACE::fputil::Sign;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::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 9a988d76c598f..93ab06dc80b26 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -24,7 +24,7 @@ using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcCosfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::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 843ecb8925ad3..3b8e14fb5f034 100644
--- a/libc/test/src/math/coshf_test.cpp
+++ b/libc/test/src/math/coshf_test.cpp
@@ -23,7 +23,7 @@ using LlvmLibcCoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcCoshfTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::coshf(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -42,7 +42,7 @@ TEST_F(LlvmLibcCoshfTest, SpecialNumbers) {
}
TEST_F(LlvmLibcCoshfTest, Overflow) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp
index e9990b3ed8e6d..d71b5a2230374 100644
--- a/libc/test/src/math/exp10_test.cpp
+++ b/libc/test/src/math/exp10_test.cpp
@@ -106,7 +106,7 @@ TEST_F(LlvmLibcExp10Test, InDoubleRange) {
double x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x < 0.0)
continue;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
double result = LIBC_NAMESPACE::exp10(x);
++cc;
if (isnan(result) || isinf(result))
diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp
index 0866488935c20..4e2d065f1292a 100644
--- a/libc/test/src/math/exp10f_test.cpp
+++ b/libc/test/src/math/exp10f_test.cpp
@@ -21,7 +21,7 @@ using LlvmLibcExp10fTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcExp10fTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp10f(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -40,7 +40,7 @@ TEST_F(LlvmLibcExp10fTest, SpecialNumbers) {
}
TEST_F(LlvmLibcExp10fTest, Overflow) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
@@ -55,7 +55,7 @@ TEST_F(LlvmLibcExp10fTest, Overflow) {
}
TEST_F(LlvmLibcExp10fTest, Underflow) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
0.0f, LIBC_NAMESPACE::exp10f(FPBits(0xff7fffffU).get_val()),
FE_UNDERFLOW);
@@ -97,7 +97,7 @@ TEST_F(LlvmLibcExp10fTest, TrickyInputs) {
0x41200000, // x = 10.0f
};
for (int i = 0; i < N; ++i) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
float x = FPBits(INPUTS[i]).get_val();
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
LIBC_NAMESPACE::exp10f(x), 0.5);
@@ -113,14 +113,14 @@ TEST_F(LlvmLibcExp10fTest, InFloatRange) {
float x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
float result = LIBC_NAMESPACE::exp10f(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
// MPFR result as MPFR can still produce valid results because of its
// wider precision.
- if (isnan(result) || isinf(result) || libc_errno != 0)
+ if (isnan(result) || isinf(result) || LIBC_NAMESPACE::libc_errno != 0)
continue;
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
LIBC_NAMESPACE::exp10f(x), 0.5);
diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp
index d66c9b757625d..2f9d7b3a2a6c9 100644
--- a/libc/test/src/math/exp2_test.cpp
+++ b/libc/test/src/math/exp2_test.cpp
@@ -81,7 +81,7 @@ TEST_F(LlvmLibcExp2Test, InDoubleRange) {
double x = FPBits(v).get_val();
if (isnan(x) || isinf(x) || x < 0.0)
continue;
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
double result = LIBC_NAMESPACE::exp2(x);
++cc;
if (isnan(result) || isinf(result))
diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp
index 18607b1d04910..f5ea8554be5c0 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -22,7 +22,7 @@ using LlvmLibcExp2fTest = LIBC_NAMESPACE::testing::FPTest<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
TEST_F(LlvmLibcExp2fTest, SpecialNumbers) {
- libc_errno = 0;
+ LIBC_NAMESPACE::libc_errno = 0;
EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp2f(aNaN));
EXPECT_MATH_ERRNO(0);
@@ -41,7 +41,7 @@ TEST_F(LlvmLibcExp2fTest, SpecialNumbers) {
}
TEST_F(LlvmLibcExp2fTest, Overflow) {
- ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/80774
More information about the libc-commits
mailing list