api.td
2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
include "config/public_api.td"
include "spec/linux.td"
include "spec/posix.td"
include "spec/stdc.td"
def SizeT : TypeDecl<"size_t"> {
let Decl = [{
#define __need_size_t
#include <stddef.h>
}];
}
def OffT : TypeDecl<"off_t"> {
let Decl = [{
#define __need_off_t
#include <__posix-types.h>
}];
}
def NullMacro : MacroDef<"NULL"> {
let Defn = [{
#define __need_NULL
#include <stddef.h>
}];
}
def ErrnoMacro : MacroDef<"errno"> {
let Defn = [{
int *__errno_location();
#define errno (*__errno_location())
}];
}
def MathAPI : PublicAPI<"math.h"> {
let Functions = [
"acos",
"acosl",
];
}
def StringAPI : PublicAPI<"string.h"> {
let Functions = [
"memcpy",
"memmove",
"memcmp",
"memchr",
"memset",
"strcpy",
"strncpy",
"strcat",
"strncat",
"strcmp",
"strcoll",
"strncmp",
"strxfrm",
"strchr",
"strcspn",
"strpbrk",
"strrchr",
"strspn",
"strstr",
"strtok",
"strerror",
"strlen",
];
let TypeDeclarations = [
SizeT,
];
let Macros = [
NullMacro,
];
}
def StdIOAPI : PublicAPI<"stdio.h"> {
let TypeDeclarations = [
SizeT,
];
let Functions = [
"snprintf",
];
}
def ErrnoAPI : PublicAPI<"errno.h"> {
let Macros = [
ErrnoMacro,
// We largely depend on linux/errno.h to give us the
// various error macro definitions. However, some libc
// implementations have chosen to provide definitions
// for some of the error macros to account for the ones
// missing in linux/errno.h. There is no harm in doing
// the same here if we define the macros only when they
// are not already defined.
MacroDefineIfNot<"ENOTSUP", "EOPNOTSUPP">,
MacroDefineIfNot<"ECANCELED", "125">,
MacroDefineIfNot<"EOWNERDEAD", "130">,
MacroDefineIfNot<"ENOTRECOVERABLE", "131">,
MacroDefineIfNot<"ERFKILL", "132">,
MacroDefineIfNot<"EHWPOISON", "133">,
];
}
def SysMManAPI : PublicAPI<"sys/mman.h"> {
let Macros = [
SimpleMacroDef<"PROT_NONE", "0">,
SimpleMacroDef<"PROT_READ", "1">,
SimpleMacroDef<"PROT_WRITE", "2">,
SimpleMacroDef<"PROT_EXEC", "4">,
SimpleMacroDef<"MAP_FIXED", "1">,
SimpleMacroDef<"MAP_PRIVATE", "2">,
SimpleMacroDef<"MAP_SHARED", "4">,
SimpleMacroDef<"MAP_FAILED", "((void*)-1)">,
// TODO: The value of 0x20 is good for x86_64, but has to be extended
// in some manner to accommodate other machine architectures.
SimpleMacroDef<"MAP_ANONYMOUS", "0x20">
// TODO: Add other MAP_* macros used by Linux.
];
let TypeDeclarations = [
SizeT,
OffT,
];
let Functions = [
"mmap",
"munmap",
];
}