[libc-commits] [libc] [libc] Removed __LIBC_CONST_ATTR attribute and updated math.yaml with the new math functions (PR #99571)

via libc-commits libc-commits at lists.llvm.org
Thu Jul 18 15:51:15 PDT 2024


https://github.com/RoseZhang03 updated https://github.com/llvm/llvm-project/pull/99571

>From ca905a9f1cb72cb492521e365d66b72b283b40f3 Mon Sep 17 00:00:00 2001
From: Rose Zhang <rosezhang at google.com>
Date: Thu, 18 Jul 2024 21:18:20 +0000
Subject: [PATCH 1/2] [libc] Removed __LIBC_CONST_ATTR attribute and updated
 math.yaml with the new math functions

- deleted attribute from fabs function
- added math functions from #98972
---
 libc/newhdrgen/yaml/math.yaml | 64 +++++++++++++++++++++++++++++++++--
 1 file changed, 62 insertions(+), 2 deletions(-)

diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml
index 8588389bca4d2..ce562c653a6d2 100644
--- a/libc/newhdrgen/yaml/math.yaml
+++ b/libc/newhdrgen/yaml/math.yaml
@@ -64,8 +64,6 @@ functions:
     return_type: double
     arguments:
       - type: double
-    attributes:
-      - __LIBC_CONST_ATTR
   - name: fabsf
     standards: 
       - stdc
@@ -364,6 +362,20 @@ functions:
     arguments:
       - type: double
       - type: double
+  - name: fmull
+    standards:
+      - stdc
+    return_type: float
+    arguments:
+      - type: long double
+      - type: long double
+  - name: dmull
+    standards:
+      - stdc
+    return_type: double
+    arguments:
+      - type: long double
+      - type: long double
   - name: frexp
     standards: 
       - stdc
@@ -1323,6 +1335,30 @@ functions:
       - type: long double
       - type: long double
     guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16mul
+    standards:
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: double
+      - type: double
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16mulf
+    standards:
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: float
+      - type: float
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16mull
+    standards:
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: long double
+      - type: long double
+    guard: LIBC_TYPES_HAS_FLOAT16
   - name: f16sqrt
     standards: 
       - llvm_libc_ext
@@ -1756,6 +1792,14 @@ functions:
       - type: float128
       - type: float128
     guard: LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
+  - name: f16mulf128
+    standards:
+      - stdc
+    return_type: _Float16
+    arguments:
+      - type: float128
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
   - name: f16sqrtf128
     standards: 
       - llvm_libc_ext
@@ -1896,6 +1940,22 @@ functions:
       - type: float128
       - type: float128
     guard: LIBC_TYPES_HAS_FLOAT128
+  - name: fmulf128
+    standards:
+      - llvm_libc_ext
+    return_type: float
+    arguments:
+      - type: float128
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT128
+  - name: dmulf128
+    standards:
+      - llvm_libc_ext
+    return_type: double
+    arguments:
+      - type: float128
+      - type: float128
+    guard: LIBC_TYPES_HAS_FLOAT128
   - name: frexpf128
     standards: 
       - stdc

>From fe88268af6f9b54a819fd54b9937ecb685f880b9 Mon Sep 17 00:00:00 2001
From: Rose Zhang <rosezhang at google.com>
Date: Thu, 18 Jul 2024 22:50:56 +0000
Subject: [PATCH 2/2] statvfs.h is now able to be generated

---
 libc/config/linux/api.td                  | 2 +-
 libc/config/linux/x86_64/headers.txt      | 3 +--
 libc/newhdrgen/yaml/sys/sys_statvfs.yaml  | 2 ++
 libc/src/sys/statvfs/linux/CMakeLists.txt | 6 +++---
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index a10dec06e2452..320f3e92183bf 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -267,5 +267,5 @@ def SearchAPI : PublicAPI<"search.h"> {
 }
 
 def SysStatvfsAPI : PublicAPI<"sys/statvfs.h"> {
-  let Types = ["fsblkcnt_t", "fsfilcnt_t", "struct statvfs"];
+  let Types = ["struct statvfs"];
 }
diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt
index 8a52d80e1fbfb..0294f62bc2f7a 100644
--- a/libc/config/linux/x86_64/headers.txt
+++ b/libc/config/linux/x86_64/headers.txt
@@ -45,8 +45,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.sys_select
     libc.include.sys_socket
     libc.include.sys_stat
-    # statvfs is broken, will uncomment once it's fixed.
-    # libc.include.sys_statvfs
+    libc.include.sys_statvfs
     libc.include.sys_syscall
     libc.include.sys_time
     libc.include.sys_types
diff --git a/libc/newhdrgen/yaml/sys/sys_statvfs.yaml b/libc/newhdrgen/yaml/sys/sys_statvfs.yaml
index 3651901e9f2c7..53666770a5de6 100644
--- a/libc/newhdrgen/yaml/sys/sys_statvfs.yaml
+++ b/libc/newhdrgen/yaml/sys/sys_statvfs.yaml
@@ -2,6 +2,8 @@ header: sys-statvfs.h
 macros: []
 types:
   - type_name: struct_statvfs
+  - type_name: fsblkcnt_t
+  - type_name: fsfilcnt_t
 enums: []
 objects: []
 functions:
diff --git a/libc/src/sys/statvfs/linux/CMakeLists.txt b/libc/src/sys/statvfs/linux/CMakeLists.txt
index a6660c02badf7..2953717e70392 100644
--- a/libc/src/sys/statvfs/linux/CMakeLists.txt
+++ b/libc/src/sys/statvfs/linux/CMakeLists.txt
@@ -8,7 +8,7 @@ add_header_library(
     libc.src.__support.common
     libc.src.__support.CPP.optional
     libc.include.sys_syscall
-    libc.include.llvm-libc-types.struct_statvfs
+    libc.include.sys_statvfs
 )
 
 add_entrypoint_object(
@@ -19,7 +19,7 @@ add_entrypoint_object(
     ../statvfs.h
   DEPENDS
     libc.src.__support.libc_assert
-    libc.include.llvm-libc-types.struct_statvfs
+    libc.include.sys_statvfs
     .statfs_utils
 )
 
@@ -31,7 +31,7 @@ add_entrypoint_object(
     ../fstatvfs.h
   DEPENDS
     libc.src.__support.libc_assert
-    libc.include.llvm-libc-types.struct_statvfs
+    libc.include.sys_statvfs
     .statfs_utils
 )
 



More information about the libc-commits mailing list