[libc-commits] [libc] [libc] cmake configruation for newhdrgen (PR #98257)
via libc-commits
libc-commits at lists.llvm.org
Thu Jul 11 13:35:40 PDT 2024
https://github.com/aaryanshukla updated https://github.com/llvm/llvm-project/pull/98257
>From 8502b463b718f7f75faa73b848bd48214525d3e2 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Wed, 10 Jul 2024 00:46:38 +0000
Subject: [PATCH 1/3] [libc] cmake configruation for newhdrgen
- this is a draft to get more input/reviews
- tests have been done on dirent and ctype to see matching results as
old headergen
- added entrypoints filtering within the script
---
libc/cmake/modules/LLVMLibCHeaderRules.cmake | 87 +++++++++++++++++++-
libc/include/CMakeLists.txt | 7 +-
libc/newhdrgen/yaml_to_classes.py | 32 +++++--
3 files changed, 114 insertions(+), 12 deletions(-)
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index 7fc6860f23eb2..51e546b687098 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -6,6 +6,7 @@
# <target name>
# HDR <header file>
# )
+
function(add_header target_name)
cmake_parse_arguments(
"ADD_HEADER"
@@ -15,7 +16,7 @@ function(add_header target_name)
${ARGN}
)
if(NOT ADD_HEADER_HDR)
- message(FATAL_ERROR "'add_header' rules requires the HDR argument specifying a headef file.")
+ message(FATAL_ERROR "'add_header' rules requires the HDR argument specifying a header file.")
endif()
set(absolute_path ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_HEADER_HDR})
@@ -66,6 +67,90 @@ function(add_header target_name)
)
endfunction(add_header)
+function(add_yaml_header target_name)
+ cmake_parse_arguments(
+ "ADD_YAML_HDR"
+ "PUBLIC" # No optional arguments
+ "YAML_FILE;DEF_FILE;GEN_HDR" # Single value arguments
+ "DEPENDS" # Multi value arguments
+ ${ARGN}
+ )
+ get_fq_target_name(${target_name} fq_target_name)
+ if(NOT LLVM_LIBC_FULL_BUILD)
+ # We don't want to use generated headers if we are doing a non-full-build.
+ add_library(${fq_target_name} INTERFACE)
+ return()
+ endif()
+ if(NOT ADD_YAML_HDR_DEF_FILE)
+ message(FATAL_ERROR "`add_yaml_hdr` rule requires DEF_FILE to be specified.")
+ endif()
+ if(NOT ADD_YAML_HDR_GEN_HDR)
+ message(FATAL_ERROR "`add_yaml_hdr` rule requires GEN_HDR to be specified.")
+ endif()
+ if(NOT ADD_YAML_HDR_YAML_FILE)
+ message(FATAL_ERROR "`add_yaml_hdr` rule requires YAML_FILE to be specified.")
+ endif()
+
+ set(absolute_path ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_YAML_HDR_GEN_HDR})
+ file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_SOURCE_DIR} ${absolute_path})
+ set(out_file ${LIBC_INCLUDE_DIR}/${relative_path})
+ set(yaml_file ${CMAKE_SOURCE_DIR}/${ADD_YAML_HDR_YAML_FILE})
+ set(def_file ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_YAML_HDR_DEF_FILE})
+
+ set(fq_data_files "")
+ if(ADD_YAML_HDR_DATA_FILES)
+ foreach(data_file IN LISTS ADD_YAML_HDR_DATA_FILES)
+ list(APPEND fq_data_files "${CMAKE_CURRENT_SOURCE_DIR}/${data_file}")
+ endforeach(data_file)
+ endif()
+
+ set(entry_points "${TARGET_ENTRYPOINT_NAME_LIST}")
+ list(TRANSFORM entry_points PREPEND "--e=")
+
+ add_custom_command(
+ OUTPUT ${out_file}
+ COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/newhdrgen/yaml_to_classes.py
+ ${yaml_file}
+ ${def_file}
+ ${entry_points}
+ --output_dir ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${yaml_file} ${def_file} ${fq_data_files}
+ COMMENT "Generating header ${ADD_YAML_HDR_GEN_HDR} from ${yaml_file} and ${def_file}"
+ )
+
+ if(ADD_YAML_HDR_DEPENDS)
+ get_fq_deps_list(fq_deps_list ${ADD_YAML_HDR_DEPENDS})
+ # Dependencies of a add_header target can only be another add_gen_header target
+ # or an add_header target.
+ foreach(dep IN LISTS fq_deps_list)
+ get_target_property(header_file ${dep} HEADER_FILE_PATH)
+ if(NOT header_file)
+ message(FATAL_ERROR "Invalid dependency '${dep}' for '${fq_target_name}'.")
+ endif()
+ endforeach()
+ endif()
+ set(generated_hdr_target ${fq_target_name}.__generated_hdr__)
+ add_custom_target(
+ ${generated_hdr_target}
+ DEPENDS ${out_file} ${fq_deps_list}
+ )
+
+ add_header_library(
+ ${target_name}
+ HDRS
+ ${out_file}
+ )
+
+ add_dependencies(${fq_target_name} ${generated_hdr_target})
+
+ set_target_properties(
+ ${fq_target_name}
+ PROPERTIES
+ HEADER_FILE_PATH ${out_file}
+ DEPS "${fq_deps_list}"
+ )
+endfunction(add_yaml_header)
+
# A rule for generated header file targets.
# Usage:
# add_gen_header(
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index f8ef35078a8c4..6f4cb9e1ba1d5 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LIBC_INCLUDE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
include(LLVMLibCHeaderRules)
+
# The GPU build wants to install files in the compiler's resource directory.
if(LIBC_TARGET_OS_IS_GPU)
include(GetClangResourceDir)
@@ -17,16 +18,18 @@ add_header(
__llvm-libc-common.h
)
-add_gen_header(
+add_yaml_header(
ctype
+ YAML_FILE ../libc/newhdrgen/yaml/ctype.yaml
DEF_FILE ctype.h.def
GEN_HDR ctype.h
DEPENDS
.llvm_libc_common_h
)
-add_gen_header(
+add_yaml_header(
dirent
+ YAML_FILE ../libc/newhdrgen/yaml/dirent.yaml
DEF_FILE dirent.h.def
GEN_HDR dirent.h
DEPENDS
diff --git a/libc/newhdrgen/yaml_to_classes.py b/libc/newhdrgen/yaml_to_classes.py
index 9e0337f4a308e..ee2abec4fdc11 100644
--- a/libc/newhdrgen/yaml_to_classes.py
+++ b/libc/newhdrgen/yaml_to_classes.py
@@ -11,7 +11,6 @@
import yaml
import argparse
-
from pathlib import Path
from header import HeaderFile
from class_implementation.classes.macro import Macro
@@ -22,12 +21,13 @@
from class_implementation.classes.object import Object
-def yaml_to_classes(yaml_data):
+def yaml_to_classes(yaml_data, entry_points=None):
"""
- Convert YAML data to header classes.
+ Convert YAML data to header classes, filtering functions by entry points.
Args:
yaml_data: The YAML data containing header specifications.
+ entry_points: A list of entry points to filter functions.
Returns:
HeaderFile: An instance of HeaderFile populated with the data.
@@ -47,6 +47,9 @@ def yaml_to_classes(yaml_data):
)
functions = yaml_data.get("functions", [])
+ if entry_points:
+ entry_points_set = set(entry_points)
+ functions = [f for f in functions if f["name"] in entry_points_set]
sorted_functions = sorted(functions, key=lambda x: x["name"])
for function_data in sorted_functions:
arguments = [arg["type"] for arg in function_data["arguments"]]
@@ -75,19 +78,20 @@ def yaml_to_classes(yaml_data):
return header
-def load_yaml_file(yaml_file):
+def load_yaml_file(yaml_file, entry_points):
"""
- Load YAML file and convert it to header classes.
+ Load YAML file and convert it to header classes, filtering by entry points.
Args:
yaml_file: The path to the YAML file.
+ entry_points: A list of entry points to filter functions.
Returns:
HeaderFile: An instance of HeaderFile populated with the data from the YAML file.
"""
with open(yaml_file, "r") as f:
yaml_data = yaml.safe_load(f)
- return yaml_to_classes(yaml_data)
+ return yaml_to_classes(yaml_data, entry_points)
def fill_public_api(header_str, h_def_content):
@@ -177,7 +181,7 @@ def increase_indent(self, flow=False, indentless=False):
print(f"Added function {new_function.name} to {yaml_file}")
-def main(yaml_file, h_def_file, output_dir, add_function=None):
+def main(yaml_file, h_def_file, output_dir, add_function=None, entry_points=None):
"""
Main function to generate header files from YAML and .h.def templates.
@@ -186,12 +190,13 @@ def main(yaml_file, h_def_file, output_dir, add_function=None):
h_def_file: Path to the .h.def template file.
output_dir: Directory to output the generated header file.
add_function: Details of the function to be added to the YAML file (if any).
+ entry_points: A list of entry points to filter functions.
"""
if add_function:
add_function_to_yaml(yaml_file, add_function)
- header = load_yaml_file(yaml_file)
+ header = load_yaml_file(yaml_file, entry_points)
with open(h_def_file, "r") as f:
h_def_content = f.read()
@@ -234,6 +239,15 @@ def main(yaml_file, h_def_file, output_dir, add_function=None):
),
help="Add a function to the YAML file",
)
+ parser.add_argument(
+ "--e", action="append", help="Entry point to include", dest="entry_points"
+ )
args = parser.parse_args()
- main(args.yaml_file, args.h_def_file, args.output_dir, args.add_function)
+ main(
+ args.yaml_file,
+ args.h_def_file,
+ args.output_dir,
+ args.add_function,
+ args.entry_points,
+ )
>From a3541019545f6a7c4e2732d51b0c569e829a4b57 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Wed, 10 Jul 2024 19:32:46 +0000
Subject: [PATCH 2/3] swapped custom_command with custom_target
---
libc/cmake/modules/LLVMLibCHeaderRules.cmake | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index 51e546b687098..b02bfd7648d78 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -107,8 +107,8 @@ function(add_yaml_header target_name)
set(entry_points "${TARGET_ENTRYPOINT_NAME_LIST}")
list(TRANSFORM entry_points PREPEND "--e=")
- add_custom_command(
- OUTPUT ${out_file}
+ add_custom_target(
+ generate_${ADD_YAML_HDR_GEN_HDR}
COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/newhdrgen/yaml_to_classes.py
${yaml_file}
${def_file}
@@ -132,7 +132,7 @@ function(add_yaml_header target_name)
set(generated_hdr_target ${fq_target_name}.__generated_hdr__)
add_custom_target(
${generated_hdr_target}
- DEPENDS ${out_file} ${fq_deps_list}
+ DEPENDS generate_${ADD_YAML_HDR_GEN_HDR} ${fq_deps_list}
)
add_header_library(
>From 452329cba7a1a0fccaf6fbfb07a7cae010171722 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 11 Jul 2024 20:34:20 +0000
Subject: [PATCH 3/3] switched back to custom_command
- able to generate all headers with new headergen (waiting on landing
for assert.yaml)
- fixed bugs within yaml files
---
libc/cmake/modules/LLVMLibCHeaderRules.cmake | 6 +-
libc/include/CMakeLists.txt | 139 +++++++++++++------
libc/newhdrgen/yaml/dlfcn.yaml | 39 ++++++
libc/newhdrgen/yaml/features.yaml | 8 ++
libc/newhdrgen/yaml/pthread.yaml | 31 +----
libc/newhdrgen/yaml/sys_random.yaml | 2 +-
6 files changed, 147 insertions(+), 78 deletions(-)
create mode 100644 libc/newhdrgen/yaml/dlfcn.yaml
create mode 100644 libc/newhdrgen/yaml/features.yaml
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index b02bfd7648d78..51e546b687098 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -107,8 +107,8 @@ function(add_yaml_header target_name)
set(entry_points "${TARGET_ENTRYPOINT_NAME_LIST}")
list(TRANSFORM entry_points PREPEND "--e=")
- add_custom_target(
- generate_${ADD_YAML_HDR_GEN_HDR}
+ add_custom_command(
+ OUTPUT ${out_file}
COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/newhdrgen/yaml_to_classes.py
${yaml_file}
${def_file}
@@ -132,7 +132,7 @@ function(add_yaml_header target_name)
set(generated_hdr_target ${fq_target_name}.__generated_hdr__)
add_custom_target(
${generated_hdr_target}
- DEPENDS generate_${ADD_YAML_HDR_GEN_HDR} ${fq_deps_list}
+ DEPENDS ${out_file} ${fq_deps_list}
)
add_header_library(
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 6f4cb9e1ba1d5..4aef98463a06d 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -39,8 +39,9 @@ add_yaml_header(
.llvm-libc-types.struct_dirent
)
-add_gen_header(
+add_yaml_header(
fcntl
+ YAML_FILE ../libc/newhdrgen/yaml/fcntl.yaml
DEF_FILE fcntl.h.def
GEN_HDR fcntl.h
DEPENDS
@@ -54,8 +55,9 @@ add_gen_header(
.llvm_libc_common_h
)
-add_gen_header(
+add_yaml_header(
dlfcn
+ YAML_FILE ../libc/newhdrgen/yaml/dlfcn.yaml
DEF_FILE dlfcn.h.def
GEN_HDR dlfcn.h
DEPENDS
@@ -65,6 +67,7 @@ add_gen_header(
add_gen_header(
features
+ YAML_FILE ../libc/newhdrgen/yaml/features.yaml
DEF_FILE features.h.def
GEN_HDR features.h
DEPENDS
@@ -72,8 +75,9 @@ add_gen_header(
.llvm-libc-macros.features_macros
)
-add_gen_header(
+add_yaml_header(
fenv
+ YAML_FILE ../libc/newhdrgen/yaml/fenv.yaml
DEF_FILE fenv.h.def
GEN_HDR fenv.h
DEPENDS
@@ -83,8 +87,9 @@ add_gen_header(
.llvm-libc-types.fexcept_t
)
-add_gen_header(
+add_yaml_header(
inttypes
+ YAML_FILE ../libc/newhdrgen/yaml/inttypes.yaml
DEF_FILE inttypes.h.def
GEN_HDR inttypes.h
DEPENDS
@@ -93,32 +98,36 @@ add_gen_header(
.llvm-libc-macros.inttypes_macros
)
-add_gen_header(
+add_yaml_header(
float
+ YAML_FILE ../libc/newhdrgen/yaml/float.yaml
DEF_FILE float.h.def
GEN_HDR float.h
DEPENDS
.llvm-libc-macros.float_macros
)
-add_gen_header(
+add_yaml_header(
stdint
+ YAML_FILE ../libc/newhdrgen/yaml/stdint.yaml
DEF_FILE stdint.h.def
GEN_HDR stdint.h
DEPENDS
.llvm-libc-macros.stdint_macros
)
-add_gen_header(
+add_yaml_header(
limits
+ YAML_FILE ../libc/newhdrgen/yaml/limits.yaml
DEF_FILE limits.h.def
GEN_HDR limits.h
DEPENDS
.llvm-libc-macros.limits_macros
)
-add_gen_header(
+add_yaml_header(
math
+ YAML_FILE ../libc/newhdrgen/yaml/math.yaml
DEF_FILE math.h.def
GEN_HDR math.h
DEPENDS
@@ -130,8 +139,9 @@ add_gen_header(
.llvm-libc-types.float128
)
-add_gen_header(
+add_yaml_header(
stdfix
+ YAML_FILE ../libc/newhdrgen/yaml/stdfix.yaml
DEF_FILE stdfix.h.def
GEN_HDR stdfix.h
DEPENDS
@@ -141,8 +151,9 @@ add_gen_header(
# TODO: This should be conditional on POSIX networking being included.
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa)
-add_gen_header(
+add_yaml_header(
arpa_inet
+ YAML_FILE ../libc/newhdrgen/yaml/arpa_inet.yaml
DEF_FILE arpa/inet.h.def
GEN_HDR arpa/inet.h
DEPENDS
@@ -158,8 +169,9 @@ add_gen_header(
.llvm-libc-macros.assert_macros
)
-add_gen_header(
+add_yaml_header(
setjmp
+ YAML_FILE ../libc/newhdrgen/yaml/setjmp.yaml
DEF_FILE setjmp.h.def
GEN_HDR setjmp.h
DEPENDS
@@ -167,8 +179,9 @@ add_gen_header(
.llvm-libc-types.jmp_buf
)
-add_gen_header(
+add_yaml_header(
string
+ YAML_FILE ../libc/newhdrgen/yaml/string.yaml
DEF_FILE string.h.def
GEN_HDR string.h
DEPENDS
@@ -177,8 +190,9 @@ add_gen_header(
.llvm-libc-types.size_t
)
-add_gen_header(
+add_yaml_header(
strings
+ YAML_FILE ../libc/newhdrgen/yaml/strings.yaml
DEF_FILE strings.h.def
GEN_HDR strings.h
DEPENDS
@@ -186,8 +200,9 @@ add_gen_header(
.llvm-libc-types.size_t
)
-add_gen_header(
+add_yaml_header(
search
+ YAML_FILE ../libc/newhdrgen/yaml/search.yaml
DEF_FILE search.h.def
GEN_HDR search.h
DEPENDS
@@ -198,8 +213,9 @@ add_gen_header(
.llvm-libc-types.size_t
)
-add_gen_header(
+add_yaml_header(
time
+ YAML_FILE ../libc/newhdrgen/yaml/time.yaml
DEF_FILE time.h.def
GEN_HDR time.h
DEPENDS
@@ -213,8 +229,9 @@ add_gen_header(
.llvm-libc-types.clockid_t
)
-add_gen_header(
+add_yaml_header(
threads
+ YAML_FILE ../libc/newhdrgen/yaml/threads.yaml
DEF_FILE threads.h.def
GEN_HDR threads.h
DEPENDS
@@ -229,8 +246,9 @@ add_gen_header(
.llvm-libc-types.tss_dtor_t
)
-add_gen_header(
+add_yaml_header(
errno
+ YAML_FILE ../libc/newhdrgen/yaml/errno.yaml
DEF_FILE errno.h.def
GEN_HDR errno.h
DEPENDS
@@ -238,8 +256,9 @@ add_gen_header(
.llvm-libc-macros.error_number_macros
)
-add_gen_header(
+add_yaml_header(
signal
+ YAML_FILE ../libc/newhdrgen/yaml/signal.yaml
DEF_FILE signal.h.def
GEN_HDR signal.h
DEPENDS
@@ -253,8 +272,9 @@ add_gen_header(
.llvm-libc-types.pid_t
)
-add_gen_header(
+add_yaml_header(
stdbit
+ YAML_FILE ../libc/newhdrgen/yaml/stdbit.yaml
DEF_FILE stdbit.h.def
GEN_HDR stdbit.h
DEPENDS
@@ -262,8 +282,9 @@ add_gen_header(
.llvm-libc-macros.stdbit_macros
)
-add_gen_header(
+add_yaml_header(
stdckdint
+ YAML_FILE ../libc/newhdrgen/yaml/stdckdint.yaml
DEF_FILE stdckdint.h.def
GEN_HDR stdckdint.h
DEPENDS
@@ -271,8 +292,9 @@ add_gen_header(
.llvm-libc-macros.stdckdint_macros
)
-add_gen_header(
+add_yaml_header(
stdio
+ YAML_FILE ../libc/newhdrgen/yaml/stdio.yaml
DEF_FILE stdio.h.def
GEN_HDR stdio.h
DEPENDS
@@ -286,8 +308,9 @@ add_gen_header(
.llvm_libc_common_h
)
-add_gen_header(
+add_yaml_header(
stdlib
+ YAML_FILE ../libc/newhdrgen/yaml/stdlib.yaml
DEF_FILE stdlib.h.def
GEN_HDR stdlib.h
DEPENDS
@@ -303,8 +326,9 @@ add_gen_header(
.llvm-libc-types.__atexithandler_t
)
-add_gen_header(
+add_yaml_header(
unistd
+ YAML_FILE ../libc/newhdrgen/yaml/unistd.yaml
DEF_FILE unistd.h.def
GEN_HDR unistd.h
DEPENDS
@@ -321,8 +345,9 @@ add_gen_header(
.llvm-libc-types.__getoptargv_t
)
-add_gen_header(
+add_yaml_header(
pthread
+ YAML_FILE ../libc/newhdrgen/yaml/pthread.yaml
DEF_FILE pthread.h.def
GEN_HDR pthread.h
DEPENDS
@@ -342,8 +367,9 @@ add_gen_header(
.llvm-libc-types.pthread_t
)
-add_gen_header(
+add_yaml_header(
sched
+ YAML_FILE ../libc/newhdrgen/yaml/sched.yaml
DEF_FILE sched.h.def
GEN_HDR sched.h
DEPENDS
@@ -358,8 +384,9 @@ add_gen_header(
.llvm-libc-types.struct_timespec
)
-add_gen_header(
+add_yaml_header(
spawn
+ YAML_FILE ../libc/newhdrgen/yaml/spawn.yaml
DEF_FILE spawn.h.def
GEN_HDR spawn.h
DEPENDS
@@ -375,8 +402,9 @@ add_gen_header(
# them.
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/sys)
-add_gen_header(
+add_yaml_header(
sys_auxv
+ YAML_FILE ../libc/newhdrgen/yaml/sys_auxv.yaml
DEF_FILE sys/auxv.h.def
GEN_HDR sys/auxv.h
DEPENDS
@@ -384,8 +412,9 @@ add_gen_header(
.llvm-libc-macros.sys_auxv_macros
)
-add_gen_header(
+add_yaml_header(
sys_epoll
+ YAML_FILE ../libc/newhdrgen/yaml/sys_epoll.yaml
DEF_FILE sys/epoll.h.def
GEN_HDR sys/epoll.h
DEPENDS
@@ -396,8 +425,9 @@ add_gen_header(
.llvm-libc-macros.sys_epoll_macros
)
-add_gen_header(
+add_yaml_header(
sys_ioctl
+ YAML_FILE ../libc/newhdrgen/yaml/sys_ioctl.yaml
DEF_FILE sys/ioctl.h.def
GEN_HDR sys/ioctl.h
DEPENDS
@@ -405,8 +435,9 @@ add_gen_header(
.llvm-libc-macros.sys_ioctl_macros
)
-add_gen_header(
+add_yaml_header(
sys_mman
+ YAML_FILE ../libc/newhdrgen/yaml/sys_mman.yaml
DEF_FILE sys/mman.h.def
GEN_HDR sys/mman.h
DEPENDS
@@ -417,8 +448,9 @@ add_gen_header(
.llvm-libc-types.ssize_t
)
-add_gen_header(
+add_yaml_header(
sys_prctl
+ YAML_FILE ../libc/newhdrgen/yaml/sys_prctl.yaml
DEF_FILE sys/prctl.h.def
GEN_HDR sys/prctl.h
DEPENDS
@@ -433,8 +465,9 @@ add_header(
.llvm-libc-macros.sys_queue_macros
)
-add_gen_header(
+add_yaml_header(
sys_random
+ YAML_FILE ../libc/newhdrgen/yaml/sys_random.yaml
DEF_FILE sys/random.h.def
GEN_HDR sys/random.h
DEPENDS
@@ -444,8 +477,9 @@ add_gen_header(
.llvm-libc-types.ssize_t
)
-add_gen_header(
+add_yaml_header(
sys_resource
+ YAML_FILE ../libc/newhdrgen/yaml/sys_resource.yaml
DEF_FILE sys/resource.h.def
GEN_HDR sys/resource.h
DEPENDS
@@ -455,8 +489,9 @@ add_gen_header(
.llvm-libc-types.struct_rlimit
)
-add_gen_header(
+add_yaml_header(
sys_stat
+ YAML_FILE ../libc/newhdrgen/yaml/sys_stat.yaml
DEF_FILE sys/stat.h.def
GEN_HDR sys/stat.h
DEPENDS
@@ -476,8 +511,9 @@ add_gen_header(
.llvm-libc-types.struct_stat
)
-add_gen_header(
+add_yaml_header(
sys_select
+ YAML_FILE ../libc/newhdrgen/yaml/sys_select.yaml
DEF_FILE sys/select.h.def
GEN_HDR sys/select.h
DEPENDS
@@ -491,8 +527,9 @@ add_gen_header(
.llvm-libc-types.struct_timeval
)
-add_gen_header(
+add_yaml_header(
sys_sendfile
+ YAML_FILE ../libc/newhdrgen/yaml/sys_sendfile.yaml
DEF_FILE sys/sendfile.h.def
GEN_HDR sys/sendfile.h
DEPENDS
@@ -502,8 +539,9 @@ add_gen_header(
.llvm-libc-types.ssize_t
)
-add_gen_header(
+add_yaml_header(
sys_socket
+ YAML_FILE ../libc/newhdrgen/yaml/sys_socket.yaml
DEF_FILE sys/socket.h.def
GEN_HDR sys/socket.h
DEPENDS
@@ -515,8 +553,9 @@ add_gen_header(
.llvm-libc-types.struct_sockaddr_un
)
-add_gen_header(
+add_yaml_header(
sys_statvfs
+ YAML_FILE ../libc/newhdrgen/yaml/sys_statvfs.yaml
DEF_FILE sys/statvfs.h.def
GEN_HDR sys/statvfs.h
DEPENDS
@@ -524,14 +563,16 @@ add_gen_header(
.llvm-libc-types.struct_statvfs
)
-add_gen_header(
+add_yaml_header(
sys_syscall
+ YAML_FILE ../libc/newhdrgen/yaml/sys_syscall.yaml
DEF_FILE sys/syscall.h.def
GEN_HDR sys/syscall.h
)
-add_gen_header(
+add_yaml_header(
sys_time
+ YAML_FILE ../libc/newhdrgen/yaml/sys_time.yaml
DEF_FILE sys/time.h.def
GEN_HDR sys/time.h
DEPENDS
@@ -540,8 +581,9 @@ add_gen_header(
.llvm-libc-macros.sys_time_macros
)
-add_gen_header(
+add_yaml_header(
sys_types
+ YAML_FILE ../libc/newhdrgen/yaml/sys_types.yaml
DEF_FILE sys/types.h.def
GEN_HDR sys/types.h
DEPENDS
@@ -569,8 +611,9 @@ add_gen_header(
.llvm-libc-types.uid_t
)
-add_gen_header(
+add_yaml_header(
sys_utsname
+ YAML_FILE ../libc/newhdrgen/yaml/sys_utsname.yaml
DEF_FILE sys/utsname.h.def
GEN_HDR sys/utsname.h
DEPENDS
@@ -578,8 +621,9 @@ add_gen_header(
.llvm-libc-types.struct_utsname
)
-add_gen_header(
+add_yaml_header(
sys_wait
+ YAML_FILE ../libc/newhdrgen/yaml/sys_wait.yaml
DEF_FILE sys/wait.h.def
GEN_HDR sys/wait.h
DEPENDS
@@ -590,8 +634,9 @@ add_gen_header(
.llvm-libc-types.siginfo_t
)
-add_gen_header(
+add_yaml_header(
termios
+ YAML_FILE ../libc/newhdrgen/yaml/termios.yaml
DEF_FILE termios.h.def
GEN_HDR termios.h
DEPENDS
@@ -604,8 +649,9 @@ add_gen_header(
.llvm-libc-types.tcflag_t
)
-add_gen_header(
+add_yaml_header(
uchar
+ YAML_FILE ../libc/newhdrgen/yaml/uchar.yaml
DEF_FILE uchar.h.def
GEN_HDR uchar.h
DEPENDS
@@ -616,8 +662,9 @@ add_gen_header(
.llvm-libc-types.char32_t
)
-add_gen_header(
+add_yaml_header(
wchar
+ YAML_FILE ../libc/newhdrgen/yaml/wchar.yaml
DEF_FILE wchar.h.def
GEN_HDR wchar.h
DEPENDS
diff --git a/libc/newhdrgen/yaml/dlfcn.yaml b/libc/newhdrgen/yaml/dlfcn.yaml
new file mode 100644
index 0000000000000..7912336d57d22
--- /dev/null
+++ b/libc/newhdrgen/yaml/dlfcn.yaml
@@ -0,0 +1,39 @@
+header: dlfcn.h
+macros:
+ - macro_name: RTLD_LAZY
+ macro_value: null
+ - macro_name: RTLD_NOW
+ macro_value: null
+ - macro_name: RTLD_GLOBAL
+ macro_value: null
+ - macro_name: RTLD_LOCAL
+ macro_value: null
+types: []
+enums: []
+objects: []
+functions:
+ - name: dlclose
+ standards:
+ - POSIX
+ return_type: int
+ arguments:
+ - type: void *
+ - name: dlerror
+ standards:
+ - POSIX
+ return_type: char *
+ arguments: []
+ - name: dlopen
+ standards:
+ - POSIX
+ return_type: void *
+ arguments:
+ - type: const char *
+ - type: int
+ - name: dlsym
+ standards:
+ - POSIX
+ return_type: void *
+ arguments:
+ - type: void *__restrict
+ - type: const char *__restrict
\ No newline at end of file
diff --git a/libc/newhdrgen/yaml/features.yaml b/libc/newhdrgen/yaml/features.yaml
new file mode 100644
index 0000000000000..749f752f84287
--- /dev/null
+++ b/libc/newhdrgen/yaml/features.yaml
@@ -0,0 +1,8 @@
+header: features.h
+standards:
+ - stdc
+macros: []
+types: []
+enums: []
+objects: []
+functions: []
\ No newline at end of file
diff --git a/libc/newhdrgen/yaml/pthread.yaml b/libc/newhdrgen/yaml/pthread.yaml
index 14a562082d5de..8c320125a90fa 100644
--- a/libc/newhdrgen/yaml/pthread.yaml
+++ b/libc/newhdrgen/yaml/pthread.yaml
@@ -2,6 +2,7 @@ header: pthread.h
macros: []
types:
- type_name: pthread_t
+ - type_name: pthread_rwlock_t
- type_name: pthread_once_t
- type_name: pthread_mutex_t
- type_name: pthread_mutexattr_t
@@ -13,33 +14,7 @@ types:
- type_name: __pthread_start_t
- type_name: __pthread_once_func_t
- type_name: __atfork_callback_t
-enums:
- - name: PTHREAD_CREATE_JOINABLE
- value: 0x0
- - name: PTHREAD_CREATE_DETACHED
- value: 0x1
- - name: PTHREAD_MUTEX_NORMAL
- value: 0x0
- - name: PTHREAD_MUTEX_ERRORCHECK
- value: 0x1
- - name: PTHREAD_MUTEX_RECURSIVE
- value: 0x2
- - name: PTHREAD_MUTEX_DEFAULT
- value: 0x0
- - name: PTHREAD_PROCESS_PRIVATE
- value: 0x0
- - name: PTHREAD_PROCESS_SHARED
- value: 0x1
- - name: PTHREAD_MUTEX_STALLED
- value: 0x0
- - name: PTHREAD_MUTEX_ROBUST
- value: 0x1
- - name: PTHREAD_RWLOCK_PREFER_READER_NP
- value: 0
- - name: PTHREAD_RWLOCK_PREFER_WRITER_NP
- value: 1
- - name: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
- value: 2
+enums: []
functions:
- name: pthread_atfork
standards:
@@ -184,7 +159,7 @@ functions:
- name: pthread_exit
standards:
- POSIX
- return_type: __Noreturn void
+ return_type: _Noreturn void
arguments:
- type: void *
- name: pthread_getname_np
diff --git a/libc/newhdrgen/yaml/sys_random.yaml b/libc/newhdrgen/yaml/sys_random.yaml
index 233fb2c7988cb..6d84056d7dd71 100644
--- a/libc/newhdrgen/yaml/sys_random.yaml
+++ b/libc/newhdrgen/yaml/sys_random.yaml
@@ -4,7 +4,7 @@ types:
- type_name: ssize_t
- type_name: size_t
enums: []
-objects:
+objects: []
functions:
- name: getrandom
standards:
More information about the libc-commits
mailing list