[libc-commits] [libc] [llvm] [libc] Make next-type functions use the emulated float128 type (PR #217575)

via libc-commits libc-commits at lists.llvm.org
Fri Sep 4 05:58:37 PDT 2026


https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/217575

>From ca09f8970051ee718f67c9fac1586358b8013ddb Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Fri, 4 Sep 2026 18:07:33 +0530
Subject: [PATCH 1/3] next functions

---
 libc/config/baremetal/aarch64/entrypoints.txt       |  6 +++---
 libc/config/baremetal/arm/entrypoints.txt           |  6 +++---
 libc/config/baremetal/riscv/entrypoints.txt         |  6 +++---
 libc/config/darwin/aarch64/entrypoints.txt          |  6 +++---
 libc/config/darwin/x86_64/entrypoints.txt           |  3 +++
 libc/config/freebsd/x86_64/entrypoints.txt          |  6 +++---
 libc/config/gpu/amdgpu/entrypoints.txt              |  3 +++
 libc/config/gpu/nvptx/entrypoints.txt               |  3 +++
 libc/config/linux/aarch64/entrypoints.txt           |  6 +++---
 libc/config/linux/arm/entrypoints.txt               |  3 +++
 libc/config/linux/riscv/entrypoints.txt             |  6 +++---
 libc/config/linux/x86_64/entrypoints.txt            |  6 +++---
 libc/config/windows/entrypoints.txt                 |  3 +++
 libc/shared/math/nextafterf128.h                    |  6 ------
 libc/shared/math/nextdownf128.h                     |  6 ------
 libc/shared/math/nextupf128.h                       |  6 ------
 libc/src/__support/math/CMakeLists.txt              |  6 +++---
 libc/src/__support/math/nextafterf128.h             | 11 ++++-------
 libc/src/__support/math/nextdownf128.h              | 11 ++++-------
 libc/src/__support/math/nextupf128.h                | 11 ++++-------
 libc/src/math/generic/CMakeLists.txt                |  3 +++
 libc/src/math/generic/nextafterf128.cpp             |  6 +++++-
 libc/src/math/generic/nextdownf128.cpp              |  6 +++++-
 libc/src/math/generic/nextupf128.cpp                |  5 ++++-
 libc/src/math/nextafterf128.h                       |  5 +++++
 libc/src/math/nextdownf128.h                        |  5 +++++
 libc/src/math/nextupf128.h                          |  5 +++++
 libc/test/shared/shared_math_constexpr_test.cpp     | 13 ++++++++++---
 libc/test/shared/shared_math_test.cpp               | 13 ++++++++-----
 libc/test/src/math/CMakeLists.txt                   |  1 +
 libc/test/src/math/nextafterf128_test.cpp           |  5 +++++
 libc/test/src/math/smoke/CMakeLists.txt             |  3 +++
 libc/test/src/math/smoke/nextafterf128_test.cpp     |  5 +++++
 libc/test/src/math/smoke/nextdownf128_test.cpp      |  5 +++++
 libc/test/src/math/smoke/nextupf128_test.cpp        |  5 +++++
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel   | 12 +++++++++---
 .../libc/test/src/math/smoke/BUILD.bazel            |  9 +++++++++
 37 files changed, 146 insertions(+), 80 deletions(-)

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 757e4729699d1..66911050bbf4a 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -545,15 +545,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -784,9 +787,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 13d4f777650f7..ef01c5a9e07fb 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -557,15 +557,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -795,9 +798,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 88613b39086a5..3313ac9b6be4c 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -553,15 +553,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -792,9 +795,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index c6c8357207959..a7b95b744e960 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -364,15 +364,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -604,9 +607,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 716ab572f8d3c..3e38ac38b3791 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -225,10 +225,13 @@ 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.nextdownf128
     #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 8f6c178301c2f..f242f02e63125 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -274,10 +274,13 @@ 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.nextdownf128
     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
@@ -544,9 +547,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5c5e5891da822..c28eab98db184 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -488,15 +488,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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 afae725484a89..3dd0cebb4aaa7 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -485,15 +485,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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 554513e686eab..54825e1d2428d 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -725,15 +725,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -958,9 +961,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 79b674fd99e9f..5a91d1569a2d8 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -537,15 +537,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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 9272a670d35d6..590f64bae3aa3 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -794,15 +794,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -1044,9 +1047,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 43c04275ef8e4..6cb5144f95fbb 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -803,15 +803,18 @@ 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
+    libc.src.math.nextdownf128
     libc.src.math.nextdownl
     libc.src.math.nexttoward
     libc.src.math.nexttowardf
     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
@@ -1053,9 +1056,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
-    libc.src.math.nextafterf128
-    libc.src.math.nextdownf128
-    libc.src.math.nextupf128
     libc.src.math.remainderf128
     libc.src.math.remquof128
     libc.src.math.scalblnf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a48b49e169b3..9549c1485c831 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -307,10 +307,13 @@ 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.nextdownf128
     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/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/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/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 cf9bc11fce824..b80c67cb0848d 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4488,7 +4488,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
 )
