[libc-commits] [libc] [libc][math] Add iscanonical functions to math.yaml (PR #199317)

via libc-commits libc-commits at lists.llvm.org
Fri May 22 21:06:54 PDT 2026


https://github.com/jofrn created https://github.com/llvm/llvm-project/pull/199317

[libc][math] Add iscanonical functions to math.yaml
    
    Surface the existing iscanonical, iscanonicalf, iscanonicalf128,
    iscanonicalf16, and iscanonicall implementations through the
    generated math.h. Addresses part of #199266.
    
    To test:
    `cmake -Bbuild -Sruntimes -GNinja -DLLVM_ENABLE_RUNTIMES=libc -DLLVM_LIBC_FULL_BUILD=ON`
    `pip install pyyaml`
    `ninja -C build libc.include.math.__generated_hdr__`
    
    Add `-DLIBC_TYPES_HAS_FLOAT128=ON` to test for iscanonicalf128
    in cmake invocation if host does not support it.

>From 3bea19d85c172ac48daae055e4dae7dec6ced7a2 Mon Sep 17 00:00:00 2001
From: jofrn <165626406+jofrn at users.noreply.github.com>
Date: Fri, 22 May 2026 19:48:45 -0700
Subject: [PATCH] [libc][math] Add iscanonical functions to math.yaml

Surface the existing iscanonical, iscanonicalf, iscanonicalf128,
iscanonicalf16, and iscanonicall implementations through the
generated math.h. Addresses part of #199266.

To test:
`cmake -Bbuild -Sruntimes -GNinja -DLLVM_ENABLE_RUNTIMES=libc -DLLVM_LIBC_FULL_BUILD=ON`
`pip install pyyaml`
`ninja -C build libc.include.math.__generated_hdr__`

Add `-DLIBC_TYPES_HAS_FLOAT128=ON` to test for iscanonicalf128
in cmake invocation if host does not support it.
---
 libc/include/math.yaml | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/libc/include/math.yaml b/libc/include/math.yaml
index 36ff380a1b305..0d9181f1ff173 100644
--- a/libc/include/math.yaml
+++ b/libc/include/math.yaml
@@ -1588,6 +1588,38 @@ functions:
     return_type: int
     arguments:
       - type: long double
+  - name: iscanonical
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: double
+  - name: iscanonicalf
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: float
+  - name: iscanonicalf128
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT128
+  - name: iscanonicalf16
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: _Float16
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: iscanonicall
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: long double
   - name: isnan
     standards:
       - bsd



More information about the libc-commits mailing list