Skip to content

Commit f7d4236

Browse files
authored
[libc][NFC] Rename LIBC_LONG_DOUBLE_IS_ macros (#83399)
Umbrella bug #83182
1 parent ded5de1 commit f7d4236

File tree

14 files changed

+100
-92
lines changed

14 files changed

+100
-92
lines changed

libc/src/__support/FPUtil/ManipulationFunctions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ LIBC_INLINE T nextafter(T from, U to) {
233233
} // namespace fputil
234234
} // namespace LIBC_NAMESPACE
235235

236-
#ifdef LIBC_LONG_DOUBLE_IS_X86_FLOAT80
236+
#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
237237
#include "x86_64/NextAfterLongDouble.h"
238-
#endif // LIBC_LONG_DOUBLE_IS_X86_FLOAT80
238+
#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
239239

240240
#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_MANIPULATIONFUNCTIONS_H

libc/src/__support/FPUtil/NormalFloat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ template <typename T> struct NormalFloat {
172172
}
173173
};
174174

175-
#ifdef LIBC_LONG_DOUBLE_IS_X86_FLOAT80
175+
#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
176176
template <>
177177
LIBC_INLINE void
178178
NormalFloat<long double>::init_from_bits(FPBits<long double> bits) {
@@ -261,7 +261,7 @@ template <> LIBC_INLINE NormalFloat<long double>::operator long double() const {
261261
result.set_implicit_bit(1);
262262
return result.get_val();
263263
}
264-
#endif // LIBC_LONG_DOUBLE_IS_X86_FLOAT80
264+
#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
265265

266266
} // namespace fputil
267267
} // namespace LIBC_NAMESPACE

libc/src/__support/FPUtil/generic/sqrt.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ template <typename T> struct SpecialLongDouble {
2727
static constexpr bool VALUE = false;
2828
};
2929

30-
#if defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
30+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
3131
template <> struct SpecialLongDouble<long double> {
3232
static constexpr bool VALUE = true;
3333
};
34-
#endif // LIBC_LONG_DOUBLE_IS_X86_FLOAT80
34+
#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
3535

3636
template <typename T>
3737
LIBC_INLINE void normalize(int &exponent,
@@ -43,12 +43,12 @@ LIBC_INLINE void normalize(int &exponent,
4343
mantissa <<= shift;
4444
}
4545

46-
#ifdef LIBC_LONG_DOUBLE_IS_FLOAT64
46+
#ifdef LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64
4747
template <>
4848
LIBC_INLINE void normalize<long double>(int &exponent, uint64_t &mantissa) {
4949
normalize<double>(exponent, mantissa);
5050
}
51-
#elif !defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
51+
#elif !defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
5252
template <>
5353
LIBC_INLINE void normalize<long double>(int &exponent, UInt128 &mantissa) {
5454
const uint64_t hi_bits = static_cast<uint64_t>(mantissa >> 64);

libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LIBC_INLINE long double sqrt(long double x);
3434

3535
// Correctly rounded SQRT for all rounding modes.
3636
// Shift-and-add algorithm.
37-
#if defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
37+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
3838
LIBC_INLINE long double sqrt(long double x) {
3939
using LDBits = FPBits<long double>;
4040
using StorageType = typename LDBits::StorageType;
@@ -130,7 +130,7 @@ LIBC_INLINE long double sqrt(long double x) {
130130
return out.get_val();
131131
}
132132
}
133-
#endif // LIBC_LONG_DOUBLE_IS_X86_FLOAT80
133+
#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
134134

135135
} // namespace x86
136136
} // namespace fputil

libc/src/__support/FPUtil/x86_64/sqrt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template <> LIBC_INLINE double sqrt<double>(double x) {
3333
return result;
3434
}
3535

36-
#ifdef LIBC_LONG_DOUBLE_IS_FLOAT64
36+
#ifdef LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64
3737
template <> LIBC_INLINE long double sqrt<long double>(long double x) {
3838
long double result;
3939
__asm__ __volatile__("sqrtsd %x1, %x0" : "=x"(result) : "x"(x));

libc/src/__support/float_to_string.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ class FloatToString {
615615
}
616616
};
617617

618-
#if !defined(LIBC_LONG_DOUBLE_IS_FLOAT64) && \
618+
#if !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64) && \
619619
!defined(LIBC_COPT_FLOAT_TO_STR_NO_SPECIALIZE_LD)
620620
// --------------------------- LONG DOUBLE FUNCTIONS ---------------------------
621621

@@ -837,7 +837,7 @@ template <> class FloatToString<long double> {
837837
}
838838
};
839839

840-
#endif // !LIBC_LONG_DOUBLE_IS_FLOAT64 &&
840+
#endif // !LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64 &&
841841
// !LIBC_COPT_FLOAT_TO_STR_NO_SPECIALIZE_LD
842842

843843
} // namespace LIBC_NAMESPACE

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
// 'long double' properties.
2121
#if (LDBL_MANT_DIG == 53)
22-
#define LIBC_LONG_DOUBLE_IS_FLOAT64
22+
#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64
2323
#elif (LDBL_MANT_DIG == 64)
24-
#define LIBC_LONG_DOUBLE_IS_X86_FLOAT80
24+
#define LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
2525
#elif (LDBL_MANT_DIG == 113)
26-
#define LIBC_LONG_DOUBLE_IS_FLOAT128
26+
#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128
2727
#endif
2828

2929
// float16 support.
@@ -53,7 +53,7 @@ using float16 = _Float16;
5353
// float128 support.
5454
#if defined(LIBC_COMPILER_HAS_C23_FLOAT128) || \
5555
defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION) || \
56-
defined(LIBC_LONG_DOUBLE_IS_FLOAT128)
56+
defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
5757
#define LIBC_TYPES_HAS_FLOAT128
5858
#endif
5959

