Skip to content

Commit 6322cf0

Browse files
committed
int128_opt -> native_int128
1 parent 8dfd236 commit 6322cf0

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

include/fmt/base.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,19 @@ constexpr auto is_constant_evaluated(bool default_value = false) noexcept
396396
#elif defined(__SIZEOF_INT128__) && !defined(__NVCC__) && \
397397
!(FMT_CLANG_VERSION && FMT_MSC_VERSION)
398398
# define FMT_USE_INT128 1
399-
using int128_opt = __int128_t; // An optional native 128-bit integer.
400-
using uint128_opt = __uint128_t;
401-
inline auto map(int128_opt x) -> int128_opt { return x; }
402-
inline auto map(uint128_opt x) -> uint128_opt { return x; }
399+
using native_int128 = __int128_t;
400+
using native_uint128 = __uint128_t;
401+
inline auto map(native_int128 x) -> native_int128 { return x; }
402+
inline auto map(native_uint128 x) -> native_uint128 { return x; }
403403
#else
404404
# define FMT_USE_INT128 0
405405
#endif
406406
#if !FMT_USE_INT128
407-
enum class int128_opt {};
408-
enum class uint128_opt {};
407+
enum class native_int128 {}; // A fallback to reduce conditional compilation.
408+
enum class native_uint128 {};
409409
// Reduce template instantiations.
410-
inline auto map(int128_opt) -> monostate { return {}; }
411-
inline auto map(uint128_opt) -> monostate { return {}; }
410+
inline auto map(native_int128) -> monostate { return {}; }
411+
inline auto map(native_uint128) -> monostate { return {}; }
412412
#endif
413413

