Skip to content

Commit a105113

Browse files
authored
[libc] newhdrgen: updated sorting of guarded functions in fuction generation (#98241)
In yaml_to_classes.py, changed order of adding functions so that guarded functions appear after regular functions. Guarded functions will still be alphabetically sorted within each guard. Each group of guarded functions will appear in alphabetical order of the guard name. Fixed issus in math.yaml such as missing guards. Fixed Function class for spacing issues and the order in which attributes are listed in the function header. Deleted extra whitespace in the last line of unistd.yaml.
1 parent eb97761 commit a105113

File tree

7 files changed

+915
-820
lines changed

7 files changed

+915
-820
lines changed

libc/newhdrgen/class_implementation/classes/function.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ def __init__(
2323
self.attributes = attributes or ""
2424

2525
def __str__(self):
26-
attributes_str = self.attributes
26+
attributes_str = " ".join(self.attributes)
2727
arguments_str = ", ".join(self.arguments)
28-
result = f"{self.return_type} {self.name}({arguments_str}){attributes_str};"
28+
if attributes_str == "":
29+
result = f"{self.return_type} {self.name}({arguments_str}) __NOEXCEPT;"
30+
else:
31+
result = f"{attributes_str} {self.return_type} {self.name}({arguments_str}) __NOEXCEPT;"
2932
if self.guard:
3033
result = f"#ifdef {self.guard}\n{result}\n#endif // {self.guard}"
3134
return result

libc/newhdrgen/header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ def __str__(self):
6262
content.append("")
6363
for object in self.objects:
6464
content.append(str(object))
65-
content.append("\n__END_C_DECLS")
65+
content.append("__END_C_DECLS")
6666

6767
return "\n".join(content)

libc/newhdrgen/yaml/dlfcn.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
header: dlfcn.h
2+
macros:
3+
- macro_name: RTLD_LAZY
4+
macro_value: null
5+
- macro_name: RTLD_NOW
6+
macro_value: null
7+
- macro_name: RTLD_GLOBAL
8+
macro_value: null
9+
- macro_name: RTLD_LOCAL
10+
macro_value: null
11+
types: []
12+
enums: []
13+
objects: []
14+
functions:
15+
- name: dlclose
16+
standards:
17+
- POSIX
18+
return_type: int
19+
arguments:
20+
- type: void *
21+
- name: dlerror
22+
standards:
23+
- POSIX
24+
return_type: char *
25+
arguments: []
26+
- name: dlopen
27+
standards:
28+
- POSIX
29+
return_type: void *
30+
arguments:
31+
- type: const char *
32+
- type: int
33+
- name: dlsym
34+
standards:
35+
- POSIX
36+
return_type: void *
37+
arguments:
38+
- type: void *__restrict
39+
- type: const char *__restrict

0 commit comments

Comments
 (0)