libc/src/__support/str_to_float.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ template <class T> LIBC_INLINE void set_implicit_bit(fputil::FPBits<T> &) {
5151
return;
5252
}
5353

54-
#if defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
54+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
5555
template <>
5656
LIBC_INLINE void
5757
set_implicit_bit<long double>(fputil::FPBits<long double> &result) {
5858
result.set_implicit_bit(result.get_biased_exponent() != 0);
5959
}
60-
#endif
60+
#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
6161

6262
// This Eisel-Lemire implementation is based on the algorithm described in the
6363
// paper Number Parsing at a Gigabyte per Second, Software: Practice and
@@ -176,7 +176,7 @@ eisel_lemire(ExpandedFloat<T> init_num,
176176
return output;
177177
}
178178

179-
#if !defined(LIBC_LONG_DOUBLE_IS_FLOAT64)
179+
#if !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
180180
template <>
181181
LIBC_INLINE cpp::optional<ExpandedFloat<long double>>
182182
eisel_lemire<long double>(ExpandedFloat<long double> init_num,
@@ -297,7 +297,7 @@ eisel_lemire<long double>(ExpandedFloat<long double> init_num,
297297
output.exponent = exp2;
298298
return output;
299299
}
300-
#endif
300+
#endif // !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
301301

302302
// The nth item in POWERS_OF_TWO represents the greatest power of two less than
303303
// 10^n. This tells us how much we can safely shift without overshooting.
@@ -460,7 +460,7 @@ template <> class ClingerConsts<double> {
460460
static constexpr double MAX_EXACT_INT = 9007199254740991.0;
461461
};
462462

463-
#if defined(LIBC_LONG_DOUBLE_IS_FLOAT64)
463+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
464464
template <> class ClingerConsts<long double> {
465465
public:
466466
static constexpr long double POWERS_OF_TEN_ARRAY[] = {
@@ -473,7 +473,7 @@ template <> class ClingerConsts<long double> {
473473
static constexpr long double MAX_EXACT_INT =
474474
ClingerConsts<double>::MAX_EXACT_INT;
475475
};
476-
#elif defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
476+
#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
477477
template <> class ClingerConsts<long double> {
478478
public:
479479
static constexpr long double POWERS_OF_TEN_ARRAY[] = {
@@ -484,7 +484,7 @@ template <> class ClingerConsts<long double> {
484484
static constexpr int32_t DIGITS_IN_MANTISSA = 21;
485485
static constexpr long double MAX_EXACT_INT = 18446744073709551615.0L;
486486
};
487-
#else
487+
#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
488488
template <> class ClingerConsts<long double> {
489489
public:
490490
static constexpr long double POWERS_OF_TEN_ARRAY[] = {
@@ -498,6 +498,8 @@ template <> class ClingerConsts<long double> {
498498
static constexpr long double MAX_EXACT_INT =
499499
10384593717069655257060992658440191.0L;
500500
};
501+
#else
502+
#error "Unknown long double type"
501503
#endif
502504

503505
// Take an exact mantissa and exponent and attempt to convert it using only

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ TEST(LlvmLibcFPBitsTest, X86LongDoubleType) {
503503
}
504504
#else
505505
TEST(LlvmLibcFPBitsTest, LongDoubleType) {
506-
#if defined(LIBC_LONG_DOUBLE_IS_FLOAT64)
506+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
507507
return; // The tests for the "double" type cover for this case.
508508
#else
509509
using LongDoubleBits = FPBits<long double>;

libc/test/src/__support/str_to_long_double_test.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace LIBC_NAMESPACE {
77
using LlvmLibcStrToLongDblTest = LlvmLibcStrToFloatTest<long double>;
88
using LIBC_NAMESPACE::operator""_u128;
99

10-
#if defined(LIBC_LONG_DOUBLE_IS_FLOAT64)
10+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
1111

1212
TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat64AsLongDouble) {
1313
eisel_lemire_test(123, 0, 0x1EC00000000000, 1029);
1414
}
1515

16-
#elif defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
16+
#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
1717

1818
TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat80Simple) {
1919
eisel_lemire_test(123, 0, 0xf600000000000000, 16389);
@@ -54,7 +54,7 @@ TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat80Fallback) {
5454
ASSERT_FALSE(internal::eisel_lemire<long double>({1, -1000}).has_value());
5555
}
5656

57-
#else // Quad precision long double
57+
#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
5858

5959
TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat128Simple) {
6060
eisel_lemire_test(123, 0, 0x1ec00'00000000'00000000'00000000_u128, 16389);
@@ -77,6 +77,8 @@ TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat128Fallback) {
7777
.has_value());
7878
}
7979

80+
#else
81+
#error "Unknown long double type"
8082
#endif
8183

8284
} // namespace LIBC_NAMESPACE

libc/test/src/math/smoke/nanl_test.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
#include "test/UnitTest/Test.h"
1313
#include <signal.h>
1414

15-
#if defined(LIBC_LONG_DOUBLE_IS_FLOAT64)
15+
#if defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
1616
#define SELECT_LONG_DOUBLE(val, _, __) val
17-
#elif defined(LIBC_LONG_DOUBLE_IS_X86_FLOAT80)
17+
#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
1818
#define SELECT_LONG_DOUBLE(_, val, __) val
19-
#else
19+
#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
2020
#define SELECT_LONG_DOUBLE(_, __, val) val
21+
#else
22+
#error "Unknown long double type"
2123
#endif
2224

2325
class LlvmLibcNanlTest : public LIBC_NAMESPACE::testing::Test {

0 commit comments

Comments
 (0)