1 include "config/public_api.td"
3 include "spec/linux.td"
4 include "spec/posix.td"
7 def SizeT : TypeDecl<"size_t"> {
14 def OffT : TypeDecl<"off_t"> {
17 #include <__posix-types.h>
21 def NullMacro : MacroDef<"NULL"> {
28 def ErrnoMacro : MacroDef<"errno"> {
33 int *__errno_location();
34 #define errno (*__errno_location())
38 def MathAPI : PublicAPI<"math.h"> {
45 def StringAPI : PublicAPI<"string.h"> {
71 let TypeDeclarations = [
80 def StdIOAPI : PublicAPI<"stdio.h"> {
81 let TypeDeclarations = [
90 def StdlibAPI : PublicAPI<"stdlib.h"> {
97 def ErrnoAPI : PublicAPI<"errno.h"> {
100 // We largely depend on linux/errno.h to give us the
101 // various error macro definitions. However, some libc
102 // implementations have chosen to provide definitions
103 // for some of the error macros to account for the ones
104 // missing in linux/errno.h. There is no harm in doing
105 // the same here if we define the macros only when they
106 // are not already defined.
107 MacroDefineIfNot<"ENOTSUP", "EOPNOTSUPP">,
108 MacroDefineIfNot<"ECANCELED", "125">,
109 MacroDefineIfNot<"EOWNERDEAD", "130">,
110 MacroDefineIfNot<"ENOTRECOVERABLE", "131">,
111 MacroDefineIfNot<"ERFKILL", "132">,
112 MacroDefineIfNot<"EHWPOISON", "133">,
116 def SysMManAPI : PublicAPI<"sys/mman.h"> {
118 SimpleMacroDef<"PROT_NONE", "0">,
119 SimpleMacroDef<"PROT_READ", "1">,
120 SimpleMacroDef<"PROT_WRITE", "2">,
121 SimpleMacroDef<"PROT_EXEC", "4">,
123 SimpleMacroDef<"MAP_FIXED", "1">,
124 SimpleMacroDef<"MAP_PRIVATE", "2">,
125 SimpleMacroDef<"MAP_SHARED", "4">,
127 SimpleMacroDef<"MAP_FAILED", "((void*)-1)">,
129 // TODO: The value of 0x20 is good for x86_64, but has to be extended
130 // in some manner to accommodate other machine architectures.
131 SimpleMacroDef<"MAP_ANONYMOUS", "0x20">
133 // TODO: Add other MAP_* macros used by Linux.
136 let TypeDeclarations = [
147 def SignalAPI : PublicAPI<"signal.h"> {
156 def MtxT : TypeDecl<"mtx_t"> {
159 unsigned char __internal_data[4];
165 def ThreadStartT : TypeDecl<"thrd_start_t"> {
166 let Decl = "typedef int (*thrd_start_t)(void *);";
169 def ThreadsAPI : PublicAPI<"threads.h"> {
170 let TypeDeclarations = [