@@ -4592,7 +4592,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
 )
@@ -4650,7 +4650,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/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/__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/__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 28b8e954530dd..74f1c859d096b 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3242,6 +3242,7 @@ add_entrypoint_object(
   HDRS
     ../nextafterf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.nextafterf128
 )
 
@@ -3352,6 +3353,7 @@ add_entrypoint_object(
   HDRS
     ../nextdownf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.nextdownf128
 )
 
@@ -3412,6 +3414,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 3363db898fe0b..5e0f862fb5c4d 100644
--- a/libc/src/math/generic/nextafterf128.cpp
+++ b/libc/src/math/generic/nextafterf128.cpp
@@ -7,12 +7,16 @@
 //===----------------------------------------------------------------------===//
 
 #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/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/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/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/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/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 862c056411f5c..775a7fd001f0f 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -428,6 +428,16 @@ static_assert(0L == LIBC_NAMESPACE::shared::lrintf128(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(LIBC_NAMESPACE::fputil::FPBits<Float128>::min_subnormal(
+                  LIBC_NAMESPACE::Sign::NEG)
+                  .get_val() ==
+              LIBC_NAMESPACE::shared::nextdownf128(Float128(0.0)));
+static_assert(
+    LIBC_NAMESPACE::fputil::FPBits<Float128>::min_subnormal().get_val() ==
+    LIBC_NAMESPACE::shared::nextupf128(Float128(0.0)));
 static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::rintf128(Float128(0.0)));
 static_assert(Float128(0.0) ==
               LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0)));
@@ -503,9 +513,6 @@ static_assert(0.0f ==
               LIBC_NAMESPACE::shared::fmulf128(float128(0.0), float128(0.0)));
 static_assert(0.0f ==
               LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
-static_assert(float128(0.0) ==
-              LIBC_NAMESPACE::shared::nextafterf128(float128(0.0),
-                                                    float128(0.0)));
 static_assert(1 == [] {
   const char arg{};
   return LIBC_NAMESPACE::fputil::FPBits<float128>(
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7b785331f36c6..67a8c402cf91e 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -581,6 +581,9 @@ 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)));
@@ -619,6 +622,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::rintf128(Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0),
                LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0)));
@@ -696,12 +704,7 @@ 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();
-  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 8f1a543de0a5e..b7547bbcee555 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2246,6 +2246,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.nextafterf128
     libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.FPUtil.float128
     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..482709d80a9c2 100644
--- a/libc/test/src/math/nextafterf128_test.cpp
+++ b/libc/test/src/math/nextafterf128_test.cpp
@@ -8,6 +8,11 @@
 
 #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 a61b854a85fb2..d8d9644439983 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4112,6 +4112,7 @@ add_fp_unittest(
     libc.src.math.nextafterf128
     libc.src.__support.CPP.bit
     libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.fp_bits
 )
 
