diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake index c3f50df1dda53..3a9e1e3b1cf8b 100644 --- a/libc/cmake/modules/CheckCompilerFeatures.cmake +++ b/libc/cmake/modules/CheckCompilerFeatures.cmake @@ -55,7 +55,7 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) if(has_feature) list(APPEND AVAILABLE_COMPILER_FEATURES ${feature}) if(${feature} STREQUAL "float128") - set(LIBC_COMPILER_HAS_FLOAT128 TRUE) + set(LIBC_TYPES_HAS_FLOAT128 TRUE) elseif(${feature} STREQUAL "fixed_point") set(LIBC_COMPILER_HAS_FIXED_POINT TRUE) endif() diff --git a/libc/cmake/modules/compiler_features/check_float128.cpp b/libc/cmake/modules/compiler_features/check_float128.cpp index 20f889c14f997..64fa9f97dff3a 100644 --- a/libc/cmake/modules/compiler_features/check_float128.cpp +++ b/libc/cmake/modules/compiler_features/check_float128.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/properties/types.h" -#ifndef LIBC_COMPILER_HAS_FLOAT128 +#ifndef LIBC_TYPES_HAS_FLOAT128 #error unsupported #endif diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index a6dc74101dbcc..06832a41221dd 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -414,7 +414,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.truncl ) -if(LIBC_COMPILER_HAS_FLOAT128) +if(LIBC_TYPES_HAS_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.ceilf128 diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index fc4d8828f4c68..bf518083b51f5 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -423,7 +423,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.truncl ) -if(LIBC_COMPILER_HAS_FLOAT128) +if(LIBC_TYPES_HAS_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.ceilf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 27c9a42934c24..bc10512d942fa 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -442,7 +442,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.truncl ) -if(LIBC_COMPILER_HAS_FLOAT128) +if(LIBC_TYPES_HAS_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.ceilf128 diff --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst index c76f8874f3aef..e6fc6df5a0f6b 100644 --- a/libc/docs/dev/code_style.rst +++ b/libc/docs/dev/code_style.rst @@ -48,7 +48,7 @@ We define two kinds of macros: * ``cpu_features.h`` - Target cpu feature availability. e.g., ``LIBC_TARGET_CPU_HAS_AVX2``. * ``types.h`` - Type properties and availability. - e.g., ``LIBC_COMPILER_HAS_FLOAT128``. + e.g., ``LIBC_TYPES_HAS_FLOAT128``. * ``os.h`` - Target os properties. e.g., ``LIBC_TARGET_OS_IS_LINUX``. diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index 5b97255b89974..94ac62966f3ba 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -364,37 +364,37 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"copysign", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"copysignf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"copysignl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"copysignf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"copysignf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"ceil", RetValSpec, [ArgSpec]>, FunctionSpec<"ceilf", RetValSpec, [ArgSpec]>, FunctionSpec<"ceill", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"ceilf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"ceilf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fabs", RetValSpec, [ArgSpec], [ConstAttr]>, FunctionSpec<"fabsf", RetValSpec, [ArgSpec]>, FunctionSpec<"fabsl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"fabsf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"fabsf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fdim", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fdimf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fdiml", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fdimf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"fdimf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"floor", RetValSpec, [ArgSpec]>, FunctionSpec<"floorf", RetValSpec, [ArgSpec]>, FunctionSpec<"floorl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"floorf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"floorf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fmin", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fminf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"fminf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fmax", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaxf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaxl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmaxf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"fmaxf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fma", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, FunctionSpec<"fmaf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, @@ -406,7 +406,7 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"frexp", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"frexpf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"frexpl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"frexpf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"frexpf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"hypot", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"hypotf", RetValSpec, [ArgSpec, ArgSpec]>, @@ -414,17 +414,17 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"ilogb", RetValSpec, [ArgSpec]>, FunctionSpec<"ilogbf", RetValSpec, [ArgSpec]>, FunctionSpec<"ilogbl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"ilogbf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"ilogbf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"llogb", RetValSpec, [ArgSpec]>, FunctionSpec<"llogbf", RetValSpec, [ArgSpec]>, FunctionSpec<"llogbl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"llogbf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"llogbf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"ldexp", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"ldexpf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"ldexpl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"ldexpf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"ldexpf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"log10", RetValSpec, [ArgSpec]>, FunctionSpec<"log10f", RetValSpec, [ArgSpec]>, @@ -441,7 +441,7 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"logb", RetValSpec, [ArgSpec]>, FunctionSpec<"logbf", RetValSpec, [ArgSpec]>, FunctionSpec<"logbl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"logbf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"logbf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"modf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"modff", RetValSpec, [ArgSpec, ArgSpec]>, @@ -476,7 +476,7 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"round", RetValSpec, [ArgSpec]>, FunctionSpec<"roundf", RetValSpec, [ArgSpec]>, FunctionSpec<"roundl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"roundf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"roundf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"lround", RetValSpec, [ArgSpec]>, FunctionSpec<"lroundf", RetValSpec, [ArgSpec]>, @@ -501,12 +501,12 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"sqrt", RetValSpec, [ArgSpec]>, FunctionSpec<"sqrtf", RetValSpec, [ArgSpec]>, FunctionSpec<"sqrtl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"sqrtf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"sqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"trunc", RetValSpec, [ArgSpec]>, FunctionSpec<"truncf", RetValSpec, [ArgSpec]>, FunctionSpec<"truncl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"truncf128", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FLOAT128">, + GuardedFunctionSpec<"truncf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"nearbyint", RetValSpec, [ArgSpec]>, FunctionSpec<"nearbyintf", RetValSpec, [ArgSpec]>, diff --git a/libc/src/__support/CPP/type_traits/is_floating_point.h b/libc/src/__support/CPP/type_traits/is_floating_point.h index 7f01cc41cae8f..4c8f50f4e91f9 100644 --- a/libc/src/__support/CPP/type_traits/is_floating_point.h +++ b/libc/src/__support/CPP/type_traits/is_floating_point.h @@ -11,7 +11,7 @@ #include "src/__support/CPP/type_traits/is_same.h" #include "src/__support/CPP/type_traits/remove_cv.h" #include "src/__support/macros/attributes.h" -#include "src/__support/macros/properties/types.h" +#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 namespace LIBC_NAMESPACE::cpp { @@ -24,13 +24,13 @@ template struct is_floating_point { } public: -#if defined(LIBC_COMPILER_HAS_FLOAT128) +#if defined(LIBC_TYPES_HAS_FLOAT128) LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of(); #else LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of(); -#endif // LIBC_COMPILER_HAS_FLOAT128 +#endif // LIBC_TYPES_HAS_FLOAT128 }; template LIBC_INLINE_VAR constexpr bool is_floating_point_v = diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h index 64bf2d0ac4382..7b3882dde1b72 100644 --- a/libc/src/__support/FPUtil/FPBits.h +++ b/libc/src/__support/FPUtil/FPBits.h @@ -15,7 +15,7 @@ #include "src/__support/common.h" #include "src/__support/libc_assert.h" // LIBC_ASSERT #include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR -#include "src/__support/macros/properties/types.h" // LIBC_COMPILER_HAS_FLOAT128 +#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 #include "src/__support/math_extras.h" // mask_trailing_ones #include @@ -808,12 +808,8 @@ template LIBC_INLINE static constexpr FPType get_fp_type() { else if constexpr (cpp::is_same_v) return FPType::IEEE754_Binary16; #endif -#if defined(LIBC_COMPILER_HAS_C23_FLOAT128) - else if constexpr (cpp::is_same_v) - return FPType::IEEE754_Binary128; -#endif -#if defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION) - else if constexpr (cpp::is_same_v) +#if defined(LIBC_TYPES_HAS_FLOAT128) + else if constexpr (cpp::is_same_v) return FPType::IEEE754_Binary128; #endif else diff --git a/libc/src/__support/macros/properties/types.h b/libc/src/__support/macros/properties/types.h index f1108aef33ba6..595871e73b8fc 100644 --- a/libc/src/__support/macros/properties/types.h +++ b/libc/src/__support/macros/properties/types.h @@ -54,8 +54,7 @@ using float16 = _Float16; #if defined(LIBC_COMPILER_HAS_C23_FLOAT128) || \ defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION) || \ defined(LIBC_LONG_DOUBLE_IS_FLOAT128) -// TODO: Replace with LIBC_HAS_FLOAT128 -#define LIBC_COMPILER_HAS_FLOAT128 +#define LIBC_TYPES_HAS_FLOAT128 #endif #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H diff --git a/libc/test/src/__support/FPUtil/fpbits_test.cpp b/libc/test/src/__support/FPUtil/fpbits_test.cpp index 4f9f53afe5478..852ab6e31b65b 100644 --- a/libc/test/src/__support/FPUtil/fpbits_test.cpp +++ b/libc/test/src/__support/FPUtil/fpbits_test.cpp @@ -575,7 +575,7 @@ TEST(LlvmLibcFPBitsTest, LongDoubleType) { } #endif -#if defined(LIBC_COMPILER_HAS_FLOAT128) +#if defined(LIBC_TYPES_HAS_FLOAT128) TEST(LlvmLibcFPBitsTest, Float128Type) { using Float128Bits = FPBits; @@ -643,4 +643,4 @@ TEST(LlvmLibcFPBitsTest, Float128Type) { Float128Bits quiet_nan = Float128Bits::quiet_nan(); EXPECT_EQ(quiet_nan.is_quiet_nan(), true); } -#endif // LIBC_COMPILER_HAS_FLOAT128 +#endif // LIBC_TYPES_HAS_FLOAT128 diff --git a/libc/test/src/__support/uint_test.cpp b/libc/test/src/__support/uint_test.cpp index 1a1171b46781e..963c553b10d01 100644 --- a/libc/test/src/__support/uint_test.cpp +++ b/libc/test/src/__support/uint_test.cpp @@ -54,7 +54,7 @@ TEST(LlvmLibcUIntClassTest, BitCastToFromNativeUint128) { } #endif -#ifdef LIBC_COMPILER_HAS_FLOAT128 +#ifdef LIBC_TYPES_HAS_FLOAT128 TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat128) { static_assert(cpp::is_trivially_copyable::value); static_assert(sizeof(LL_UInt128) == sizeof(float128)); @@ -65,7 +65,7 @@ TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat128) { EXPECT_TRUE(value == forth); } } -#endif +#endif // LIBC_TYPES_HAS_FLOAT128 TEST(LlvmLibcUIntClassTest, BasicInit) { LL_UInt128 half_val(12345);