[libc-commits] [libc] [libc] Canonicalize generated fenv.h (PR #127363)

Roland McGrath via libc-commits libc-commits at lists.llvm.org
Mon Feb 17 15:14:14 PST 2025


https://github.com/frobtech updated https://github.com/llvm/llvm-project/pull/127363

>From c9815006378601d9277b48b676a39e5741fd2610 Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr at google.com>
Date: Fri, 14 Feb 2025 01:08:30 -0800
Subject: [PATCH 1/2] [libc] Canonicalize generated fenv.h

This removes the custom template for fenv.h by declaring all the
standard-specified macros using macro_header.
---
 libc/include/fenv.h.def | 17 -----------------
 libc/include/fenv.yaml  | 33 ++++++++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 24 deletions(-)
 delete mode 100644 libc/include/fenv.h.def

diff --git a/libc/include/fenv.h.def b/libc/include/fenv.h.def
deleted file mode 100644
index c677b2a5930dc..0000000000000
--- a/libc/include/fenv.h.def
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- C standard library header fenv.h ----------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_FENV_H
-#define LLVM_LIBC_FENV_H
-
-#include "__llvm-libc-common.h"
-#include "llvm-libc-macros/fenv-macros.h"
-
-%%public_api()
-
-#endif // LLVM_LIBC_FENV_H
diff --git a/libc/include/fenv.yaml b/libc/include/fenv.yaml
index 1ecaf63085504..8d0bf27d34162 100644
--- a/libc/include/fenv.yaml
+++ b/libc/include/fenv.yaml
@@ -1,11 +1,30 @@
 header: fenv.h
-header_template: fenv.h.def
-macros: []
+standards:
+  - stdc
+macros:
+  - macro_name: FE_ALL_EXCEPT
+    macro_header: fenv-macros.h
+  - macro_name: FE_DIVBYZERO
+    macro_header: fenv-macros.h
+  - macro_name: FE_INEXACT
+    macro_header: fenv-macros.h
+  - macro_name: FE_INVALID
+    macro_header: fenv-macros.h
+  - macro_name: FE_OVERFLOW
+    macro_header: fenv-macros.h
+  - macro_name: FE_UNDERFLOW
+    macro_header: fenv-macros.h
+  - macro_name: FE_DOWNWARD
+    macro_header: fenv-macros.h
+  - macro_name: FE_DOWNWARD
+    macro_header: fenv-macros.h
+  - macro_name: FE_UPWARD
+    macro_header: fenv-macros.h
+  - macro_name: FE_DFL_ENV
+    macro_header: fenv-macros.h
 types:
   - type_name: fenv_t
   - type_name: fexcept_t
-enums: []
-objects: []
 functions:
   - name: feclearexcept
     standards:
@@ -15,14 +34,14 @@ functions:
       - type: int
   - name: fedisableexcept
     standards:
-      - GNUExtensions
+      - gnu
     return_type: int
     arguments:
       - type: int
     guard: null
   - name: feenableexcept
     standards:
-      - GNUExtensions
+      - gnu
     return_type: int
     arguments:
       - type: int
@@ -35,7 +54,7 @@ functions:
       - type: fenv_t *
   - name: fegetexcept
     standards:
-      - GNUExtensions
+      - gnu
     return_type: int
     arguments: []
   - name: fegetexceptflag

>From da7e4f22aa86cfc6a817d8904f3e1d6376be4f7c Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr at google.com>
Date: Mon, 17 Feb 2025 15:12:20 -0800
Subject: [PATCH 2/2] Fix missing FE_* macros

---
 libc/include/fenv.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libc/include/fenv.yaml b/libc/include/fenv.yaml
index 8d0bf27d34162..c7cc7e87df37f 100644
--- a/libc/include/fenv.yaml
+++ b/libc/include/fenv.yaml
@@ -16,7 +16,9 @@ macros:
     macro_header: fenv-macros.h
   - macro_name: FE_DOWNWARD
     macro_header: fenv-macros.h
-  - macro_name: FE_DOWNWARD
+  - macro_name: FE_TONEAREST
+    macro_header: fenv-macros.h
+  - macro_name: FE_TOWARDZERO
     macro_header: fenv-macros.h
   - macro_name: FE_UPWARD
     macro_header: fenv-macros.h



More information about the libc-commits mailing list