diff options
| author | Guillaume Chatelet <gchatelet@google.com> | 2023-09-26 11:45:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-26 11:45:04 +0200 |
| commit | b6bc9d72f65a5086f310f321e969d96e9a559e75 (patch) | |
| tree | 1e9a9f8c36c9dfc0106507f7b7a0055af83c4a07 /libc/test/src/stdlib | |
| parent | 7675f541f75baa20e8ec007cd625a837e89fc01f (diff) | |
[libc] Mass replace enclosing namespace (#67032)
This is step 4 of
https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
Diffstat (limited to 'libc/test/src/stdlib')
30 files changed, 136 insertions, 129 deletions
diff --git a/libc/test/src/stdlib/AtoiTest.h b/libc/test/src/stdlib/AtoiTest.h index 923489d6644c..85701828c0f6 100644 --- a/libc/test/src/stdlib/AtoiTest.h +++ b/libc/test/src/stdlib/AtoiTest.h @@ -11,9 +11,10 @@ #include <limits.h> -using __llvm_libc::cpp::is_same_v; +using LIBC_NAMESPACE::cpp::is_same_v; -template <typename ReturnT> struct AtoTest : public __llvm_libc::testing::Test { +template <typename ReturnT> +struct AtoTest : public LIBC_NAMESPACE::testing::Test { using FunctionT = ReturnT (*)(const char *); void validNumbers(FunctionT func) { diff --git a/libc/test/src/stdlib/DivTest.h b/libc/test/src/stdlib/DivTest.h index 5867c5b7a023..90fae6c4df44 100644 --- a/libc/test/src/stdlib/DivTest.h +++ b/libc/test/src/stdlib/DivTest.h @@ -9,7 +9,7 @@ #include "test/UnitTest/Test.h" template <typename IntType, typename ReturnType> -class DivTest : public __llvm_libc::testing::Test { +class DivTest : public LIBC_NAMESPACE::testing::Test { public: using DivFunc = ReturnType(IntType, IntType); diff --git a/libc/test/src/stdlib/StrtolTest.h b/libc/test/src/stdlib/StrtolTest.h index 24726b418817..11794c4bfe05 100644 --- a/libc/test/src/stdlib/StrtolTest.h +++ b/libc/test/src/stdlib/StrtolTest.h @@ -15,7 +15,7 @@ #include <limits.h> #include <stddef.h> -using __llvm_libc::cpp::is_signed_v; +using LIBC_NAMESPACE::cpp::is_signed_v; static inline char int_to_b36_char(int input) { if (input < 0 || input > 36) @@ -26,13 +26,13 @@ static inline char int_to_b36_char(int input) { } template <typename ReturnT> -struct StrtoTest : public __llvm_libc::testing::Test { +struct StrtoTest : public LIBC_NAMESPACE::testing::Test { using FunctionT = ReturnT (*)(const char *, char **, int); static constexpr ReturnT T_MAX = - __llvm_libc::cpp::numeric_limits<ReturnT>::max(); + LIBC_NAMESPACE::cpp::numeric_limits<ReturnT>::max(); static constexpr ReturnT T_MIN = - __llvm_libc::cpp::numeric_limits<ReturnT>::min(); + LIBC_NAMESPACE::cpp::numeric_limits<ReturnT>::min(); void InvalidBase(FunctionT func) { const char *ten = "10"; diff --git a/libc/test/src/stdlib/_Exit_test.cpp b/libc/test/src/stdlib/_Exit_test.cpp index af5cd23743f6..9ca0fc51aab8 100644 --- a/libc/test/src/stdlib/_Exit_test.cpp +++ b/libc/test/src/stdlib/_Exit_test.cpp @@ -13,9 +13,9 @@ #include <stdlib.h> TEST(LlvmLibcStdlib, _Exit) { - EXPECT_EXITS([] { __llvm_libc::_Exit(1); }, 1); - EXPECT_EXITS([] { __llvm_libc::_Exit(65); }, 65); + EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(1); }, 1); + EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(65); }, 65); - EXPECT_EXITS([] { __llvm_libc::exit(1); }, 1); - EXPECT_EXITS([] { __llvm_libc::exit(65); }, 65); + EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1); + EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65); } diff --git a/libc/test/src/stdlib/abort_test.cpp b/libc/test/src/stdlib/abort_test.cpp index 6e6f1aeeb91e..766c8d5fbb21 100644 --- a/libc/test/src/stdlib/abort_test.cpp +++ b/libc/test/src/stdlib/abort_test.cpp @@ -14,6 +14,6 @@ TEST(LlvmLibcStdlib, abort) { // -1 matches against any signal, which is necessary for now until - // __llvm_libc::abort() unblocks SIGABRT. - EXPECT_DEATH([] { __llvm_libc::abort(); }, WITH_SIGNAL(-1)); + // LIBC_NAMESPACE::abort() unblocks SIGABRT. + EXPECT_DEATH([] { LIBC_NAMESPACE::abort(); }, WITH_SIGNAL(-1)); } diff --git a/libc/test/src/stdlib/abs_test.cpp b/libc/test/src/stdlib/abs_test.cpp index a402253fb069..171383e2c913 100644 --- a/libc/test/src/stdlib/abs_test.cpp +++ b/libc/test/src/stdlib/abs_test.cpp @@ -9,8 +9,8 @@ #include "src/stdlib/abs.h" #include "test/UnitTest/Test.h" -TEST(LlvmLibcAbsTest, Zero) { EXPECT_EQ(__llvm_libc::abs(0), 0); } +TEST(LlvmLibcAbsTest, Zero) { EXPECT_EQ(LIBC_NAMESPACE::abs(0), 0); } -TEST(LlvmLibcAbsTest, Positive) { EXPECT_EQ(__llvm_libc::abs(1), 1); } +TEST(LlvmLibcAbsTest, Positive) { EXPECT_EQ(LIBC_NAMESPACE::abs(1), 1); } -TEST(LlvmLibcAbsTest, Negative) { EXPECT_EQ(__llvm_libc::abs(-1), 1); } +TEST(LlvmLibcAbsTest, Negative) { EXPECT_EQ(LIBC_NAMESPACE::abs(-1), 1); } diff --git a/libc/test/src/stdlib/atexit_test.cpp b/libc/test/src/stdlib/atexit_test.cpp index eb295adfb719..8a785ccb8cce 100644 --- a/libc/test/src/stdlib/atexit_test.cpp +++ b/libc/test/src/stdlib/atexit_test.cpp @@ -18,38 +18,39 @@ TEST(LlvmLibcAtExit, Basic) { a = 0; auto test = [] { - int status = __llvm_libc::atexit(+[] { + int status = LIBC_NAMESPACE::atexit(+[] { if (a != 1) __builtin_trap(); }); - status |= __llvm_libc::atexit(+[] { a++; }); + status |= LIBC_NAMESPACE::atexit(+[] { a++; }); if (status) __builtin_trap(); - __llvm_libc::exit(0); + LIBC_NAMESPACE::exit(0); }; EXPECT_EXITS(test, 0); } TEST(LlvmLibcAtExit, AtExitCallsSysExit) { auto test = [] { - __llvm_libc::atexit(+[] { _Exit(1); }); - __llvm_libc::exit(0); + LIBC_NAMESPACE::atexit(+[] { _Exit(1); }); + LIBC_NAMESPACE::exit(0); }; EXPECT_EXITS(test, 1); } static int size; -static __llvm_libc::cpp::array<int, 256> arr; +static LIBC_NAMESPACE::cpp::array<int, 256> arr; template <int... Ts> -void register_atexit_handlers(__llvm_libc::cpp::integer_sequence<int, Ts...>) { - (__llvm_libc::atexit(+[] { arr[size++] = Ts; }), ...); +void register_atexit_handlers( + LIBC_NAMESPACE::cpp::integer_sequence<int, Ts...>) { + (LIBC_NAMESPACE::atexit(+[] { arr[size++] = Ts; }), ...); } template <int count> constexpr auto getTest() { return [] { - __llvm_libc::atexit(+[] { + LIBC_NAMESPACE::atexit(+[] { if (size != count) __builtin_trap(); for (int i = 0; i < count; i++) @@ -57,8 +58,8 @@ template <int count> constexpr auto getTest() { __builtin_trap(); }); register_atexit_handlers( - __llvm_libc::cpp::make_integer_sequence<int, count>{}); - __llvm_libc::exit(0); + LIBC_NAMESPACE::cpp::make_integer_sequence<int, count>{}); + LIBC_NAMESPACE::exit(0); }; } @@ -80,9 +81,9 @@ TEST(LlvmLibcAtExit, Many) { TEST(LlvmLibcAtExit, HandlerCallsAtExit) { auto test = [] { - __llvm_libc::atexit( - +[] { __llvm_libc::atexit(+[] { __llvm_libc::exit(1); }); }); - __llvm_libc::exit(0); + LIBC_NAMESPACE::atexit( + +[] { LIBC_NAMESPACE::atexit(+[] { LIBC_NAMESPACE::exit(1); }); }); + LIBC_NAMESPACE::exit(0); }; EXPECT_EXITS(test, 1); } diff --git a/libc/test/src/stdlib/atof_test.cpp b/libc/test/src/stdlib/atof_test.cpp index efa9f6c96d36..ed3d4c26308c 100644 --- a/libc/test/src/stdlib/atof_test.cpp +++ b/libc/test/src/stdlib/atof_test.cpp @@ -16,21 +16,21 @@ #include <limits.h> #include <stddef.h> -using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; +using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; // This is just a simple test to make sure that this function works at all. It's // functionally identical to strtod so the bulk of the testing is there. TEST(LlvmLibcAToFTest, SimpleTest) { - __llvm_libc::fputil::FPBits<double> expected_fp = - __llvm_libc::fputil::FPBits<double>(uint64_t(0x405ec00000000000)); + LIBC_NAMESPACE::fputil::FPBits<double> expected_fp = + LIBC_NAMESPACE::fputil::FPBits<double>(uint64_t(0x405ec00000000000)); libc_errno = 0; - EXPECT_THAT(__llvm_libc::atof("123"), + EXPECT_THAT(LIBC_NAMESPACE::atof("123"), Succeeds<double>(static_cast<double>(expected_fp))); } TEST(LlvmLibcAToFTest, FailedParsingTest) { libc_errno = 0; // atof does not flag errors. - EXPECT_THAT(__llvm_libc::atof("???"), Succeeds<double>(0.0)); + EXPECT_THAT(LIBC_NAMESPACE::atof("???"), Succeeds<double>(0.0)); } diff --git a/libc/test/src/stdlib/atoi_test.cpp b/libc/test/src/stdlib/atoi_test.cpp index 6fbde557e1f0..4973fbb3c1da 100644 --- a/libc/test/src/stdlib/atoi_test.cpp +++ b/libc/test/src/stdlib/atoi_test.cpp @@ -12,4 +12,4 @@ #include "test/UnitTest/Test.h" -ATOI_TEST(Atoi, __llvm_libc::atoi) +ATOI_TEST(Atoi, LIBC_NAMESPACE::atoi) diff --git a/libc/test/src/stdlib/atol_test.cpp b/libc/test/src/stdlib/atol_test.cpp index ad1cbba94650..cc817087d05f 100644 --- a/libc/test/src/stdlib/atol_test.cpp +++ b/libc/test/src/stdlib/atol_test.cpp @@ -12,4 +12,4 @@ #include "test/UnitTest/Test.h" -ATOI_TEST(Atol, __llvm_libc::atol) +ATOI_TEST(Atol, LIBC_NAMESPACE::atol) diff --git a/libc/test/src/stdlib/atoll_test.cpp b/libc/test/src/stdlib/atoll_test.cpp index 8052f2fb15b6..0c7a1331da29 100644 --- a/libc/test/src/stdlib/atoll_test.cpp +++ b/libc/test/src/stdlib/atoll_test.cpp @@ -12,4 +12,4 @@ #include "test/UnitTest/Test.h" -ATOI_TEST(Atoll, __llvm_libc::atoll) +ATOI_TEST(Atoll, LIBC_NAMESPACE::atoll) diff --git a/libc/test/src/stdlib/bsearch_test.cpp b/libc/test/src/stdlib/bsearch_test.cpp index 4726f28c129a..689145806ba8 100644 --- a/libc/test/src/stdlib/bsearch_test.cpp +++ b/libc/test/src/stdlib/bsearch_test.cpp @@ -25,13 +25,14 @@ static int int_compare(const void *l, const void *r) { TEST(LlvmLibcBsearchTest, ErrorInputs) { int val = 123; - EXPECT_TRUE(__llvm_libc::bsearch(nullptr, &val, 1, sizeof(int), - int_compare) == nullptr); - EXPECT_TRUE(__llvm_libc::bsearch(&val, nullptr, 1, sizeof(int), - int_compare) == nullptr); - EXPECT_TRUE(__llvm_libc::bsearch(&val, &val, 0, sizeof(int), int_compare) == + EXPECT_TRUE(LIBC_NAMESPACE::bsearch(nullptr, &val, 1, sizeof(int), + int_compare) == nullptr); + EXPECT_TRUE(LIBC_NAMESPACE::bsearch(&val, nullptr, 1, sizeof(int), + int_compare) == nullptr); + EXPECT_TRUE(LIBC_NAMESPACE::bsearch(&val, &val, 0, sizeof(int), + int_compare) == nullptr); + EXPECT_TRUE(LIBC_NAMESPACE::bsearch(&val, &val, 1, 0, int_compare) == nullptr); - EXPECT_TRUE(__llvm_libc::bsearch(&val, &val, 1, 0, int_compare) == nullptr); } TEST(LlvmLibcBsearchTest, IntegerArray) { @@ -45,7 +46,7 @@ TEST(LlvmLibcBsearchTest, IntegerArray) { for (size_t i = 0; i < s; ++i) { int key = ARRAY[i]; void *elem = - __llvm_libc::bsearch(&key, ARRAY, s, sizeof(int), int_compare); + LIBC_NAMESPACE::bsearch(&key, ARRAY, s, sizeof(int), int_compare); ASSERT_EQ(*reinterpret_cast<int *>(elem), key); } } @@ -53,26 +54,26 @@ TEST(LlvmLibcBsearchTest, IntegerArray) { // Non existent keys for (size_t s = 1; s <= ARRAY_SIZE; ++s) { int key = 5; - ASSERT_TRUE(__llvm_libc::bsearch(&key, &ARRAY, s, sizeof(int), - int_compare) == nullptr); + ASSERT_TRUE(LIBC_NAMESPACE::bsearch(&key, &ARRAY, s, sizeof(int), + int_compare) == nullptr); key = 125; - ASSERT_TRUE(__llvm_libc::bsearch(&key, &ARRAY, s, sizeof(int), - int_compare) == nullptr); + ASSERT_TRUE(LIBC_NAMESPACE::bsearch(&key, &ARRAY, s, sizeof(int), + int_compare) == nullptr); key = 136; - ASSERT_TRUE(__llvm_libc::bsearch(&key, &ARRAY, s, sizeof(int), - int_compare) == nullptr); + ASSERT_TRUE(LIBC_NAMESPACE::bsearch(&key, &ARRAY, s, sizeof(int), + int_compare) == nullptr); key = 12345; - ASSERT_TRUE(__llvm_libc::bsearch(&key, &ARRAY, s, sizeof(int), - int_compare) == nullptr); + ASSERT_TRUE(LIBC_NAMESPACE::bsearch(&key, &ARRAY, s, sizeof(int), + int_compare) == nullptr); } } TEST(LlvmLibcBsearchTest, SameKeyAndArray) { constexpr int ARRAY[5] = {1, 2, 3, 4, 5}; constexpr size_t ARRAY_SIZE = sizeof(ARRAY) / sizeof(int); - void *elem = - __llvm_libc::bsearch(ARRAY, ARRAY, ARRAY_SIZE, sizeof(int), int_compare); + void *elem = LIBC_NAMESPACE::bsearch(ARRAY, ARRAY, ARRAY_SIZE, sizeof(int), + int_compare); EXPECT_EQ(*reinterpret_cast<int *>(elem), ARRAY[0]); } diff --git a/libc/test/src/stdlib/div_test.cpp b/libc/test/src/stdlib/div_test.cpp index 6b1f20d18685..d06b8348b646 100644 --- a/libc/test/src/stdlib/div_test.cpp +++ b/libc/test/src/stdlib/div_test.cpp @@ -12,4 +12,4 @@ #include <stdlib.h> -LIST_DIV_TESTS(int, div_t, __llvm_libc::div) +LIST_DIV_TESTS(int, div_t, LIBC_NAMESPACE::div) diff --git a/libc/test/src/stdlib/labs_test.cpp b/libc/test/src/stdlib/labs_test.cpp index 1209d174331e..535d1da5d5f4 100644 --- a/libc/test/src/stdlib/labs_test.cpp +++ b/libc/test/src/stdlib/labs_test.cpp @@ -9,8 +9,8 @@ #include "src/stdlib/labs.h" #include "test/UnitTest/Test.h" -TEST(LlvmLibcLabsTest, Zero) { EXPECT_EQ(__llvm_libc::labs(0l), 0l); } +TEST(LlvmLibcLabsTest, Zero) { EXPECT_EQ(LIBC_NAMESPACE::labs(0l), 0l); } -TEST(LlvmLibcLabsTest, Positive) { EXPECT_EQ(__llvm_libc::labs(1l), 1l); } +TEST(LlvmLibcLabsTest, Positive) { EXPECT_EQ(LIBC_NAMESPACE::labs(1l), 1l); } -TEST(LlvmLibcLabsTest, Negative) { EXPECT_EQ(__llvm_libc::labs(-1l), 1l); } +TEST(LlvmLibcLabsTest, Negative) { EXPECT_EQ(LIBC_NAMESPACE::labs(-1l), 1l); } diff --git a/libc/test/src/stdlib/ldiv_test.cpp b/libc/test/src/stdlib/ldiv_test.cpp index d28d38789a71..6b84163d6547 100644 --- a/libc/test/src/stdlib/ldiv_test.cpp +++ b/libc/test/src/stdlib/ldiv_test.cpp @@ -12,4 +12,4 @@ #include <stdlib.h> -LIST_DIV_TESTS(long, ldiv_t, __llvm_libc::ldiv) +LIST_DIV_TESTS(long, ldiv_t, LIBC_NAMESPACE::ldiv) diff --git a/libc/test/src/stdlib/llabs_test.cpp b/libc/test/src/stdlib/llabs_test.cpp index 13ed4f8f1c52..a6dfa4655f28 100644 --- a/libc/test/src/stdlib/llabs_test.cpp +++ b/libc/test/src/stdlib/llabs_test.cpp @@ -9,8 +9,12 @@ #include "src/stdlib/llabs.h" #include "test/UnitTest/Test.h" -TEST(LlvmLibcLlabsTest, Zero) { EXPECT_EQ(__llvm_libc::llabs(0ll), 0ll); } +TEST(LlvmLibcLlabsTest, Zero) { EXPECT_EQ(LIBC_NAMESPACE::llabs(0ll), 0ll); } -TEST(LlvmLibcLlabsTest, Positive) { EXPECT_EQ(__llvm_libc::llabs(1ll), 1ll); } +TEST(LlvmLibcLlabsTest, Positive) { + EXPECT_EQ(LIBC_NAMESPACE::llabs(1ll), 1ll); +} -TEST(LlvmLibcLlabsTest, Negative) { EXPECT_EQ(__llvm_libc::llabs(-1ll), 1ll); } +TEST(LlvmLibcLlabsTest, Negative) { + EXPECT_EQ(LIBC_NAMESPACE::llabs(-1ll), 1ll); +} diff --git a/libc/test/src/stdlib/lldiv_test.cpp b/libc/test/src/stdlib/lldiv_test.cpp index 5fa0de23f930..d803894fa862 100644 --- a/libc/test/src/stdlib/lldiv_test.cpp +++ b/libc/test/src/stdlib/lldiv_test.cpp @@ -12,4 +12,4 @@ #include <stdlib.h> -LIST_DIV_TESTS(long long, lldiv_t, __llvm_libc::lldiv) +LIST_DIV_TESTS(long long, lldiv_t, LIBC_NAMESPACE::lldiv) diff --git a/libc/test/src/stdlib/malloc_test.cpp b/libc/test/src/stdlib/malloc_test.cpp index 579d5dca53f0..d9023cf56d9f 100644 --- a/libc/test/src/stdlib/malloc_test.cpp +++ b/libc/test/src/stdlib/malloc_test.cpp @@ -11,9 +11,9 @@ #include "test/UnitTest/Test.h" TEST(LlvmLibcMallocTest, Allocate) { - int *ptr = reinterpret_cast<int *>(__llvm_libc::malloc(sizeof(int))); + int *ptr = reinterpret_cast<int *>(LIBC_NAMESPACE::malloc(sizeof(int))); EXPECT_NE(reinterpret_cast<void *>(ptr), static_cast<void *>(nullptr)); *ptr = 1; EXPECT_EQ(*ptr, 1); - __llvm_libc::free(ptr); + LIBC_NAMESPACE::free(ptr); } diff --git a/libc/test/src/stdlib/qsort_r_test.cpp b/libc/test/src/stdlib/qsort_r_test.cpp index ceb58fc1e896..2c810f411b03 100644 --- a/libc/test/src/stdlib/qsort_r_test.cpp +++ b/libc/test/src/stdlib/qsort_r_test.cpp @@ -33,8 +33,8 @@ TEST(LlvmLibcQsortRTest, SortedArray) { size_t count = 0; - __llvm_libc::qsort_r(array, ARRAY_SIZE, sizeof(int), int_compare_count, - &count); + LIBC_NAMESPACE::qsort_r(array, ARRAY_SIZE, sizeof(int), int_compare_count, + &count); ASSERT_LE(array[0], 10); ASSERT_LE(array[1], 23); @@ -74,8 +74,8 @@ TEST(LlvmLibcQsortRTest, ReverseSortedArray) { size_t count = 0; - __llvm_libc::qsort_r(array, ARRAY_SIZE, sizeof(int), int_compare_count, - &count); + LIBC_NAMESPACE::qsort_r(array, ARRAY_SIZE, sizeof(int), int_compare_count, + &count); for (int i = 0; i < int(ARRAY_SIZE - 1); ++i) ASSERT_LE(array[i], i + 1); @@ -127,9 +127,9 @@ TEST(LlvmLibcQsortRTest, SafeTypeErasure) { }; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(PriorityVal); - __llvm_libc::qsort_r(array, ARRAY_SIZE, sizeof(PriorityVal), - type_erased_comp<PriorityVal>, - reinterpret_cast<void *>(compare_priority_val)); + LIBC_NAMESPACE::qsort_r(array, ARRAY_SIZE, sizeof(PriorityVal), + type_erased_comp<PriorityVal>, + reinterpret_cast<void *>(compare_priority_val)); EXPECT_EQ(array[0].priority, -1); EXPECT_EQ(array[0].size, 100); diff --git a/libc/test/src/stdlib/qsort_test.cpp b/libc/test/src/stdlib/qsort_test.cpp index 9808ad0dcc27..0822d490e652 100644 --- a/libc/test/src/stdlib/qsort_test.cpp +++ b/libc/test/src/stdlib/qsort_test.cpp @@ -29,7 +29,7 @@ TEST(LlvmLibcQsortTest, SortedArray) { 1133, 1135, 1155, 1170, 1171, 11100, 12310}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 10); ASSERT_LE(array[1], 23); @@ -63,7 +63,7 @@ TEST(LlvmLibcQsortTest, ReverseSortedArray) { 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); for (int i = 0; i < int(ARRAY_SIZE - 1); ++i) ASSERT_LE(array[i], i + 1); @@ -75,7 +75,7 @@ TEST(LlvmLibcQsortTest, AllEqualElements) { 100, 100, 100, 100, 100, 100, 100}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); for (size_t i = 0; i < ARRAY_SIZE - 1; ++i) ASSERT_LE(array[i], 100); @@ -86,7 +86,7 @@ TEST(LlvmLibcQsortTest, UnsortedArray1) { 60, 171, 11, 1, -1, -5, -10, 1155, 1170, 1171, 12, -100}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], -100); ASSERT_LE(array[1], -10); @@ -119,7 +119,7 @@ TEST(LlvmLibcQsortTest, UnsortedArray2) { int array[7] = {10, 40, 45, 55, 35, 23, 60}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 10); ASSERT_LE(array[1], 23); @@ -134,7 +134,7 @@ TEST(LlvmLibcQsortTest, UnsortedArrayDuplicateElements1) { int array[6] = {10, 10, 20, 20, 5, 5}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 5); ASSERT_LE(array[1], 5); @@ -148,7 +148,7 @@ TEST(LlvmLibcQsortTest, UnsortedArrayDuplicateElements2) { int array[10] = {20, 10, 10, 10, 10, 20, 21, 21, 21, 21}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 10); ASSERT_LE(array[1], 10); @@ -166,7 +166,7 @@ TEST(LlvmLibcQsortTest, UnsortedArrayDuplicateElements3) { int array[10] = {20, 30, 30, 30, 30, 20, 21, 21, 21, 21}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 20); ASSERT_LE(array[1], 20); @@ -184,7 +184,7 @@ TEST(LlvmLibcQsortTest, UnsortedThreeElementArray1) { int array[3] = {14999024, 0, 3}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 0); ASSERT_LE(array[1], 3); @@ -195,7 +195,7 @@ TEST(LlvmLibcQsortTest, UnsortedThreeElementArray2) { int array[3] = {3, 14999024, 0}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 0); ASSERT_LE(array[1], 3); @@ -206,7 +206,7 @@ TEST(LlvmLibcQsortTest, UnsortedThreeElementArray3) { int array[3] = {3, 0, 14999024}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 0); ASSERT_LE(array[1], 3); @@ -217,7 +217,7 @@ TEST(LlvmLibcQsortTest, SameElementThreeElementArray) { int array[3] = {12345, 12345, 12345}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 12345); ASSERT_LE(array[1], 12345); @@ -228,7 +228,7 @@ TEST(LlvmLibcQsortTest, UnsortedTwoElementArray1) { int array[2] = {14999024, 0}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 0); ASSERT_LE(array[1], 14999024); @@ -238,7 +238,7 @@ TEST(LlvmLibcQsortTest, UnsortedTwoElementArray2) { int array[2] = {0, 14999024}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 0); ASSERT_LE(array[1], 14999024); @@ -248,7 +248,7 @@ TEST(LlvmLibcQsortTest, SameElementTwoElementArray) { int array[2] = {12345, 12345}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], 12345); ASSERT_LE(array[1], 12345); @@ -259,7 +259,7 @@ TEST(LlvmLibcQSortTest, SingleElementArray) { int array[1] = {ELEM}; constexpr size_t ARRAY_SIZE = sizeof(array) / sizeof(int); - __llvm_libc::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); + LIBC_NAMESPACE::qsort(array, ARRAY_SIZE, sizeof(int), int_compare); ASSERT_LE(array[0], ELEM); } diff --git a/libc/test/src/stdlib/rand_test.cpp b/libc/test/src/stdlib/rand_test.cpp index 4bebbe37ffbe..6f25708e5390 100644 --- a/libc/test/src/stdlib/rand_test.cpp +++ b/libc/test/src/stdlib/rand_test.cpp @@ -17,7 +17,7 @@ TEST(LlvmLibcRandTest, UnsetSeed) { static int vals[1000]; for (size_t i = 0; i < 1000; ++i) { - int val = __llvm_libc::rand(); + int val = LIBC_NAMESPACE::rand(); ASSERT_GE(val, 0); ASSERT_LE(val, RAND_MAX); vals[i] = val; @@ -26,27 +26,27 @@ TEST(LlvmLibcRandTest, UnsetSeed) { // The C standard specifies that if 'srand' is never called it should behave // as if 'srand' was called with a value of 1. If we seed the value with 1 we // should get the same sequence as the unseeded version. - __llvm_libc::srand(1); + LIBC_NAMESPACE::srand(1); for (size_t i = 0; i < 1000; ++i) - ASSERT_EQ(__llvm_libc::rand(), vals[i]); + ASSERT_EQ(LIBC_NAMESPACE::rand(), vals[i]); } TEST(LlvmLibcRandTest, SetSeed) { const unsigned int SEED = 12344321; - __llvm_libc::srand(SEED); + LIBC_NAMESPACE::srand(SEED); const size_t NUM_RESULTS = 10; int results[NUM_RESULTS]; for (size_t i = 0; i < NUM_RESULTS; ++i) { - results[i] = __llvm_libc::rand(); + results[i] = LIBC_NAMESPACE::rand(); ASSERT_GE(results[i], 0); ASSERT_LE(results[i], RAND_MAX); } // If the seed is set to the same value, it should give the same sequence. - __llvm_libc::srand(SEED); + LIBC_NAMESPACE::srand(SEED); for (size_t i = 0; i < NUM_RESULTS; ++i) { - int val = __llvm_libc::rand(); + int val = LIBC_NAMESPACE::rand(); EXPECT_EQ(results[i], val); } } diff --git a/libc/test/src/stdlib/strtod_test.cpp b/libc/test/src/stdlib/strtod_test.cpp index 70129ba0714d..b1bdd89e41fd 100644 --- a/libc/test/src/stdlib/strtod_test.cpp +++ b/libc/test/src/stdlib/strtod_test.cpp @@ -17,13 +17,13 @@ #include <limits.h> #include <stddef.h> -using __llvm_libc::fputil::testing::ForceRoundingModeTest; -using __llvm_libc::fputil::testing::RoundingMode; +using LIBC_NAMESPACE::fputil::testing::ForceRoundingModeTest; +using LIBC_NAMESPACE::fputil::testing::RoundingMode; -using __llvm_libc::testing::ErrnoSetterMatcher::Fails; -using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; +using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; +using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; -class LlvmLibcStrToDTest : public __llvm_libc::testing::Test, +class LlvmLibcStrToDTest : public LIBC_NAMESPACE::testing::Test, ForceRoundingModeTest<RoundingMode::Nearest> { public: void run_test(const char *inputString, const ptrdiff_t expectedStrLen, @@ -44,11 +44,11 @@ public: // This is so that the result can be compared in parts. char *str_end = nullptr; - __llvm_libc::fputil::FPBits<double> expected_fp = - __llvm_libc::fputil::FPBits<double>(expectedRawData); + LIBC_NAMESPACE::fputil::FPBits<double> expected_fp = + LIBC_NAMESPACE::fputil::FPBits<double>(expectedRawData); libc_errno = 0; - double result = __llvm_libc::strtod(inputString, &str_end); + double result = LIBC_NAMESPACE::strtod(inputString, &str_end); if (expectedErrno == 0) EXPECT_THAT(result, Succeeds<double>(static_cast<double>(expected_fp))); else diff --git a/libc/test/src/stdlib/strtof_test.cpp b/libc/test/src/stdlib/strtof_test.cpp index 9151cbeb88d5..15a8a34ef4fb 100644 --- a/libc/test/src/stdlib/strtof_test.cpp +++ b/libc/test/src/stdlib/strtof_test.cpp @@ -17,10 +17,10 @@ #include <limits.h> #include <stddef.h> -using __llvm_libc::fputil::testing::ForceRoundingModeTest; -using __llvm_libc::fputil::testing::RoundingMode; +using LIBC_NAMESPACE::fputil::testing::ForceRoundingModeTest; +using LIBC_NAMESPACE::fputil::testing::RoundingMode; -class LlvmLibcStrToFTest : public __llvm_libc::testing::Test, +class LlvmLibcStrToFTest : public LIBC_NAMESPACE::testing::Test, ForceRoundingModeTest<RoundingMode::Nearest> { public: void run_test(const char *inputString, const ptrdiff_t expectedStrLen, @@ -41,11 +41,11 @@ public: // This is so that the result can be compared in parts. char *str_end = nullptr; - __llvm_libc::fputil::FPBits<float> expected_fp = - __llvm_libc::fputil::FPBits<float>(expectedRawData); + LIBC_NAMESPACE::fputil::FPBits<float> expected_fp = + LIBC_NAMESPACE::fputil::FPBits<float>(expectedRawData); libc_errno = 0; - float result = __llvm_libc::strtof(inputString, &str_end); + float result = LIBC_NAMESPACE::strtof(inputString, &str_end); EXPECT_EQ(str_end - inputString, expectedStrLen); EXPECT_FP_EQ(result, static_cast<float>(expected_fp)); diff --git a/libc/test/src/stdlib/strtoint32_test.cpp b/libc/test/src/stdlib/strtoint32_test.cpp index fa5e57145d24..4ca20f3333f5 100644 --- a/libc/test/src/stdlib/strtoint32_test.cpp +++ b/libc/test/src/stdlib/strtoint32_test.cpp @@ -14,7 +14,7 @@ #include "StrtolTest.h" #include "test/UnitTest/Test.h" -namespace __llvm_libc { +namespace LIBC_NAMESPACE { int32_t strtoint32(const char *__restrict str, char **__restrict str_end, int base) { @@ -39,7 +39,7 @@ uint32_t strtouint32(const char *__restrict str, char **__restrict str_end, return result; } -} // namespace __llvm_libc +} // namespace LIBC_NAMESPACE -STRTOL_TEST(Strtoint32, __llvm_libc::strtoint32) -STRTOL_TEST(Strtouint32, __llvm_libc::strtouint32) +STRTOL_TEST(Strtoint32, LIBC_NAMESPACE::strtoint32) +STRTOL_TEST(Strtouint32, LIBC_NAMESPACE::strtouint32) diff --git a/libc/test/src/stdlib/strtoint64_test.cpp b/libc/test/src/stdlib/strtoint64_test.cpp index 95e4761881f5..f8d807b146f2 100644 --- a/libc/test/src/stdlib/strtoint64_test.cpp +++ b/libc/test/src/stdlib/strtoint64_test.cpp @@ -14,7 +14,7 @@ #include "StrtolTest.h" #include "test/UnitTest/Test.h" -namespace __llvm_libc { +namespace LIBC_NAMESPACE { int64_t strtoint64(const char *__restrict str, char **__restrict str_end, int base) { @@ -39,7 +39,7 @@ uint64_t strtouint64(const char *__restrict str, char **__restrict str_end, return result; } -} // namespace __llvm_libc +} // namespace LIBC_NAMESPACE -STRTOL_TEST(Strtoint64, __llvm_libc::strtoint64) -STRTOL_TEST(Strtouint64, __llvm_libc::strtouint64) +STRTOL_TEST(Strtoint64, LIBC_NAMESPACE::strtoint64) +STRTOL_TEST(Strtouint64, LIBC_NAMESPACE::strtouint64) diff --git a/libc/test/src/stdlib/strtol_test.cpp b/libc/test/src/stdlib/strtol_test.cpp index fb92ee6978d9..a6ce262559f7 100644 --- a/libc/test/src/stdlib/strtol_test.cpp +++ b/libc/test/src/stdlib/strtol_test.cpp @@ -12,4 +12,4 @@ #include "StrtolTest.h" -STRTOL_TEST(Strtol, __llvm_libc::strtol) +STRTOL_TEST(Strtol, LIBC_NAMESPACE::strtol) diff --git a/libc/test/src/stdlib/strtold_test.cpp b/libc/test/src/stdlib/strtold_test.cpp index dfa1fb7e939b..680a93188c76 100644 --- a/libc/test/src/stdlib/strtold_test.cpp +++ b/libc/test/src/stdlib/strtold_test.cpp @@ -24,7 +24,7 @@ #define SELECT_CONST(_, __, val) val #endif -class LlvmLibcStrToLDTest : public __llvm_libc::testing::Test { +class LlvmLibcStrToLDTest : public LIBC_NAMESPACE::testing::Test { public: #if defined(LONG_DOUBLE_IS_DOUBLE) void run_test(const char *inputString, const ptrdiff_t expectedStrLen, @@ -74,16 +74,16 @@ public: // +-- 15 Exponent Bits char *str_end = nullptr; - __llvm_libc::fputil::FPBits<long double> expected_fp = - __llvm_libc::fputil::FPBits<long double>(expectedRawData); + LIBC_NAMESPACE::fputil::FPBits<long double> expected_fp = + LIBC_NAMESPACE::fputil::FPBits<long double>(expectedRawData); const int expected_errno = expectedErrno; libc_errno = 0; - long double result = __llvm_libc::strtold(inputString, &str_end); + long double result = LIBC_NAMESPACE::strtold(inputString, &str_end); - __llvm_libc::fputil::FPBits<long double> actual_fp = - __llvm_libc::fputil::FPBits<long double>(); - actual_fp = __llvm_libc::fputil::FPBits<long double>(result); + LIBC_NAMESPACE::fputil::FPBits<long double> actual_fp = + LIBC_NAMESPACE::fputil::FPBits<long double>(); + actual_fp = LIBC_NAMESPACE::fputil::FPBits<long double>(result); EXPECT_EQ(str_end - inputString, expectedStrLen); diff --git a/libc/test/src/stdlib/strtoll_test.cpp b/libc/test/src/stdlib/strtoll_test.cpp index b4b197d59ea0..8e94cdc6a389 100644 --- a/libc/test/src/stdlib/strtoll_test.cpp +++ b/libc/test/src/stdlib/strtoll_test.cpp @@ -12,4 +12,4 @@ #include "StrtolTest.h" -STRTOL_TEST(Strtoll, __llvm_libc::strtoll) +STRTOL_TEST(Strtoll, LIBC_NAMESPACE::strtoll) diff --git a/libc/test/src/stdlib/strtoul_test.cpp b/libc/test/src/stdlib/strtoul_test.cpp index f2cd8603a983..7ba721139dd3 100644 --- a/libc/test/src/stdlib/strtoul_test.cpp +++ b/libc/test/src/stdlib/strtoul_test.cpp @@ -12,4 +12,4 @@ #include "StrtolTest.h" -STRTOL_TEST(Strtoul, __llvm_libc::strtoul) +STRTOL_TEST(Strtoul, LIBC_NAMESPACE::strtoul) diff --git a/libc/test/src/stdlib/strtoull_test.cpp b/libc/test/src/stdlib/strtoull_test.cpp index c2544060d8bd..c9a0b8de46b5 100644 --- a/libc/test/src/stdlib/strtoull_test.cpp +++ b/libc/test/src/stdlib/strtoull_test.cpp @@ -12,4 +12,4 @@ #include "StrtolTest.h" -STRTOL_TEST(Strtoull, __llvm_libc::strtoull) +STRTOL_TEST(Strtoull, LIBC_NAMESPACE::strtoull) |