@@ -4274,6 +4275,7 @@ add_fp_unittest(
     NextDownTest.h
   DEPENDS
     libc.src.math.nextdownf128
+    libc.src.__support.FPUtil.float128
 )
 
 add_fp_unittest(
@@ -4347,6 +4349,7 @@ add_fp_unittest(
     NextUpTest.h
   DEPENDS
     libc.src.math.nextupf128
+    libc.src.__support.FPUtil.float128
 )
 
 add_fp_unittest(
diff --git a/libc/test/src/math/smoke/nextafterf128_test.cpp b/libc/test/src/math/smoke/nextafterf128_test.cpp
index a8d000ff4de38..482709d80a9c2 100644
--- a/libc/test/src/math/smoke/nextafterf128_test.cpp
+++ b/libc/test/src/math/smoke/nextafterf128_test.cpp
@@ -8,6 +8,11 @@
 
 #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/nextdownf128_test.cpp b/libc/test/src/math/smoke/nextdownf128_test.cpp
index 932a8b36a59e4..239f35f54e6f8 100644
--- a/libc/test/src/math/smoke/nextdownf128_test.cpp
+++ b/libc/test/src/math/smoke/nextdownf128_test.cpp
@@ -8,6 +8,11 @@
 
 #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/libc/test/src/math/smoke/nextupf128_test.cpp b/libc/test/src/math/smoke/nextupf128_test.cpp
index ddd385a7b159b..0408514e7713d 100644
--- a/libc/test/src/math/smoke/nextupf128_test.cpp
+++ b/libc/test/src/math/smoke/nextupf128_test.cpp
@@ -8,6 +8,11 @@
 
 #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 fc1164d88d111..4b8374bcc62ba 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -8507,9 +8507,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",
     ],
 )
 
@@ -8564,10 +8564,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",
     ],
 )
 
@@ -8669,9 +8669,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",
     ],
 )
 
@@ -13121,6 +13121,8 @@ libc_math_function(
 libc_math_function(
     name = "nextafterf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_nextafterf128",
     ],
 )
@@ -13163,6 +13165,8 @@ libc_math_function(
 libc_math_function(
     name = "nextdownf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_nextdownf128",
     ],
 )