414414
// Casts a nonnegative integer to unsigned.
@@ -985,8 +985,8 @@ FMT_TYPE_CONSTANT(int, int_type);
985985
FMT_TYPE_CONSTANT(unsigned, uint_type);
986986
FMT_TYPE_CONSTANT(long long, long_long_type);
987987
FMT_TYPE_CONSTANT(ullong, ulong_long_type);
988-
FMT_TYPE_CONSTANT(int128_opt, int128_type);
989-
FMT_TYPE_CONSTANT(uint128_opt, uint128_type);
988+
FMT_TYPE_CONSTANT(native_int128, int128_type);
989+
FMT_TYPE_CONSTANT(native_uint128, uint128_type);
990990
FMT_TYPE_CONSTANT(bool, bool_type);
991991
FMT_TYPE_CONSTANT(Char, char_type);
992992
FMT_TYPE_CONSTANT(float, float_type);
@@ -1156,8 +1156,8 @@ template <typename Char> struct type_mapper {
11561156
static auto map(unsigned long) -> ulong_type;
11571157
static auto map(long long) -> long long;
11581158
static auto map(ullong) -> ullong;
1159-
static auto map(int128_opt) -> int128_opt;
1160-
static auto map(uint128_opt) -> uint128_opt;
1159+
static auto map(native_int128) -> native_int128;
1160+
static auto map(native_uint128) -> native_uint128;
11611161
static auto map(bool) -> bool;
11621162

11631163
template <typename T, FMT_ENABLE_IF(is_code_unit<T>::value)>
@@ -2080,8 +2080,8 @@ template <typename Context> class value {
20802080
unsigned uint_value;
20812081
long long long_long_value;
20822082
ullong ulong_long_value;
2083-
int128_opt int128_value;
2084-
uint128_opt uint128_value;
2083+
native_int128 int128_value;
2084+
native_uint128 uint128_value;
20852085
bool bool_value;
20862086
char_type char_value;
20872087
float float_value;
@@ -2105,8 +2105,8 @@ template <typename Context> class value {
21052105
: value(ulong_type(x)) {}
21062106
constexpr FMT_INLINE value(long long x FMT_BUILTIN) : long_long_value(x) {}
21072107
constexpr FMT_INLINE value(ullong x FMT_BUILTIN) : ulong_long_value(x) {}
2108-
FMT_INLINE value(int128_opt x FMT_BUILTIN) : int128_value(x) {}
2109-
FMT_INLINE value(uint128_opt x FMT_BUILTIN) : uint128_value(x) {}
2108+
FMT_INLINE value(native_int128 x FMT_BUILTIN) : int128_value(x) {}
2109+
FMT_INLINE value(native_uint128 x FMT_BUILTIN) : uint128_value(x) {}
21102110
constexpr FMT_INLINE value(bool x FMT_BUILTIN) : bool_value(x) {}
21112111

21122112
template <typename T, FMT_ENABLE_IF(is_code_unit<T>::value)>

include/fmt/format.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
#endif
4848

4949
#ifndef FMT_MODULE
50+
# include <stdint.h> // uint32_t
5051
# include <stdlib.h> // malloc, free
5152
# include <string.h> // memcpy
52-
# include <stdint.h> // uint32_t
5353

5454
# include <cmath> // std::signbit
5555
# include <cstddef> // std::byte
@@ -403,7 +403,8 @@ class uint128_fallback {
403403
}
404404
};
405405

406-
using uint128_t = conditional_t<FMT_USE_INT128, uint128_opt, uint128_fallback>;
406+
using uint128_t =
407+
conditional_t<FMT_USE_INT128, native_uint128, uint128_fallback>;
407408

408409
#ifdef UINTPTR_MAX
409410
using uintptr_t = ::uintptr_t;
@@ -420,8 +421,8 @@ template <typename T> constexpr auto num_bits() -> int {
420421
return std::numeric_limits<T>::digits;
421422
}
422423
// std::numeric_limits<T>::digits may return 0 for 128-bit ints.
423-
template <> constexpr auto num_bits<int128_opt>() -> int { return 128; }
424-
template <> constexpr auto num_bits<uint128_opt>() -> int { return 128; }
424+
template <> constexpr auto num_bits<native_int128>() -> int { return 128; }
425+
template <> constexpr auto num_bits<native_uint128>() -> int { return 128; }
425426
template <> constexpr auto num_bits<uint128_fallback>() -> int { return 128; }
426427

427428
// A heterogeneous bit_cast used for converting 96-bit long double to uint128_t
@@ -738,13 +739,13 @@ FMT_CONSTEXPR inline auto display_width_of(uint32_t cp) noexcept -> size_t {
738739
}
739740

740741
template <typename T> struct is_integral : std::is_integral<T> {};
741-
template <> struct is_integral<int128_opt> : std::true_type {};
742+
template <> struct is_integral<native_int128> : std::true_type {};
742743
template <> struct is_integral<uint128_t> : std::true_type {};
743744

744745
template <typename T>
745746
using is_signed =
746747
std::integral_constant<bool, std::numeric_limits<T>::is_signed ||
747-
std::is_same<T, int128_opt>::value>;
748+
std::is_same<T, native_int128>::value>;
748749

749750
template <typename T>
750751
using is_integer =
@@ -1125,7 +1126,7 @@ template <typename T> FMT_CONSTEXPR auto count_digits_fallback(T n) -> int {
11251126
}
11261127
}
11271128
#if FMT_USE_INT128
1128-
FMT_CONSTEXPR inline auto count_digits(uint128_opt n) -> int {
1129+
FMT_CONSTEXPR inline auto count_digits(native_uint128 n) -> int {
11291130
return count_digits_fallback(n);
11301131
}
11311132
#endif
@@ -1213,7 +1214,9 @@ FMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int {
12131214
template <typename Int> constexpr auto digits10() noexcept -> int {
12141215
return std::numeric_limits<Int>::digits10;
12151216
}
1216-
template <> constexpr auto digits10<int128_opt>() noexcept -> int { return 38; }
1217+
template <> constexpr auto digits10<native_int128>() noexcept -> int {
1218+
return 38;
1219+
}
12171220
template <> constexpr auto digits10<uint128_t>() noexcept -> int { return 38; }
12181221

12191222
template <typename Char> struct thousands_sep_result {
@@ -1471,7 +1474,7 @@ template <typename WChar, typename Buffer = memory_buffer> class to_utf8 {
14711474
// Computes 128-bit result of multiplication of two 64-bit unsigned integers.
14721475
FMT_INLINE auto umul128(uint64_t x, uint64_t y) noexcept -> uint128_fallback {
14731476
#if FMT_USE_INT128
1474-
auto p = static_cast<uint128_opt>(x) * static_cast<uint128_opt>(y);
1477+
auto p = static_cast<native_uint128>(x) * static_cast<native_uint128>(y);
14751478
return {static_cast<uint64_t>(p >> 64), static_cast<uint64_t>(p)};
14761479
#elif defined(_MSC_VER) && defined(_M_AMD64)
14771480
auto hi = uint64_t();
@@ -1514,7 +1517,7 @@ inline auto floor_log2_pow10(int e) noexcept -> int {
15141517
// Computes upper 64 bits of multiplication of two 64-bit unsigned integers.
15151518
inline auto umul128_upper64(uint64_t x, uint64_t y) noexcept -> uint64_t {
15161519
#if FMT_USE_INT128
1517-
auto p = static_cast<uint128_opt>(x) * static_cast<uint128_opt>(y);
1520+
auto p = static_cast<native_uint128>(x) * static_cast<native_uint128>(y);
15181521
return static_cast<uint64_t>(p >> 64);
15191522
#elif defined(_MSC_VER) && defined(_M_AMD64)
15201523
return __umulh(x, y);

0 commit comments

Comments
 (0)