[libc-commits] [libc] [llvm] [libc] Make canonicalizef128, modff128 and remquof128 use the emulated float128 type (PR #223769)
Aditya Goyal via libc-commits
libc-commits at lists.llvm.org
Tue Sep 29 14:47:55 PDT 2026
https://github.com/goyaladitya05 updated https://github.com/llvm/llvm-project/pull/223769
>From 78928069a8545ee4d313dea24e996ac28fd3c740 Mon Sep 17 00:00:00 2001
From: Aditya Goyal <goyaladitya2403 at gmail.com>
Date: Tue, 15 Sep 2026 22:56:05 +0530
Subject: [PATCH 1/6] [libc] Make canonicalizef128, modff128 and remquof128 use
the emulated float128 type
---
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/canonicalizef128.h | 6 ----
libc/shared/math/modff128.h | 6 ----
libc/shared/math/remquof128.h | 6 ----
libc/src/__support/math/CMakeLists.txt | 6 ++--
libc/src/__support/math/canonicalizef128.h | 12 +++-----
libc/src/__support/math/modff128.h | 11 +++----
libc/src/__support/math/remquof128.h | 11 +++----
libc/src/math/canonicalizef128.h | 5 ++++
libc/src/math/generic/CMakeLists.txt | 3 ++
libc/src/math/generic/canonicalizef128.cpp | 9 +++++-
libc/src/math/generic/modff128.cpp | 9 +++++-
libc/src/math/generic/remquof128.cpp | 6 +++-
libc/src/math/modff128.h | 5 ++++
libc/src/math/remquof128.h | 5 ++++
.../shared/shared_math_constexpr_test.cpp | 26 ++++++++---------
libc/test/shared/shared_math_test.cpp | 29 +++++++++----------
libc/test/src/math/smoke/CMakeLists.txt | 3 ++
.../src/math/smoke/canonicalizef128_test.cpp | 5 ++++
libc/test/src/math/smoke/modff128_test.cpp | 5 ++++
libc/test/src/math/smoke/remquof128_test.cpp | 5 ++++
.../llvm-project-overlay/libc/BUILD.bazel | 12 ++++++--
.../libc/test/src/math/smoke/BUILD.bazel | 7 +++++
35 files changed, 154 insertions(+), 101 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 757e4729699d1..00c65d2389855 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -366,6 +366,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -535,6 +536,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -562,6 +564,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -760,7 +763,6 @@ endif()
if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -782,13 +784,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 8f9abb411129b..a5bcad12ee90a 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -378,6 +378,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -547,6 +548,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -574,6 +576,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -771,7 +774,6 @@ endif()
if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -793,13 +795,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 622d6156cff11..a4e8e5c2ca004 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -374,6 +374,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -543,6 +544,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -570,6 +572,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -768,7 +771,6 @@ endif()
if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -790,13 +792,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index d702b2c5a6549..e14f7296c2fd0 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -192,6 +192,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -361,6 +362,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -388,6 +390,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -587,7 +590,6 @@ endif()
if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -609,13 +611,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 716ab572f8d3c..b0c35bc4b0f05 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -123,6 +123,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.copysignf
#libc.src.math.copysignf128
#libc.src.math.copysignl
+ #libc.src.math.canonicalizef128
#libc.src.math.ceil
#libc.src.math.ceilf
#libc.src.math.ceilf128
@@ -215,6 +216,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.logbl
#libc.src.math.modf
#libc.src.math.modff
+ #libc.src.math.modff128
#libc.src.math.modfl
#libc.src.math.nan
#libc.src.math.nanf
@@ -233,6 +235,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.remainder
#libc.src.math.remainderl
#libc.src.math.remquof
+ #libc.src.math.remquof128
#libc.src.math.remquo
#libc.src.math.remquol
#libc.src.math.rint
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 8f6c178301c2f..84c216bbcdfe2 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -134,6 +134,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.copysignf
libc.src.math.copysignf128
libc.src.math.copysignl
+ libc.src.math.canonicalizef128
libc.src.math.ceil
libc.src.math.ceilf
libc.src.math.ceilf128
@@ -264,6 +265,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -284,6 +286,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainder
libc.src.math.remainderl
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquo
libc.src.math.remquol
libc.src.math.rint
@@ -520,7 +523,6 @@ endif()
if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan2l
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -542,13 +544,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5c5e5891da822..78d89f137afd2 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -317,6 +317,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -478,6 +479,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -505,6 +507,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index afae725484a89..1905f184e93e4 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -313,6 +313,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -475,6 +476,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -502,6 +504,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index fd931e7a0a615..016ae5d79ecba 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -561,6 +561,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -726,6 +727,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -753,6 +755,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -945,7 +948,6 @@ endif()
if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -967,13 +969,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index e32430cac7c8c..2350678b508e3 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -388,6 +388,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
+ libc.src.math.canonicalizef128
libc.src.math.ceil
libc.src.math.ceilf
libc.src.math.ceilf128
@@ -533,6 +534,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -560,6 +562,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 2525202d4ff10..a8feb88a33266 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -624,6 +624,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -793,6 +794,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -820,6 +822,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -1029,7 +1032,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.atan2l
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -1051,13 +1053,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 42cbcd02513eb..f3cb0f6b8be80 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -635,6 +635,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -804,6 +805,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -831,6 +833,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -1040,7 +1043,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.atan2l
- libc.src.math.canonicalizef128
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
@@ -1062,13 +1064,11 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.ldexpf128
libc.src.math.llogbf128
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
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a48b49e169b3..15e3fb2f004e9 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -166,6 +166,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.copysignf
libc.src.math.copysignf128
libc.src.math.copysignl
+ libc.src.math.canonicalizef128
libc.src.math.ceil
libc.src.math.ceilf
libc.src.math.ceilf128
@@ -297,6 +298,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -317,6 +319,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainder
libc.src.math.remainderl
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquo
libc.src.math.remquol
libc.src.math.rint
diff --git a/libc/shared/math/canonicalizef128.h b/libc/shared/math/canonicalizef128.h
index 3e58766807f07..63b9a399fe2c8 100644
--- a/libc/shared/math/canonicalizef128.h
+++ b/libc/shared/math/canonicalizef128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/canonicalizef128.h"
@@ -24,6 +20,4 @@ using math::canonicalizef128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
diff --git a/libc/shared/math/modff128.h b/libc/shared/math/modff128.h
index 480dc16d4fe3c..b8b061a14467f 100644
--- a/libc/shared/math/modff128.h
+++ b/libc/shared/math/modff128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_MODFF128_H
#define LLVM_LIBC_SHARED_MATH_MODFF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/modff128.h"
@@ -24,6 +20,4 @@ using math::modff128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_MODFF128_H
diff --git a/libc/shared/math/remquof128.h b/libc/shared/math/remquof128.h
index 4331c02bb9979..877f562db77c0 100644
--- a/libc/shared/math/remquof128.h
+++ b/libc/shared/math/remquof128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_REMQUOF128_H
#define LLVM_LIBC_SHARED_MATH_REMQUOF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/remquof128.h"
@@ -24,6 +20,4 @@ using math::remquof128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_REMQUOF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 0871a5bf229b6..3e82032932dd2 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -690,8 +690,8 @@ add_header_library(
HDRS
canonicalizef128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
@@ -2120,8 +2120,8 @@ add_header_library(
HDRS
modff128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
@@ -2355,8 +2355,8 @@ add_header_library(
HDRS
remquof128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/canonicalizef128.h b/libc/src/__support/math/canonicalizef128.h
index 77ce2058bc859..86acd6bff45d8 100644
--- a/libc/src/__support/math/canonicalizef128.h
+++ b/libc/src/__support/math/canonicalizef128.h
@@ -9,24 +9,20 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
-LIBC_INLINE constexpr int canonicalizef128(float128 *cx, const float128 *x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr int canonicalizef128(Float128 *cx, const Float128 *x) {
return fputil::canonicalize(*cx, *x);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
diff --git a/libc/src/__support/math/modff128.h b/libc/src/__support/math/modff128.h
index b519298a50ae1..a9d85ae3f5a06 100644
--- a/libc/src/__support/math/modff128.h
+++ b/libc/src/__support/math/modff128.h
@@ -9,23 +9,20 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_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 modff128(float128 x, float128 *iptr) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 modff128(Float128 x, Float128 *iptr) {
return fputil::modf(x, *iptr);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
diff --git a/libc/src/__support/math/remquof128.h b/libc/src/__support/math/remquof128.h
index d22b3359d43c8..8650650b05879 100644
--- a/libc/src/__support/math/remquof128.h
+++ b/libc/src/__support/math/remquof128.h
@@ -9,23 +9,20 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 remquof128(float128 x, float128 y, int *exp) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 remquof128(Float128 x, Float128 y, int *exp) {
return fputil::remquo(x, y, *exp);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
diff --git a/libc/src/math/canonicalizef128.h b/libc/src/math/canonicalizef128.h
index eeeb7e3fb4526..f50a3b02661bc 100644
--- a/libc/src/math/canonicalizef128.h
+++ b/libc/src/math/canonicalizef128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SRC_MATH_CANONICALIZEF128_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
+
int canonicalizef128(float128 *cx, const float128 *x);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 28b8e954530dd..0f3dac332f311 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -37,6 +37,7 @@ add_entrypoint_object(
HDRS
../canonicalizef128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.canonicalizef128
)
@@ -2003,6 +2004,7 @@ add_entrypoint_object(
HDRS
../modff128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.modff128
)
@@ -2764,6 +2766,7 @@ add_entrypoint_object(
HDRS
../remquof128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.remquof128
)
diff --git a/libc/src/math/generic/canonicalizef128.cpp b/libc/src/math/generic/canonicalizef128.cpp
index 48bce08a555cf..f48793d53d58a 100644
--- a/libc/src/math/generic/canonicalizef128.cpp
+++ b/libc/src/math/generic/canonicalizef128.cpp
@@ -7,12 +7,19 @@
//===----------------------------------------------------------------------===//
#include "src/math/canonicalizef128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/canonicalizef128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(int, canonicalizef128, (float128 * cx, const float128 *x)) {
- return math::canonicalizef128(cx, x);
+ Float128 cx_val{};
+ const Float128 x_val = cpp::bit_cast<Float128>(*x);
+ int result = math::canonicalizef128(&cx_val, &x_val);
+ *cx = cpp::bit_cast<float128>(cx_val);
+ return result;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/modff128.cpp b/libc/src/math/generic/modff128.cpp
index 099bb2e907fb8..0402f45f7e4f2 100644
--- a/libc/src/math/generic/modff128.cpp
+++ b/libc/src/math/generic/modff128.cpp
@@ -7,12 +7,19 @@
//===----------------------------------------------------------------------===//
#include "src/math/modff128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/modff128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, modff128, (float128 x, float128 *iptr)) {
- return math::modff128(x, iptr);
+ Float128 iptr_val{};
+ float128 result = cpp::bit_cast<float128>(
+ math::modff128(cpp::bit_cast<Float128>(x), &iptr_val));
+ *iptr = cpp::bit_cast<float128>(iptr_val);
+ return result;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquof128.cpp b/libc/src/math/generic/remquof128.cpp
index 779597d00eac0..b866d3be30cf2 100644
--- a/libc/src/math/generic/remquof128.cpp
+++ b/libc/src/math/generic/remquof128.cpp
@@ -7,12 +7,16 @@
//===----------------------------------------------------------------------===//
#include "src/math/remquof128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/remquof128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, remquof128, (float128 x, float128 y, int *exp)) {
- return math::remquof128(x, y, exp);
+ return cpp::bit_cast<float128>(math::remquof128(
+ cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y), exp));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/modff128.h b/libc/src/math/modff128.h
index 32c98423a050c..7c4a3aab17dc4 100644
--- a/libc/src/math/modff128.h
+++ b/libc/src/math/modff128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_MODFF128_H
#define LLVM_LIBC_SRC_MATH_MODFF128_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 modff128(float128 x, float128 *iptr);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/remquof128.h b/libc/src/math/remquof128.h
index 49e99a9a8bb2c..3dbfd50b9ea57 100644
--- a/libc/src/math/remquof128.h
+++ b/libc/src/math/remquof128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_REMQUOF128_H
#define LLVM_LIBC_SRC_MATH_REMQUOF128_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 remquof128(float128 x, float128 y, int *exp);
} // 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..4180a595a5aeb 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -380,6 +380,11 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
// Emulated Float128 Tests
//===----------------------------------------------------------------------===//
+static_assert(0 == [] {
+ Float128 cx = Float128(0.0);
+ Float128 x = Float128(0.0);
+ return LIBC_NAMESPACE::shared::canonicalizef128(&cx, &x);
+}());
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::copysignf128(Float128(0.0),
@@ -426,8 +431,16 @@ static_assert(0LL == LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
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) == [] {
+ Float128 iptr{};
+ return LIBC_NAMESPACE::shared::modff128(Float128(0.0), &iptr);
+}());
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0)));
+static_assert(Float128(0.0) == [] {
+ int exp{};
+ return LIBC_NAMESPACE::shared::remquof128(Float128(1.0), Float128(1.0), &exp);
+}());
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::rintf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0)));
@@ -442,11 +455,6 @@ static_assert(Float128(0.0) ==
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-static_assert(0 == [] {
- float128 cx = float128(0.0);
- float128 x = float128(0.0);
- return LIBC_NAMESPACE::shared::canonicalizef128(&cx, &x);
-}());
static_assert(0.0 ==
LIBC_NAMESPACE::shared::ddivf128(float128(0.0), float128(1.0)));
static_assert(0.0 ==
@@ -480,17 +488,9 @@ static_assert(1 ==
&TOTALORDERMAGF128_Y));
static_assert(0 ==
LIBC_NAMESPACE::shared::fmodf128(float128(4.0), float128(2.0)));
-static_assert(float128(0.0) == [] {
- float128 iptr{};
- return LIBC_NAMESPACE::shared::modff128(float128(0.0), &iptr);
-}());
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::remainderf128(float128(1.0),
float128(1.0)));
-static_assert(float128(0.0) == [] {
- int exp{};
- return LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0), &exp);
-}());
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0.0));
static_assert(float128(0.0) ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7b785331f36c6..c0641765ead91 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -583,6 +583,11 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0)));
+ Float128 canonicalizef128_cx = Float128(0.0);
+ Float128 canonicalizef128_x = Float128(0.0);
+ EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef128(&canonicalizef128_cx,
+ &canonicalizef128_x));
+ EXPECT_FP_EQ(Float128(0.0), canonicalizef128_cx);
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128(
Float128(0.0), Float128(0.0)));
@@ -617,8 +622,17 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf128(Float128(0.0)));
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
+ Float128 modff128_iptr = Float128(0.0);
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::modff128(Float128(0.0), &modff128_iptr));
+ EXPECT_FP_EQ(Float128(0.0), modff128_iptr);
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0)));
+ int remquof128_exp = 0;
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::remquof128(Float128(1.0), Float128(1.0),
+ &remquof128_exp));
+ EXPECT_EQ(1, remquof128_exp);
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)));
@@ -655,12 +669,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf128(
float128(2.0), float128(3.0)));
- float128 canonicalizef128_cx = float128(0.0);
- float128 canonicalizef128_x = float128(0.0);
- EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef128(&canonicalizef128_cx,
- &canonicalizef128_x));
- EXPECT_FP_EQ(float128(0.0), canonicalizef128_cx);
-
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16subf128(
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16fmaf128(
@@ -735,17 +743,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_EQ(1, LIBC_NAMESPACE::shared::totalordermagf128(&totalordermagf128_x,
&totalordermagf128_y));
LIBC_NAMESPACE::shared::fmodf128(float128(1.0), float128(1.0));
- float128 modff128_iptr = float128(0.0);
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::modff128(float128(0.0), &modff128_iptr));
- EXPECT_FP_EQ(float128(0.0), modff128_iptr);
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::remainderf128(
float128(1.0), float128(1.0)));
- int remquof128_exp = 0;
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0),
- &remquof128_exp));
- EXPECT_EQ(1, remquof128_exp);
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0L));
EXPECT_FP_EQ(float128(0.0),
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index a61b854a85fb2..b20f8b21320fd 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -446,6 +446,7 @@ add_fp_unittest(
HDRS
CanonicalizeTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.canonicalizef128
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.fenv_impl
@@ -2573,6 +2574,7 @@ add_fp_unittest(
HDRS
ModfTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.modff128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
@@ -3757,6 +3759,7 @@ add_fp_unittest(
HDRS
RemQuoTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.remquof128
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
diff --git a/libc/test/src/math/smoke/canonicalizef128_test.cpp b/libc/test/src/math/smoke/canonicalizef128_test.cpp
index 242e2331a29ea..dab208bc19924 100644
--- a/libc/test/src/math/smoke/canonicalizef128_test.cpp
+++ b/libc/test/src/math/smoke/canonicalizef128_test.cpp
@@ -8,6 +8,11 @@
#include "CanonicalizeTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/canonicalizef128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_CANONICALIZE_TESTS(float128, LIBC_NAMESPACE::canonicalizef128)
diff --git a/libc/test/src/math/smoke/modff128_test.cpp b/libc/test/src/math/smoke/modff128_test.cpp
index 062d40138e729..af6e7582923ac 100644
--- a/libc/test/src/math/smoke/modff128_test.cpp
+++ b/libc/test/src/math/smoke/modff128_test.cpp
@@ -8,6 +8,11 @@
#include "ModfTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/modff128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_MODF_TESTS(float128, LIBC_NAMESPACE::modff128)
diff --git a/libc/test/src/math/smoke/remquof128_test.cpp b/libc/test/src/math/smoke/remquof128_test.cpp
index 8ef6c3b31cef2..f2ecfbc6e51f0 100644
--- a/libc/test/src/math/smoke/remquof128_test.cpp
+++ b/libc/test/src/math/smoke/remquof128_test.cpp
@@ -8,6 +8,11 @@
#include "RemQuoTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/remquof128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_REMQUO_TESTS(float128, LIBC_NAMESPACE::remquof128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 11d15b69e718b..86b01b09c3628 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -6126,8 +6126,8 @@ libc_support_library(
hdrs = ["src/__support/math/canonicalizef128.h"],
deps = [
":__support_fputil_basic_operations",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -7547,8 +7547,8 @@ libc_support_library(
hdrs = ["src/__support/math/modff128.h"],
deps = [
":__support_fputil_manipulation_functions",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -7781,8 +7781,8 @@ libc_support_library(
hdrs = ["src/__support/math/remquof128.h"],
deps = [
":__support_fputil_division_and_remainder_operations",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -11830,6 +11830,8 @@ libc_math_function(
libc_math_function(
name = "canonicalizef128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_canonicalizef128",
],
)
@@ -13909,6 +13911,8 @@ libc_math_function(
libc_math_function(
name = "modff128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_modff128",
],
)
@@ -14256,6 +14260,8 @@ libc_math_function(
libc_math_function(
name = "remquof128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_remquof128",
],
)
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 e1d9305617303..800dba891b0f4 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
@@ -114,6 +114,7 @@ math_test(
name = "canonicalizef128",
hdrs = ["CanonicalizeTest.h"],
deps = [
+ "//libc:__support_fputil_float128",
"//libc:__support_integer_literals",
],
)
@@ -1600,6 +1601,9 @@ math_test(
math_test(
name = "modff128",
hdrs = ["ModfTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
@@ -1808,6 +1812,9 @@ math_test(
math_test(
name = "remquof128",
hdrs = ["RemQuoTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
>From 589c93279c34d271a9f6602d6fc548f710235ee6 Mon Sep 17 00:00:00 2001
From: Aditya Goyal <goyaladitya2403 at gmail.com>
Date: Tue, 15 Sep 2026 23:10:57 +0530
Subject: [PATCH 2/6] [libc] Fix Bazel dep ordering for buildifier
---
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 86b01b09c3628..9ff9742a9ab91 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -7546,8 +7546,8 @@ libc_support_library(
name = "__support_math_modff128",
hdrs = ["src/__support/math/modff128.h"],
deps = [
- ":__support_fputil_manipulation_functions",
":__support_fputil_float128",
+ ":__support_fputil_manipulation_functions",
":__support_macros_config",
],
)
>From b0d45e573ee3b10e17e0bc0196d92ff557da2246 Mon Sep 17 00:00:00 2001
From: Aditya Goyal <goyaladitya2403 at gmail.com>
Date: Wed, 16 Sep 2026 00:50:50 +0530
Subject: [PATCH 3/6] fix ordering
---
libc/config/darwin/x86_64/entrypoints.txt | 2 +-
libc/config/linux/arm/entrypoints.txt | 2 +-
libc/config/windows/entrypoints.txt | 2 +-
libc/src/__support/math/CMakeLists.txt | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index b0c35bc4b0f05..88150f2c17b01 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -119,11 +119,11 @@ set(TARGET_LIBM_ENTRYPOINTS
## Currently disabled for failing tests.
# math.h entrypoints
#libc.src.math.atan2f128
+ #libc.src.math.canonicalizef128
#libc.src.math.copysign
#libc.src.math.copysignf
#libc.src.math.copysignf128
#libc.src.math.copysignl
- #libc.src.math.canonicalizef128
#libc.src.math.ceil
#libc.src.math.ceilf
#libc.src.math.ceilf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 2350678b508e3..ecaa0862767f6 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -385,10 +385,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan
libc.src.math.atanf
libc.src.math.atanhf
+ libc.src.math.canonicalizef128
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
- libc.src.math.canonicalizef128
libc.src.math.ceil
libc.src.math.ceilf
libc.src.math.ceilf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 15e3fb2f004e9..8b5d38c560942 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -159,6 +159,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan
libc.src.math.atanf
libc.src.math.atanhf
+ libc.src.math.canonicalizef128
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
@@ -166,7 +167,6 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.copysignf
libc.src.math.copysignf128
libc.src.math.copysignl
- libc.src.math.canonicalizef128
libc.src.math.ceil
libc.src.math.ceilf
libc.src.math.ceilf128
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 3e82032932dd2..72588f2f8b553 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -2120,8 +2120,8 @@ add_header_library(
HDRS
modff128.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.FPUtil.float128
+ libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
>From 66a488ecab2f2a53adc27054c5d423baaeabe272 Mon Sep 17 00:00:00 2001
From: Aditya Goyal <goyaladitya2403 at gmail.com>
Date: Wed, 16 Sep 2026 00:58:16 +0530
Subject: [PATCH 4/6] add empty line
---
libc/src/__support/math/canonicalizef128.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libc/src/__support/math/canonicalizef128.h b/libc/src/__support/math/canonicalizef128.h
index 86acd6bff45d8..d1c0552ae632c 100644
--- a/libc/src/__support/math/canonicalizef128.h
+++ b/libc/src/__support/math/canonicalizef128.h
@@ -14,6 +14,7 @@
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
+
namespace math {
using LIBC_NAMESPACE::fputil::Float128;
>From 25f5b2833be29b5c4dae5ff81e782ab1ce7dd10c Mon Sep 17 00:00:00 2001
From: Aditya Goyal <goyaladitya2403 at gmail.com>
Date: Wed, 16 Sep 2026 01:54:05 +0530
Subject: [PATCH 5/6] update file headers
---
libc/shared/math/canonicalizef128.h | 7 ++++++-
libc/shared/math/modff128.h | 7 ++++++-
libc/shared/math/remquof128.h | 7 ++++++-
libc/src/__support/math/canonicalizef128.h | 7 ++++++-
libc/src/__support/math/modff128.h | 7 ++++++-
libc/src/__support/math/remquof128.h | 7 ++++++-
libc/src/math/canonicalizef128.h | 7 ++++++-
libc/src/math/generic/canonicalizef128.cpp | 7 ++++++-
libc/src/math/generic/modff128.cpp | 7 ++++++-
libc/src/math/generic/remquof128.cpp | 7 ++++++-
libc/src/math/modff128.h | 7 ++++++-
libc/src/math/remquof128.h | 7 ++++++-
libc/test/src/math/smoke/canonicalizef128_test.cpp | 7 ++++++-
libc/test/src/math/smoke/modff128_test.cpp | 7 ++++++-
libc/test/src/math/smoke/remquof128_test.cpp | 7 ++++++-
15 files changed, 90 insertions(+), 15 deletions(-)
diff --git a/libc/shared/math/canonicalizef128.h b/libc/shared/math/canonicalizef128.h
index 63b9a399fe2c8..f9813e0a1a66b 100644
--- a/libc/shared/math/canonicalizef128.h
+++ b/libc/shared/math/canonicalizef128.h
@@ -1,10 +1,15 @@
-//===-- Shared canonicalizef128 function ------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared declaration of the float128 canonicalize function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
diff --git a/libc/shared/math/modff128.h b/libc/shared/math/modff128.h
index b8b061a14467f..98b4643e99ba5 100644
--- a/libc/shared/math/modff128.h
+++ b/libc/shared/math/modff128.h
@@ -1,10 +1,15 @@
-//===-- Shared modff128 function --------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared declaration of the float128 modf function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_MODFF128_H
#define LLVM_LIBC_SHARED_MATH_MODFF128_H
diff --git a/libc/shared/math/remquof128.h b/libc/shared/math/remquof128.h
index 877f562db77c0..a3bbbfdc9c2bc 100644
--- a/libc/shared/math/remquof128.h
+++ b/libc/shared/math/remquof128.h
@@ -1,10 +1,15 @@
-//===-- Shared remquof128 function ------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared declaration of the float128 remquo function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_REMQUOF128_H
#define LLVM_LIBC_SHARED_MATH_REMQUOF128_H
diff --git a/libc/src/__support/math/canonicalizef128.h b/libc/src/__support/math/canonicalizef128.h
index d1c0552ae632c..98f44806a4647 100644
--- a/libc/src/__support/math/canonicalizef128.h
+++ b/libc/src/__support/math/canonicalizef128.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for canonicalizef128 --------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 canonicalize function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
diff --git a/libc/src/__support/math/modff128.h b/libc/src/__support/math/modff128.h
index a9d85ae3f5a06..59e8c6484df9c 100644
--- a/libc/src/__support/math/modff128.h
+++ b/libc/src/__support/math/modff128.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for modff128 ----------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 modf function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
diff --git a/libc/src/__support/math/remquof128.h b/libc/src/__support/math/remquof128.h
index 8650650b05879..648793752d517 100644
--- a/libc/src/__support/math/remquof128.h
+++ b/libc/src/__support/math/remquof128.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for remquof128 --------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 remquo function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
diff --git a/libc/src/math/canonicalizef128.h b/libc/src/math/canonicalizef128.h
index f50a3b02661bc..79bf59d0c8a83 100644
--- a/libc/src/math/canonicalizef128.h
+++ b/libc/src/math/canonicalizef128.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for canonicalizef128 ---------------*-C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Declaration of the float128 canonicalize function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
diff --git a/libc/src/math/generic/canonicalizef128.cpp b/libc/src/math/generic/canonicalizef128.cpp
index f48793d53d58a..2013e30c75ee5 100644
--- a/libc/src/math/generic/canonicalizef128.cpp
+++ b/libc/src/math/generic/canonicalizef128.cpp
@@ -1,10 +1,15 @@
-//===-- Implementation of canonicalizef128 function------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the canonicalizef128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/canonicalizef128.h"
#include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/generic/modff128.cpp b/libc/src/math/generic/modff128.cpp
index 0402f45f7e4f2..8769d36e56cab 100644
--- a/libc/src/math/generic/modff128.cpp
+++ b/libc/src/math/generic/modff128.cpp
@@ -1,10 +1,15 @@
-//===-- Implementation of modff128 function -------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the modff128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/modff128.h"
#include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/generic/remquof128.cpp b/libc/src/math/generic/remquof128.cpp
index b866d3be30cf2..0e3a825dd45a2 100644
--- a/libc/src/math/generic/remquof128.cpp
+++ b/libc/src/math/generic/remquof128.cpp
@@ -1,10 +1,15 @@
-//===-- Implementation of remquof128 function -----------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the remquof128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/remquof128.h"
#include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/modff128.h b/libc/src/math/modff128.h
index 7c4a3aab17dc4..cfb25ca360a3c 100644
--- a/libc/src/math/modff128.h
+++ b/libc/src/math/modff128.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for modff128 -----------------------*- C++-*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Declaration of the float128 modf function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_MODFF128_H
#define LLVM_LIBC_SRC_MATH_MODFF128_H
diff --git a/libc/src/math/remquof128.h b/libc/src/math/remquof128.h
index 3dbfd50b9ea57..f9b74dd3442dc 100644
--- a/libc/src/math/remquof128.h
+++ b/libc/src/math/remquof128.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for remquof128 --------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Declaration of the float128 remquo function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_REMQUOF128_H
#define LLVM_LIBC_SRC_MATH_REMQUOF128_H
diff --git a/libc/test/src/math/smoke/canonicalizef128_test.cpp b/libc/test/src/math/smoke/canonicalizef128_test.cpp
index dab208bc19924..9be722e0e256e 100644
--- a/libc/test/src/math/smoke/canonicalizef128_test.cpp
+++ b/libc/test/src/math/smoke/canonicalizef128_test.cpp
@@ -1,10 +1,15 @@
-//===-- Unittests for canonicalizef128 ------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Smoke tests for the canonicalizef128 function.
+///
+//===----------------------------------------------------------------------===//
#include "CanonicalizeTest.h"
diff --git a/libc/test/src/math/smoke/modff128_test.cpp b/libc/test/src/math/smoke/modff128_test.cpp
index af6e7582923ac..ee738d749fbca 100644
--- a/libc/test/src/math/smoke/modff128_test.cpp
+++ b/libc/test/src/math/smoke/modff128_test.cpp
@@ -1,10 +1,15 @@
-//===-- Unittests for modff128 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Smoke tests for the modff128 function.
+///
+//===----------------------------------------------------------------------===//
#include "ModfTest.h"
diff --git a/libc/test/src/math/smoke/remquof128_test.cpp b/libc/test/src/math/smoke/remquof128_test.cpp
index f2ecfbc6e51f0..a1c7568fa7b22 100644
--- a/libc/test/src/math/smoke/remquof128_test.cpp
+++ b/libc/test/src/math/smoke/remquof128_test.cpp
@@ -1,10 +1,15 @@
-//===-- Unittests for remquof128 ------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Smoke tests for the remquof128 function.
+///
+//===----------------------------------------------------------------------===//
#include "RemQuoTest.h"
>From cbd661cd705361fcf97ccea6ba736094bc2000b3 Mon Sep 17 00:00:00 2001
From: Aditya Goyal <goyaladitya2403 at gmail.com>
Date: Wed, 16 Sep 2026 01:54:07 +0530
Subject: [PATCH 6/6] add src/math tests for modff128 and remquof128
---
libc/test/src/math/CMakeLists.txt | 32 +++++++++++++++++++
libc/test/src/math/ModfTest.h | 2 +-
libc/test/src/math/modff128_test.cpp | 23 +++++++++++++
libc/test/src/math/remquof128_test.cpp | 23 +++++++++++++
libc/utils/MPFRWrapper/MPFRUtils.cpp | 10 ++++++
.../libc/test/src/math/BUILD.bazel | 12 +++++++
6 files changed, 101 insertions(+), 1 deletion(-)
create mode 100644 libc/test/src/math/modff128_test.cpp
create mode 100644 libc/test/src/math/remquof128_test.cpp
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 8f1a543de0a5e..dd8849b88f84c 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1797,6 +1797,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_fp_unittest(
+ modff128_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ modff128_test.cpp
+ HDRS
+ ModfTest.h
+ DEPENDS
+ libc.src.math.modff128
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_fp_unittest(
fdimf_test
SUITE
@@ -2145,6 +2160,23 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ remquof128_test
+ NEED_MPFR_F128
+ SUITE
+ libc-math-unittests
+ SRCS
+ remquof128_test.cpp
+ HDRS
+ RemQuoTest.h
+ DEPENDS
+ libc.src.math.remquof128
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
hypotf_test
NEED_MPFR
diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h
index a6def094c07eb..9b649c25cfccd 100644
--- a/libc/test/src/math/ModfTest.h
+++ b/libc/test/src/math/ModfTest.h
@@ -95,7 +95,7 @@ class ModfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
T integral;
T frac = func(x, &integral);
- ASSERT_TRUE(LIBC_NAMESPACE::fputil::abs(frac) < 1.0l);
+ ASSERT_TRUE(LIBC_NAMESPACE::fputil::abs(frac) < T(1.0));
ASSERT_TRUE(LIBC_NAMESPACE::fputil::trunc(x) == integral);
ASSERT_TRUE(integral + frac == x);
}
diff --git a/libc/test/src/math/modff128_test.cpp b/libc/test/src/math/modff128_test.cpp
new file mode 100644
index 0000000000000..d39a8f0647540
--- /dev/null
+++ b/libc/test/src/math/modff128_test.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Exhaustive tests for the modff128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "ModfTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/modff128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_MODF_TESTS(float128, LIBC_NAMESPACE::modff128)
diff --git a/libc/test/src/math/remquof128_test.cpp b/libc/test/src/math/remquof128_test.cpp
new file mode 100644
index 0000000000000..09d051eda1535
--- /dev/null
+++ b/libc/test/src/math/remquof128_test.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Exhaustive tests for the remquof128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "RemQuoTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/remquof128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_REMQUO_TESTS(float128, LIBC_NAMESPACE::remquof128)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 83500cb59de9d..bc82ea3aea31d 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -382,6 +382,11 @@ template void explain_binary_operation_two_outputs_error<float16>(
template void explain_binary_operation_two_outputs_error<bfloat16>(
Operation, const BinaryInput<bfloat16> &, const BinaryOutput<bfloat16> &,
double, RoundingMode);
+#ifdef LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
+template void explain_binary_operation_two_outputs_error<float128>(
+ Operation, const BinaryInput<float128> &, const BinaryOutput<float128> &,
+ double, RoundingMode);
+#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
template <typename InputType, typename OutputType>
void explain_binary_operation_one_output_error(
@@ -667,6 +672,11 @@ template bool compare_binary_operation_two_outputs<float16>(
template bool compare_binary_operation_two_outputs<bfloat16>(
Operation, const BinaryInput<bfloat16> &, const BinaryOutput<bfloat16> &,
double, RoundingMode);
+#ifdef LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
+template bool compare_binary_operation_two_outputs<float128>(
+ Operation, const BinaryInput<float128> &, const BinaryOutput<float128> &,
+ double, RoundingMode);
+#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
template <typename InputType, typename OutputType>
bool compare_binary_operation_one_output(Operation op,
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index 8e5706c085f39..7d0cb322a3fc7 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -589,6 +589,12 @@ math_mpfr_test(
# TODO: add nan tests.
+math_mpfr_test(
+ name = "modff128",
+ hdrs = ["ModfTest.h"],
+ deps = ["//libc:__support_fputil_float128"],
+)
+
math_mpfr_test(
name = "nearbyint",
hdrs = ["NearbyIntTest.h"],
@@ -644,6 +650,12 @@ math_mpfr_test(
hdrs = ["RemQuoTest.h"],
)
+math_mpfr_test(
+ name = "remquof128",
+ hdrs = ["RemQuoTest.h"],
+ deps = ["//libc:__support_fputil_float128"],
+)
+
math_mpfr_test(
name = "remquof16",
hdrs = ["RemQuoTest.h"],
More information about the libc-commits
mailing list