Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f6b2a22

Browse files
authoredOct 1, 2024··
[libc] Move struct Sign into LIBC_NAMESPACE (#110709)
The struct Sign should be in the correct namespace. Also update the various tests that use it.
1 parent 4206c37 commit f6b2a22

31 files changed

+57
-0
lines changed
 

‎libc/src/__support/sign.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
1313

14+
namespace LIBC_NAMESPACE_DECL {
15+
1416
// A type to interact with signed arithmetic types.
1517
struct Sign {
1618
LIBC_INLINE constexpr bool is_pos() const { return !is_negative; }
@@ -37,4 +39,5 @@ struct Sign {
3739
LIBC_INLINE_VAR constexpr Sign Sign::NEG = Sign(true);
3840
LIBC_INLINE_VAR constexpr Sign Sign::POS = Sign(false);
3941

42+
} // namespace LIBC_NAMESPACE_DECL
4043
#endif // LLVM_LIBC_SRC___SUPPORT_SIGN_H

‎libc/test/UnitTest/FPMatcher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "hdr/math_macros.h"
2323

24+
using LIBC_NAMESPACE::Sign;
25+
2426
namespace LIBC_NAMESPACE_DECL {
2527
namespace testing {
2628

‎libc/test/src/__support/FPUtil/dyadic_float_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Float128 = LIBC_NAMESPACE::fputil::DyadicFloat<128>;
1717
using Float192 = LIBC_NAMESPACE::fputil::DyadicFloat<192>;
1818
using Float256 = LIBC_NAMESPACE::fputil::DyadicFloat<256>;
19+
using LIBC_NAMESPACE::Sign;
1920

2021
TEST(LlvmLibcDyadicFloatTest, BasicConversions) {
2122
Float128 x(Sign::POS, /*exponent*/ 0,

‎libc/test/src/__support/FPUtil/fpbits_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "src/__support/sign.h" // Sign
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
1617
using LIBC_NAMESPACE::fputil::FPBits;
1718
using LIBC_NAMESPACE::fputil::FPType;
1819
using LIBC_NAMESPACE::fputil::internal::FPRep;

‎libc/test/src/math/FDimTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
17+
1618
template <typename T>
1719
class FDimTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1820
public:

‎libc/test/src/math/HypotTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "hdr/math_macros.h"
1919

20+
using LIBC_NAMESPACE::Sign;
21+
2022
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
2123

2224
template <typename T>

‎libc/test/src/math/ILogbTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "test/UnitTest/FEnvSafeTest.h"
1717
#include "test/UnitTest/Test.h"
1818

19+
using LIBC_NAMESPACE::Sign;
20+
1921
class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2022
public:
2123
template <typename T> struct ILogbFunc {

‎libc/test/src/math/LdExpTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "hdr/math_macros.h"
2020
#include <stdint.h>
2121

22+
using LIBC_NAMESPACE::Sign;
23+
2224
template <typename T>
2325
class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2426
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;

‎libc/test/src/math/NextAfterTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "test/UnitTest/FPMatcher.h"
1919
#include "test/UnitTest/Test.h"
2020

21+
using LIBC_NAMESPACE::Sign;
22+
2123
template <typename T>
2224
class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2325
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;

‎libc/test/src/math/RIntTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "hdr/math_macros.h"
2222

2323
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
24+
using LIBC_NAMESPACE::Sign;
2425

2526
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
2627
FE_TONEAREST};

‎libc/test/src/math/RemQuoTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "utils/MPFRWrapper/MPFRUtils.h"
1919

2020
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
21+
using LIBC_NAMESPACE::Sign;
2122

2223
template <typename T>
2324
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

‎libc/test/src/math/RoundToIntegerTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <errno.h>
2323

2424
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
25+
using LIBC_NAMESPACE::Sign;
2526

2627
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
2728
FE_TONEAREST};

‎libc/test/src/math/atanhf_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <stdint.h>
1919

2020
using LlvmLibcAtanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;
21+
using LIBC_NAMESPACE::Sign;
2122

2223
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
2324

‎libc/test/src/math/smoke/AddTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "test/UnitTest/FPMatcher.h"
1818
#include "test/UnitTest/Test.h"
1919

20+
using LIBC_NAMESPACE::Sign;
21+
2022
template <typename OutType, typename InType>
2123
class AddTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2224

‎libc/test/src/math/smoke/DivTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "test/UnitTest/RoundingModeUtils.h"
1717
#include "test/UnitTest/Test.h"
1818

19+
using LIBC_NAMESPACE::Sign;
20+
1921
template <typename OutType, typename InType>
2022
class DivTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2123

‎libc/test/src/math/smoke/FDimTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "test/UnitTest/FPMatcher.h"
1313
#include "test/UnitTest/Test.h"
1414

15+
using LIBC_NAMESPACE::Sign;
16+
1517
template <typename T>
1618
class FDimTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1719
public:

‎libc/test/src/math/smoke/GetPayloadTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
17+
1618
template <typename T>
1719
class GetPayloadTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1820

‎libc/test/src/math/smoke/ILogbTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "test/UnitTest/FEnvSafeTest.h"
1616
#include "test/UnitTest/Test.h"
1717

18+
using LIBC_NAMESPACE::Sign;
19+
1820
template <typename OutType, typename InType>
1921
class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2022
using FPBits = LIBC_NAMESPACE::fputil::FPBits<InType>;

‎libc/test/src/math/smoke/LdExpTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <stdint.h>
2020

21+
using LIBC_NAMESPACE::Sign;
22+
2123
template <typename T, typename U = int>
2224
class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2325
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;

‎libc/test/src/math/smoke/MulTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "test/UnitTest/FPMatcher.h"
1717
#include "test/UnitTest/Test.h"
1818

19+
using LIBC_NAMESPACE::Sign;
20+
1921
template <typename OutType, typename InType>
2022
class MulTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2123

‎libc/test/src/math/smoke/NearbyIntTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "test/UnitTest/FPMatcher.h"
1616
#include "test/UnitTest/Test.h"
1717

18+
using LIBC_NAMESPACE::Sign;
19+
1820
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
1921
FE_TONEAREST};
2022

‎libc/test/src/math/smoke/NextAfterTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "hdr/fenv_macros.h"
2020

21+
using LIBC_NAMESPACE::Sign;
22+
2123
// TODO: Strengthen errno,exception checks and remove these assert macros
2224
// after new matchers/test fixtures are added
2325
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \

‎libc/test/src/math/smoke/NextTowardTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "hdr/fenv_macros.h"
2020

21+
using LIBC_NAMESPACE::Sign;
22+
2123
// TODO: Strengthen errno,exception checks and remove these assert macros
2224
// after new matchers/test fixtures are added
2325
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \

‎libc/test/src/math/smoke/RIntTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "hdr/fenv_macros.h"
1919
#include "hdr/math_macros.h"
2020

21+
using LIBC_NAMESPACE::Sign;
22+
2123
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
2224
FE_TONEAREST};
2325

‎libc/test/src/math/smoke/RemQuoTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "test/UnitTest/FPMatcher.h"
1515
#include "test/UnitTest/Test.h"
1616

17+
using LIBC_NAMESPACE::Sign;
18+
1719
template <typename T>
1820
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1921
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;

‎libc/test/src/math/smoke/SetPayloadSigTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
17+
1618
template <typename T>
1719
class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1820

‎libc/test/src/math/smoke/SetPayloadTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
17+
1618
template <typename T>
1719
class SetPayloadTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1820

‎libc/test/src/math/smoke/SubTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "test/UnitTest/FPMatcher.h"
1717
#include "test/UnitTest/Test.h"
1818

19+
using LIBC_NAMESPACE::Sign;
20+
1921
template <typename OutType, typename InType>
2022
class SubTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2123

‎libc/test/src/math/smoke/TotalOrderMagTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
17+
1618
template <typename T>
1719
class TotalOrderMagTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1820

‎libc/test/src/math/smoke/TotalOrderTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16+
using LIBC_NAMESPACE::Sign;
17+
1618
template <typename T>
1719
class TotalOrderTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
1820

‎libc/test/src/math/smoke/atanhf_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <errno.h>
1717
#include <stdint.h>
1818

19+
using LIBC_NAMESPACE::Sign;
20+
1921
using LlvmLibcAtanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;
2022

2123
TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) {

0 commit comments

Comments
 (0)
Please sign in to comment.