[libc] add isascii and toascii implementations
[lldb.git] / libc / spec / posix.td
1 def SigSetType : NamedType<"sigset_t">;
2 def SigSetPtrType : PtrType<SigSetType>;
3 def ConstSigSetPtrType : ConstType<SigSetPtrType>;
4 def RestrictedSigSetType : RestrictedPtrType<SigSetType>;
5 def ConstRestrictedSigSetType : ConstType<RestrictedSigSetType>;
6
7 def StructSigaction : NamedType<"struct sigaction">;
8 def StructSigactionPtr : PtrType<StructSigaction>;
9 def ConstStructSigactionPtr : ConstType<StructSigactionPtr>;
10 def RestrictedStructSigactionPtr : RestrictedPtrType<StructSigaction>;
11 def ConstRestrictedStructSigactionPtr : ConstType<RestrictedStructSigactionPtr>;
12
13 def POSIX : StandardSpec<"POSIX"> {
14   PtrType CharPtr = PtrType<CharType>;
15   RestrictedPtrType RestrictedCharPtr = RestrictedPtrType<CharType>;
16   RestrictedPtrType CharRestrictedDoublePtr = RestrictedPtrType<CharPtr>;
17   ConstType ConstCharPtr = ConstType<CharPtr>;
18   ConstType ConstRestrictedCharPtr = ConstType<RestrictedCharPtr>;
19
20   NamedType OffTType = NamedType<"off_t">;
21   NamedType SSizeTType = NamedType<"ssize_t">;
22
23   HeaderSpec Errno = HeaderSpec<
24       "errno.h",
25       [
26         Macro<"E2BIG">,
27         Macro<"EACCES">,
28         Macro<"EADDRINUSE">,
29         Macro<"EADDRNOTAVAIL">,
30         Macro<"EAFNOSUPPORT">,
31         Macro<"EAGAIN">,
32         Macro<"EALREADY">,
33         Macro<"EBADF">,
34         Macro<"EBADMSG">,
35         Macro<"EBUSY">,
36         Macro<"ECANCELED">,
37         Macro<"ECHILD">,
38         Macro<"ECONNABORTED">,
39         Macro<"ECONNREFUSED">,
40         Macro<"ECONNRESET">,
41         Macro<"EDEADLK">,
42         Macro<"EDESTADDRREQ">,
43         Macro<"EDQUOT">,
44         Macro<"EEXIST">,
45         Macro<"EFAULT">,
46         Macro<"EFBIG">,
47         Macro<"EHOSTUNREACH">,
48         Macro<"EIDRM">,
49         Macro<"EINPROGRESS">,
50         Macro<"EINTR">,
51         Macro<"EINVAL">,
52         Macro<"EIO">,
53         Macro<"EISCONN">,
54         Macro<"EISDIR">,
55         Macro<"ELOOP">,
56         Macro<"EMFILE">,
57         Macro<"EMLINK">,
58         Macro<"EMSGSIZE">,
59         Macro<"EMULTIHOP">,
60         Macro<"ENAMETOOLONG">,
61         Macro<"ENETDOWN">,
62         Macro<"ENETRESET">,
63         Macro<"ENETUNREACH">,
64         Macro<"ENFILE">,
65         Macro<"ENOBUFS">,
66         Macro<"ENODATA">,
67         Macro<"ENODEV">,
68         Macro<"ENOENT">,
69         Macro<"ENOEXEC">,
70         Macro<"ENOLCK">,
71         Macro<"ENOLINK">,
72         Macro<"ENOMEM">,
73         Macro<"ENOMSG">,
74         Macro<"ENOPROTOOPT">,
75         Macro<"ENOSPC">,
76         Macro<"ENOSR">,
77         Macro<"ENOSTR">,
78         Macro<"ENOSYS">,
79         Macro<"ENOTCONN">,
80         Macro<"ENOTDIR">,
81         Macro<"ENOTEMPTY">,
82         Macro<"ENOTRECOVERABLE">,
83         Macro<"ENOTSOCK">,
84         Macro<"ENOTSUP">,
85         Macro<"ENOTTY">,
86         Macro<"ENXIO">,
87         Macro<"EOPNOTSUPP">,
88         Macro<"EOVERFLOW">,
89         Macro<"EOWNERDEAD">,
90         Macro<"EPERM">,
91         Macro<"EPIPE">,
92         Macro<"EPROTO">,
93         Macro<"EPROTONOSUPPORT">,
94         Macro<"EPROTOTYPE">,
95         Macro<"EROFS">,
96         Macro<"ESPIPE">,
97         Macro<"ESRCH">,
98         Macro<"ESTALE">,
99         Macro<"ETIME">,
100         Macro<"ETIMEDOUT">,
101         Macro<"ETXTBSY">,
102         Macro<"EWOULDBLOCK">,
103         Macro<"EXDEV">,
104       ],
105       [], // Types
106       [], // Enumerations
107       []  // Functions
108   >;
109
110   HeaderSpec SysMMan = HeaderSpec<
111       "sys/mman.h",
112       [
113         // TODO: Add a facility to bunch macros into bitwise-or-able groups.
114         // POSIX requires it, so such thing should be captured in this spec.
115         Macro<"PROT_EXEC">,
116         Macro<"PROT_NONE">,
117         Macro<"PROT_READ">,
118         Macro<"PROT_WRITE">,
119
120         Macro<"MAP_FIXED">,
121         Macro<"MAP_PRIVATE">,
122         Macro<"MAP_SHARED">,
123
124         Macro<"MAP_FAILED">,
125       ],
126       [
127         SizeTType,
128         OffTType,
129       ],
130       [], // Enumerations
131       [
132         FunctionSpec<
133             "mmap",
134             RetValSpec<VoidPtr>,
135             [ArgSpec<VoidPtr>,
136              ArgSpec<SizeTType>,
137              ArgSpec<IntType>,
138              ArgSpec<IntType>,
139              ArgSpec<IntType>,
140              ArgSpec<OffTType>]
141         >,
142         FunctionSpec<
143             "munmap",
144             RetValSpec<IntType>,
145             [ArgSpec<VoidPtr>, ArgSpec<SizeTType>]
146         >,
147       ]
148   >;
149
150   HeaderSpec Signal = HeaderSpec<
151       "signal.h",
152       [], // Macros
153       [
154         SigSetType,
155         StructSigaction,
156       ],
157       [], // Enumerations
158       [
159         FunctionSpec<
160           "sigaction",
161           RetValSpec<IntType>,
162           [ArgSpec<IntType>,
163            ArgSpec<ConstRestrictedStructSigactionPtr>,
164            ArgSpec<RestrictedStructSigactionPtr>]
165         >,
166         FunctionSpec<
167           "sigdelset",
168           RetValSpec<IntType>,
169           [ArgSpec<SigSetPtrType>,
170            ArgSpec<IntType>]
171         >,
172         FunctionSpec<
173           "sigprocmask",
174           RetValSpec<IntType>,
175           [ArgSpec<IntType>, ArgSpec<ConstRestrictedSigSetType>, ArgSpec<RestrictedSigSetType>]
176         >,
177         FunctionSpec<
178           "sigemptyset",
179           RetValSpec<IntType>,
180           [ArgSpec<SigSetPtrType>]
181         >,
182         FunctionSpec<
183           "sigaddset",
184           RetValSpec<IntType>,
185           [ArgSpec<SigSetPtrType>,
186            ArgSpec<IntType>]
187         >,
188         FunctionSpec<
189           "sigfillset",
190           RetValSpec<IntType>,
191           [ArgSpec<SigSetPtrType>]
192         >,
193       ]
194   >;
195
196   HeaderSpec UniStd = HeaderSpec<
197     "unistd.h",
198     [], // Macros
199     [
200       SSizeTType,
201       SizeTType,
202     ],
203     [], // Enumerations
204     [
205         FunctionSpec<
206           "write",
207           RetValSpec<SSizeTType>,
208           [ArgSpec<IntType>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>]
209         >,
210     ]
211   >;
212   
213   HeaderSpec String = HeaderSpec<
214     "string.h",
215     [
216         Macro<"NULL">,
217     ],
218     [
219         SizeTType,
220     ],
221     [], // Enumerations
222     [
223         FunctionSpec<
224             "strnlen",
225              RetValSpec<SizeTType>,
226              [ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
227         >,
228         FunctionSpec<
229             "strtok_r",
230             RetValSpec<CharPtr>,
231             [ArgSpec<RestrictedCharPtr>,
232              ArgSpec<ConstRestrictedCharPtr>,
233              ArgSpec<CharRestrictedDoublePtr>]
234         >,
235     ]
236   >;
237
238   HeaderSpec CType = HeaderSpec<
239     "ctype.h",
240     [], // Macros
241     [], // Types
242     [], // Enumerations
243     [
244         FunctionSpec<
245             "isascii",
246             RetValSpec<IntType>,
247             [ArgSpec<IntType>]
248         >,
249     ]
250   >;
251
252   let Headers = [
253     CType,
254     Errno,
255     SysMMan,
256     Signal,
257     UniStd,
258     String
259   ];
260 }