Skip to content

Commit aa63b90

Browse files
committed
[libc] Implement process_mrelease #117851
1 parent b6dfdd2 commit aa63b90

File tree

12 files changed

+457
-1
lines changed

12 files changed

+457
-1
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ set(TARGET_LIBC_ENTRYPOINTS
252252
libc.src.sys.mman.munlockall
253253
libc.src.sys.mman.munmap
254254
libc.src.sys.mman.remap_file_pages
255+
libc.src.sys.mman.process_mrelease
255256
libc.src.sys.mman.posix_madvise
256257
libc.src.sys.mman.shm_open
257258
libc.src.sys.mman.shm_unlink

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ set(TARGET_LIBC_ENTRYPOINTS
251251
libc.src.sys.mman.munmap
252252
libc.src.sys.mman.remap_file_pages
253253
libc.src.sys.mman.posix_madvise
254+
libc.src.sys.mman.process_mrelease
254255
libc.src.sys.mman.shm_open
255256
libc.src.sys.mman.shm_unlink
256257

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ set(TARGET_LIBC_ENTRYPOINTS
252252
libc.src.sys.mman.munmap
253253
libc.src.sys.mman.remap_file_pages
254254
libc.src.sys.mman.posix_madvise
255+
libc.src.sys.mman.process_mrelease
255256
libc.src.sys.mman.shm_open
256257
libc.src.sys.mman.shm_unlink
257258

libc/hdrgen/yaml/sys/mman.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,10 @@ functions:
132132
return_type: int
133133
arguments:
134134
- type: const char *
135+
- name: process_mrelease
136+
standards:
137+
- Linux
138+
return_type: int
139+
arguments:
140+
- type: int
141+
- type: unsigned int

libc/include/sys/syscall.h.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,5 +2349,12 @@
23492349
#define SYS_writev __NR_writev
23502350
#endif
23512351

2352+
#ifdef __NR_process_mrelease
2353+
#define SYS_process_mrelease __NR_process_mrelease
2354+
#endif
2355+
2356+
#ifdef __NR_pidfd_open
2357+
#define SYS_pidfd_open __NR_pidfd_open
2358+
#endif
23522359

23532360
#endif // LLVM_LIBC_SYS_SYSCALL_H

libc/spec/linux.td

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
def StructEpollEvent : NamedType<"struct epoll_event">;
2+
def StructEpollEventPtr : PtrType<StructEpollEvent>;
3+
4+
def StructEpollData : NamedType<"struct epoll_data">;
5+
6+
def Linux : StandardSpec<"Linux"> {
7+
HeaderSpec Errno = HeaderSpec<
8+
"errno.h",
9+
[
10+
Macro<"ENOMEDIUM">,
11+
Macro<"ENOTBLK">,
12+
Macro<"EMEDIUMTYPE">,
13+
Macro<"EBADSLT">,
14+
Macro<"ECHRNG">,
15+
Macro<"ERFKILL">,
16+
Macro<"EUSERS">,
17+
Macro<"EBADR">,
18+
Macro<"EL3HLT">,
19+
Macro<"ENOTUNIQ">,
20+
Macro<"EXFULL">,
21+
Macro<"EHOSTDOWN">,
22+
Macro<"EL3RST">,
23+
Macro<"ENOPKG">,
24+
Macro<"ENOCSI">,
25+
Macro<"EUNATCH">,
26+
Macro<"EREMCHG">,
27+
Macro<"ETOOMANYREFS">,
28+
Macro<"EL2HLT">,
29+
Macro<"EBADFD">,
30+
Macro<"EREMOTEIO">,
31+
Macro<"ENAVAIL">,
32+
Macro<"ELIBEXEC">,
33+
Macro<"ESHUTDOWN">,
34+
Macro<"ENOKEY">,
35+
Macro<"ESTRPIPE">,
36+
Macro<"EKEYREJECTED">,
37+
Macro<"ESRMNT">,
38+
Macro<"EKEYREVOKED">,
39+
Macro<"EBADE">,
40+
Macro<"ELIBBAD">,
41+
Macro<"EISNAM">,
42+
Macro<"EBFONT">,
43+
Macro<"EPFNOSUPPORT">,
44+
Macro<"EREMOTE">,
45+
Macro<"EDEADLOCK">,
46+
Macro<"ENONET">,
47+
Macro<"EDOTDOT">,
48+
Macro<"EKEYEXPIRED">,
49+
Macro<"ELIBSCN">,
50+
Macro<"ERESTART">,
51+
Macro<"EBADRQC">,
52+
Macro<"EUCLEAN">,
53+
Macro<"ENOANO">,
54+
Macro<"ELIBACC">,
55+
Macro<"EHWPOISON">,
56+
Macro<"ELIBMAX">,
57+
Macro<"ESOCKTNOSUPPORT">,
58+
Macro<"ENOTNAM">,
59+
Macro<"ELNRNG">,
60+
Macro<"EL2NSYNC">,
61+
Macro<"EADV">,
62+
Macro<"ECOMM">,
63+
]
64+
>;
65+
66+
HeaderSpec Sched = HeaderSpec<
67+
"sched.h",
68+
[
69+
Macro<"SCHED_OTHER">,
70+
Macro<"SCHED_FIFO">,
71+
Macro<"SCHED_RR">,
72+
Macro<"SCHED_BATCH">,
73+
Macro<"SCHED_ISO">,
74+
Macro<"SCHED_IDLE">,
75+
Macro<"SCHED_DEADLINE">,
76+
],
77+
[], // Types
78+
[], // Enumerations
79+
[] // Functions
80+
>;
81+
82+
HeaderSpec SysMMan = HeaderSpec<
83+
"sys/mman.h",
84+
[Macro<"MAP_ANONYMOUS">],
85+
[], // Types
86+
[], // Enumerations
87+
[
88+
FunctionSpec<
89+
"mincore",
90+
RetValSpec<IntType>,
91+
[
92+
ArgSpec<VoidPtr>,
93+
ArgSpec<SizeTType>,
94+
ArgSpec<UnsignedCharPtr>,
95+
]
96+
>,
97+
FunctionSpec<
98+
"mlock2",
99+
RetValSpec<IntType>,
100+
[
101+
ArgSpec<VoidPtr>,
102+
ArgSpec<SizeTType>,
103+
ArgSpec<UnsignedIntType>,
104+
]
105+
>,
106+
FunctionSpec<
107+
"remap_file_pages",
108+
RetValSpec<IntType>,
109+
[
110+
ArgSpec<VoidPtr>,
111+
ArgSpec<SizeTType>,
112+
ArgSpec<IntType>,
113+
ArgSpec<SizeTType>,
114+
ArgSpec<IntType>,
115+
FunctionSpec<
116+
"process_mrelease",
117+
RetValSpec<IntType>,
118+
[
119+
ArgSpec<IntType>,
120+
ArgSpec<UnsignedIntType>
121+
]
122+
>,
123+
FunctionSpec<
124+
"mremap",
125+
RetValSpec<VoidPtr>,
126+
[
127+
ArgSpec<VoidPtr>,
128+
ArgSpec<SizeTType>,
129+
ArgSpec<SizeTType>,
130+
ArgSpec<IntType>,
131+
ArgSpec<VarArgType>,
132+
]
133+
>,
134+
] // Functions
135+
>;
136+
137+
138+
HeaderSpec SysPrctl = HeaderSpec<
139+
"sys/prctl.h",
140+
[], // Macros
141+
[], // Types
142+
[], // Enumerations
143+
[
144+
FunctionSpec<
145+
"prctl",
146+
RetValSpec<IntType>,
147+
[
148+
ArgSpec<IntType>,
149+
ArgSpec<UnsignedLongType>,
150+
ArgSpec<UnsignedLongType>,
151+
ArgSpec<UnsignedLongType>,
152+
ArgSpec<UnsignedLongType>,
153+
]
154+
>,
155+
] // Functions
156+
>;
157+
158+
HeaderSpec SysRandom = HeaderSpec<
159+
"sys/random.h",
160+
[
161+
Macro<"GRND_RANDOM">,
162+
Macro<"GRND_NONBLOCK">,
163+
Macro<"GRND_INSECURE">,
164+
],
165+
[SizeTType, SSizeTType], // Types
166+
[], // Enumerations
167+
[
168+
FunctionSpec<
169+
"getrandom",
170+
RetValSpec<SSizeTType>,
171+
[
172+
ArgSpec<VoidPtr>,
173+
ArgSpec<SizeTType>,
174+
ArgSpec<UnsignedIntType>
175+
]
176+
>,
177+
]
178+
>;
179+
180+
HeaderSpec SysTime = HeaderSpec<
181+
"sys/time.h",
182+
[
183+
Macro<"timeradd">,
184+
Macro<"timersub">,
185+
Macro<"timerclear">,
186+
Macro<"timerisset">,
187+
Macro<"timercmp">,
188+
],
189+
[StructTimevalType], // Types
190+
[], // Enumerations
191+
[] // Functions
192+
>;
193+
194+
195+
HeaderSpec SysEpoll = HeaderSpec<
196+
"sys/epoll.h",
197+
[], // Macros
198+
[
199+
StructEpollEvent,
200+
StructEpollData,
201+
SigSetType,
202+
StructTimeSpec,
203+
], // Types
204+
[], // Enumerations
205+
[
206+
FunctionSpec<
207+
"epoll_create",
208+
RetValSpec<IntType>,
209+
[
210+
ArgSpec<IntType>
211+
]
212+
>,
213+
FunctionSpec<
214+
"epoll_create1",
215+
RetValSpec<IntType>,
216+
[
217+
ArgSpec<IntType>
218+
]
219+
>,
220+
FunctionSpec<
221+
"epoll_ctl",
222+
RetValSpec<IntType>,
223+
[
224+
ArgSpec<IntType>,
225+
ArgSpec<IntType>,
226+
ArgSpec<IntType>,
227+
ArgSpec<StructEpollEventPtr>
228+
]
229+
>,
230+
FunctionSpec<
231+
"epoll_wait",
232+
RetValSpec<IntType>,
233+
[
234+
ArgSpec<IntType>,
235+
ArgSpec<StructEpollEventPtr>,
236+
ArgSpec<IntType>,
237+
ArgSpec<IntType>
238+
]
239+
>,
240+
FunctionSpec<
241+
"epoll_pwait",
242+
RetValSpec<IntType>,
243+
[
244+
ArgSpec<IntType>,
245+
ArgSpec<StructEpollEventPtr>,
246+
ArgSpec<IntType>,
247+
ArgSpec<IntType>,
248+
ArgSpec<ConstSigSetPtrType>
249+
]
250+
>,
251+
FunctionSpec<
252+
"epoll_pwait2",
253+
RetValSpec<IntType>,
254+
[
255+
ArgSpec<IntType>,
256+
ArgSpec<StructEpollEventPtr>,
257+
ArgSpec<IntType>,
258+
ArgSpec<ConstStructTimeSpecPtr>,
259+
ArgSpec<ConstSigSetPtrType>
260+
]
261+
>,
262+
] // Functions
263+
>;
264+
265+
HeaderSpec Signal = HeaderSpec<
266+
"signal.h",
267+
[
268+
Macro<"NSIG">,
269+
270+
Macro<"SIGHUP">,
271+
Macro<"SIGINT">,
272+
Macro<"SIGQUIT">,
273+
Macro<"SIGILL">,
274+
Macro<"SIGTRAP">,
275+
Macro<"SIGABRT">,
276+
Macro<"SIGIOT">,
277+
Macro<"SIGBUS">,
278+
Macro<"SIGFPE">,
279+
Macro<"SIGKILL">,
280+
Macro<"SIGUSR1">,
281+
Macro<"SIGSEGV">,
282+
Macro<"SIGUSR2">,
283+
Macro<"SIGPIPE">,
284+
Macro<"SIGALRM">,
285+
Macro<"SIGTERM">,
286+
Macro<"SIGSTKFLT">,
287+
Macro<"SIGCHLD">,
288+
Macro<"SIGCONT">,
289+
Macro<"SIGSTOP">,
290+
Macro<"SIGTSTP">,
291+
Macro<"SIGTTIN">,
292+
Macro<"SIGTTOU">,
293+
Macro<"SIGURG">,
294+
Macro<"SIGXCPU">,
295+
Macro<"SIGXFSZ">,
296+
Macro<"SIGVTALRM">,
297+
Macro<"SIGPROF">,
298+
Macro<"SIGWINCH">,
299+
Macro<"SIGIO">,
300+
Macro<"SIGPOLL">,
301+
Macro<"SIGPWR">,
302+
Macro<"SIGSYS">,
303+
Macro<"SIGUNUSED">,
304+
]
305+
>;
306+
307+
308+
HeaderSpec UniStd = HeaderSpec<
309+
"unistd.h",
310+
[], // Macros
311+
[],
312+
[], // Enumerations
313+
[
314+
FunctionSpec<
315+
"pipe2",
316+
RetValSpec<IntType>,
317+
[ArgSpec<IntPtr>, ArgSpec<IntType>] //TODO: make this int[2]
318+
>,
319+
],
320+
[]
321+
>;
322+
323+
324+
let Headers = [
325+
Errno,
326+
SysEpoll,
327+
SysMMan,
328+
SysPrctl,
329+
SysRandom,
330+
SysTime,
331+
Signal,
332+
UniStd,
333+
];
334+
}

libc/src/sys/mman/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,9 @@ add_entrypoint_object(
113113
DEPENDS
114114
.${LIBC_TARGET_OS}.mremap
115115
)
116+
117+
add_entrypoint_object(
118+
process_mrelease
119+
ALIAS
120+
DEPENDS
121+
.${LIBC_TARGET_OS}.process_mrelease)

0 commit comments

Comments
 (0)