[SLP]Fix PR107036: Check if the type of the user is sizable before requesting its...
[llvm-project.git] / libc / spec / gnu_ext.td
blobe360c766c5c5478089fed9aa0e34b571c5f8e967
1 def CpuSetT : NamedType<"cpu_set_t">;
2 def CpuSetPtr : PtrType<CpuSetT>;
3 def ConstCpuSetPtr : ConstType<CpuSetPtr>;
5 def QSortRCompareT : NamedType<"__qsortrcompare_t">;
6 def StructHsearchData : NamedType<"struct hsearch_data">;
7 def StructHsearchDataPtr : PtrType<StructHsearchData>;
9 def GnuExtensions : StandardSpec<"GNUExtensions"> {
10   NamedType CookieIOFunctionsT = NamedType<"cookie_io_functions_t">;
11   HeaderSpec CType = HeaderSpec<
12     "ctype.h",
13     [], // Macros
14     [], // Types
15     [], // Enumerations
16     [
17         FunctionSpec<
18             "toascii",
19             RetValSpec<IntType>,
20             [ArgSpec<IntType>]
21         >,
22     ]
23   >;
25   HeaderSpec Math = HeaderSpec<
26       "math.h",
27       [], // Macros
28       [], // Types
29       [], // Enumerations
30       [
31         FunctionSpec<
32             "sincosf",
33             RetValSpec<VoidType>,
34             [ArgSpec<FloatType>, ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]
35         >,
36       ]
37   >;
39   HeaderSpec Sched = HeaderSpec<
40       "sched.h",
41       [], // Macros
42       [PidT, SizeTType, CpuSetT], // Types
43       [], // Enumerations
44       [
45         FunctionSpec<
46             "sched_getaffinity",
47             RetValSpec<IntType>,
48             [ArgSpec<PidT>, ArgSpec<SizeTType>, ArgSpec<CpuSetPtr>]
49         >,
50         FunctionSpec<
51             "sched_setaffinity",
52             RetValSpec<IntType>,
53             [ArgSpec<PidT>, ArgSpec<SizeTType>, ArgSpec<ConstCpuSetPtr>]
54         >,
55       ]
56   >;
57   HeaderSpec String = HeaderSpec<
58       "string.h",
59       [], // Macros
60       [], // Types
61       [], // Enumerations
62       [
63          FunctionSpec<
64             "memmem",
65             RetValSpec<VoidPtr>,
66             [ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>]
67         >,
68         FunctionSpec<
69             "memrchr",
70             RetValSpec<VoidPtr>,
71             [ArgSpec<ConstVoidPtr>, ArgSpec<IntType>, ArgSpec<SizeTType>]
72         >,
73         FunctionSpec<
74             "strerror_r",
75             RetValSpec<CharPtr>,
76             [ArgSpec<IntType>, ArgSpec<CharPtr>, ArgSpec<SizeTType>]
77         >,
78         FunctionSpec<
79             "strcasestr",
80             RetValSpec<CharPtr>,
81             [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
82         >,
83         FunctionSpec<
84             "strchrnul",
85             RetValSpec<CharPtr>,
86             [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
87         >,
88       ]
89   >;
91   HeaderSpec Search = HeaderSpec<
92     "search.h",
93     [], // Macros
94     [
95         StructHsearchData
96     ],
97     [], // Enumerations
98     [
99         FunctionSpec<
100             "hcreate_r",
101             RetValSpec<IntType>,
102             [
103                 ArgSpec<SizeTType>,
104                 ArgSpec<StructHsearchDataPtr>
105             ]
106         >,
107         FunctionSpec<
108             "hdestroy_r",
109             RetValSpec<VoidType>,
110             [
111                 ArgSpec<StructHsearchDataPtr>
112             ]
113         >,
114         FunctionSpec<
115             "hsearch_r",
116             RetValSpec<IntType>,
117             [
118                 ArgSpec<EntryType>,
119                 ArgSpec<ActionType>,
120                 ArgSpec<EntryTypePtrPtr>,
121                 ArgSpec<StructHsearchDataPtr>
122             ]
123         >,
124     ]
125   >;
127   HeaderSpec FEnv = HeaderSpec<
128       "fenv.h",
129       [], // Macros
130       [], // Types
131       [], // Enumerations
132       [
133         FunctionSpec<
134             "fedisableexcept",
135             RetValSpec<IntType>,
136             [ArgSpec<IntType>]
137         >,
138         FunctionSpec<
139             "feenableexcept",
140             RetValSpec<IntType>,
141             [ArgSpec<IntType>]
142         >,
143         FunctionSpec<
144             "fegetexcept",
145             RetValSpec<IntType>,
146             []
147         >
148       ]
149   >;
151   HeaderSpec StdIO = HeaderSpec<
152       "stdio.h",
153       [], // Macros
154       [CookieIOFunctionsT], // Types
155       [], // Enumerations
156       [
157           FunctionSpec<
158               "clearerr_unlocked",
159               RetValSpec<VoidType>,
160               [ArgSpec<FILEPtr>]
161           >,
162           FunctionSpec<
163               "feof_unlocked",
164               RetValSpec<IntType>,
165               [ArgSpec<FILEPtr>]
166           >,
167           FunctionSpec<
168               "ferror_unlocked",
169               RetValSpec<IntType>,
170               [ArgSpec<FILEPtr>]
171           >,
172           FunctionSpec<
173               "fopencookie",
174               RetValSpec<FILEPtr>,
175               [ArgSpec<VoidPtr>, ArgSpec<ConstCharPtr>, ArgSpec<CookieIOFunctionsT>]
176           >,
177           FunctionSpec<
178               "fread_unlocked",
179               RetValSpec<SizeTType>,
180               [ArgSpec<VoidRestrictedPtr>,
181                ArgSpec<SizeTType>,
182                ArgSpec<SizeTType>,
183                ArgSpec<FILERestrictedPtr>]
184           >,
185           FunctionSpec<
186               "fwrite_unlocked",
187               RetValSpec<SizeTType>,
188               [ArgSpec<ConstVoidRestrictedPtr>,
189                ArgSpec<SizeTType>,
190                ArgSpec<SizeTType>,
191                ArgSpec<FILERestrictedPtr>]
192           >,
193           FunctionSpec<
194               "fgetc_unlocked",
195               RetValSpec<IntType>,
196               [ArgSpec<FILEPtr>]
197           >,
198       ]
199   >;
201   HeaderSpec StdLib = HeaderSpec<
202       "stdlib.h",
203       [], // Macros
204       [QSortRCompareT], // Types
205       [], // Enumerations
206       [
207           FunctionSpec<
208                 "qsort_r",
209                 RetValSpec<VoidType>,
210                 [ArgSpec<VoidPtr>, ArgSpec<SizeTType>, ArgSpec<SizeTType>, ArgSpec<QSortRCompareT>, ArgSpec<VoidPtr>]
211           >,
212       ]
213   >;
215   HeaderSpec PThread = HeaderSpec<
216       "pthread.h",
217       [], // Macros
218       [], // Types
219       [], // Enumerations
220       [
221           FunctionSpec<
222               "pthread_setname_np",
223               RetValSpec<IntType>,
224               [ArgSpec<PThreadTType>, ArgSpec<ConstCharPtr>]
225           >,
226           FunctionSpec<
227               "pthread_getname_np",
228               RetValSpec<IntType>,
229               [ArgSpec<PThreadTType>, ArgSpec<CharPtr>, ArgSpec<SizeTType>]
230           >,
231       ]
232   >;
234   HeaderSpec SysAuxv = HeaderSpec<
235       "sys/auxv.h",
236       [], // Macros
237       [], // Types
238       [], // Enumerations
239       [
240           FunctionSpec<
241               "getauxval",
242               RetValSpec<UnsignedLongType>,
243               [ArgSpec<UnsignedLongType>]
244           >,
245       ]  // Functions
246   >;
248   HeaderSpec SendFile = HeaderSpec<
249       "sys/sendfile.h",
250       [], // Macros
251       [OffTType, SizeTType, SSizeTType,], // Types
252       [], // Enumerations
253       [
254           FunctionSpec<
255               "sendfile",
256               RetValSpec<SSizeTType>,
257               [ArgSpec<IntType>, ArgSpec<IntType>, ArgSpec<OffTPtr>, ArgSpec<SizeTType>]
258           >,
259       ]
260   >;
262   HeaderSpec UniStd = HeaderSpec<
263     "unistd.h",
264     [], // Macros
265     [], // Types
266     [], // Enumerations
267     [
268         FunctionSpec<
269             "dup2",
270             RetValSpec<IntType>,
271             [ArgSpec<IntType>, ArgSpec<IntType>, ArgSpec<IntType>]
272         >,
273     ]
274   >;
276   let Headers = [
277     CType,
278     FEnv,
279     Math,
280     PThread,
281     Sched,
282     SendFile,
283     SysAuxv,
284     StdIO,
285     StdLib,
286     String,
287     Search,
288     UniStd,
289   ];