1add_subdirectory(llvm-libc-macros)
2add_subdirectory(llvm-libc-types)
3
4add_header(
5  llvm_libc_common_h
6  HDR
7    __llvm-libc-common.h
8)
9
10add_gen_header(
11  ctype
12  DEF_FILE ctype.h.def
13  GEN_HDR ctype.h
14  DEPENDS
15    .llvm_libc_common_h
16)
17
18add_gen_header(
19  dirent
20  DEF_FILE dirent.h.def
21  GEN_HDR dirent.h
22  DEPENDS
23    .llvm_libc_common_h
24    .llvm-libc-types.DIR
25    .llvm-libc-types.ino_t
26    .llvm-libc-types.struct_dirent
27)
28
29add_gen_header(
30  fcntl
31  DEF_FILE fcntl.h.def
32  GEN_HDR fcntl.h
33  DEPENDS
34    .llvm_libc_common_h
35    .llvm-libc-macros.fcntl_macros
36    .llvm-libc-types.mode_t
37)
38
39add_gen_header(
40  fenv
41  DEF_FILE fenv.h.def
42  GEN_HDR fenv.h
43  DEPENDS
44    .llvm_libc_common_h
45    .llvm-libc-types.fenv_t
46    .llvm-libc-types.fexcept_t
47)
48
49add_gen_header(
50  inttypes
51  DEF_FILE inttypes.h.def
52  GEN_HDR inttypes.h
53  DEPENDS
54    .llvm_libc_common_h
55    .llvm-libc-types.imaxdiv_t
56)
57
58add_gen_header(
59  math
60  DEF_FILE math.h.def
61  GEN_HDR math.h
62  DEPENDS
63    .llvm_libc_common_h
64    .llvm-libc-types.double_t
65    .llvm-libc-types.float_t
66)
67
68add_gen_header(
69  assert_h
70  DEF_FILE assert.h.def
71  GEN_HDR assert.h
72  DEPENDS
73    .llvm_libc_common_h
74)
75
76add_gen_header(
77  string
78  DEF_FILE string.h.def
79  GEN_HDR string.h
80  DEPENDS
81    .llvm_libc_common_h
82    .llvm-libc-types.size_t
83)
84
85add_gen_header(
86  time
87  DEF_FILE time.h.def
88  GEN_HDR time.h
89  DEPENDS
90    .llvm_libc_common_h
91    .llvm-libc-types.time_t
92    .llvm-libc-types.struct_tm
93)
94
95add_gen_header(
96  threads
97  DEF_FILE threads.h.def
98  GEN_HDR threads.h
99  DEPENDS
100    .llvm_libc_common_h
101    .llvm-libc-types.__call_once_func_t
102    .llvm-libc-types.cnd_t
103    .llvm-libc-types.mtx_t
104    .llvm-libc-types.once_flag
105    .llvm-libc-types.thrd_start_t
106    .llvm-libc-types.thrd_t
107)
108
109add_gen_header(
110  errno
111  DEF_FILE errno.h.def
112  PARAMS
113    platform_errno=../config/${LIBC_TARGET_OS}/errno.h.in
114  GEN_HDR errno.h
115  DATA_FILES
116    ../config/${LIBC_TARGET_OS}/errno.h.in
117)
118
119add_gen_header(
120  signal
121  DEF_FILE signal.h.def
122  PARAMS
123    platform_signal=../config/${LIBC_TARGET_OS}/signal.h.in
124  GEN_HDR signal.h
125  DATA_FILES
126    ../config/${LIBC_TARGET_OS}/signal.h.in
127  DEPENDS
128    .llvm-libc-types.struct_sigaction
129    .llvm-libc-types.__sighandler_t
130)
131
132add_gen_header(
133  stdio
134  DEF_FILE stdio.h.def
135  GEN_HDR stdio.h
136  DEPENDS
137    .llvm_libc_common_h
138    .llvm-libc-macros.file_seek_macros
139    .llvm-libc-types.cookie_io_functions_t
140    .llvm-libc-types.FILE
141    .llvm-libc-types.size_t
142)
143
144add_gen_header(
145  stdlib
146  DEF_FILE stdlib.h.def
147  GEN_HDR stdlib.h
148  DEPENDS
149    .llvm_libc_common_h
150    .llvm-libc-types.__bsearchcompare_t
151    .llvm-libc-types.__qsortcompare_t
152    .llvm-libc-types.div_t
153    .llvm-libc-types.ldiv_t
154    .llvm-libc-types.lldiv_t
155    .llvm-libc-types.size_t
156    .llvm-libc-types.__atexithandler_t
157)
158
159add_gen_header(
160  unistd
161  DEF_FILE unistd.h.def
162  GEN_HDR unistd.h
163  DEPENDS
164    .llvm_libc_common_h
165    .llvm-libc-macros.file_seek_macros
166    .llvm-libc-types.size_t
167    .llvm-libc-types.ssize_t
168)
169
170add_gen_header(
171  pthread
172  DEF_FILE pthread.h.def
173  GEN_HDR pthread.h
174  DEPENDS
175    .llvm_libc_common_h
176    .llvm-libc-types.__pthread_start_t
177    .llvm-libc-types.pthread_attr_t
178    .llvm-libc-types.pthread_mutex_t
179    .llvm-libc-types.pthread_mutexattr_t
180    .llvm-libc-types.pthread_t
181)
182
183# TODO: Not all platforms will have a include/sys directory. Add the sys
184# directory and the targets for sys/*.h files conditional to the OS requiring
185# them.
186file(MAKE_DIRECTORY "sys")
187
188add_gen_header(
189  sys_mman
190  DEF_FILE sys/mman.h.def
191  GEN_HDR sys/mman.h
192  DEPENDS
193    .llvm_libc_common_h
194    .llvm-libc-types.off_t
195    .llvm-libc-types.ssize_t
196)
197
198add_gen_header(
199  sys_stat
200  DEF_FILE sys/stat.h.def
201  GEN_HDR sys/stat.h
202  DEPENDS
203    .llvm_libc_common_h
204    .llvm-libc-types.mode_t
205)
206
207add_gen_header(
208  sys_syscall
209  DEF_FILE sys/syscall.h.def
210  GEN_HDR sys/syscall.h
211  PARAMS
212    syscall_numbers=../config/${LIBC_TARGET_OS}/syscall_numbers.h.inc
213  DATA_FILES
214    ../config/${LIBC_TARGET_OS}/syscall_numbers.h.inc
215)
216