[llvm-branch-commits] [libc] [llvm] [libc] Make next-type functions use the emulated float128 type (PR #217575)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 20 03:27:43 PDT 2026
https://github.com/Sukumarsawant created https://github.com/llvm/llvm-project/pull/217575
None
>From a1d1300d96df79fa17781d9fd8992c2c42fe1f4f Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 20 Aug 2026 15:35:12 +0530
Subject: [PATCH 1/3] nextafterf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/entrypoints.txt | 2 +-
libc/config/baremetal/riscv/entrypoints.txt | 2 +-
libc/config/darwin/aarch64/entrypoints.txt | 2 +-
libc/config/darwin/x86_64/entrypoints.txt | 1 +
libc/config/freebsd/x86_64/entrypoints.txt | 2 +-
libc/config/gpu/amdgpu/entrypoints.txt | 1 +
libc/config/gpu/nvptx/entrypoints.txt | 1 +
libc/config/linux/aarch64/entrypoints.txt | 2 +-
libc/config/linux/arm/entrypoints.txt | 1 +
libc/config/linux/riscv/entrypoints.txt | 2 +-
libc/config/linux/x86_64/entrypoints.txt | 2 +-
libc/config/windows/entrypoints.txt | 1 +
libc/shared/math/nextafterf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/nextafterf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/nextafterf128.cpp | 5 ++++-
libc/src/math/nextafterf128.h | 5 +++++
libc/test/shared/shared_math_constexpr_test.cpp | 4 +---
libc/test/shared/shared_math_test.cpp | 3 +--
libc/test/src/math/CMakeLists.txt | 1 +
libc/test/src/math/nextafterf128_test.cpp | 5 +++++
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/nextafterf128_test.cpp | 5 +++++
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 +++-
.../libc/test/src/math/smoke/BUILD.bazel | 3 +++
27 files changed, 48 insertions(+), 29 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index c4dd3dcac1eec..c4388440cc91f 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -539,6 +539,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -780,7 +781,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 283ffbbb330ff..ad6313b62419d 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -551,6 +551,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -791,7 +792,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 4fc769a9c40d5..5ea9c1436a851 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -547,6 +547,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -788,7 +789,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 96efac733c1bb..a04bf5cec57b4 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -358,6 +358,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -600,7 +601,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index ff29edf14c74b..888d1c36f19a8 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -220,6 +220,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.nearbyintl
#libc.src.math.nextafter
#libc.src.math.nextafterf
+ #libc.src.math.nextafterf128
#libc.src.math.nextafterl
#libc.src.math.nexttoward
#libc.src.math.nexttowardf
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 799af1ccb4f0b..d1fff8b7366db 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -268,6 +268,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -538,7 +539,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index a727eaa4b6b89..4a2ac95764366 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -482,6 +482,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 952e6e961839c..7d1eaaee32e64 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -479,6 +479,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index e274e87036078..1434a7c3d3df6 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -698,6 +698,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -933,7 +934,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index c3306022a3c67..2993eeb69cd02 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -513,6 +513,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index feeecd3311e61..48306edc6a293 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -766,6 +766,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -1018,7 +1019,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 5658e67002907..860664dfc6a8a 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -776,6 +776,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
@@ -1028,7 +1029,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 56399adecc082..d9416a5d73ff4 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -301,6 +301,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nearbyintl
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.nextafterf128
libc.src.math.nextafterl
libc.src.math.nexttoward
libc.src.math.nexttowardf
diff --git a/libc/shared/math/nextafterf128.h b/libc/shared/math/nextafterf128.h
index 95bece2ba874a..6ff2087983a9f 100644
--- a/libc/shared/math/nextafterf128.h
+++ b/libc/shared/math/nextafterf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_NEXTAFTERF128_H
#define LLVM_LIBC_SHARED_MATH_NEXTAFTERF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/nextafterf128.h"
@@ -24,6 +20,4 @@ using math::nextafterf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_NEXTAFTERF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 415a75c1ace22..68d68807fad8d 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4433,7 +4433,7 @@ add_header_library(
HDRS
nextafterf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/nextafterf128.h b/libc/src/__support/math/nextafterf128.h
index d9c07b4d6b68f..ac4f6d0325e49 100644
--- a/libc/src/__support/math/nextafterf128.h
+++ b/libc/src/__support/math/nextafterf128.h
@@ -9,24 +9,21 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_NEXTAFTERF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTAFTERF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 nextafterf128(float128 x, float128 y) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 nextafterf128(Float128 x, Float128 y) {
return fputil::nextafter(x, y);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTAFTERF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index e63aac676e95d..e4627c76af96f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3221,6 +3221,7 @@ add_entrypoint_object(
HDRS
../nextafterf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.nextafterf128
)
diff --git a/libc/src/math/generic/nextafterf128.cpp b/libc/src/math/generic/nextafterf128.cpp
index 3363db898fe0b..cdaf8a43e2c0f 100644
--- a/libc/src/math/generic/nextafterf128.cpp
+++ b/libc/src/math/generic/nextafterf128.cpp
@@ -7,12 +7,15 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextafterf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/nextafterf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, nextafterf128, (float128 x, float128 y)) {
- return math::nextafterf128(x, y);
+ return cpp::bit_cast<float128>(math::nextafterf128(cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y)));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/nextafterf128.h b/libc/src/math/nextafterf128.h
index 99b15d6cf43b9..679ea23225faa 100644
--- a/libc/src/math/nextafterf128.h
+++ b/libc/src/math/nextafterf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H
#define LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
float128 nextafterf128(float128 x, float128 y);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index bc3b719561e4e..1065286d6e754 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -381,6 +381,7 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
//===----------------------------------------------------------------------===//
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+static_assert(float128(0.0) == LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::copysignf128(Float128(0.0),
Float128(0.0)));
@@ -495,9 +496,6 @@ static_assert(0.0f ==
static_assert(0LL == LIBC_NAMESPACE::shared::llrintf128(float128(0.0)));
static_assert(0L == LIBC_NAMESPACE::shared::lrintf128(float128(0.0)));
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::nextafterf128(float128(0.0),
- float128(0.0)));
static_assert(float128(0.0) == LIBC_NAMESPACE::shared::rintf128(float128(0.0)));
static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf128(float128(0.0)));
static_assert(0 == LIBC_NAMESPACE::shared::isnanf128(float128(0.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 62297bf1cfec4..1162b3e88d48d 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -584,6 +584,7 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+ EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128(
Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0)));
@@ -691,8 +692,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)));
float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val();
EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(float128(0.0)));
- EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128(
- float128(0.0), float128(0.0)));
#ifdef LIBC_TYPES_HAS_FLOAT16
EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128(
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 7d20cedc0f7bf..fb25023ff0e34 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2030,6 +2030,7 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.nextafterf128
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
diff --git a/libc/test/src/math/nextafterf128_test.cpp b/libc/test/src/math/nextafterf128_test.cpp
index a8d000ff4de38..9ee60ef21cffe 100644
--- a/libc/test/src/math/nextafterf128_test.cpp
+++ b/libc/test/src/math/nextafterf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "NextAfterTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/nextafterf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_NEXTAFTER_TESTS(float128, LIBC_NAMESPACE::nextafterf128)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 6839727c42270..ce2c2e4684c3d 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4077,6 +4077,7 @@ add_fp_unittest(
NextAfterTest.h
DEPENDS
libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.float128
libc.src.math.nextafterf128
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
diff --git a/libc/test/src/math/smoke/nextafterf128_test.cpp b/libc/test/src/math/smoke/nextafterf128_test.cpp
index a8d000ff4de38..9ee60ef21cffe 100644
--- a/libc/test/src/math/smoke/nextafterf128_test.cpp
+++ b/libc/test/src/math/smoke/nextafterf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "NextAfterTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/nextafterf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_NEXTAFTER_TESTS(float128, LIBC_NAMESPACE::nextafterf128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 35d7bf94bb028..5432982f559de 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -8413,9 +8413,9 @@ libc_support_library(
name = "__support_math_nextafterf128",
hdrs = ["src/__support/math/nextafterf128.h"],
deps = [
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -12990,6 +12990,8 @@ libc_math_function(
libc_math_function(
name = "nextafterf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_nextafterf128",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index 02efcaeac23c1..35007df494e35 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -1287,6 +1287,9 @@ math_test(
name = "nextafterf128",
hdrs = ["NextAfterTest.h"],
deps = ["//libc:__support_sign"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
>From bba29da2fd520a9a63e36d16c630420efd81b9fe Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 20 Aug 2026 15:36:00 +0530
Subject: [PATCH 2/3] nextupf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/entrypoints.txt | 2 +-
libc/config/baremetal/riscv/entrypoints.txt | 2 +-
libc/config/darwin/aarch64/entrypoints.txt | 2 +-
libc/config/darwin/x86_64/entrypoints.txt | 1 +
libc/config/freebsd/x86_64/entrypoints.txt | 2 +-
libc/config/gpu/amdgpu/entrypoints.txt | 1 +
libc/config/gpu/nvptx/entrypoints.txt | 1 +
libc/config/linux/aarch64/entrypoints.txt | 2 +-
libc/config/linux/arm/entrypoints.txt | 1 +
libc/config/linux/riscv/entrypoints.txt | 2 +-
libc/config/linux/x86_64/entrypoints.txt | 2 +-
libc/config/windows/entrypoints.txt | 1 +
libc/shared/math/nextupf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/nextupf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/nextafterf128.cpp | 3 ++-
libc/src/math/generic/nextupf128.cpp | 5 ++++-
libc/src/math/nextupf128.h | 5 +++++
libc/test/shared/shared_math_constexpr_test.cpp | 4 +++-
libc/test/shared/shared_math_test.cpp | 5 +++--
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/nextupf128_test.cpp | 5 +++++
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 +++-
.../libc/test/src/math/smoke/BUILD.bazel | 3 +++
26 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index c4388440cc91f..451088d46f8d7 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -549,6 +549,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -782,7 +783,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index ad6313b62419d..7f314b0365f26 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -561,6 +561,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -793,7 +794,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 5ea9c1436a851..51e14eafc2683 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -557,6 +557,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -790,7 +791,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index a04bf5cec57b4..4303ec1999a51 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -368,6 +368,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -602,7 +603,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 888d1c36f19a8..91e1aa9f58c80 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -225,6 +225,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.nexttoward
#libc.src.math.nexttowardf
#libc.src.math.nexttowardl
+ #libc.src.math.nextupf128
#libc.src.math.remainderf
#libc.src.math.remainder
#libc.src.math.remainderl
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index d1fff8b7366db..ad888e492bce8 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -273,6 +273,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttoward
libc.src.math.nexttowardf
libc.src.math.nexttowardl
+ libc.src.math.nextupf128
libc.src.math.pow
libc.src.math.powf
libc.src.math.remainderf
@@ -540,7 +541,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 4a2ac95764366..8eed91b308c0a 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -492,6 +492,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 7d1eaaee32e64..0f67ee2d31235 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -489,6 +489,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 1434a7c3d3df6..e05903bfc297e 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -708,6 +708,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -935,7 +936,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 2993eeb69cd02..3459448897c27 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -523,6 +523,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 48306edc6a293..4cc5775716711 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -776,6 +776,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -1020,7 +1021,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 860664dfc6a8a..7cce5bc0f6b8f 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -786,6 +786,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttowardl
libc.src.math.nextup
libc.src.math.nextupf
+ libc.src.math.nextupf128
libc.src.math.nextupl
libc.src.math.pow
libc.src.math.powf
@@ -1030,7 +1031,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.modff128
libc.src.math.nanf128
libc.src.math.nextdownf128
- libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index d9416a5d73ff4..c1c621ad04b94 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -306,6 +306,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nexttoward
libc.src.math.nexttowardf
libc.src.math.nexttowardl
+ libc.src.math.nextupf128
libc.src.math.pow
libc.src.math.powf
libc.src.math.remainderf
diff --git a/libc/shared/math/nextupf128.h b/libc/shared/math/nextupf128.h
index 4d8312efa9311..6da0606a3cbe6 100644
--- a/libc/shared/math/nextupf128.h
+++ b/libc/shared/math/nextupf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_NEXTUPF128_H
#define LLVM_LIBC_SHARED_MATH_NEXTUPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/nextupf128.h"
@@ -24,6 +20,4 @@ using math::nextupf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_NEXTUPF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 68d68807fad8d..f170c875a1e5f 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4537,7 +4537,7 @@ add_header_library(
HDRS
nextupf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/nextupf128.h b/libc/src/__support/math/nextupf128.h
index 2b618e4095968..42f0d6444a2c5 100644
--- a/libc/src/__support/math/nextupf128.h
+++ b/libc/src/__support/math/nextupf128.h
@@ -9,24 +9,21 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_NEXTUPF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTUPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 nextupf128(float128 x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 nextupf128(Float128 x) {
return fputil::nextupdown</*IsDown=*/false>(x);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTUPF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index e4627c76af96f..5ddbac3500457 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3392,6 +3392,7 @@ add_entrypoint_object(
HDRS
../nextupf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.nextupf128
)
diff --git a/libc/src/math/generic/nextafterf128.cpp b/libc/src/math/generic/nextafterf128.cpp
index cdaf8a43e2c0f..5e0f862fb5c4d 100644
--- a/libc/src/math/generic/nextafterf128.cpp
+++ b/libc/src/math/generic/nextafterf128.cpp
@@ -15,7 +15,8 @@ namespace LIBC_NAMESPACE_DECL {
using LIBC_NAMESPACE::fputil::Float128;
LLVM_LIBC_FUNCTION(float128, nextafterf128, (float128 x, float128 y)) {
- return cpp::bit_cast<float128>(math::nextafterf128(cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y)));
+ return cpp::bit_cast<float128>(math::nextafterf128(
+ cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y)));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/nextupf128.cpp b/libc/src/math/generic/nextupf128.cpp
index 71a7b20b86741..f5e8e98870a65 100644
--- a/libc/src/math/generic/nextupf128.cpp
+++ b/libc/src/math/generic/nextupf128.cpp
@@ -7,12 +7,15 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextupf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/nextupf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, nextupf128, (float128 x)) {
- return math::nextupf128(x);
+ return cpp::bit_cast<float128>(math::nextupf128(cpp::bit_cast<Float128>(x)));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/nextupf128.h b/libc/src/math/nextupf128.h
index 755c08d891d64..8e911b5aa6fad 100644
--- a/libc/src/math/nextupf128.h
+++ b/libc/src/math/nextupf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_NEXTUPF128_H
#define LLVM_LIBC_SRC_MATH_NEXTUPF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
float128 nextupf128(float128 x);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 1065286d6e754..30e8261104a42 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -381,7 +381,9 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
//===----------------------------------------------------------------------===//
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
-static_assert(float128(0.0) == LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), Float128(0.0)));
+static_assert(float128(0.0) ==
+ LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0),
+ Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::copysignf128(Float128(0.0),
Float128(0.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 1162b3e88d48d..6f846c1c70d85 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -584,7 +584,9 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
- EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( Float128(0.0), Float128(0.0)));
+ EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(Float128(0.0)));
+ EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128(
+ Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128(
Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0)));
@@ -691,7 +693,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_FP_EQ(neg_min_denormal,
LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)));
float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val();
- EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(float128(0.0)));
#ifdef LIBC_TYPES_HAS_FLOAT16
EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128(
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index ce2c2e4684c3d..7643264cb6dfc 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4315,6 +4315,7 @@ add_fp_unittest(
HDRS
NextUpTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.nextupf128
)
diff --git a/libc/test/src/math/smoke/nextupf128_test.cpp b/libc/test/src/math/smoke/nextupf128_test.cpp
index ddd385a7b159b..96cc6932ccea8 100644
--- a/libc/test/src/math/smoke/nextupf128_test.cpp
+++ b/libc/test/src/math/smoke/nextupf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "NextUpTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/nextupf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_NEXTUP_TESTS(float128, LIBC_NAMESPACE::nextupf128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 5432982f559de..2587c7203222b 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -8575,9 +8575,9 @@ libc_support_library(
name = "__support_math_nextupf128",
hdrs = ["src/__support/math/nextupf128.h"],
deps = [
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -13104,6 +13104,8 @@ libc_math_function(
libc_math_function(
name = "nextupf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_nextupf128",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index 35007df494e35..e6c00e989421b 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -1361,6 +1361,9 @@ math_test(
math_test(
name = "nextupf128",
hdrs = ["NextUpTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
>From ef99b5d2c931b8dbd5ea09c67fce7eff82a63dc6 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 20 Aug 2026 15:40:46 +0530
Subject: [PATCH 3/3] nextdownf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/entrypoints.txt | 2 +-
libc/config/baremetal/riscv/entrypoints.txt | 2 +-
libc/config/darwin/aarch64/entrypoints.txt | 2 +-
libc/config/darwin/x86_64/entrypoints.txt | 1 +
libc/config/freebsd/x86_64/entrypoints.txt | 2 +-
libc/config/gpu/amdgpu/entrypoints.txt | 1 +
libc/config/gpu/nvptx/entrypoints.txt | 1 +
libc/config/linux/aarch64/entrypoints.txt | 2 +-
libc/config/linux/arm/entrypoints.txt | 1 +
libc/config/linux/riscv/entrypoints.txt | 2 +-
libc/config/linux/x86_64/entrypoints.txt | 2 +-
libc/config/windows/entrypoints.txt | 1 +
libc/shared/math/nextdownf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/nextdownf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/nextdownf128.cpp | 6 +++++-
libc/src/math/nextdownf128.h | 5 +++++
libc/test/shared/shared_math_constexpr_test.cpp | 6 +++---
libc/test/shared/shared_math_test.cpp | 13 ++++++++-----
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/nextdownf128_test.cpp | 5 +++++
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 +++-
.../libc/test/src/math/smoke/BUILD.bazel | 3 +++
25 files changed, 52 insertions(+), 32 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 451088d46f8d7..f944fd507e711 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -543,6 +543,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -782,7 +783,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 7f314b0365f26..2d7f3b456d1a0 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -555,6 +555,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -793,7 +794,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 51e14eafc2683..548ea52e96eaf 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -551,6 +551,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -790,7 +791,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 4303ec1999a51..492be8088f66f 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -362,6 +362,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -602,7 +603,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 91e1aa9f58c80..feeb568133521 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -222,6 +222,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.nextafterf
#libc.src.math.nextafterf128
#libc.src.math.nextafterl
+ #libc.src.math.nextdownf128
#libc.src.math.nexttoward
#libc.src.math.nexttowardf
#libc.src.math.nexttowardl
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index ad888e492bce8..8e71db9b4996d 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -270,6 +270,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterf
libc.src.math.nextafterf128
libc.src.math.nextafterl
+ libc.src.math.nextdownf128
libc.src.math.nexttoward
libc.src.math.nexttowardf
libc.src.math.nexttowardl
@@ -540,7 +541,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 8eed91b308c0a..9b9fb891f9b2b 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -486,6 +486,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 0f67ee2d31235..8b861abc30550 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -483,6 +483,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index e05903bfc297e..86c992aea86da 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -702,6 +702,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -935,7 +936,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 3459448897c27..18e557fd7eefe 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -517,6 +517,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 4cc5775716711..cd8afd64aee77 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -770,6 +770,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -1020,7 +1021,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 7cce5bc0f6b8f..d4b12dc3443af 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -780,6 +780,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterl
libc.src.math.nextdown
libc.src.math.nextdownf
+ libc.src.math.nextdownf128
libc.src.math.nextdownl
libc.src.math.nexttoward
libc.src.math.nexttowardf
@@ -1030,7 +1031,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.lrintf128
libc.src.math.modff128
libc.src.math.nanf128
- libc.src.math.nextdownf128
libc.src.math.remainderf128
libc.src.math.remquof128
libc.src.math.rintf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index c1c621ad04b94..c83486ff1eb17 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -303,6 +303,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.nextafterf
libc.src.math.nextafterf128
libc.src.math.nextafterl
+ libc.src.math.nextdownf128
libc.src.math.nexttoward
libc.src.math.nexttowardf
libc.src.math.nexttowardl
diff --git a/libc/shared/math/nextdownf128.h b/libc/shared/math/nextdownf128.h
index 958d1f2cc5297..902a101dfb19d 100644
--- a/libc/shared/math/nextdownf128.h
+++ b/libc/shared/math/nextdownf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H
#define LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/nextdownf128.h"
@@ -24,6 +20,4 @@ using math::nextdownf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index f170c875a1e5f..8b1e34eea2522 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4595,7 +4595,7 @@ add_header_library(
HDRS
nextdownf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/nextdownf128.h b/libc/src/__support/math/nextdownf128.h
index b3a93c3909058..13fb2421935f4 100644
--- a/libc/src/__support/math/nextdownf128.h
+++ b/libc/src/__support/math/nextdownf128.h
@@ -9,24 +9,21 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 nextdownf128(float128 x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 nextdownf128(Float128 x) {
return fputil::nextupdown</*IsDown=*/true>(x);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 5ddbac3500457..3925affb9cf72 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3332,6 +3332,7 @@ add_entrypoint_object(
HDRS
../nextdownf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.nextdownf128
)
diff --git a/libc/src/math/generic/nextdownf128.cpp b/libc/src/math/generic/nextdownf128.cpp
index 3a9a60fe7130a..087bdb984677e 100644
--- a/libc/src/math/generic/nextdownf128.cpp
+++ b/libc/src/math/generic/nextdownf128.cpp
@@ -7,12 +7,16 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdownf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/nextdownf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, nextdownf128, (float128 x)) {
- return math::nextdownf128(x);
+ return cpp::bit_cast<float128>(
+ math::nextdownf128(cpp::bit_cast<Float128>(x)));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/nextdownf128.h b/libc/src/math/nextdownf128.h
index 60ba251f67d55..3f9099f084e34 100644
--- a/libc/src/math/nextdownf128.h
+++ b/libc/src/math/nextdownf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_NEXTDOWNF128_H
#define LLVM_LIBC_SRC_MATH_NEXTDOWNF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
float128 nextdownf128(float128 x);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 30e8261104a42..db8a949b76c73 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -381,9 +381,6 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
//===----------------------------------------------------------------------===//
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0),
- Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::copysignf128(Float128(0.0),
Float128(0.0)));
@@ -425,6 +422,9 @@ static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
static_assert(0L == LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0)));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0),
+ Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::roundf128(Float128(0.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 6f846c1c70d85..5e69673154ea6 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -581,12 +581,12 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
// Emulated float128 tests
TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<Float128>;
+ Float128 neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val();
+ Float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val();
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
- EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(Float128(0.0)));
- EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128(
- Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128(
Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0)));
@@ -617,6 +617,11 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0)));
+ EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::nextafterf128(
+ Float128(0.0), Float128(0.0)));
+ EXPECT_FP_EQ(neg_min_denormal,
+ LIBC_NAMESPACE::shared::nextdownf128(Float128(0.0)));
+ EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::roundf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(1.0), LIBC_NAMESPACE::shared::sqrtf128(Float128(1.0)));
}
@@ -690,8 +695,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_FP_EQ(float128(0.0), setpayloadsigf128_res);
float128 neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val();
- EXPECT_FP_EQ(neg_min_denormal,
- LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)));
float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val();
#ifdef LIBC_TYPES_HAS_FLOAT16
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 7643264cb6dfc..b0cb51db79482 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4242,6 +4242,7 @@ add_fp_unittest(
HDRS
NextDownTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.nextdownf128
)
diff --git a/libc/test/src/math/smoke/nextdownf128_test.cpp b/libc/test/src/math/smoke/nextdownf128_test.cpp
index 932a8b36a59e4..603b31a9f05cc 100644
--- a/libc/test/src/math/smoke/nextdownf128_test.cpp
+++ b/libc/test/src/math/smoke/nextdownf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "NextDownTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/nextdownf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_NEXTDOWN_TESTS(float128, LIBC_NAMESPACE::nextdownf128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 2587c7203222b..2f2c5655bf21c 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -8470,10 +8470,10 @@ libc_support_library(
name = "__support_math_nextdownf128",
hdrs = ["src/__support/math/nextdownf128.h"],
deps = [
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
":__support_macros_properties_types",
- ":llvm_libc_types_float128",
],
)
@@ -13034,6 +13034,8 @@ libc_math_function(
libc_math_function(
name = "nextdownf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_nextdownf128",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index e6c00e989421b..e82f9730fd6b4 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -1316,6 +1316,9 @@ math_test(
math_test(
name = "nextdownf128",
hdrs = ["NextDownTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
More information about the llvm-branch-commits
mailing list