[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / spec / posix.td
blobfc3fe421ca9192425d97b89a1330120da87f9a69
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>;
7 def SigInfoType : NamedType<"siginfo_t">;
8 def UnionSigVal : NamedType<"union sigval">;
10 def StructSigaction : NamedType<"struct sigaction">;
11 def StructSigactionPtr : PtrType<StructSigaction>;
12 def ConstStructSigactionPtr : ConstType<StructSigactionPtr>;
13 def RestrictedStructSigactionPtr : RestrictedPtrType<StructSigaction>;
14 def ConstRestrictedStructSigactionPtr : ConstType<RestrictedStructSigactionPtr>;
16 def PThreadStartT : NamedType<"__pthread_start_t">;
17 def PThreadTSSDtorT : NamedType<"__pthread_tss_dtor_t">;
18 def PThreadKeyT : NamedType<"pthread_key_t">;
19 def PThreadKeyTPtr : PtrType<PThreadKeyT>;
20 def PThreadOnceT : NamedType<"pthread_once_t">;
21 def PThreadOnceTPtr : PtrType<PThreadOnceT>;
22 def PThreadOnceCallback : NamedType<"__pthread_once_func_t">;
24 def InoT : NamedType<"ino_t">;
25 def UidT : NamedType<"uid_t">;
26 def GidT : NamedType<"gid_t">;
27 def DevT : NamedType<"dev_t">;
28 def ClockIdT : NamedType<"clockid_t">;
29 def BlkSizeT : NamedType<"blksize_t">;
30 def BlkCntT : NamedType<"blkcnt_t">;
31 def NLinkT : NamedType<"nlink_t">;
33 def StatType : NamedType<"struct stat">;
34 def StatTypePtr : PtrType<StatType>;
35 def RestrictedStatTypePtr : RestrictedPtrType<StatType>;
37 def DIR : NamedType<"DIR">;
38 def DIRPtr : PtrType<DIR>;
39 def DIRRestrictedPtr : RestrictedPtrType<DIR>;
40 def StructDirent : NamedType<"struct dirent">;
41 def StructDirentPtr : PtrType<StructDirent>;
42 def StructDirentPtrPtr : PtrType<StructDirentPtr>;
43 def ConstStructDirentPtrPtr : ConstType<StructDirentPtrPtr>;
45 def StructTimeSpec : NamedType<"struct timespec">;
46 def StructTimeSpecPtr : PtrType<StructTimeSpec>;
48 def ExecArgvT : NamedType<"__exec_argv_t">;
49 def ExecEnvpT : NamedType<"__exec_envp_t">;
51 def AtForkCallbackT : NamedType<"__atfork_callback_t">;
53 def PosixSpawnFileActionsT : NamedType<"posix_spawn_file_actions_t">;
54 def PosixSpawnFileActionsTPtr : PtrType<PosixSpawnFileActionsT>;
55 def ConstPosixSpawnFileActionsTPtr : ConstType<PosixSpawnFileActionsTPtr>;
56 def PosixSpawnFileActionsTRestrictedPtr : RestrictedPtrType<PosixSpawnFileActionsT>;
58 def PosixSpawnAttrT : NamedType<"posix_spawnattr_t">;
59 def RestrictedPosixSpawnAttrTPtrType : RestrictedPtrType<PosixSpawnAttrT>;
61 def CcT : NamedType<"cc_t">;
62 def SpeedT : NamedType<"speed_t">;
63 def StructTermios : NamedType<"struct termios">;
64 def StructTermiosPtr : PtrType<StructTermios>;
65 def ConstStructTermiosPtr : ConstType<StructTermiosPtr>;
66 def TcFlagT : NamedType<"tcflag_t">;
68 def StackT : NamedType<"stack_t">;
69 def StackTPtr : PtrType<StackT>;
70 def RestrictedStackTPtr : RestrictedPtrType<StackT>;
71 def ConstRestrictedStackTPtr : ConstType<RestrictedStackTPtr>;
73 def FdSet : NamedType<"fd_set">;
74 def FdSetPtr : PtrType<FdSet>;
75 def RestrictedFdSetPtr : RestrictedPtrType<FdSet>;
77 def GetoptArgvT : NamedType<"__getoptargv_t">;
79 def POSIX : StandardSpec<"POSIX"> {
80   PtrType CharPtr = PtrType<CharType>;
81   RestrictedPtrType RestrictedCharPtr = RestrictedPtrType<CharType>;
82   RestrictedPtrType CharRestrictedDoublePtr = RestrictedPtrType<CharPtr>;
83   ConstType ConstCharPtr = ConstType<CharPtr>;
84   ConstType ConstRestrictedCharPtr = ConstType<RestrictedCharPtr>;
86   NamedType ModeTType = NamedType<"mode_t">;
88   NamedType PThreadAttrTType = NamedType<"pthread_attr_t">;
89   PtrType PThreadAttrTPtr = PtrType<PThreadAttrTType>;
90   RestrictedPtrType RestrictedPThreadAttrTPtr = RestrictedPtrType<PThreadAttrTType>;
91   ConstType ConstPThreadAttrTPtr = ConstType<PThreadAttrTPtr>;
92   ConstType ConstRestrictedPThreadAttrTPtr = ConstType<RestrictedPThreadAttrTPtr>;
94   NamedType PThreadMutexAttrTType = NamedType<"pthread_mutexattr_t">;
95   PtrType PThreadMutexAttrTPtr = PtrType<PThreadMutexAttrTType>;
96   RestrictedPtrType RestrictedPThreadMutexAttrTPtr = RestrictedPtrType<PThreadMutexAttrTType>;
97   ConstType ConstPThreadMutexAttrTPtr = ConstType<PThreadMutexAttrTPtr>;
98   ConstType ConstRestrictedPThreadMutexAttrTPtr = ConstType<RestrictedPThreadMutexAttrTPtr>;
100   NamedType PThreadMutexTType = NamedType<"pthread_mutex_t">;
101   PtrType PThreadMutexTPtr = PtrType<PThreadMutexTType>;
102   RestrictedPtrType RestrictedPThreadMutexTPtr = RestrictedPtrType<PThreadMutexTType>;
103   ConstType ConstPThreadMutexTPtr = ConstType<PThreadMutexTPtr>;
104   ConstType ConstRestrictedPThreadMutexTPtr = ConstType<RestrictedPThreadMutexTPtr>;
106   PtrType PThreadTPtr = PtrType<PThreadTType>;
107   RestrictedPtrType RestrictedPThreadTPtr = RestrictedPtrType<PThreadTType>;
109   HeaderSpec Errno = HeaderSpec<
110       "errno.h",
111       [
112         Macro<"E2BIG">,
113         Macro<"EACCES">,
114         Macro<"EADDRINUSE">,
115         Macro<"EADDRNOTAVAIL">,
116         Macro<"EAFNOSUPPORT">,
117         Macro<"EAGAIN">,
118         Macro<"EALREADY">,
119         Macro<"EBADF">,
120         Macro<"EBADMSG">,
121         Macro<"EBUSY">,
122         Macro<"ECANCELED">,
123         Macro<"ECHILD">,
124         Macro<"ECONNABORTED">,
125         Macro<"ECONNREFUSED">,
126         Macro<"ECONNRESET">,
127         Macro<"EDEADLK">,
128         Macro<"EDESTADDRREQ">,
129         Macro<"EDQUOT">,
130         Macro<"EEXIST">,
131         Macro<"EFAULT">,
132         Macro<"EFBIG">,
133         Macro<"EHOSTUNREACH">,
134         Macro<"EIDRM">,
135         Macro<"EINPROGRESS">,
136         Macro<"EINTR">,
137         Macro<"EINVAL">,
138         Macro<"EIO">,
139         Macro<"EISCONN">,
140         Macro<"EISDIR">,
141         Macro<"ELOOP">,
142         Macro<"EMFILE">,
143         Macro<"EMLINK">,
144         Macro<"EMSGSIZE">,
145         Macro<"EMULTIHOP">,
146         Macro<"ENAMETOOLONG">,
147         Macro<"ENETDOWN">,
148         Macro<"ENETRESET">,
149         Macro<"ENETUNREACH">,
150         Macro<"ENFILE">,
151         Macro<"ENOBUFS">,
152         Macro<"ENODATA">,
153         Macro<"ENODEV">,
154         Macro<"ENOENT">,
155         Macro<"ENOEXEC">,
156         Macro<"ENOLCK">,
157         Macro<"ENOLINK">,
158         Macro<"ENOMEM">,
159         Macro<"ENOMSG">,
160         Macro<"ENOPROTOOPT">,
161         Macro<"ENOSPC">,
162         Macro<"ENOSR">,
163         Macro<"ENOSTR">,
164         Macro<"ENOSYS">,
165         Macro<"ENOTCONN">,
166         Macro<"ENOTDIR">,
167         Macro<"ENOTEMPTY">,
168         Macro<"ENOTRECOVERABLE">,
169         Macro<"ENOTSOCK">,
170         Macro<"ENOTSUP">,
171         Macro<"ENOTTY">,
172         Macro<"ENXIO">,
173         Macro<"EOPNOTSUPP">,
174         Macro<"EOVERFLOW">,
175         Macro<"EOWNERDEAD">,
176         Macro<"EPERM">,
177         Macro<"EPIPE">,
178         Macro<"EPROTO">,
179         Macro<"EPROTONOSUPPORT">,
180         Macro<"EPROTOTYPE">,
181         Macro<"EROFS">,
182         Macro<"ESPIPE">,
183         Macro<"ESRCH">,
184         Macro<"ESTALE">,
185         Macro<"ETIME">,
186         Macro<"ETIMEDOUT">,
187         Macro<"ETXTBSY">,
188         Macro<"EWOULDBLOCK">,
189         Macro<"EXDEV">,
190       ],
191       [], // Types
192       [], // Enumerations
193       []  // Functions
194   >;
196   HeaderSpec FCntl = HeaderSpec<
197     "fcntl.h",
198     [], // Macros
199     [ModeTType],
200     [], // Enumerations
201     [
202       FunctionSpec<
203           "creat",
204           RetValSpec<IntType>,
205           [ArgSpec<ConstCharPtr>, ArgSpec<ModeTType>]
206       >,
207       FunctionSpec<
208           "open",
209           RetValSpec<IntType>,
210           [ArgSpec<ConstCharPtr>, ArgSpec<IntType>, ArgSpec<VarArgType>]
211       >,
212       FunctionSpec<
213           "openat",
214           RetValSpec<IntType>,
215           [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>, ArgSpec<VarArgType>]
216       >,
217     ]
218   >;
220   HeaderSpec SysMMan = HeaderSpec<
221       "sys/mman.h",
222       [
223         // TODO: Add a facility to bunch macros into bitwise-or-able groups.
224         // POSIX requires it, so such thing should be captured in this spec.
225         Macro<"PROT_EXEC">,
226         Macro<"PROT_NONE">,
227         Macro<"PROT_READ">,
228         Macro<"PROT_WRITE">,
230         Macro<"MAP_FIXED">,
231         Macro<"MAP_PRIVATE">,
232         Macro<"MAP_SHARED">,
234         Macro<"MAP_FAILED">,
235       ],
236       [
237         SizeTType,
238         OffTType,
239       ],
240       [], // Enumerations
241       [
242         FunctionSpec<
243             "madvise",
244             RetValSpec<IntType>,
245             [ArgSpec<VoidPtr>,
246              ArgSpec<SizeTType>,
247              ArgSpec<IntType>]
248         >,
249         FunctionSpec<
250             "mmap",
251             RetValSpec<VoidPtr>,
252             [ArgSpec<VoidPtr>,
253              ArgSpec<SizeTType>,
254              ArgSpec<IntType>,
255              ArgSpec<IntType>,
256              ArgSpec<IntType>,
257              ArgSpec<OffTType>]
258         >,
259         FunctionSpec<
260             "mprotect",
261             RetValSpec<IntType>,
262             [ArgSpec<VoidPtr>,
263              ArgSpec<SizeTType>,
264              ArgSpec<IntType>]
265         >,
266         FunctionSpec<
267             "munmap",
268             RetValSpec<IntType>,
269             [ArgSpec<VoidPtr>, ArgSpec<SizeTType>]
270         >,
271         FunctionSpec<
272             "posix_madvise",
273             RetValSpec<IntType>,
274             [ArgSpec<VoidPtr>,
275              ArgSpec<SizeTType>,
276              ArgSpec<IntType>]
277         >,
278       ]
279   >;
281   HeaderSpec Signal = HeaderSpec<
282       "signal.h",
283       [], // Macros
284       [
285         SigInfoType,
286         SigSetType,
287         StackT,
288         StructSigaction,
289         UnionSigVal,
290         PidT,
291       ],
292       [], // Enumerations
293       [
294         FunctionSpec<
295           "kill",
296           RetValSpec<IntType>,
297           [ArgSpec<PidT>,
298             ArgSpec<IntType>]
299         >,
300         FunctionSpec<
301           "sigaction",
302           RetValSpec<IntType>,
303           [ArgSpec<IntType>,
304            ArgSpec<ConstRestrictedStructSigactionPtr>,
305            ArgSpec<RestrictedStructSigactionPtr>]
306         >,
307         FunctionSpec<
308           "sigaltstack",
309           RetValSpec<IntType>,
310           [ArgSpec<ConstRestrictedStackTPtr>, ArgSpec<RestrictedStackTPtr>]
311         >,
312         FunctionSpec<
313           "sigdelset",
314           RetValSpec<IntType>,
315           [ArgSpec<SigSetPtrType>,
316            ArgSpec<IntType>]
317         >,
318         FunctionSpec<
319           "sigprocmask",
320           RetValSpec<IntType>,
321           [ArgSpec<IntType>, ArgSpec<ConstRestrictedSigSetType>, ArgSpec<RestrictedSigSetType>]
322         >,
323         FunctionSpec<
324           "sigemptyset",
325           RetValSpec<IntType>,
326           [ArgSpec<SigSetPtrType>]
327         >,
328         FunctionSpec<
329           "sigaddset",
330           RetValSpec<IntType>,
331           [ArgSpec<SigSetPtrType>,
332            ArgSpec<IntType>]
333         >,
334         FunctionSpec<
335           "sigfillset",
336           RetValSpec<IntType>,
337           [ArgSpec<SigSetPtrType>]
338         >,
339       ]
340   >;
342   HeaderSpec UniStd = HeaderSpec<
343     "unistd.h",
344     [], // Macros
345     [
346       ExecArgvT,
347       ExecEnvpT,
348       OffTType,
349       SSizeTType,
350       SizeTType,
351       PidT,
352       UidT,
353       GetoptArgvT,
354     ],
355     [], // Enumerations
356     [
357         FunctionSpec<
358           "access",
359           RetValSpec<IntType>,
360           [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
361         >,
362         FunctionSpec<
363           "chdir",
364           RetValSpec<IntType>,
365           [ArgSpec<ConstCharPtr>]
366         >,
367         FunctionSpec<
368           "dup",
369           RetValSpec<IntType>,
370           [ArgSpec<IntType>]
371         >,
372         FunctionSpec<
373           "dup2",
374           RetValSpec<IntType>,
375           [ArgSpec<IntType>, ArgSpec<IntType>]
376         >,
377         FunctionSpec<
378           "dup3",
379           RetValSpec<IntType>,
380           [ArgSpec<IntType>, ArgSpec<IntType>, ArgSpec<IntType>]
381         >,
382         FunctionSpec<
383           "fchdir",
384           RetValSpec<IntType>,
385           [ArgSpec<IntType>]
386         >,
387         FunctionSpec<
388           "getcwd",
389           RetValSpec<CharPtr>,
390           [ArgSpec<CharPtr>, ArgSpec<SizeTType>]
391         >,
392         FunctionSpec<
393           "close",
394           RetValSpec<IntType>,
395           [ArgSpec<IntType>]
396         >,
397         FunctionSpec<
398           "execv",
399           RetValSpec<IntType>,
400           [ArgSpec<ConstCharPtr>, ArgSpec<ExecArgvT>]
401         >,
402         FunctionSpec<
403           "execve",
404           RetValSpec<IntType>,
405           [ArgSpec<ConstCharPtr>, ArgSpec<ExecArgvT>, ArgSpec<ExecEnvpT>]
406         >,
407         FunctionSpec<
408           "fork",
409           RetValSpec<PidT>,
410           [ArgSpec<VoidType>]
411         >,
412         FunctionSpec<
413           "fsync",
414           RetValSpec<IntType>,
415           [ArgSpec<IntType>]
416         >,
417         FunctionSpec<
418           "ftruncate",
419           RetValSpec<IntType>,
420           [ArgSpec<ConstCharPtr>, ArgSpec<OffTType>]
421         >,
422         FunctionSpec<
423           "geteuid",
424           RetValSpec<UidT>,
425           [ArgSpec<VoidType>]
426         >,
427         FunctionSpec<
428           "getpid",
429           RetValSpec<PidT>,
430           [ArgSpec<VoidType>]
431         >,
432         FunctionSpec<
433           "getppid",
434           RetValSpec<PidT>,
435           [ArgSpec<VoidType>]
436         >,
437         FunctionSpec<
438           "getuid",
439           RetValSpec<UidT>,
440           [ArgSpec<VoidType>]
441         >,
442         FunctionSpec<
443           "isatty",
444           RetValSpec<IntType>,
445           [ArgSpec<IntType>]
446         >,
447         FunctionSpec<
448           "link",
449           RetValSpec<IntType>,
450           [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
451         >,
452         FunctionSpec<
453           "linkat",
454           RetValSpec<IntType>,
455           [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
456         >,
457         FunctionSpec<
458           "lseek",
459           RetValSpec<OffTType>,
460           [ArgSpec<IntType>, ArgSpec<OffTType>, ArgSpec<IntType>]
461         >,
462         FunctionSpec<
463           "pread",
464           RetValSpec<SSizeTType>,
465           [ArgSpec<IntType>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>, ArgSpec<OffTType>]
466         >,
467         FunctionSpec<
468           "pwrite",
469           RetValSpec<SSizeTType>,
470           [ArgSpec<IntType>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>, ArgSpec<OffTType>]
471         >,
472         FunctionSpec<
473           "read",
474           RetValSpec<SSizeTType>,
475           [ArgSpec<IntType>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>]
476         >,
477         FunctionSpec<
478           "readlink",
479           RetValSpec<SSizeTType>,
480           [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<CharRestrictedPtr>, ArgSpec<SizeTType>]
481         >,
482         FunctionSpec<
483           "readlinkat",
484           RetValSpec<SSizeTType>,
485           [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<CharRestrictedPtr>, ArgSpec<SizeTType>]
486         >,
487         FunctionSpec<
488           "rmdir",
489           RetValSpec<IntType>,
490           [ArgSpec<ConstCharPtr>]
491         >,
492         FunctionSpec<
493           "getpid",
494           RetValSpec<IntType>,
495           [ArgSpec<VoidType>]
496         >,
497         FunctionSpec<
498           "getppid",
499           RetValSpec<IntType>,
500           [ArgSpec<VoidType>]
501         >,
502         FunctionSpec<
503           "link",
504           RetValSpec<IntType>,
505           [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
506         >,
507         FunctionSpec<
508           "linkat",
509           RetValSpec<IntType>,
510           [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
511         >,
512         FunctionSpec<
513           "lseek",
514           RetValSpec<OffTType>,
515           [ArgSpec<IntType>, ArgSpec<OffTType>, ArgSpec<IntType>]
516         >,
517         FunctionSpec<
518           "pread",
519           RetValSpec<SSizeTType>,
520           [ArgSpec<IntType>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>, ArgSpec<OffTType>]
521         >,
522         FunctionSpec<
523           "pwrite",
524           RetValSpec<SSizeTType>,
525           [ArgSpec<IntType>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>, ArgSpec<OffTType>]
526         >,
527         FunctionSpec<
528           "read",
529           RetValSpec<SSizeTType>,
530           [ArgSpec<IntType>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>]
531         >,
532         FunctionSpec<
533           "readlink",
534           RetValSpec<SSizeTType>,
535           [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<CharRestrictedPtr>, ArgSpec<SizeTType>]
536         >,
537         FunctionSpec<
538           "readlinkat",
539           RetValSpec<SSizeTType>,
540           [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<CharRestrictedPtr>, ArgSpec<SizeTType>]
541         >,
542         FunctionSpec<
543           "rmdir",
544           RetValSpec<IntType>,
545           [ArgSpec<ConstCharPtr>]
546         >,
547         FunctionSpec<
548           "symlink",
549           RetValSpec<IntType>,
550           [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
551         >,
552         FunctionSpec<
553           "symlinkat",
554           RetValSpec<IntType>,
555           [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>, ArgSpec<ConstCharPtr>]
556         >,
557         FunctionSpec<
558           "sysconf",
559           RetValSpec<IntType>,
560           [ArgSpec<IntType>]
561         >,
562         FunctionSpec<
563           "__llvm_libc_syscall",
564           RetValSpec<LongType>,
565           [ArgSpec<LongType>,ArgSpec<LongType>,ArgSpec<LongType>,ArgSpec<LongType>,ArgSpec<LongType>,ArgSpec<LongType>,ArgSpec<LongType>]
566         >,
567         FunctionSpec<
568           "truncate",
569           RetValSpec<IntType>,
570           [ArgSpec<IntType>, ArgSpec<OffTType>]
571         >,
572         FunctionSpec<
573           "unlink",
574           RetValSpec<IntType>,
575           [ArgSpec<ConstCharPtr>]
576         >,
577         FunctionSpec<
578           "unlinkat",
579           RetValSpec<IntType>,
580           [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
581         >,
582         FunctionSpec<
583           "write",
584           RetValSpec<SSizeTType>,
585           [ArgSpec<IntType>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>]
586         >,
587         FunctionSpec<
588           "getopt",
589           RetValSpec<IntType>,
590           [ArgSpec<IntType>, ArgSpec<GetoptArgvT>, ArgSpec<ConstCharPtr>]
591         >,
592     ],
593     [
594         ObjectSpec<"environ", "char **">,
595         ObjectSpec<
596           "optarg",
597           "char *"
598         >,
599         ObjectSpec<
600           "optind",
601           "int"
602         >,
603         ObjectSpec<
604           "opterr",
605           "int"
606         >,
607         ObjectSpec<
608           "optopt",
609           "int"
610         >,
611     ]
612   >;
614   HeaderSpec StdLib = HeaderSpec<
615     "stdlib.h",
616     [], // Macros
617     [], // Types
618     [], // Enumerations
619     [
620         FunctionSpec<
621           "getenv",
622           RetValSpec<CharPtr>,
623           [ArgSpec<ConstCharPtr>]
624         >,
625     ]
626   >;
628   HeaderSpec String = HeaderSpec<
629     "string.h",
630     [
631         Macro<"NULL">,
632     ],
633     [
634         SizeTType,
635     ],
636     [], // Enumerations
637     [
638         FunctionSpec<
639             "memccpy",
640             RetValSpec<VoidPtr>,
641             [ArgSpec<VoidRestrictedPtr>,
642              ArgSpec<ConstVoidRestrictedPtr>,
643              ArgSpec<IntType>,
644              ArgSpec<SizeTType>]
645         >,
646         FunctionSpec<
647             "mempcpy",
648             RetValSpec<VoidPtr>,
649             [ArgSpec<VoidRestrictedPtr>,
650              ArgSpec<ConstVoidRestrictedPtr>,
651              ArgSpec<SizeTType>]
652         >,
653         FunctionSpec<
654             "stpcpy",
655             RetValSpec<CharPtr>,
656             [ArgSpec<RestrictedCharPtr>,
657              ArgSpec<ConstRestrictedCharPtr>]
658         >,
659         FunctionSpec<
660             "stpncpy",
661             RetValSpec<CharPtr>,
662             [ArgSpec<RestrictedCharPtr>,
663              ArgSpec<ConstRestrictedCharPtr>,
664              ArgSpec<SizeTType>]
665         >,
666         FunctionSpec<
667             "strnlen",
668              RetValSpec<SizeTType>,
669              [ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
670         >,
671         FunctionSpec<
672             "strtok_r",
673             RetValSpec<CharPtr>,
674             [ArgSpec<RestrictedCharPtr>,
675              ArgSpec<ConstRestrictedCharPtr>,
676              ArgSpec<CharRestrictedDoublePtr>]
677         >,
678         FunctionSpec<
679             "strsignal",
680             RetValSpec<CharPtr>,
681             [ArgSpec<IntType>]
682         >,
683     ]
684   >;
686   HeaderSpec CType = HeaderSpec<
687     "ctype.h",
688     [], // Macros
689     [], // Types
690     [], // Enumerations
691     [
692         FunctionSpec<
693             "isascii",
694             RetValSpec<IntType>,
695             [ArgSpec<IntType>]
696         >,
697     ]
698   >;
700   NamedType RLimTType = NamedType<"rlim_t">;
701   NamedType StructRLimitType = NamedType<"struct rlimit">;
702   PtrType StructRLimitPtr = PtrType<StructRLimitType>;
703   ConstType ConstStructRLimitPtr = ConstType<StructRLimitType>;
704   HeaderSpec SysResource = HeaderSpec<
705     "sys/resource.h",
706     [], // Macros
707     [RLimTType, StructRLimitType], // Types
708     [], // Enumerations
709     [
710         FunctionSpec<
711           "getrlimit",
712           RetValSpec<IntType>,
713           [ArgSpec<StructRLimitPtr>]
714         >,
715         FunctionSpec<
716           "setrlimit",
717           RetValSpec<IntType>,
718           [ArgSpec<ConstStructRLimitPtr>]
719         >,
720     ]
721   >;
723   HeaderSpec SysStat = HeaderSpec<
724     "sys/stat.h",
725     [], // Macros
726     [
727         ModeTType,
728         DevT,
729         InoT,
730         UidT,
731         GidT,
732         StructTimeSpec,
733         StructTimevalType,
734         BlkSizeT,
735         BlkCntT,
736         OffTType,
737         NLinkT,
738         StatType,
739     ], // Types
740     [], // Enumerations
741     [
742         FunctionSpec<
743           "chmod",
744           RetValSpec<IntType>,
745           [ArgSpec<ConstCharPtr>, ArgSpec<ModeTType>]
746         >,
747         FunctionSpec<
748           "fchmod",
749           RetValSpec<IntType>,
750           [ArgSpec<IntType>, ArgSpec<ModeTType>]
751         >,
752         FunctionSpec<
753           "fchmodat",
754           RetValSpec<IntType>,
755           [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<ModeTType>, ArgSpec<IntType>]
756         >,
757         FunctionSpec<
758             "fstat",
759             RetValSpec<IntType>,
760             [ArgSpec<IntType>, ArgSpec<StatTypePtr>]
761         >,
762         FunctionSpec<
763             "lstat",
764             RetValSpec<IntType>,
765             [ArgSpec<ConstRestrictedCharPtr>, ArgSpec<RestrictedStatTypePtr>]
766         >,
767         FunctionSpec<
768             "mkdir",
769             RetValSpec<IntType>,
770             [ArgSpec<ConstCharPtr>, ArgSpec<ModeTType>]
771         >,
772         FunctionSpec<
773             "mkdirat",
774             RetValSpec<IntType>,
775             [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<ModeTType>]
776         >,
777         FunctionSpec<
778             "stat",
779             RetValSpec<IntType>,
780             [ArgSpec<ConstRestrictedCharPtr>, ArgSpec<RestrictedStatTypePtr>]
781         >,
782     ]
783   >;
785   NamedType StructUtsName = NamedType<"struct utsname">;
786   PtrType StructUtsNamePtr = PtrType<StructUtsName>;
787   HeaderSpec SysUtsName = HeaderSpec<
788     "sys/utsname.h",
789     [], // Macros
790     [StructUtsName], // Types
791     [], // Enumerations
792     [
793         FunctionSpec<
794             "uname",
795             RetValSpec<IntType>,
796             [ArgSpec<StructUtsNamePtr>]
797         >,
798     ]
799   >;
801   HeaderSpec ArpaInet = HeaderSpec<
802       "arpa/inet.h",
803       [], // Macros
804       [], // Types
805       [], // Enumerations
806       [
807           FunctionSpec<
808               "htonl",
809               RetValSpec<UInt32Type>,
810               [ArgSpec<UInt32Type>]
811           >,
812           FunctionSpec<
813               "htons",
814               RetValSpec<UInt16Type>,
815               [ArgSpec<UInt16Type>]
816           >,
817           FunctionSpec<
818               "ntohl",
819               RetValSpec<UInt32Type>,
820               [ArgSpec<UInt32Type>]
821           >,
822           FunctionSpec<
823               "ntohs",
824               RetValSpec<UInt16Type>,
825               [ArgSpec<UInt16Type>]
826           >,
827       ]
828   >;
830   HeaderSpec PThread = HeaderSpec<
831     "pthread.h",
832     [], // Macros
833     [
834         AtForkCallbackT,
835         PThreadAttrTType,
836         PThreadKeyT,
837         PThreadMutexAttrTType,
838         PThreadMutexTType,
839         PThreadOnceCallback,
840         PThreadOnceT,
841         PThreadStartT,
842         PThreadTSSDtorT,
843         PThreadTType,
844     ], // Types
845     [], // Enumerations
846     [
847       FunctionSpec<
848           "pthread_atfork",
849           RetValSpec<IntType>,
850           [ArgSpec<AtForkCallbackT>, ArgSpec<AtForkCallbackT>, ArgSpec<AtForkCallbackT>]
851       >,
852       FunctionSpec<
853           "pthread_attr_init",
854           RetValSpec<IntType>,
855           [ArgSpec<PThreadAttrTPtr>]
856       >,
857       FunctionSpec<
858           "pthread_attr_destroy",
859           RetValSpec<IntType>,
860           [ArgSpec<PThreadAttrTPtr>]
861       >,
862       FunctionSpec<
863           "pthread_attr_getdetachstate",
864           RetValSpec<IntType>,
865           [ArgSpec<ConstPThreadAttrTPtr>, ArgSpec<IntPtr>]
866       >,
867       FunctionSpec<
868           "pthread_attr_setdetachstate",
869           RetValSpec<IntType>,
870           [ArgSpec<PThreadAttrTPtr>, ArgSpec<IntType>]
871       >,
872       FunctionSpec<
873           "pthread_attr_getguardsize",
874           RetValSpec<IntType>,
875           [ArgSpec<ConstRestrictedPThreadAttrTPtr>, ArgSpec<RestrictedSizeTPtr>]
876       >,
877       FunctionSpec<
878           "pthread_attr_setguardsize",
879           RetValSpec<IntType>,
880           [ArgSpec<PThreadAttrTPtr>, ArgSpec<SizeTType>]
881       >,
882       FunctionSpec<
883           "pthread_attr_getstacksize",
884           RetValSpec<IntType>,
885           [ArgSpec<ConstRestrictedPThreadAttrTPtr>, ArgSpec<RestrictedSizeTPtr>]
886       >,
887       FunctionSpec<
888           "pthread_attr_setstacksize",
889           RetValSpec<IntType>,
890           [ArgSpec<PThreadAttrTPtr>, ArgSpec<SizeTType>]
891       >,
892       FunctionSpec<
893           "pthread_attr_getstack",
894           RetValSpec<IntType>,
895           [ArgSpec<ConstRestrictedPThreadAttrTPtr>, ArgSpec<RestrictedVoidPtrPtr>, ArgSpec<RestrictedSizeTPtr>]
896       >,
897       FunctionSpec<
898           "pthread_attr_setstack",
899           RetValSpec<IntType>,
900           [ArgSpec<PThreadAttrTPtr>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>]
901       >,
902       FunctionSpec<
903           "pthread_create",
904           RetValSpec<IntType>,
905           [ArgSpec<RestrictedPThreadTPtr>, ArgSpec<ConstRestrictedPThreadAttrTPtr>, ArgSpec<PThreadStartT>, ArgSpec<VoidPtr>]
906       >,
907       FunctionSpec<
908           "pthread_join",
909           RetValSpec<IntType>,
910           [ArgSpec<PThreadTType>, ArgSpec<VoidPtrPtr>]
911       >,
912       FunctionSpec<
913           "pthread_detach",
914           RetValSpec<IntType>,
915           [ArgSpec<PThreadTType>]
916       >,
917       FunctionSpec<
918           "pthread_exit",
919           RetValSpec<VoidType>,
920           [ArgSpec<VoidPtr>]
921       >,
922       FunctionSpec<
923           "pthread_self",
924           RetValSpec<PThreadTType>,
925           [ArgSpec<VoidType>]
926       >,
927       FunctionSpec<
928           "pthread_equal",
929           RetValSpec<IntType>,
930           [ArgSpec<PThreadTType>, ArgSpec<PThreadTType>]
931       >,
932       FunctionSpec<
933           "pthread_mutexattr_init",
934           RetValSpec<IntType>,
935           [ArgSpec<PThreadMutexAttrTPtr>]
936       >,
937       FunctionSpec<
938           "pthread_mutexattr_destroy",
939           RetValSpec<IntType>,
940           [ArgSpec<PThreadMutexAttrTPtr>]
941       >,
942       FunctionSpec<
943           "pthread_mutexattr_gettype",
944           RetValSpec<IntType>,
945           [ArgSpec<ConstRestrictedPThreadMutexAttrTPtr>, ArgSpec<RestrictedIntPtr>]
946       >,
947       FunctionSpec<
948           "pthread_mutexattr_settype",
949           RetValSpec<IntType>,
950           [ArgSpec<RestrictedPThreadMutexAttrTPtr>, ArgSpec<IntType>]
951       >,
952       FunctionSpec<
953           "pthread_mutexattr_getrobust",
954           RetValSpec<IntType>,
955           [ArgSpec<ConstRestrictedPThreadMutexAttrTPtr>, ArgSpec<RestrictedIntPtr>]
956       >,
957       FunctionSpec<
958           "pthread_mutexattr_setrobust",
959           RetValSpec<IntType>,
960           [ArgSpec<RestrictedPThreadMutexAttrTPtr>, ArgSpec<IntType>]
961       >,
962       FunctionSpec<
963           "pthread_mutexattr_getpshared",
964           RetValSpec<IntType>,
965           [ArgSpec<ConstRestrictedPThreadMutexAttrTPtr>, ArgSpec<RestrictedIntPtr>]
966       >,
967       FunctionSpec<
968           "pthread_mutexattr_setpshared",
969           RetValSpec<IntType>,
970           [ArgSpec<RestrictedPThreadMutexAttrTPtr>, ArgSpec<IntType>]
971       >,
972       FunctionSpec<
973           "pthread_mutexattr_getprotocol",
974           RetValSpec<IntType>,
975           [ArgSpec<ConstRestrictedPThreadMutexAttrTPtr>, ArgSpec<RestrictedIntPtr>]
976       >,
977       FunctionSpec<
978           "pthread_mutexattr_setprotocol",
979           RetValSpec<IntType>,
980           [ArgSpec<RestrictedPThreadMutexAttrTPtr>, ArgSpec<IntType>]
981       >,
982       FunctionSpec<
983           "pthread_mutexattr_getprioceiling",
984           RetValSpec<IntType>,
985           [ArgSpec<ConstRestrictedPThreadMutexAttrTPtr>, ArgSpec<RestrictedIntPtr>]
986       >,
987       FunctionSpec<
988           "pthread_mutexattr_setprioceiling",
989           RetValSpec<IntType>,
990           [ArgSpec<RestrictedPThreadMutexAttrTPtr>, ArgSpec<IntType>]
991       >,
992       FunctionSpec<
993           "pthread_mutex_init",
994           RetValSpec<IntType>,
995           [ArgSpec<RestrictedPThreadMutexTPtr>, ArgSpec<ConstRestrictedPThreadMutexAttrTPtr>]
996       >,
997       FunctionSpec<
998           "pthread_mutex_destroy",
999           RetValSpec<IntType>,
1000           [ArgSpec<PThreadMutexTPtr>]
1001       >,
1002       FunctionSpec<
1003           "pthread_mutex_lock",
1004           RetValSpec<IntType>,
1005           [ArgSpec<PThreadMutexTPtr>]
1006       >,
1007       FunctionSpec<
1008           "pthread_mutex_unlock",
1009           RetValSpec<IntType>,
1010           [ArgSpec<PThreadMutexTPtr>]
1011       >,
1012       FunctionSpec<
1013           "pthread_key_create",
1014           RetValSpec<IntType>,
1015           [ArgSpec<PThreadKeyTPtr>, ArgSpec<PThreadTSSDtorT>]
1016       >,
1017       FunctionSpec<
1018           "pthread_key_delete",
1019           RetValSpec<IntType>,
1020           [ArgSpec<PThreadKeyT>]
1021       >,
1022       FunctionSpec<
1023           "pthread_getspecific",
1024           RetValSpec<VoidPtr>,
1025           [ArgSpec<PThreadKeyT>]
1026       >,
1027       FunctionSpec<
1028           "pthread_setspecific",
1029           RetValSpec<VoidPtr>,
1030           [ArgSpec<PThreadKeyT>, ArgSpec<ConstVoidPtr>]
1031       >,
1032       FunctionSpec<
1033           "pthread_once",
1034           RetValSpec<IntType>,
1035           [ArgSpec<PThreadOnceTPtr>, ArgSpec<PThreadOnceCallback>]
1036       >,
1037     ]
1038   >;
1040   HeaderSpec StdIO = HeaderSpec<
1041       "stdio.h",
1042       [], // Macros
1043       [], // Types
1044       [], // Enumerations
1045       [
1046           FunctionSpec<
1047               "flockfile",
1048               RetValSpec<VoidType>,
1049               [ArgSpec<FILEPtr>]
1050           >,
1051           FunctionSpec<
1052               "funlockfile",
1053               RetValSpec<VoidType>,
1054               [ArgSpec<FILEPtr>]
1055           >,
1056           FunctionSpec<
1057               "getc_unlocked",
1058               RetValSpec<IntType>,
1059               [ArgSpec<FILEPtr>]
1060           >,
1061       ]
1062   >;
1064   HeaderSpec Dirent = HeaderSpec<
1065       "dirent.h",
1066       [], // Macros
1067       [InoT, StructDirent, DIR], // Types
1068       [], // Enumerations
1069       [
1070           FunctionSpec<
1071               "alphasort",
1072               RetValSpec<IntType>,
1073               [ArgSpec<ConstStructDirentPtrPtr>, ArgSpec<ConstStructDirentPtrPtr>]
1074           >,
1075           FunctionSpec<
1076               "closedir",
1077               RetValSpec<IntType>,
1078               [ArgSpec<DIRPtr>]
1079           >,
1080           FunctionSpec<
1081               "dirfd",
1082               RetValSpec<IntType>,
1083               [ArgSpec<DIRPtr>]
1084           >,
1085           FunctionSpec<
1086               "fdopendir",
1087               RetValSpec<DIRPtr>,
1088               [ArgSpec<IntType>]
1089           >,
1090           FunctionSpec<
1091               "opendir",
1092               RetValSpec<DIRPtr>,
1093               [ArgSpec<ConstCharPtr>]
1094           >,
1095           FunctionSpec<
1096               "readdir",
1097               RetValSpec<StructDirentPtr>,
1098               [ArgSpec<DIRPtr>]
1099           >,
1100       ]
1101   >;
1103   HeaderSpec Time = HeaderSpec<
1104       "time.h",
1105       [], // Macros
1106       [ClockIdT, StructTimeSpec, StructTimevalType], // Types
1107       [], // Enumerations
1108       [
1109           FunctionSpec<
1110               "clock_gettime",
1111               RetValSpec<IntType>,
1112               [ArgSpec<ClockIdT>, ArgSpec<StructTimeSpecPtr>]
1113           >,
1114           FunctionSpec<
1115               "gettimeofday",
1116               RetValSpec<IntType>,
1117               [ArgSpec<StructTimevalPtr>, ArgSpec<VoidPtr>]
1118           >,
1119           FunctionSpec<
1120               "nanosleep",
1121               RetValSpec<IntType>,
1122               [ArgSpec<StructTimeSpecPtr>, ArgSpec<StructTimeSpecPtr>]
1123           >,
1124       ]
1125   >;
1127   HeaderSpec SysWait = HeaderSpec<
1128     "sys/wait.h",
1129     [], // Macros
1130     [PidT, StructRUsage],
1131     [], // Enumerations
1132     [
1133       FunctionSpec<
1134         "wait",
1135         RetValSpec<PidT>,
1136         [ArgSpec<IntPtr>]
1137       >,
1138       FunctionSpec<
1139         "waitpid",
1140         RetValSpec<PidT>,
1141         [ArgSpec<PidT>, ArgSpec<IntPtr>, ArgSpec<IntType>]
1142       >
1143     ]
1144   >;
1146   HeaderSpec SysIOctl = HeaderSpec<
1147     "sys/ioctl.h",
1148     [
1149       Macro<"TIOCGETD">,
1150     ],  // Macros
1151     [], // Types
1152     [], // Enumerations
1153     []  // Functions
1154   >;
1156   HeaderSpec Spawn = HeaderSpec<
1157     "spawn.h",
1158     [], // Macros
1159     [ModeTType, PosixSpawnAttrT, PidT, PosixSpawnFileActionsT],
1160     [], // Enumerations
1161     [
1162       FunctionSpec<
1163         "posix_spawn_file_actions_addclose",
1164         RetValSpec<IntType>,
1165         [ArgSpec<PosixSpawnFileActionsTPtr>, ArgSpec<IntType>]
1166       >,
1167       FunctionSpec<
1168         "posix_spawn_file_actions_adddup2",
1169         RetValSpec<IntType>,
1170         [ArgSpec<PosixSpawnFileActionsTPtr>, ArgSpec<IntType>, ArgSpec<IntType>]
1171       >,
1172       FunctionSpec<
1173         "posix_spawn_file_actions_addopen",
1174         RetValSpec<IntType>,
1175         [ArgSpec<PosixSpawnFileActionsTRestrictedPtr>, ArgSpec<IntType>,
1176          ArgSpec<ConstCharRestrictedPtr>, ArgSpec<IntType>, ArgSpec<ModeTType>]
1177       >,
1178       FunctionSpec<
1179         "posix_spawn_file_actions_destroy",
1180         RetValSpec<IntType>,
1181         [ArgSpec<PosixSpawnFileActionsTPtr>]
1182       >,
1183       FunctionSpec<
1184         "posix_spawn_file_actions_init",
1185         RetValSpec<IntType>,
1186         [ArgSpec<PosixSpawnFileActionsTPtr>]
1187       >,
1188       FunctionSpec<
1189         "posix_spawn",
1190         RetValSpec<IntType>,
1191         [ArgSpec<RestrictedPidTPtr>, ArgSpec<ConstCharRestrictedPtr>,
1192          ArgSpec<PosixSpawnFileActionsTPtr>, ArgSpec<RestrictedPosixSpawnAttrTPtrType>,
1193          ArgSpec<ConstCharRestrictedPtrPtr>, ArgSpec<ConstCharRestrictedPtrPtr>]
1194       >,
1195     ]
1196   >;
1198   HeaderSpec Termios = HeaderSpec<
1199     "termios.h",
1200     [
1201       Macro<"NCCS">,
1202     ],
1203     [CcT, PidT, SpeedT, StructTermios, TcFlagT], // Types
1204     [], // Enumerations
1205     [
1206       FunctionSpec<
1207         "cfgetispeed",
1208         RetValSpec<SpeedT>,
1209         [ArgSpec<ConstStructTermiosPtr>]
1210       >,
1211       FunctionSpec<
1212         "cfgetospeed",
1213         RetValSpec<SpeedT>,
1214         [ArgSpec<ConstStructTermiosPtr>]
1215       >,
1216       FunctionSpec<
1217         "cfsetispeed",
1218         RetValSpec<SpeedT>,
1219         [ArgSpec<StructTermiosPtr>, ArgSpec<SpeedT>]
1220       >,
1221       FunctionSpec<
1222         "cfsetospeed",
1223         RetValSpec<SpeedT>,
1224         [ArgSpec<StructTermiosPtr>, ArgSpec<SpeedT>]
1225       >,
1226       FunctionSpec<
1227         "tcdrain",
1228         RetValSpec<IntType>,
1229         [ArgSpec<IntType>]
1230       >,
1231       FunctionSpec<
1232         "tcflow",
1233         RetValSpec<IntType>,
1234         [ArgSpec<IntType>, ArgSpec<IntType>]
1235       >,
1236       FunctionSpec<
1237         "tcflush",
1238         RetValSpec<IntType>,
1239         [ArgSpec<IntType>, ArgSpec<IntType>]
1240       >,
1241       FunctionSpec<
1242         "tcgetattr",
1243         RetValSpec<IntType>,
1244         [ArgSpec<IntType>, ArgSpec<StructTermiosPtr>]
1245       >,
1246       FunctionSpec<
1247         "tcgetsid",
1248         RetValSpec<PidT>,
1249         [ArgSpec<IntType>]
1250       >,
1251       FunctionSpec<
1252         "tcsendbreak",
1253         RetValSpec<IntType>,
1254         [ArgSpec<IntType>, ArgSpec<IntType>]
1255       >,
1256       FunctionSpec<
1257         "tcsetattr",
1258         RetValSpec<IntType>,
1259         [ArgSpec<IntType>, ArgSpec<IntType>, ArgSpec<StructTermiosPtr>]
1260       >,
1261     ]
1262   >;
1264   HeaderSpec SysSelect = HeaderSpec<
1265     "sys/select.h",
1266     [], // Macros
1267     [FdSet, SigSetType, StructTimevalType, StructTimeSpec, SuSecondsT, TimeTType],
1268     [], // Enumerations
1269     [
1270       FunctionSpec<
1271         "select",
1272         RetValSpec<IntType>,
1273         [
1274             ArgSpec<IntType>, ArgSpec<RestrictedFdSetPtr>, ArgSpec<RestrictedFdSetPtr>,
1275             ArgSpec<RestrictedFdSetPtr>, ArgSpec<RestrictedStructTimevalPtr>
1276         ]
1277       >
1278     ]
1279   >;
1281   HeaderSpec SysTypes = HeaderSpec<
1282     "sys/types.h",
1283     [], // Macros
1284     [BlkCntT, BlkSizeT, ClockIdT, DevT, GidT, InoT, ModeTType, NLinkT, OffTType, PidT,
1285      PThreadAttrTType, PThreadKeyT, PThreadMutexTType, PThreadMutexAttrTType, PThreadOnceT, PThreadTType,
1286      SizeTType, SSizeTType, SuSecondsT, TimeTType, UidT],
1287     [], // Enumerations
1288     []  // Functions
1289   >;
1291   let Headers = [
1292     ArpaInet,
1293     CType,
1294     Dirent,
1295     Errno,
1296     FCntl,
1297     PThread,
1298     Signal,
1299     Spawn,
1300     StdIO,
1301     StdLib,
1302     SysIOctl,
1303     SysMMan,
1304     SysResource,
1305     SysSelect,
1306     SysStat,
1307     SysTypes,
1308     SysUtsName,
1309     SysWait,
1310     Time,
1311     Termios,
1312     UniStd,
1313     String
1314   ];