Skip to content

Commit 6a6f3c9

Browse files
committed
[libc] Remove hard dependencies on linux from macros headers
Currently all of this logic expects to include and link with the headers in the `linux/` directory. This patch adds a wrapper macro to optionally add the appropriate dependency if it exists. This is preliminary to adding some GPU specific versions of these files. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D159021
1 parent 212beb6 commit 6a6f3c9

File tree

1 file changed

+54
-55
lines changed

1 file changed

+54
-55
lines changed

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,172 @@
1-
add_subdirectory(linux)
2-
3-
add_header(
1+
# Helper function to set up dependencies if they exist.
2+
function(add_macro_header name)
3+
cmake_parse_arguments(
4+
"MACRO_HEADER"
5+
"" # Optional arguments
6+
"HDR" # Single value arguments
7+
"" # Multi-value arguments
8+
${ARGN}
9+
)
10+
if(TARGET libc.include.llvm-libc-macros.${LIBC_TARGET_OS}.${name})
11+
add_header(
12+
${name}
13+
HDR
14+
${MACRO_HEADER_HDR}
15+
DEPENDS
16+
.${LIBC_TARGET_OS}.${name}
17+
)
18+
else()
19+
add_header(
20+
${name}
21+
HDR
22+
${MACRO_HEADER_HDR}
23+
)
24+
endif()
25+
endfunction(add_macro_header)
26+
27+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
28+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
29+
endif()
30+
31+
add_macro_header(
432
generic_error_number_macros
533
HDR
634
generic-error-number-macros.h
735
)
836

9-
add_header(
37+
add_macro_header(
1038
null_macro
1139
HDR
1240
null-macro.h
1341
)
1442

15-
add_header(
43+
add_macro_header(
1644
fcntl_macros
1745
HDR
1846
fcntl-macros.h
19-
DEPENDS
20-
.linux.fcntl_macros
2147
)
2248

23-
add_header(
49+
add_macro_header(
2450
fenv_macros
2551
HDR
2652
fenv-macros.h
2753
)
2854

29-
add_header(
55+
add_macro_header(
3056
file_seek_macros
3157
HDR
3258
file-seek-macros.h
3359
)
3460

35-
add_header(
61+
add_macro_header(
3662
math_macros
3763
HDR
3864
math-macros.h
3965
)
4066

41-
add_header(
67+
add_macro_header(
4268
sched_macros
4369
HDR
4470
sched-macros.h
45-
DEPENDS
46-
.linux.sched_macros
4771
)
4872

49-
add_header(
73+
add_macro_header(
5074
signal_macros
5175
HDR
5276
signal-macros.h
53-
DEPENDS
54-
.linux.signal_macros
5577
)
5678

57-
add_header(
79+
add_macro_header(
5880
stdio_macros
5981
HDR
6082
stdio-macros.h
6183
)
6284

63-
add_header(
85+
add_macro_header(
6486
stdlib_macros
6587
HDR
6688
stdlib-macros.h
6789
)
6890

69-
add_header(
91+
add_macro_header(
7092
sys_auxv_macros
7193
HDR
7294
sys-auxv-macros.h
7395
)
7496

75-
add_header(
97+
add_macro_header(
7698
sys_ioctl_macros
7799
HDR
78100
sys-ioctl-macros.h
79-
DEPENDS
80-
.linux.sys_ioctl_macros
81101
)
82102

83-
84-
add_header(
103+
add_macro_header(
85104
sys_stat_macros
86105
HDR
87106
sys-stat-macros.h
88-
DEPENDS
89-
.linux.sys_stat_macros
90107
)
91108

92-
add_header(
109+
add_macro_header(
93110
sys_mman_macros
94111
HDR
95112
sys-mman-macros.h
96-
DEPENDS
97-
.linux.sys_mman_macros
98113
)
99114

100-
add_header(
115+
add_macro_header(
101116
sys_random_macros
102117
HDR
103118
sys-random-macros.h
104-
DEPENDS
105-
.linux.sys_random_macros
106119
)
107120

108-
add_header(
121+
add_macro_header(
109122
sys_resource_macros
110123
HDR
111124
sys-resource-macros.h
112-
DEPENDS
113-
.linux.sys_resource_macros
114125
)
115126

116-
add_header(
127+
add_macro_header(
117128
sys_select_macros
118129
HDR
119130
sys-select-macros.h
120131
)
121132

122-
add_header(
133+
add_macro_header(
123134
sys_socket_macros
124135
HDR
125136
sys-socket-macros.h
126-
DEPENDS
127-
.linux.sys_socket_macros
128137
)
129138

130-
add_header(
139+
add_macro_header(
131140
sys_time_macros
132141
HDR
133142
sys-time-macros.h
134-
DEPENDS
135-
.linux.sys_time_macros
136143
)
137144

138-
add_header(
145+
add_macro_header(
139146
sys_wait_macros
140147
HDR
141148
sys-wait-macros.h
142-
DEPENDS
143-
.linux.sys_wait_macros
144149
)
145150

146-
add_header(
151+
add_macro_header(
147152
termios_macros
148153
HDR
149154
termios-macros.h
150-
DEPENDS
151-
.linux.termios_macros
152155
)
153156

154-
add_header(
157+
add_macro_header(
155158
time_macros
156159
HDR
157160
time-macros.h
158-
DEPENDS
159-
.linux.time_macros
160161
)
161162

162-
add_header(
163+
add_macro_header(
163164
unistd_macros
164165
HDR
165166
unistd-macros.h
166-
DEPENDS
167-
.linux.unistd_macros
168167
)
169168

170-
add_header(
169+
add_macro_header(
171170
wchar_macros
172171
HDR
173172
wchar-macros.h

0 commit comments

Comments
 (0)