Skip to content

[libc] Provide LIBC_TYPES_HAS_INT64 #83441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libc/src/__support/UInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "src/__support/math_extras.h" // SumCarry, DiffBorrow
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128, LIBC_TYPES_HAS_INT64
#include "src/__support/math_extras.h" // SumCarry, DiffBorrow
#include "src/__support/number_pair.h"

#include <stddef.h> // For size_t
Expand Down Expand Up @@ -940,11 +940,11 @@ namespace internal {
// availability.
template <size_t Bits>
struct WordTypeSelector : cpp::type_identity<
#if defined(UINT64_MAX)
#ifdef LIBC_TYPES_HAS_INT64
uint64_t
#else
uint32_t
#endif
#endif // LIBC_TYPES_HAS_INT64
> {
};
// Except if we request 32 bits explicitly.
Expand Down
7 changes: 6 additions & 1 deletion libc/src/__support/macros/properties/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "src/__support/macros/properties/cpu_features.h"
#include "src/__support/macros/properties/os.h"

#include <stdint.h> // __SIZEOF_INT128__
#include <stdint.h> // UINT64_MAX, __SIZEOF_INT128__

// 'long double' properties.
#if (LDBL_MANT_DIG == 53)
Expand All @@ -28,6 +28,11 @@
#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128
#endif

// int64 / uint64 support
#if defined(UINT64_MAX)
#define LIBC_TYPES_HAS_INT64
#endif // UINT64_MAX

// int128 / uint128 support
#if defined(__SIZEOF_INT128__)
#define LIBC_TYPES_HAS_INT128
Expand Down
9 changes: 3 additions & 6 deletions libc/src/string/memory_utils/op_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "src/__support/common.h"
#include "src/__support/endian.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64
#include "src/string/memory_utils/op_builtin.h"
#include "src/string/memory_utils/utils.h"

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

#if defined(UINT64_MAX)
#define LLVM_LIBC_HAS_UINT64
#endif

namespace LIBC_NAMESPACE {
// Compiler types using the vector attributes.
using generic_v128 = uint8_t __attribute__((__vector_size__(16)));
Expand All @@ -60,9 +57,9 @@ template <typename T> struct is_scalar : cpp::false_type {};
template <> struct is_scalar<uint8_t> : cpp::true_type {};
template <> struct is_scalar<uint16_t> : cpp::true_type {};
template <> struct is_scalar<uint32_t> : cpp::true_type {};
#ifdef LLVM_LIBC_HAS_UINT64
#ifdef LIBC_TYPES_HAS_INT64
template <> struct is_scalar<uint64_t> : cpp::true_type {};
#endif // LLVM_LIBC_HAS_UINT64
#endif // LIBC_TYPES_HAS_INT64
// Meant to match std::numeric_limits interface.
// NOLINTNEXTLINE(readability-identifier-naming)
template <typename T> constexpr bool is_scalar_v = is_scalar<T>::value;
Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/string/memory_utils/op_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "memory_check_utils.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64
#include "src/string/memory_utils/op_aarch64.h"
#include "src/string/memory_utils/op_builtin.h"
#include "src/string/memory_utils/op_generic.h" // LLVM_LIBC_HAS_UINT64
#include "src/string/memory_utils/op_riscv.h"
#include "src/string/memory_utils/op_x86.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -124,9 +124,9 @@ using MemsetImplementations = testing::TypeList<
builtin::Memset<32>, //
builtin::Memset<64>,
#endif
#ifdef LLVM_LIBC_HAS_UINT64
#ifdef LIBC_TYPES_HAS_INT64
generic::Memset<uint64_t>, generic::Memset<cpp::array<uint64_t, 2>>,
#endif
#endif // LIBC_TYPES_HAS_INT64
#ifdef __AVX512F__
generic::Memset<generic_v512>, generic::Memset<cpp::array<generic_v512, 2>>,
#endif
Expand Down Expand Up @@ -210,9 +210,9 @@ using BcmpImplementations = testing::TypeList<
#ifndef LIBC_TARGET_ARCH_IS_ARM // Removing non uint8_t types for ARM
generic::Bcmp<uint16_t>,
generic::Bcmp<uint32_t>, //
#ifdef LLVM_LIBC_HAS_UINT64
#ifdef LIBC_TYPES_HAS_INT64
generic::Bcmp<uint64_t>,
#endif // LLVM_LIBC_HAS_UINT64
#endif // LIBC_TYPES_HAS_INT64
generic::BcmpSequence<uint16_t, uint8_t>,
generic::BcmpSequence<uint32_t, uint8_t>, //
generic::BcmpSequence<uint32_t, uint16_t>, //
Expand Down Expand Up @@ -292,9 +292,9 @@ using MemcmpImplementations = testing::TypeList<
#ifndef LIBC_TARGET_ARCH_IS_ARM // Removing non uint8_t types for ARM
generic::Memcmp<uint16_t>,
generic::Memcmp<uint32_t>, //
#ifdef LLVM_LIBC_HAS_UINT64
#ifdef LIBC_TYPES_HAS_INT64
generic::Memcmp<uint64_t>,
#endif // LLVM_LIBC_HAS_UINT64
#endif // LIBC_TYPES_HAS_INT64
generic::MemcmpSequence<uint16_t, uint8_t>,
generic::MemcmpSequence<uint32_t, uint16_t, uint8_t>, //
#endif // LIBC_TARGET_ARCH_IS_ARM
Expand Down