@@ -13233,6 +13237,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 1ea19f953e0ad..8c47fb7858e49 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
@@ -1304,6 +1304,9 @@ math_test(
     name = "nextafterf128",
     hdrs = ["NextAfterTest.h"],
     deps = ["//libc:__support_sign"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(
@@ -1330,6 +1333,9 @@ math_test(
 math_test(
     name = "nextdownf128",
     hdrs = ["NextDownTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(
@@ -1375,6 +1381,9 @@ math_test(
 math_test(
     name = "nextupf128",
     hdrs = ["NextUpTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(

>From b578bc7b4360e2690dfa11d9723d8d493ed69bde Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Fri, 4 Sep 2026 18:12:43 +0530
Subject: [PATCH 2/3] nit

---
 libc/test/shared/shared_math_test.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 67a8c402cf91e..fe3c4f5b4abbd 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -583,7 +583,7 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
 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();
+  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)));
@@ -704,7 +704,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
   EXPECT_FP_EQ(float128(0.0), setpayloadsigf128_res);
 
   float128 neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val();
-  float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val();
+  float128 min_denormal = FPBits::min_subnormal(Sign::POS).get_val();
 
 #ifdef LIBC_TYPES_HAS_FLOAT16
   EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128(

>From 9ad80a94e23fe527b6b1136a45d5d2c0b790e96c Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Fri, 4 Sep 2026 18:28:11 +0530
Subject: [PATCH 3/3] add T()

---
 libc/test/src/math/NextAfterTest.h | 36 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h
index 82d5378ec3533..eed6e25b07965 100644
--- a/libc/test/src/math/NextAfterTest.h
+++ b/libc/test/src/math/NextAfterTest.h
@@ -40,8 +40,8 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
   typedef T (*NextAfterFunc)(T, T);
 
   void testNaN(NextAfterFunc func) {
-    ASSERT_FP_EQ(func(nan, 0), nan);
-    ASSERT_FP_EQ(func(0, nan), nan);
+    ASSERT_FP_EQ(func(nan, T(0)), nan);
+    ASSERT_FP_EQ(func(T(0), nan), nan);
   }
 
   void testBoundaries(NextAfterFunc func) {
@@ -61,57 +61,57 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     ASSERT_FP_EQ(result, expected);
 
     x = neg_zero;
-    result = func(x, 1);
+    result = func(x, T(1));
     expected_bits = 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
 
-    result = func(x, -1);
+    result = func(x, T(-1));
     expected_bits = FPBits::SIGN_MASK + 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
 
     // 'from' is max subnormal value.
     x = LIBC_NAMESPACE::cpp::bit_cast<T>(max_subnormal);
-    result = func(x, 1);
+    result = func(x, T(1));
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(min_normal);
     ASSERT_FP_EQ(result, expected);
 
-    result = func(x, 0);
+    result = func(x, T(0));
     expected_bits = max_subnormal - 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
 
     x = -x;
 
-    result = func(x, -1);
+    result = func(x, T(-1));
     expected_bits = FPBits::SIGN_MASK + min_normal;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
 
-    result = func(x, 0);
+    result = func(x, T(0));
     expected_bits = FPBits::SIGN_MASK + max_subnormal - 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
 
     // 'from' is min subnormal value.
     x = LIBC_NAMESPACE::cpp::bit_cast<T>(min_subnormal);
-    result = func(x, 1);
+    result = func(x, T(1));
     expected_bits = min_subnormal + 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
-    ASSERT_FP_EQ(func(x, 0), zero);
+    ASSERT_FP_EQ(func(x, T(0)), zero);
 
     x = -x;
-    result = func(x, -1);
+    result = func(x, T(-1));
     expected_bits = FPBits::SIGN_MASK + min_subnormal + 1;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
-    ASSERT_FP_EQ(func(x, 0), T(-0.0));
+    ASSERT_FP_EQ(func(x, T(0)), T(-0.0));
 
     // 'from' is min normal.
     x = LIBC_NAMESPACE::cpp::bit_cast<T>(min_normal);
-    result = func(x, 0);
+    result = func(x, T(0));
     expected_bits = max_subnormal;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
@@ -122,7 +122,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     ASSERT_FP_EQ(result, expected);
 
     x = -x;
-    result = func(x, 0);
+    result = func(x, T(0));
     expected_bits = FPBits::SIGN_MASK + max_subnormal;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
@@ -142,14 +142,14 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // 'from' is infinity.
     x = inf;
-    result = func(x, 0);
+    result = func(x, T(0));
     expected_bits = max_normal;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
     ASSERT_FP_EQ(func(x, inf), inf);
 
     x = neg_inf;
-    result = func(x, 0);
+    result = func(x, T(0));
     expected_bits = FPBits::SIGN_MASK + max_normal;
     expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits);
     ASSERT_FP_EQ(result, expected);
@@ -157,7 +157,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // 'from' is a power of 2.
     x = T(32.0);
-    result = func(x, 0);
+    result = func(x, T(0));
     FPBits x_bits = FPBits(x);
     FPBits result_bits = FPBits(result);
     ASSERT_EQ(result_bits.get_biased_exponent(),
@@ -172,7 +172,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     x = -x;
 
-    result = func(x, 0);
+    result = func(x, T(0));
     result_bits = FPBits(result);
     ASSERT_EQ(result_bits.get_biased_exponent(),
               uint16_t(x_bits.get_biased_exponent() - 1));



More information about the libc-commits mailing list