Skip to content

Commit a84e66a

Browse files
authored
[libc] Provide LIBC_TYPES_HAS_INT64 (#83441)
Umbrella bug #83182
1 parent def038b commit a84e66a

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

libc/src/__support/UInt.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#include "src/__support/CPP/limits.h"
1515
#include "src/__support/CPP/optional.h"
1616
#include "src/__support/CPP/type_traits.h"
17-
#include "src/__support/macros/attributes.h" // LIBC_INLINE
18-
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
19-
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
20-
#include "src/__support/math_extras.h" // SumCarry, DiffBorrow
17+
#include "src/__support/macros/attributes.h" // LIBC_INLINE
18+
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
19+
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128, LIBC_TYPES_HAS_INT64
20+
#include "src/__support/math_extras.h" // SumCarry, DiffBorrow
2121
#include "src/__support/number_pair.h"
2222

2323
#include <stddef.h> // For size_t
@@ -940,11 +940,11 @@ namespace internal {
940940
// availability.
941941
template <size_t Bits>
942942
struct WordTypeSelector : cpp::type_identity<
943-
#if defined(UINT64_MAX)
943+
#ifdef LIBC_TYPES_HAS_INT64
944944
uint64_t
945945
#else
946946
uint32_t
947-
#endif
947+
#endif // LIBC_TYPES_HAS_INT64
948948
> {
949949
};
950950
// Except if we request 32 bits explicitly.

libc/src/__support/macros/properties/types.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "src/__support/macros/properties/cpu_features.h"
1818
#include "src/__support/macros/properties/os.h"
1919

20-
#include <stdint.h> // __SIZEOF_INT128__
20+
#include <stdint.h> // UINT64_MAX, __SIZEOF_INT128__
2121

2222
// 'long double' properties.
2323
#if (LDBL_MANT_DIG == 53)
@@ -28,6 +28,11 @@
2828
#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128
2929
#endif
3030

31+
// int64 / uint64 support
32+
#if defined(UINT64_MAX)
33+
#define LIBC_TYPES_HAS_INT64
34+
#endif // UINT64_MAX
35+
3136
// int128 / uint128 support
3237
#if defined(__SIZEOF_INT128__)
3338
#define LIBC_TYPES_HAS_INT128

libc/src/string/memory_utils/op_generic.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "src/__support/common.h"
2929
#include "src/__support/endian.h"
3030
#include "src/__support/macros/optimization.h"
31+
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64
3132
#include "src/string/memory_utils/op_builtin.h"
3233
#include "src/string/memory_utils/utils.h"
3334

@@ -37,10 +38,6 @@ static_assert((UINTPTR_MAX == 4294967295U) ||
3738
(UINTPTR_MAX == 18446744073709551615UL),
3839
"We currently only support 32- or 64-bit platforms");
3940

40-
#if defined(UINT64_MAX)
41-
#define LLVM_LIBC_HAS_UINT64
42-
#endif
43-
4441
namespace LIBC_NAMESPACE {
4542
// Compiler types using the vector attributes.
4643
using generic_v128 = uint8_t __attribute__((__vector_size__(16)));
@@ -60,9 +57,9 @@ template <typename T> struct is_scalar : cpp::false_type {};
6057
template <> struct is_scalar<uint8_t> : cpp::true_type {};
6158
template <> struct is_scalar<uint16_t> : cpp::true_type {};
6259
template <> struct is_scalar<uint32_t> : cpp::true_type {};
63-
#ifdef LLVM_LIBC_HAS_UINT64
60+
#ifdef LIBC_TYPES_HAS_INT64
6461
template <> struct is_scalar<uint64_t> : cpp::true_type {};
65-
#endif // LLVM_LIBC_HAS_UINT64
62+
#endif // LIBC_TYPES_HAS_INT64
6663
// Meant to match std::numeric_limits interface.
6764
// NOLINTNEXTLINE(readability-identifier-naming)
6865
template <typename T> constexpr bool is_scalar_v = is_scalar<T>::value;

libc/test/src/string/memory_utils/op_tests.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "memory_check_utils.h"
10+
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64
1011
#include "src/string/memory_utils/op_aarch64.h"
1112
#include "src/string/memory_utils/op_builtin.h"
12-
#include "src/string/memory_utils/op_generic.h" // LLVM_LIBC_HAS_UINT64
1313
#include "src/string/memory_utils/op_riscv.h"
1414
#include "src/string/memory_utils/op_x86.h"
1515
#include "test/UnitTest/Test.h"
@@ -124,9 +124,9 @@ using MemsetImplementations = testing::TypeList<
124124
builtin::Memset<32>, //
125125
builtin::Memset<64>,
126126
#endif
127-
#ifdef LLVM_LIBC_HAS_UINT64
127+
#ifdef LIBC_TYPES_HAS_INT64
128128
generic::Memset<uint64_t>, generic::Memset<cpp::array<uint64_t, 2>>,
129-
#endif
129+
#endif // LIBC_TYPES_HAS_INT64
130130
#ifdef __AVX512F__
131131
generic::Memset<generic_v512>, generic::Memset<cpp::array<generic_v512, 2>>,
132132
#endif
@@ -210,9 +210,9 @@ using BcmpImplementations = testing::TypeList<
210210
#ifndef LIBC_TARGET_ARCH_IS_ARM // Removing non uint8_t types for ARM
211211
generic::Bcmp<uint16_t>,
212212
generic::Bcmp<uint32_t>, //
213-
#ifdef LLVM_LIBC_HAS_UINT64
213+
#ifdef LIBC_TYPES_HAS_INT64
214214
generic::Bcmp<uint64_t>,
215-
#endif // LLVM_LIBC_HAS_UINT64
215+
#endif // LIBC_TYPES_HAS_INT64
216216
generic::BcmpSequence<uint16_t, uint8_t>,
217217
generic::BcmpSequence<uint32_t, uint8_t>, //
218218
generic::BcmpSequence<uint32_t, uint16_t>, //
@@ -292,9 +292,9 @@ using MemcmpImplementations = testing::TypeList<
292292
#ifndef LIBC_TARGET_ARCH_IS_ARM // Removing non uint8_t types for ARM
293293
generic::Memcmp<uint16_t>,
294294
generic::Memcmp<uint32_t>, //
295-
#ifdef LLVM_LIBC_HAS_UINT64
295+
#ifdef LIBC_TYPES_HAS_INT64
296296
generic::Memcmp<uint64_t>,
297-
#endif // LLVM_LIBC_HAS_UINT64
297+
#endif // LIBC_TYPES_HAS_INT64
298298
generic::MemcmpSequence<uint16_t, uint8_t>,
299299
generic::MemcmpSequence<uint32_t, uint16_t, uint8_t>, //
300300
#endif // LIBC_TARGET_ARCH_IS_ARM

0 commit comments

Comments
 (0)