aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2024-03-08 16:06:56 +0100
committerGitHub <noreply@github.com>2024-03-08 16:06:56 +0100
commit23c397c7c9407deea3398e787f2901f86207dc11 (patch)
treef42e00a90a6c564d35d25c9940464508de87c9dd /libc/test
parent01e5d4609bed5db52890cb66a91c65e9bb6a122f (diff)
downloadllvm-23c397c7c9407deea3398e787f2901f86207dc11.zip
llvm-23c397c7c9407deea3398e787f2901f86207dc11.tar.gz
llvm-23c397c7c9407deea3398e787f2901f86207dc11.tar.bz2
[libc] Provide `LIBC_TYPES_HAS_INT128` (#84149)
Umbrella bug #83182
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/UnitTest/CMakeLists.txt1
-rw-r--r--libc/test/UnitTest/LibcTest.cpp5
-rw-r--r--libc/test/UnitTest/TestLogger.cpp5
-rw-r--r--libc/test/src/__support/CMakeLists.txt6
-rw-r--r--libc/test/src/__support/CPP/CMakeLists.txt2
-rw-r--r--libc/test/src/__support/CPP/bit_test.cpp9
-rw-r--r--libc/test/src/__support/CPP/limits_test.cpp5
-rw-r--r--libc/test/src/__support/integer_literals_test.cpp5
-rw-r--r--libc/test/src/__support/uint_test.cpp9
9 files changed, 29 insertions, 18 deletions
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index 8a35f12..f7a6f4a 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -73,6 +73,7 @@ add_unittest_framework_library(
libc.src.__support.CPP.string_view
libc.src.__support.CPP.type_traits
libc.src.__support.fixed_point.fx_rep
+ libc.src.__support.macros.properties.types
libc.src.__support.OSUtil.osutil
libc.src.__support.uint
libc.src.__support.uint128
diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp
index 7dc85d0..03cd251 100644
--- a/libc/test/UnitTest/LibcTest.cpp
+++ b/libc/test/UnitTest/LibcTest.cpp
@@ -13,6 +13,7 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/UInt128.h"
#include "src/__support/fixed_point/fx_rep.h"
+#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/TestLogger.h"
#if __STDC_HOSTED__
@@ -215,11 +216,11 @@ TEST_SPECIALIZATION(bool);
// We cannot just use a single UInt128 specialization as that resolves to only
// one type, UInt<128> or __uint128_t. We want both overloads as we want to
-#ifdef __SIZEOF_INT128__
+#ifdef LIBC_TYPES_HAS_INT128
// When builtin __uint128_t type is available, include its specialization
// also.
TEST_SPECIALIZATION(__uint128_t);
-#endif
+#endif // LIBC_TYPES_HAS_INT128
TEST_SPECIALIZATION(LIBC_NAMESPACE::Int<128>);
diff --git a/libc/test/UnitTest/TestLogger.cpp b/libc/test/UnitTest/TestLogger.cpp
index 32f0ec52..4756188 100644
--- a/libc/test/UnitTest/TestLogger.cpp
+++ b/libc/test/UnitTest/TestLogger.cpp
@@ -4,6 +4,7 @@
#include "src/__support/OSUtil/io.h" // write_to_stderr
#include "src/__support/UInt.h" // is_big_int
#include "src/__support/UInt128.h"
+#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include <stdint.h>
@@ -72,9 +73,9 @@ template TestLogger &TestLogger::operator<< <unsigned long>(unsigned long);
template TestLogger &
TestLogger::operator<< <unsigned long long>(unsigned long long);
-#ifdef __SIZEOF_INT128__
+#ifdef LIBC_TYPES_HAS_INT128
template TestLogger &TestLogger::operator<< <__uint128_t>(__uint128_t);
-#endif
+#endif // LIBC_TYPES_HAS_INT128
template TestLogger &TestLogger::operator<< <UInt<128>>(UInt<128>);
template TestLogger &TestLogger::operator<< <UInt<192>>(UInt<192>);
template TestLogger &TestLogger::operator<< <UInt<256>>(UInt<256>);
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index adbacb9..91dd0dc 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -106,8 +106,9 @@ if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
SRCS
uint_test.cpp
DEPENDS
- libc.src.__support.uint
libc.src.__support.CPP.optional
+ libc.src.__support.macros.properties.types
+ libc.src.__support.uint
)
endif()
@@ -118,8 +119,9 @@ add_libc_test(
SRCS
integer_literals_test.cpp
DEPENDS
- libc.src.__support.integer_literals
libc.src.__support.CPP.optional
+ libc.src.__support.integer_literals
+ libc.src.__support.macros.properties.types
)
add_libc_test(
diff --git a/libc/test/src/__support/CPP/CMakeLists.txt b/libc/test/src/__support/CPP/CMakeLists.txt
index d7f332f..f94429e 100644
--- a/libc/test/src/__support/CPP/CMakeLists.txt
+++ b/libc/test/src/__support/CPP/CMakeLists.txt
@@ -8,6 +8,7 @@ add_libc_test(
bit_test.cpp
DEPENDS
libc.src.__support.CPP.bit
+ libc.src.__support.macros.properties.types
libc.src.__support.uint
)
@@ -49,6 +50,7 @@ add_libc_test(
limits_test.cpp
DEPENDS
libc.src.__support.CPP.limits
+ libc.src.__support.macros.properties.types
libc.src.__support.uint
)
diff --git a/libc/test/src/__support/CPP/bit_test.cpp b/libc/test/src/__support/CPP/bit_test.cpp
index da7bb33..3deb1f4 100644
--- a/libc/test/src/__support/CPP/bit_test.cpp
+++ b/libc/test/src/__support/CPP/bit_test.cpp
@@ -8,6 +8,7 @@
#include "src/__support/CPP/bit.h"
#include "src/__support/UInt.h"
+#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/Test.h"
#include <stdint.h>
@@ -15,16 +16,16 @@
namespace LIBC_NAMESPACE::cpp {
using UnsignedTypesNoBigInt = testing::TypeList<
-#if defined(__SIZEOF_INT128__)
+#if defined(LIBC_TYPES_HAS_INT128)
__uint128_t,
-#endif
+#endif // LIBC_TYPES_HAS_INT128
unsigned char, unsigned short, unsigned int, unsigned long,
unsigned long long>;
using UnsignedTypes = testing::TypeList<
-#if defined(__SIZEOF_INT128__)
+#if defined(LIBC_TYPES_HAS_INT128)
__uint128_t,
-#endif
+#endif // LIBC_TYPES_HAS_INT128
unsigned char, unsigned short, unsigned int, unsigned long,
unsigned long long, UInt<128>>;
diff --git a/libc/test/src/__support/CPP/limits_test.cpp b/libc/test/src/__support/CPP/limits_test.cpp
index d83e307..efcd683 100644
--- a/libc/test/src/__support/CPP/limits_test.cpp
+++ b/libc/test/src/__support/CPP/limits_test.cpp
@@ -8,6 +8,7 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/UInt.h"
+#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/Test.h"
namespace LIBC_NAMESPACE {
@@ -36,9 +37,9 @@ TEST(LlvmLibcLimitsTest, UInt128Limits) {
auto umax64 = LIBC_NAMESPACE::UInt<128>(cpp::numeric_limits<uint64_t>::max());
EXPECT_GT(umax128, umax64);
ASSERT_EQ(~LIBC_NAMESPACE::UInt<128>(0), umax128);
-#ifdef __SIZEOF_INT128__
+#ifdef LIBC_TYPES_HAS_INT128
ASSERT_EQ(~__uint128_t(0), cpp::numeric_limits<__uint128_t>::max());
-#endif
+#endif // LIBC_TYPES_HAS_INT128
}
} // namespace LIBC_NAMESPACE
diff --git a/libc/test/src/__support/integer_literals_test.cpp b/libc/test/src/__support/integer_literals_test.cpp
index b8b399d..5298cf3 100644
--- a/libc/test/src/__support/integer_literals_test.cpp
+++ b/libc/test/src/__support/integer_literals_test.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/integer_literals.h"
+#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/Test.h"
using LIBC_NAMESPACE::operator""_u8;
@@ -66,7 +67,7 @@ TEST(LlvmLibcIntegerLiteralTest, u64) {
}
TEST(LlvmLibcIntegerLiteralTest, u128) {
-#if defined(__SIZEOF_INT128__)
+#ifdef LIBC_TYPES_HAS_INT128
const __uint128_t ZERO = 0;
const __uint128_t U8_MAX = UINT8_MAX;
const __uint128_t U16_MAX = UINT16_MAX;
@@ -80,7 +81,7 @@ TEST(LlvmLibcIntegerLiteralTest, u128) {
const UInt128 U32_MAX = UINT32_MAX;
const UInt128 U64_MAX = UINT64_MAX;
const UInt128 U128_MAX = (U64_MAX << 64) | U64_MAX;
-#endif
+#endif // LIBC_TYPES_HAS_INT128
EXPECT_EQ(ZERO, 0_u128);
EXPECT_EQ(U8_MAX, 255_u128);
EXPECT_EQ(U8_MAX, 0xFF_u128);
diff --git a/libc/test/src/__support/uint_test.cpp b/libc/test/src/__support/uint_test.cpp
index eb1db97..851656e 100644
--- a/libc/test/src/__support/uint_test.cpp
+++ b/libc/test/src/__support/uint_test.cpp
@@ -8,6 +8,7 @@
#include "src/__support/CPP/optional.h"
#include "src/__support/UInt.h"
+#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/Test.h"
#include <math.h> // HUGE_VALF, HUGE_VALF
@@ -41,7 +42,7 @@ TEST(LlvmLibcUIntClassTest, BitCastToFromDouble) {
}
}
-#ifdef __SIZEOF_INT128__
+#ifdef LIBC_TYPES_HAS_INT128
TEST(LlvmLibcUIntClassTest, BitCastToFromNativeUint128) {
static_assert(cpp::is_trivially_copyable<LL_UInt128>::value);
static_assert(sizeof(LL_UInt128) == sizeof(__uint128_t));
@@ -52,7 +53,7 @@ TEST(LlvmLibcUIntClassTest, BitCastToFromNativeUint128) {
EXPECT_TRUE(value == forth);
}
}
-#endif
+#endif // LIBC_TYPES_HAS_INT128
#ifdef LIBC_TYPES_HAS_FLOAT128
TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat128) {
@@ -652,7 +653,7 @@ TEST(LlvmLibcUIntClassTest, BasicArithmeticInt128Tests) {
ASSERT_EQ(c * b, b);
}
-#ifdef __SIZEOF_INT128__
+#ifdef LIBC_TYPES_HAS_INT128
TEST(LlvmLibcUIntClassTest, ConstructorFromUInt128Tests) {
__uint128_t a = (__uint128_t(123) << 64) + 1;
@@ -707,7 +708,7 @@ TEST(LlvmLibcUIntClassTest, WordTypeUInt128Tests) {
EXPECT_TRUE(f == r);
}
-#endif // __SIZEOF_INT128__
+#endif // LIBC_TYPES_HAS_INT128
TEST(LlvmLibcUIntClassTest, OtherWordTypeTests) {
using LL_UInt96 = BigInt<96, false, uint32_t>;