[libc-commits] [libc] [llvm] [libc] Make exponent decomposition f128 functions use emulated Float128 (PR #229855)

Mohammed Sohail via libc-commits libc-commits at lists.llvm.org
Sun Oct 18 09:24:21 PDT 2026


https://github.com/msohail22 updated https://github.com/llvm/llvm-project/pull/229855

>From 5a2cd9547963b1854ff81ae6584e6432574fa303 Mon Sep 17 00:00:00 2001
From: Mohammed Sohail <mohd.sohail.biz at gmail.com>
Date: Wed, 7 Oct 2026 22:57:25 +0530
Subject: [PATCH 1/2] [libc] Make exponent decomposition f128 functions use
 emulated Float128

Convert frexpf128, logbf128, ilogbf128 and llogbf128 to use the emulated
fputil::Float128 type, so they are available on targets without a native
float128 type.

- Implement the __support/math headers in terms of fputil::Float128 and
  drop the LIBC_TYPES_HAS_NATIVE_FLOAT128 guards there and in the shared
  headers.
- Bit-cast between float128 and Float128 at the entrypoints, keeping the
  public signatures unchanged.
- Move the entrypoints out of the native-float128-only lists in all
  target configs.
- Update CMake and Bazel dependencies.
- Move the shared tests to the emulated Float128 section, add constexpr
  coverage, and make the smoke tests fall back to Float128.

Part of #216576.
---
 libc/config/baremetal/aarch64/entrypoints.txt |  8 ++--
 libc/config/baremetal/arm/entrypoints.txt     |  8 ++--
 libc/config/baremetal/riscv/entrypoints.txt   |  8 ++--
 libc/config/darwin/aarch64/entrypoints.txt    |  8 ++--
 libc/config/darwin/x86_64/entrypoints.txt     |  4 ++
 libc/config/freebsd/x86_64/entrypoints.txt    |  8 ++--
 libc/config/gpu/amdgpu/entrypoints.txt        |  4 ++
 libc/config/gpu/nvptx/entrypoints.txt         |  4 ++
 libc/config/linux/aarch64/entrypoints.txt     |  8 ++--
 libc/config/linux/arm/entrypoints.txt         |  4 ++
 libc/config/linux/riscv/entrypoints.txt       |  8 ++--
 libc/config/linux/x86_64/entrypoints.txt      |  8 ++--
 libc/config/windows/entrypoints.txt           |  4 ++
 libc/shared/math/frexpf128.h                  | 13 +++---
 libc/shared/math/ilogbf128.h                  | 13 +++---
 libc/shared/math/llogbf128.h                  | 13 +++---
 libc/shared/math/logbf128.h                   | 13 +++---
 libc/src/__support/math/CMakeLists.txt        | 18 +++++---
 libc/src/__support/math/frexpf128.h           | 18 ++++----
 libc/src/__support/math/ilogbf128.h           | 18 ++++----
 libc/src/__support/math/llogbf128.h           | 18 ++++----
 libc/src/__support/math/logbf128.h            | 18 ++++----
 libc/src/math/frexpf128.h                     | 12 ++++-
 libc/src/math/generic/CMakeLists.txt          |  4 ++
 libc/src/math/generic/frexpf128.cpp           | 14 ++++--
 libc/src/math/generic/ilogbf128.cpp           | 14 +++++-
 libc/src/math/generic/llogbf128.cpp           | 14 +++++-
 libc/src/math/generic/logbf128.cpp            | 12 ++++-
 libc/src/math/ilogbf128.h                     | 12 ++++-
 libc/src/math/llogbf128.h                     | 12 ++++-
 libc/src/math/logbf128.h                      | 12 ++++-
 .../shared/shared_math_constexpr_test.cpp     |  7 +++
 libc/test/shared/shared_math_test.cpp         | 17 ++++---
 libc/test/src/math/CMakeLists.txt             | 45 ++++++++++++++++++
 libc/test/src/math/ILogbTest.h                | 20 ++++----
 libc/test/src/math/LogbTest.h                 |  6 +--
 libc/test/src/math/frexpf128_test.cpp         | 23 ++++++++++
 libc/test/src/math/ilogbf128_test.cpp         | 46 +++++++++++++++++++
 libc/test/src/math/logbf128_test.cpp          | 23 ++++++++++
 libc/test/src/math/smoke/CMakeLists.txt       |  4 ++
 libc/test/src/math/smoke/frexpf128_test.cpp   | 12 ++++-
 libc/test/src/math/smoke/ilogbf128_test.cpp   | 12 ++++-
 libc/test/src/math/smoke/llogbf128_test.cpp   | 12 ++++-
 libc/test/src/math/smoke/logbf128_test.cpp    | 12 ++++-
 libc/utils/MPFRWrapper/MPFRUtils.cpp          |  8 ++++
 .../llvm-project-overlay/libc/BUILD.bazel     | 17 +++++--
 .../libc/test/src/math/BUILD.bazel            |  8 ++++
 .../libc/test/src/math/smoke/BUILD.bazel      | 12 +++++
 48 files changed, 474 insertions(+), 142 deletions(-)
 create mode 100644 libc/test/src/math/frexpf128_test.cpp
 create mode 100644 libc/test/src/math/ilogbf128_test.cpp
 create mode 100644 libc/test/src/math/logbf128_test.cpp

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 114534ce61ae6e..011c734269436d 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -473,6 +473,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -491,6 +492,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -510,6 +512,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -528,6 +531,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -777,16 +781,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index c8148815c34e34..4ac6446b17e7a6 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -485,6 +485,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -503,6 +504,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -522,6 +524,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -540,6 +543,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -788,16 +792,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 622d6156cff11d..651f22010787a6 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -476,6 +476,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -494,6 +495,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -513,6 +515,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -531,6 +534,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -780,16 +784,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     # libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index d702b2c5a65497..5f73b7ccdbfd72 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -294,6 +294,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -312,6 +313,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -331,6 +333,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -349,6 +352,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -599,16 +603,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 716ab572f8d3cd..eedc75face0ae3 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -176,6 +176,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.fmodf
     #libc.src.math.frexp
     #libc.src.math.frexpf
+    #libc.src.math.frexpf128
     #libc.src.math.frexpl
     #libc.src.math.fsub
     #libc.src.math.fsubl
@@ -183,10 +184,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.hypotf
     #libc.src.math.ilogb
     #libc.src.math.ilogbf
+    #libc.src.math.ilogbf128
     #libc.src.math.ilogbl
     #libc.src.math.iscanonicalf128
     #libc.src.math.isnanf128
     #libc.src.math.issignalingf128
+    #libc.src.math.llogbf128
     #libc.src.math.llrint
     #libc.src.math.llrintf
     #libc.src.math.llrintf128
@@ -212,6 +215,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.logf
     #libc.src.math.logb
     #libc.src.math.logbf
+    #libc.src.math.logbf128
     #libc.src.math.logbl
     #libc.src.math.modf
     #libc.src.math.modff
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 8f6c178301c2f2..5b315f0432a5b1 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -220,6 +220,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmodl
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fsub
     libc.src.math.fsubl
@@ -227,6 +228,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnanf128
@@ -253,6 +255,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.logf
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.lrint
     libc.src.math.lrintf
@@ -359,6 +362,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
     libc.src.math.issignalingl
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.nextdown
     libc.src.math.nextdownf
@@ -532,16 +536,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5c5e5891da8227..37c4dc76a708fb 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -415,6 +415,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -433,6 +434,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnan
@@ -448,6 +450,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -466,6 +469,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index afae725484a891..1b509e8e7de64a 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -411,6 +411,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     # FIXME: Broken.
     # libc.src.math.fromfp
@@ -430,6 +431,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnan
@@ -445,6 +447,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -463,6 +466,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index b8ea3258262c83..baf9f2fbd406a3 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -700,6 +700,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -718,6 +719,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -737,6 +739,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -755,6 +758,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -998,16 +1002,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index f7714b2049a27f..2fc9416a2af797 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -494,6 +494,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmul
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -510,6 +511,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnanf128
@@ -520,6 +522,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -538,6 +541,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index af7586e61e098f..2439c59cbe7f68 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -757,6 +757,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -775,6 +776,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -794,6 +796,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -812,6 +815,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -1072,16 +1076,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index b386e049255b56..0b0bf8dcdf0b70 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -779,6 +779,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -797,6 +798,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -816,6 +818,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -834,6 +837,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -1094,16 +1098,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     libc.src.math.fmodf128
     libc.src.math.fmulf128
-    libc.src.math.frexpf128
     libc.src.math.fromfpf128
     libc.src.math.fromfpxf128
     libc.src.math.fsqrtf128
     libc.src.math.fsubf128
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a48b49e169b3a..30595789f1d8cf 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -253,6 +253,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmodl
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fsub
     libc.src.math.fsubl
@@ -260,6 +261,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnanf128
@@ -268,6 +270,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.ldexpf
     libc.src.math.ldexpl
     libc.src.math.lgammaf
+    libc.src.math.llogbf128
     libc.src.math.llrint
     libc.src.math.llrintf
     libc.src.math.llrintf128
@@ -286,6 +289,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.logf
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.lrint
     libc.src.math.lrintf
diff --git a/libc/shared/math/frexpf128.h b/libc/shared/math/frexpf128.h
index 13b48635a77ba4..5f2c943cccd610 100644
--- a/libc/shared/math/frexpf128.h
+++ b/libc/shared/math/frexpf128.h
@@ -1,18 +1,19 @@
-//===-- Shared frexpf128 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 frexp function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_FREXPF128_H
 #define LLVM_LIBC_SHARED_MATH_FREXPF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/frexpf128.h"
 
@@ -24,6 +25,4 @@ using math::frexpf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_FREXPF128_H
diff --git a/libc/shared/math/ilogbf128.h b/libc/shared/math/ilogbf128.h
index 072cd1bbb7711a..b5cd1b36c1b9e8 100644
--- a/libc/shared/math/ilogbf128.h
+++ b/libc/shared/math/ilogbf128.h
@@ -1,18 +1,19 @@
-//===-- Shared ilogbf128 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 ilogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_ILOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_ILOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/ilogbf128.h"
 
@@ -24,6 +25,4 @@ using math::ilogbf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_ILOGBF128_H
diff --git a/libc/shared/math/llogbf128.h b/libc/shared/math/llogbf128.h
index f6f945c372f1e5..e6b35748756c40 100644
--- a/libc/shared/math/llogbf128.h
+++ b/libc/shared/math/llogbf128.h
@@ -1,18 +1,19 @@
-//===-- Shared llogbf128 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 llogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_LLOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_LLOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/llogbf128.h"
 
@@ -24,6 +25,4 @@ using math::llogbf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_LLOGBF128_H
diff --git a/libc/shared/math/logbf128.h b/libc/shared/math/logbf128.h
index 95c37fe88b8cd5..ad24c4386f81dc 100644
--- a/libc/shared/math/logbf128.h
+++ b/libc/shared/math/logbf128.h
@@ -1,18 +1,19 @@
-//===-- Shared logbf128 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 logb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_LOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_LOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/logbf128.h"
 
@@ -24,6 +25,4 @@ using math::logbf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_LOGBF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index ef33e3f8ada7b0..960b64c14d8f97 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -3859,8 +3859,10 @@ add_header_library(
   HDRS
     frexpf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
+    libc.src.__support.common
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
 )
 
 add_header_library(
@@ -4044,9 +4046,10 @@ add_header_library(
   HDRS
     ilogbf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
+    libc.src.__support.common
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
-    libc.include.llvm-libc-types.float128
+    libc.src.__support.macros.config
 )
 
 add_header_library(
@@ -4123,9 +4126,10 @@ add_header_library(
   HDRS
     llogbf128.h
   DEPENDS
-    libc.src.__support.macros.config
+    libc.src.__support.common
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
-    libc.include.llvm-libc-types.float128
+    libc.src.__support.macros.config
 )
 
 add_header_library(
@@ -5312,8 +5316,10 @@ add_header_library(
   HDRS
     logbf128.h
   DEPENDS
+    libc.src.__support.common
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
-    libc.src.__support.macros.properties.types
+    libc.src.__support.macros.config
 )
 
 add_header_library(
diff --git a/libc/src/__support/math/frexpf128.h b/libc/src/__support/math/frexpf128.h
index a16e401889cb36..4c54ce1337d7dd 100644
--- a/libc/src/__support/math/frexpf128.h
+++ b/libc/src/__support/math/frexpf128.h
@@ -1,19 +1,21 @@
-//===-- Implementation header for expf --------------------------*- 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 frexp function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_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/common.h"
 #include "src/__support/macros/config.h"
 
@@ -21,7 +23,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float128 frexpf128(float128 x, int *exp) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 frexpf128(Float128 x, int *exp) {
   return fputil::frexp(x, *exp);
 }
 
@@ -29,6 +33,4 @@ LIBC_INLINE constexpr float128 frexpf128(float128 x, int *exp) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
diff --git a/libc/src/__support/math/ilogbf128.h b/libc/src/__support/math/ilogbf128.h
index 9ea71fc47c7b50..8f037d568b66d4 100644
--- a/libc/src/__support/math/ilogbf128.h
+++ b/libc/src/__support/math/ilogbf128.h
@@ -1,19 +1,21 @@
-//===-- Implementation header for ilogbf128 --------------------*- 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 ilogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_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/common.h"
 #include "src/__support/macros/config.h"
 
@@ -21,7 +23,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr int ilogbf128(float128 x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr int ilogbf128(Float128 x) {
   return fputil::intlogb<int>(x);
 }
 
@@ -29,6 +33,4 @@ LIBC_INLINE constexpr int ilogbf128(float128 x) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
diff --git a/libc/src/__support/math/llogbf128.h b/libc/src/__support/math/llogbf128.h
index da925e81d1aa52..bad2e09a6e48f5 100644
--- a/libc/src/__support/math/llogbf128.h
+++ b/libc/src/__support/math/llogbf128.h
@@ -1,19 +1,21 @@
-//===-- Implementation header for llogbf128 ---------------------*- 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 llogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_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/common.h"
 #include "src/__support/macros/config.h"
 
@@ -21,7 +23,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr long llogbf128(float128 x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr long llogbf128(Float128 x) {
   return fputil::intlogb<long>(x);
 }
 
@@ -29,6 +33,4 @@ LIBC_INLINE constexpr long llogbf128(float128 x) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
diff --git a/libc/src/__support/math/logbf128.h b/libc/src/__support/math/logbf128.h
index f4671c0a944273..4a7569df351361 100644
--- a/libc/src/__support/math/logbf128.h
+++ b/libc/src/__support/math/logbf128.h
@@ -1,19 +1,21 @@
-//===-- Implementation header for logbf128-----------------------*- 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 logb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_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/common.h"
 #include "src/__support/macros/config.h"
 
@@ -21,12 +23,12 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float128 logbf128(float128 x) { return fputil::logb(x); }
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 logbf128(Float128 x) { return fputil::logb(x); }
 
 } // namespace math
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
diff --git a/libc/src/math/frexpf128.h b/libc/src/math/frexpf128.h
index e143e6f17ffb31..78a34ba7e9ebcc 100644
--- a/libc/src/math/frexpf128.h
+++ b/libc/src/math/frexpf128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for frexpf128 ---------------------*- 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 frexp function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC_MATH_FREXPF128_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 frexpf128(float128 x, int *exp);
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 28b8e954530ddf..5e9d7386d5dc46 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1527,6 +1527,7 @@ add_entrypoint_object(
   HDRS
     ../frexpf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.frexpf128
 )
 
@@ -1588,6 +1589,7 @@ add_entrypoint_object(
   HDRS
     ../ilogbf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.ilogbf128
 )
 
@@ -1675,6 +1677,7 @@ add_entrypoint_object(
   HDRS
     ../llogbf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.llogbf128
 )
 
@@ -1942,6 +1945,7 @@ add_entrypoint_object(
   HDRS
     ../logbf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.logbf128
     libc.src.errno.errno
 )
diff --git a/libc/src/math/generic/frexpf128.cpp b/libc/src/math/generic/frexpf128.cpp
index 55f7afcf4aea55..8e7edbb3ed6994 100644
--- a/libc/src/math/generic/frexpf128.cpp
+++ b/libc/src/math/generic/frexpf128.cpp
@@ -1,19 +1,27 @@
-//===-- Implementation of frexpf128 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 frexpf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/frexpf128.h"
-
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/frexpf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
+using LIBC_NAMESPACE::fputil::Float128;
+
 LLVM_LIBC_FUNCTION(float128, frexpf128, (float128 x, int *exp)) {
-  return math::frexpf128(x, exp);
+  return cpp::bit_cast<float128>(
+      math::frexpf128(cpp::bit_cast<Float128>(x), exp));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ilogbf128.cpp b/libc/src/math/generic/ilogbf128.cpp
index 2cb6032dfdbb85..19aacc27a42b91 100644
--- a/libc/src/math/generic/ilogbf128.cpp
+++ b/libc/src/math/generic/ilogbf128.cpp
@@ -1,16 +1,26 @@
-//===-- Implementation of ilogbf128 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 ilogbf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/ilogbf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/ilogbf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, ilogbf128, (float128 x)) { return math::ilogbf128(x); }
+using LIBC_NAMESPACE::fputil::Float128;
+
+LLVM_LIBC_FUNCTION(int, ilogbf128, (float128 x)) {
+  return math::ilogbf128(cpp::bit_cast<Float128>(x));
+}
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llogbf128.cpp b/libc/src/math/generic/llogbf128.cpp
index 6f8f9c4c853b8e..e046cb6a1f8629 100644
--- a/libc/src/math/generic/llogbf128.cpp
+++ b/libc/src/math/generic/llogbf128.cpp
@@ -1,16 +1,26 @@
-//===-- Implementation of llogbf128 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 llogbf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/llogbf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/llogbf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, llogbf128, (float128 x)) { return math::llogbf128(x); }
+using LIBC_NAMESPACE::fputil::Float128;
+
+LLVM_LIBC_FUNCTION(long, llogbf128, (float128 x)) {
+  return math::llogbf128(cpp::bit_cast<Float128>(x));
+}
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/logbf128.cpp b/libc/src/math/generic/logbf128.cpp
index e70a04c6aa1002..9d815aa5ae0069 100644
--- a/libc/src/math/generic/logbf128.cpp
+++ b/libc/src/math/generic/logbf128.cpp
@@ -1,18 +1,26 @@
-//===-- Implementation of logbf128 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 logbf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/logbf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/logbf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
+using LIBC_NAMESPACE::fputil::Float128;
+
 LLVM_LIBC_FUNCTION(float128, logbf128, (float128 x)) {
-  return math::logbf128(x);
+  return cpp::bit_cast<float128>(math::logbf128(cpp::bit_cast<Float128>(x)));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/ilogbf128.h b/libc/src/math/ilogbf128.h
index 9ea5e89fdf9930..92d61da35a7693 100644
--- a/libc/src/math/ilogbf128.h
+++ b/libc/src/math/ilogbf128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for ilogbf128 ---------------------*- 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 ilogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC_MATH_ILOGBF128_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 ilogbf128(float128 x);
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/llogbf128.h b/libc/src/math/llogbf128.h
index 1ad49320202573..d1d1527d81a3ef 100644
--- a/libc/src/math/llogbf128.h
+++ b/libc/src/math/llogbf128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for llogbf128 ---------------------*- 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 llogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC_MATH_LLOGBF128_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
+
 long llogbf128(float128 x);
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/logbf128.h b/libc/src/math/logbf128.h
index 9ce23978707be4..6754f2974e4621 100644
--- a/libc/src/math/logbf128.h
+++ b/libc/src/math/logbf128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for logbf128  ---------------------*- 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 logb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC_MATH_LOGBF128_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 logbf128(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 ec7f99a9ff40c0..4c2d2268ba3371 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -437,11 +437,18 @@ static_assert(Float128(0.0) ==
 static_assert(Float128(0.0) ==
               LIBC_NAMESPACE::shared::fminimum_numf128(Float128(0.0),
                                                        Float128(0.0)));
+static_assert(Float128(0.0) == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::frexpf128(Float128(0.0), &exp);
+}());
+static_assert(0 == LIBC_NAMESPACE::shared::ilogbf128(Float128(1.0)));
 static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
 static_assert(0 == LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
+static_assert(0L == LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
+static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::logbf128(Float128(1.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) ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7b785331f36c6a..4a4b870260b5e5 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -581,6 +581,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
 
 // Emulated float128 tests
 TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
+  int exponent;
+
   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)));
@@ -610,11 +612,17 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
                                   Float128(0.0), Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
                                   Float128(0.0), Float128(0.0)));
+  EXPECT_FP_EQ_ALL_ROUNDING(Float128(0.75), LIBC_NAMESPACE::shared::frexpf128(
+                                                Float128(24), &exponent));
+  EXPECT_EQ(exponent, 5);
+  EXPECT_EQ(3, LIBC_NAMESPACE::shared::ilogbf128(Float128(8.0)));
   EXPECT_EQ(1, LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
+  EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf128(Float128(0.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0),
@@ -631,27 +639,18 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
 
 TEST(LlvmLibcSharedMathTest, AllFloat128) {
   using FPBits = LIBC_NAMESPACE::fputil::FPBits<float128>;
-  int exponent;
 
   EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::ffmaf128(
                          float128(0.0), float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::shared::fsqrtf128(float128(1.0f)));
-  EXPECT_FP_EQ_ALL_ROUNDING(float128(0.75), LIBC_NAMESPACE::shared::frexpf128(
-                                                float128(24), &exponent));
-  EXPECT_EQ(exponent, 5);
-
-  EXPECT_EQ(3, LIBC_NAMESPACE::shared::ilogbf128(float128(8.0)));
   ASSERT_FP_EQ(float128(8 << 5),
                LIBC_NAMESPACE::shared::ldexpf128(float128(8), 5));
   ASSERT_FP_EQ(float128(-1 * (8 << 5)),
                LIBC_NAMESPACE::shared::ldexpf128(float128(-8), 5));
-  EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::logbf128(float128(1.0)));
   EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::dfmaf128(
                         float128(0.0), float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::dsqrtf128(float128(0.0)));
 
-  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf128(float128(1.0)));
-
   EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf128(
                                   float128(2.0), float128(3.0)));
 
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 92d599fba947e5..7bc3b20f4b1348 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1610,6 +1610,21 @@ add_fp_unittest(
     libc.src.__support.FPUtil.basic_operations
 )
 
+add_fp_unittest(
+  frexpf128_test
+  NEED_MPFR_F128
+  SUITE
+    libc-math-unittests
+  SRCS
+    frexpf128_test.cpp
+  HDRS
+    FrexpTest.h
+  DEPENDS
+    libc.src.math.frexpf128
+    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.FPUtil.float128
+)
+
 add_fp_unittest(
   ilogb_test
   SUITE
@@ -1655,6 +1670,22 @@ add_fp_unittest(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_fp_unittest(
+  ilogbf128_test
+  SUITE
+    libc-math-unittests
+  SRCS
+    ilogbf128_test.cpp
+  HDRS
+    ILogbTest.h
+  DEPENDS
+    libc.src.math.ilogbf128
+    libc.src.__support.CPP.limits
+    libc.src.__support.FPUtil.float128
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_fp_unittest(
   ldexp_test
   SUITE
@@ -1735,6 +1766,20 @@ add_fp_unittest(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_fp_unittest(
+  logbf128_test
+  SUITE
+    libc-math-unittests
+  SRCS
+    logbf128_test.cpp
+  HDRS
+    LogbTest.h
+  DEPENDS
+    libc.src.math.logbf128
+    libc.src.__support.FPUtil.float128
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_fp_unittest(
   modf_test
   SUITE
diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h
index 3357ef4df73d56..e9887795379cd0 100644
--- a/libc/test/src/math/ILogbTest.h
+++ b/libc/test/src/math/ILogbTest.h
@@ -47,13 +47,13 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     EXPECT_EQ(2, func(T(-4.0)));
 
     EXPECT_EQ(3, func(T(8.0)));
-    EXPECT_EQ(3, func(-8.0));
+    EXPECT_EQ(3, func(T(-8.0)));
 
-    EXPECT_EQ(4, func(16.0));
-    EXPECT_EQ(4, func(-16.0));
+    EXPECT_EQ(4, func(T(16.0)));
+    EXPECT_EQ(4, func(T(-16.0)));
 
-    EXPECT_EQ(5, func(32.0));
-    EXPECT_EQ(5, func(-32.0));
+    EXPECT_EQ(5, func(T(32.0)));
+    EXPECT_EQ(5, func(T(-32.0)));
   }
 
   template <typename T>
@@ -68,10 +68,10 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     EXPECT_EQ(3, func(T(-10.0)));
 
     EXPECT_EQ(4, func(T(31.0)));
-    EXPECT_EQ(4, func(-31.0));
+    EXPECT_EQ(4, func(T(-31.0)));
 
-    EXPECT_EQ(5, func(55.0));
-    EXPECT_EQ(5, func(-55.0));
+    EXPECT_EQ(5, func(T(55.0)));
+    EXPECT_EQ(5, func(T(-55.0)));
   }
 
   template <typename T>
@@ -84,7 +84,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
     for (StorageType v = MIN_SUBNORMAL; v <= MAX_SUBNORMAL; v += STEP) {
       T x = FPBits(v).get_val();
-      if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0)
+      if (FPBits(v).is_nan() || FPBits(v).is_inf() || FPBits(v).is_zero())
         continue;
 
       int exponent;
@@ -103,7 +103,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
     for (StorageType v = MIN_NORMAL; v <= MAX_NORMAL; v += STEP) {
       T x = FPBits(v).get_val();
-      if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0)
+      if (FPBits(v).is_nan() || FPBits(v).is_inf() || FPBits(v).is_zero())
         continue;
 
       int exponent;
diff --git a/libc/test/src/math/LogbTest.h b/libc/test/src/math/LogbTest.h
index 5eda0f648a117d..310c861eac80d2 100644
--- a/libc/test/src/math/LogbTest.h
+++ b/libc/test/src/math/LogbTest.h
@@ -31,8 +31,8 @@ class LogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     ASSERT_FP_EQ(aNaN, func(aNaN));
     ASSERT_FP_EQ(inf, func(inf));
     ASSERT_FP_EQ(inf, func(neg_inf));
-    ASSERT_FP_EQ(neg_inf, func(0.0));
-    ASSERT_FP_EQ(neg_inf, func(-0.0));
+    ASSERT_FP_EQ(neg_inf, func(zero));
+    ASSERT_FP_EQ(neg_inf, func(neg_zero));
   }
 
   void testPowersOfTwo(LogbFunc func) {
@@ -78,7 +78,7 @@ class LogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     constexpr StorageType STEP = STORAGE_MAX / COUNT;
     for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
       T x = FPBits(v).get_val();
-      if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0l)
+      if (FPBits(v).is_nan() || FPBits(v).is_inf() || FPBits(v).is_zero())
         continue;
 
       int exponent;
diff --git a/libc/test/src/math/frexpf128_test.cpp b/libc/test/src/math/frexpf128_test.cpp
new file mode 100644
index 00000000000000..e9c3db41eff114
--- /dev/null
+++ b/libc/test/src/math/frexpf128_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
+/// Unittests for the frexpf128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "FrexpTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/frexpf128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_FREXP_TESTS(Frexpf128, float128, LIBC_NAMESPACE::frexpf128)
diff --git a/libc/test/src/math/ilogbf128_test.cpp b/libc/test/src/math/ilogbf128_test.cpp
new file mode 100644
index 00000000000000..9ffb0cc4082ad8
--- /dev/null
+++ b/libc/test/src/math/ilogbf128_test.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unittests for the ilogbf128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "ILogbTest.h"
+
+#include "hdr/math_macros.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/ilogbf128.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogbf128) {
+  test_special_numbers<float128>(&LIBC_NAMESPACE::ilogbf128);
+}
+
+TEST_F(LlvmLibcILogbTest, PowersOfTwo_ilogbf128) {
+  test_powers_of_two<float128>(&LIBC_NAMESPACE::ilogbf128);
+}
+
+TEST_F(LlvmLibcILogbTest, SomeIntegers_ilogbf128) {
+  test_some_integers<float128>(&LIBC_NAMESPACE::ilogbf128);
+}
+
+TEST_F(LlvmLibcILogbTest, SubnormalRange_ilogbf128) {
+  test_subnormal_range<float128>(&LIBC_NAMESPACE::ilogbf128);
+}
+
+TEST_F(LlvmLibcILogbTest, NormalRange_ilogbf128) {
+  test_normal_range<float128>(&LIBC_NAMESPACE::ilogbf128);
+}
diff --git a/libc/test/src/math/logbf128_test.cpp b/libc/test/src/math/logbf128_test.cpp
new file mode 100644
index 00000000000000..e96154e30f3767
--- /dev/null
+++ b/libc/test/src/math/logbf128_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
+/// Unittests for the logbf128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "LogbTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/logbf128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_LOGB_TESTS(Logbf128, float128, LIBC_NAMESPACE::logbf128)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index d647c24cfcf365..678d25fa38ca64 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1744,6 +1744,7 @@ add_fp_unittest(
     FrexpTest.h
   DEPENDS
     libc.src.math.frexpf128
+    libc.src.__support.FPUtil.float128
 )
 
 add_fp_unittest(
@@ -2123,6 +2124,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.ilogbf128
     libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.manipulation_functions
 )
@@ -2300,6 +2302,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.llogbf128
     libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.manipulation_functions
 )
@@ -2484,6 +2487,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.logbf128
     libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
 )
 
diff --git a/libc/test/src/math/smoke/frexpf128_test.cpp b/libc/test/src/math/smoke/frexpf128_test.cpp
index 20579f25f93612..eda4cc0b3d55ee 100644
--- a/libc/test/src/math/smoke/frexpf128_test.cpp
+++ b/libc/test/src/math/smoke/frexpf128_test.cpp
@@ -1,13 +1,23 @@
-//===-- Unittests for frexpf128 -------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // 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 frexpf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "FrexpTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/frexpf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_FREXP_TESTS(Frexpf128, float128, LIBC_NAMESPACE::frexpf128);
diff --git a/libc/test/src/math/smoke/ilogbf128_test.cpp b/libc/test/src/math/smoke/ilogbf128_test.cpp
index 48ba5e0e060eb8..cd8c848a76ee92 100644
--- a/libc/test/src/math/smoke/ilogbf128_test.cpp
+++ b/libc/test/src/math/smoke/ilogbf128_test.cpp
@@ -1,13 +1,23 @@
-//===-- Unittests for ilogbf128 -------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // 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 ilogbf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "ILogbTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/ilogbf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_INTLOGB_TESTS(Ilogbf128, int, float128, LIBC_NAMESPACE::ilogbf128);
diff --git a/libc/test/src/math/smoke/llogbf128_test.cpp b/libc/test/src/math/smoke/llogbf128_test.cpp
index c3263f1f2d1ee2..4f1f42c4dcb104 100644
--- a/libc/test/src/math/smoke/llogbf128_test.cpp
+++ b/libc/test/src/math/smoke/llogbf128_test.cpp
@@ -1,13 +1,23 @@
-//===-- Unittests for llogbf128 -------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // 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 llogbf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "ILogbTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/llogbf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_INTLOGB_TESTS(Llogbf128, long, float128, LIBC_NAMESPACE::llogbf128);
diff --git a/libc/test/src/math/smoke/logbf128_test.cpp b/libc/test/src/math/smoke/logbf128_test.cpp
index 9bfd667ee10ef4..ff3e55880ec5c8 100644
--- a/libc/test/src/math/smoke/logbf128_test.cpp
+++ b/libc/test/src/math/smoke/logbf128_test.cpp
@@ -1,13 +1,23 @@
-//===-- Unittests for logbf128 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // 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 logbf128 function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "LogbTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/logbf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_LOGB_TESTS(Logbf128, float128, LIBC_NAMESPACE::logbf128)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 83500cb59de9d8..41db72c53da6bb 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -338,6 +338,10 @@ template void explain_unary_operation_two_outputs_error<float16>(
 #endif
 template void explain_unary_operation_two_outputs_error<bfloat16>(
     Operation, bfloat16, const BinaryOutput<bfloat16> &, double, RoundingMode);
+#ifdef LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
+template void explain_unary_operation_two_outputs_error<float128>(
+    Operation, float128, const BinaryOutput<float128> &, double, RoundingMode);
+#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
 
 template <typename T>
 void explain_binary_operation_two_outputs_error(
@@ -625,6 +629,10 @@ template bool compare_unary_operation_two_outputs<float16>(
 #endif
 template bool compare_unary_operation_two_outputs<bfloat16>(
     Operation, bfloat16, const BinaryOutput<bfloat16> &, double, RoundingMode);
+#ifdef LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
+template bool compare_unary_operation_two_outputs<float128>(
+    Operation, float128, const BinaryOutput<float128> &, double, RoundingMode);
+#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
 
 template <typename T>
 bool compare_binary_operation_two_outputs(Operation op,
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 5086cdaa77ed7f..1abcc38599a404 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -9475,9 +9475,9 @@ libc_support_library(
     hdrs = ["src/__support/math/frexpf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -9486,10 +9486,9 @@ libc_support_library(
     hdrs = ["src/__support/math/ilogbf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
-        ":__support_macros_properties_types",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -9888,9 +9887,9 @@ libc_support_library(
     hdrs = ["src/__support/math/llogbf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -10264,9 +10263,9 @@ libc_support_library(
     hdrs = ["src/__support/math/logbf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -13688,6 +13687,8 @@ libc_math_function(
 libc_math_function(
     name = "frexpf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_frexpf128",
     ],
 )
@@ -13897,6 +13898,8 @@ libc_math_function(
 libc_math_function(
     name = "ilogbf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_ilogbf128",
     ],
 )
@@ -13989,6 +13992,8 @@ libc_math_function(
 libc_math_function(
     name = "llogbf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_llogbf128",
     ],
 )
@@ -14196,6 +14201,8 @@ libc_math_function(
 libc_math_function(
     name = "logbf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_logbf128",
     ],
 )
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 bb65e582cacd05..534fb380897ee4 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
@@ -409,6 +409,14 @@ math_mpfr_test(
     hdrs = ["FrexpTest.h"],
 )
 
+math_mpfr_test(
+    name = "frexpf128",
+    hdrs = ["FrexpTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
+)
+
 math_mpfr_test(
     name = "fsqrt",
     hdrs = ["SqrtTest.h"],
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 d7492346e08cf9..b53edcd783509e 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
@@ -1148,6 +1148,9 @@ math_test(
 math_test(
     name = "frexpf128",
     hdrs = ["FrexpTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(
@@ -1318,6 +1321,9 @@ math_test(
 math_test(
     name = "ilogbf128",
     hdrs = ["ILogbTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(
@@ -1379,6 +1385,9 @@ math_test(
 math_test(
     name = "llogbf128",
     hdrs = ["ILogbTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(
@@ -1535,6 +1544,9 @@ math_test(
 math_test(
     name = "logbf128",
     hdrs = ["LogbTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(

>From c2196098de6991c217500d91f6543805500b4849 Mon Sep 17 00:00:00 2001
From: Mohammed Sohail <mohd.sohail.biz at gmail.com>
Date: Sun, 18 Oct 2026 21:54:01 +0530
Subject: [PATCH 2/2] Re-run CI




More information about the libc-commits mailing list