From bfa440bbf82de6b03faf6779c275ef98c04dd7b2 Mon Sep 17 00:00:00 2001 From: Lucas Chollet Date: Tue, 6 Oct 2026 08:55:38 +0200 Subject: [PATCH] AK: Define FloatExtractor for long double when it's an alias of double On some platforms, like macOS on ARM, long double is a different type but has the exact same characteristics as a normal double. When it is the case, define FloatExtractor as an alias to FloatExtractor. --- AK/FloatingPoint.h | 7 +++++++ AK/Types.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/AK/FloatingPoint.h b/AK/FloatingPoint.h index f70149984bd..7dd5f2e0f21 100644 --- a/AK/FloatingPoint.h +++ b/AK/FloatingPoint.h @@ -87,6 +87,13 @@ struct FloatExtractor { }; static_assert(AssertSize, sizeof(f64)>()); +#ifdef AK_LONG_DOUBLE_IS_DOUBLE +template<> +struct FloatExtractor : FloatExtractor { +}; +static_assert(AssertSize, sizeof(FloatExtractor)>()); +#endif + template<> struct FloatExtractor { static constexpr FloatExtractor from_float(f32 f) { return bit_cast>(f); } diff --git a/AK/Types.h b/AK/Types.h index 407325aee4e..79f8a0126eb 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -30,6 +30,8 @@ using f80 = long double; # elif __LDBL_MANT_DIG__ == 113 && __LDBL_MAX_EXP__ == 16384 # define AK_HAS_FLOAT_128 1 using f128 = long double; +# elif __LDBL_MANT_DIG__ == __DBL_MANT_DIG__ && __LDBL_MAX_EXP__ == __DBL_MAX_EXP__ +# define AK_LONG_DOUBLE_IS_DOUBLE # endif #endif