154214dc516805ff5c2b6d60ee77dc9570b0686b
[lldb.git] / libc / spec / stdc.td
1 def StdC : StandardSpec<"stdc"> {
2   PtrType VoidPtr = PtrType<VoidType>;
3   ConstType ConstVoidPtr = ConstType<VoidPtr>;
4   RestrictedPtrType VoidRestrictedPtr = RestrictedPtrType<VoidType>;
5   ConstType ConstVoidRestrictedPtr = ConstType<VoidRestrictedPtr>;
6
7   PtrType CharPtr = PtrType<CharType>;
8   ConstType ConstCharPtr = ConstType<CharPtr>;
9   RestrictedPtrType CharRestrictedPtr = RestrictedPtrType<CharType>;
10   ConstType ConstCharRestrictedPtr = ConstType<CharRestrictedPtr>;
11
12   NamedType SizeTType = NamedType<"size_t">;
13
14   HeaderSpec String = HeaderSpec<
15       "string.h",
16       [
17           Macro<"NULL">,
18       ],
19       [
20           SizeTType,
21       ],
22       [
23           FunctionSpec<
24               "memcpy",
25               RetValSpec<VoidPtr>, 
26               [ArgSpec<VoidRestrictedPtr>,
27                ArgSpec<ConstVoidRestrictedPtr>,
28                ArgSpec<SizeTType>]
29           >,
30           FunctionSpec<
31               "memmove",
32               RetValSpec<VoidPtr>,
33               [ArgSpec<VoidPtr>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>]
34           >,
35           FunctionSpec<
36               "memcmp",
37               RetValSpec<IntType>,
38               [ArgSpec<ConstVoidPtr>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>]
39           >,
40           FunctionSpec<
41               "memchr",
42               RetValSpec<VoidPtr>,
43               [ArgSpec<ConstVoidPtr>, ArgSpec<IntType>, ArgSpec<SizeTType>]
44           >,
45           FunctionSpec<
46               "memset",
47               RetValSpec<VoidPtr>,
48               [ArgSpec<VoidPtr>, ArgSpec<IntType>, ArgSpec<SizeTType>]
49           >,
50           FunctionSpec<
51               "strcpy",
52               RetValSpec<CharPtr>, 
53               [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>]
54           >,
55           FunctionSpec<
56               "strncpy",
57               RetValSpec<CharPtr>, 
58               [ArgSpec<CharRestrictedPtr>,
59                ArgSpec<ConstCharRestrictedPtr>,
60                ArgSpec<SizeTType>]
61           >,
62           FunctionSpec<
63               "strcat",
64               RetValSpec<CharPtr>, 
65               [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>]
66           >,
67           FunctionSpec<
68               "strncat",
69               RetValSpec<CharPtr>, 
70               [ArgSpec<CharPtr>, ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
71           >,
72           FunctionSpec<
73               "strcmp",
74               RetValSpec<IntType>,
75               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
76           >,
77           FunctionSpec<
78               "strcoll",
79               RetValSpec<IntType>,
80               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
81           >,
82           FunctionSpec<
83               "strncmp",
84               RetValSpec<IntType>,
85               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
86           >,
87           FunctionSpec<
88               "strxfrm",
89               RetValSpec<SizeTType>, 
90               [ArgSpec<CharRestrictedPtr>,
91                ArgSpec<ConstCharRestrictedPtr>,
92                ArgSpec<SizeTType>]
93           >,
94           FunctionSpec<
95               "strchr",
96               RetValSpec<CharPtr>,
97               [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
98           >,
99           FunctionSpec<
100               "strcspn",
101               RetValSpec<SizeTType>,
102               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
103           >,
104           FunctionSpec<
105               "strpbrk",
106               RetValSpec<CharPtr>,
107               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
108           >,
109           FunctionSpec<
110               "strrchr",
111               RetValSpec<CharPtr>,
112               [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
113           >,
114           FunctionSpec<
115               "strspn",
116               RetValSpec<SizeTType>,
117               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
118           >,
119           FunctionSpec<
120               "strstr",
121               RetValSpec<CharPtr>,
122               [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
123           >,
124           FunctionSpec<
125               "strtok",
126               RetValSpec<CharPtr>,
127               [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>]
128           >,
129           FunctionSpec<
130               "strerror",
131               RetValSpec<CharPtr>,
132               [ArgSpec<IntType>]
133           >,
134           FunctionSpec<
135               "strlen",
136               RetValSpec<SizeTType>,
137               [ArgSpec<ConstCharPtr>]
138           >,
139       ]
140   >;
141
142   HeaderSpec Math = HeaderSpec<
143       "math.h",
144       [], // Macros
145       [
146           NamedType<"float_t">,
147           NamedType<"double_t">,
148       ],
149       [
150           FunctionSpec<"acos", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
151           FunctionSpec<"acosl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
152       ]
153   >;
154
155   HeaderSpec StdIO = HeaderSpec<
156       "stdio.h",
157       [], // Macros
158       [ // Types
159           SizeTType,
160       ],
161       [
162           FunctionSpec<
163               "snprintf",
164               RetValSpec<IntType>,
165               [ArgSpec<CharPtr>,
166                ArgSpec<SizeTType>,
167                ArgSpec<ConstCharRestrictedPtr>,
168                ArgSpec<VarArgType>]
169           >,
170       ]
171   >;
172
173   let Headers = [
174     Math,
175     String,
176     StdIO,
177   ];
178 }