• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This file is used to automatically generate bionic's system call stubs.
2#
3# It is processed by a python script named gensyscalls.py,
4# normally run via the genrules in libc/Android.bp.
5#
6# Each non-blank, non-comment line has the following format:
7#
8#     func_name[|alias_list][:syscall_name[:socketcall_id]]([parameter_list]) arch_list
9#
10# where:
11#     arch_list ::= "all" | arches
12#     arches    ::= arch |  arch "," arches
13#     arch      ::= "arm" | "arm64" | "riscv64" | "x86" | "x86_64" | "lp32" | "lp64"
14#
15# syscall_name corresponds to the name of the syscall, which may differ from
16# the exported function name func_name. For example: the exit_group syscall
17# is exported by libc as the _exit() function, not exit() (which does more
18# work before calling _exit()).
19#
20# alias_list is optional comma-separated list of function aliases.
21# For example, the traditional _exit() function has a C99 alias _Exit().
22#
23# No return type is specified, because it's not needed.
24#
25# The socketcall_id parameter supports x86's
26# https://man7.org/linux/man-pages/man2/socketcall.2.html
27# and can be ignored for all other syscalls and architectures.
28#
29# The number of registers required for the arguments is computed by the script,
30# based on the parameter list given here. It handles the need for register
31# pairs for 64-bit arguments on ILP32, and also arm32's requirement for such
32# pairs to start on an even register. This means that it's important to get
33# these types right!
34#
35
36# Calls that have historical 16-bit variants camping on the best names (CONFIG_UID16).
37getuid:getuid32()   lp32
38getuid:getuid()     lp64
39getgid:getgid32()   lp32
40getgid:getgid()     lp64
41geteuid:geteuid32() lp32
42geteuid:geteuid()   lp64
43getegid:getegid32() lp32
44getegid:getegid()   lp64
45getresuid:getresuid32(uid_t* ruid, uid_t* euid, uid_t* suid) lp32
46getresuid:getresuid(uid_t* ruid, uid_t* euid, uid_t* suid)   lp64
47getresgid:getresgid32(gid_t* rgid, gid_t* egid, gid_t* sgid) lp32
48getresgid:getresgid(gid_t* rgid, gid_t* egid, gid_t* sgid)   lp64
49getgroups:getgroups32(int, gid_t*) lp32
50getgroups:getgroups(int, gid_t*)   lp64
51setgid:setgid32(gid_t) lp32
52setgid:setgid(gid_t)   lp64
53setuid:setuid32(uid_t) lp32
54setuid:setuid(uid_t)   lp64
55setreuid:setreuid32(uid_t, uid_t) lp32
56setreuid:setreuid(uid_t, uid_t)   lp64
57setresuid:setresuid32(uid_t, uid_t, uid_t) lp32
58setresuid:setresuid(uid_t, uid_t, uid_t)   lp64
59setresgid:setresgid32(gid_t, gid_t, gid_t) lp32
60setresgid:setresgid(gid_t, gid_t, gid_t)   lp64
61setfsgid:setfsgid32(gid_t) lp32
62setfsgid:setfsgid(gid_t)   lp64
63setfsuid:setfsuid32(uid_t) lp32
64setfsuid:setfsuid(uid_t)   lp64
65
66readahead(int, off64_t, size_t) all
67getpgid(pid_t) all
68getppid() all
69getsid(pid_t) all
70setsid() all
71kill(pid_t, int) all
72tgkill(pid_t tgid, pid_t tid, int sig) all
73
74__brk:brk(void*) all
75execve(const char*, char* const*, char* const*)  all
76__ptrace:ptrace(int request, int pid, void* addr, void* data) all
77
78# <sys/resource.h>
79getrusage(int, struct rusage*)  all
80__getpriority:getpriority(int, id_t)  all
81setpriority(int, id_t, int)   all
82# On LP64, rlimit and rlimit64 are the same.
83# On 32-bit systems we use prlimit64 to implement the rlimit64 functions.
84getrlimit:ugetrlimit(int, struct rlimit*)  lp32
85getrlimit|getrlimit64(int, struct rlimit*)  lp64
86setrlimit(int, const struct rlimit*)  lp32
87setrlimit|setrlimit64(int, const struct rlimit*)  lp64
88prlimit64|prlimit(pid_t, int, struct rlimit64*, const struct rlimit64*)  lp64
89prlimit64(pid_t, int, struct rlimit64*, const struct rlimit64*)  lp32
90
91setgroups:setgroups32(int, const gid_t*)   lp32
92setgroups:setgroups(int, const gid_t*)     lp64
93setpgid(pid_t, pid_t)  all
94setregid:setregid32(gid_t, gid_t)  lp32
95setregid:setregid(gid_t, gid_t)    lp64
96chroot(const char*)  all
97prctl(int, unsigned long, unsigned long, unsigned long, unsigned long) all
98capget(cap_user_header_t header, cap_user_data_t data) all
99capset(cap_user_header_t header, const cap_user_data_t data) all
100sigaltstack(const stack_t*, stack_t*) all
101acct(const char*  filepath)  all
102
103# file descriptors
104read(int, void*, size_t)        all
105write(int, const void*, size_t)       all
106pread64(int, void*, size_t, off64_t) lp32
107pread64|pread(int, void*, size_t, off_t) lp64
108pwrite64(int, void*, size_t, off64_t) lp32
109pwrite64|pwrite(int, void*, size_t, off_t) lp64
110
111# On LP32, preadv/pwritev don't use off64_t --- they use pairs of 32-bit
112# arguments to avoid problems on architectures like arm32 where 64-bit arguments
113# must be in a register pair starting with an even-numbered register.
114# See linux/fs/read_write.c and https://lwn.net/Articles/311630/.
115# Note that there's an unused always-0 second long even on LP64!
116__preadv64:preadv(int, const struct iovec*, int, long, long) all
117__pwritev64:pwritev(int, const struct iovec*, int, long, long) all
118__preadv64v2:preadv2(int, const struct iovec*, int, long, long, int) all
119__pwritev64v2:pwritev2(int, const struct iovec*, int, long, long, int) all
120
121__close:close(int)  all
122close_range(unsigned int, unsigned int, int) all
123copy_file_range(int, off64_t*, int, off64_t*, size_t, unsigned int) all
124__getpid:getpid()  all
125memfd_create(const char*, unsigned) all
126munmap(void*, size_t)  all
127msync(const void*, size_t, int)    all
128mprotect(const void*, size_t, int)  all
129madvise(void*, size_t, int)  all
130process_madvise(int, const struct iovec*, size_t, int, unsigned int)     all
131mlock(const void* addr, size_t len)    all
132mlock2(const void* addr, size_t len, int flags)    all
133munlock(const void* addr, size_t len)   all
134mlockall(int flags)   all
135mseal(void*, size_t, unsigned long) lp64
136munlockall()   all
137mincore(void*  start, size_t  length, unsigned char*  vec)   all
138__ioctl:ioctl(int, int, void*)  all
139readv(int, const struct iovec*, int)   all
140writev(int, const struct iovec*, int)  all
141__fcntl64:fcntl64(int, int, void*)  lp32
142__fcntl:fcntl(int, int, void*)  lp64
143flock(int, int)   all
144__fchmod:fchmod(int, mode_t)  all
145__pipe2:pipe2(int*, int) all
146__dup:dup(int)  all
147__dup3:dup3(int, int, int)   all
148fsync(int)  all
149fdatasync(int) all
150fchown:fchown32(int, uid_t, gid_t)  lp32
151fchown:fchown(int, uid_t, gid_t)    lp64
152sync(void)  all
153syncfs(int)  all
154__fsetxattr:fsetxattr(int, const char*, const void*, size_t, int) all
155__fgetxattr:fgetxattr(int, const char*, void*, size_t) all
156__flistxattr:flistxattr(int, char*, size_t) all
157fremovexattr(int, const char*) all
158
159__getdents64:getdents64(unsigned int, struct dirent*, unsigned int)   all
160
161__openat:openat(int, const char*, int, mode_t) all
162__faccessat:faccessat(int, const char*, int)  all
163__fchmodat:fchmodat(int, const char*, mode_t)  all
164fchownat(int, const char*, uid_t, gid_t, int)  all
165fstatat64|fstatat:fstatat64(int, const char*, struct stat*, int)   lp32
166fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int)  lp64
167linkat(int, const char*, int, const char*, int)  all
168mkdirat(int, const char*, mode_t)  all
169mknodat(int, const char*, mode_t, dev_t)  all
170readlinkat(int, const char*, char*, size_t)  all
171renameat2(int, const char*, int, const char*, unsigned)  all
172symlinkat(const char*, int, const char*)  all
173unlinkat(int, const char*, int)   all
174utimensat(int, const char*, const struct timespec times[2], int)  all
175
176# Paired off_t/off64_t system calls. On 64-bit systems,
177# sizeof(off_t) == sizeof(off64_t), so there we emit two symbols that are
178# aliases. On 32-bit systems, we have two different system calls.
179# That means that every system call in this section should take three lines.
180lseek(int, off_t, int) lp32
181__llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) lp32
182lseek|lseek64(int, off_t, int) lp64
183sendfile(int out_fd, int in_fd, off_t* offset, size_t count) lp32
184sendfile64(int out_fd, int in_fd, off64_t* offset, size_t count) lp32
185sendfile|sendfile64(int out_fd, int in_fd, off_t* offset, size_t count) lp64
186truncate(const char*, off_t) lp32
187truncate64(const char*, off64_t) lp32
188truncate|truncate64(const char*, off_t) lp64
189# (fallocate only gets two lines because there is no 32-bit variant.)
190fallocate64:fallocate(int, int, off64_t, off64_t) lp32
191fallocate|fallocate64(int, int, off_t, off_t) lp64
192# (ftruncate only gets two lines because 32-bit bionic only uses the 64-bit call.)
193ftruncate64(int, off64_t) lp32
194ftruncate|ftruncate64(int, off_t) lp64
195# (mmap only gets two lines because 32-bit bionic only uses the 64-bit call.)
196__mmap2:mmap2(void*, size_t, int, int, int, long) lp32
197mmap|mmap64(void*, size_t, int, int, int, off_t) lp64
198
199# mremap is in C++ for 32-bit so we can add the PTRDIFF_MAX check.
200__mremap:mremap(void*, size_t, size_t, int, void*) lp32
201mremap(void*, size_t, size_t, int, void*) lp64
202
203# posix_fadvise64 is awkward: arm has shuffled arguments,
204# the POSIX functions don't set errno, and no architecture has posix_fadvise.
205__arm_fadvise64_64:arm_fadvise64_64(int, int, off64_t, off64_t) arm
206__fadvise64:fadvise64_64(int, off64_t, off64_t, int) x86
207__fadvise64:fadvise64(int, off64_t, off64_t, int) lp64
208
209__fstatfs64:fstatfs64(int, size_t, struct statfs*)  lp32
210__fstatfs:fstatfs(int, struct statfs*)  lp64
211__statfs64:statfs64(const char*, size_t, struct statfs*)  lp32
212__statfs:statfs(const char*, struct statfs*)  lp64
213
214fstat64|fstat:fstat64(int, struct stat*) lp32
215fstat64|fstat:fstat(int, struct stat*) lp64
216
217# file system
218chdir(const char*)              all
219mount(const char*, const char*, const char*, unsigned long, const void*)  all
220umount2(const char*, int)  all
221__getcwd:getcwd(char* buf, size_t size)  all
222fchdir(int)    all
223setxattr(const char*, const char*, const void*, size_t, int) all
224lsetxattr(const char*, const char*, const void*, size_t, int) all
225getxattr(const char*, const char*, void*, size_t) all
226lgetxattr(const char*, const char*, void*, size_t) all
227listxattr(const char*, char*, size_t) all
228llistxattr(const char*, char*, size_t) all
229removexattr(const char*, const char*) all
230lremovexattr(const char*, const char*) all
231statx(int, const char*, int, unsigned, struct statx*) all
232swapon(const char*, int) all
233swapoff(const char*) all
234
235# time
236settimeofday(const struct timeval*, const struct timezone*)   all
237times(struct tms*)       all
238nanosleep(const struct timespec*, struct timespec*)   all
239clock_settime(clockid_t, const struct timespec*)  all
240__clock_nanosleep:clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*)  all
241getitimer(int, struct itimerval*)   all
242setitimer(int, const struct itimerval*, struct itimerval*)  all
243__timer_create:timer_create(clockid_t clockid, struct sigevent* evp, __kernel_timer_t* timerid)    all
244__timer_settime:timer_settime(__kernel_timer_t, int, const struct itimerspec*, struct itimerspec*) all
245__timer_gettime:timer_gettime(__kernel_timer_t, struct itimerspec*)                                all
246__timer_getoverrun:timer_getoverrun(__kernel_timer_t)                                              all
247__timer_delete:timer_delete(__kernel_timer_t)                                                      all
248timerfd_create(clockid_t, int)   all
249timerfd_settime(int, int, const struct itimerspec*, struct itimerspec*)   all
250timerfd_gettime(int, struct itimerspec*)   all
251adjtimex(struct timex*)   all
252clock_adjtime(clockid_t, struct timex*)   all
253
254# signals
255__sigaction:sigaction(int, const struct sigaction*, struct sigaction*)  lp32
256__rt_sigaction:rt_sigaction(int, const struct sigaction*, struct sigaction*, size_t)  all
257__rt_sigpending:rt_sigpending(sigset64_t*, size_t)  all
258__rt_sigprocmask:rt_sigprocmask(int, const sigset64_t*, sigset64_t*, size_t)  all
259__rt_sigsuspend:rt_sigsuspend(const sigset64_t*, size_t)  all
260__rt_sigtimedwait:rt_sigtimedwait(const sigset64_t*, siginfo_t*, const timespec*, size_t)  all
261__rt_sigqueueinfo:rt_sigqueueinfo(pid_t, int, siginfo_t*)  all
262__signalfd4:signalfd4(int, const sigset64_t*, size_t, int)  all
263
264# sockets
265__socket:socket(int, int, int)              arm,lp64
266__socketpair:socketpair(int, int, int, int*)    arm,lp64
267bind(int, struct sockaddr*, socklen_t)  arm,lp64
268__connect:connect(int, struct sockaddr*, socklen_t)   arm,lp64
269listen(int, int)                   arm,lp64
270__accept4:accept4(int, struct sockaddr*, socklen_t*, int)  arm,lp64
271getsockname(int, struct sockaddr*, socklen_t*)  arm,lp64
272getpeername(int, struct sockaddr*, socklen_t*)  arm,lp64
273__sendto:sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t)  arm,lp64
274recvfrom(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*)  arm,lp64
275shutdown(int, int)  arm,lp64
276setsockopt(int, int, int, const void*, socklen_t)  arm,lp64
277getsockopt(int, int, int, void*, socklen_t*)    arm,lp64
278__recvmsg:recvmsg(int, struct msghdr*, unsigned int)   arm,lp64
279__sendmsg:sendmsg(int, const struct msghdr*, unsigned int)  arm,lp64
280__recvmmsg:recvmmsg(int, struct mmsghdr*, unsigned int, int, const struct timespec*)   arm,lp64
281__sendmmsg:sendmmsg(int, struct mmsghdr*, unsigned int, int)   arm,lp64
282
283# sockets for x86. These are done as an "indexed" call to socketcall syscall.
284__socket:socketcall:1(int, int, int) x86
285bind:socketcall:2(int, struct sockaddr*, int)  x86
286__connect:socketcall:3(int, struct sockaddr*, socklen_t)   x86
287listen:socketcall:4(int, int)                   x86
288getsockname:socketcall:6(int, struct sockaddr*, socklen_t*)  x86
289getpeername:socketcall:7(int, struct sockaddr*, socklen_t*)  x86
290__socketpair:socketcall:8(int, int, int, int*)    x86
291__sendto:socketcall:11(int, const void*, size_t, int, const struct sockaddr*, socklen_t)  x86
292recvfrom:socketcall:12(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*)  x86
293shutdown:socketcall:13(int, int)  x86
294setsockopt:socketcall:14(int, int, int, const void*, socklen_t)  x86
295getsockopt:socketcall:15(int, int, int, void*, socklen_t*)    x86
296__sendmsg:socketcall:16(int, const struct msghdr*, unsigned int)  x86
297__recvmsg:socketcall:17(int, struct msghdr*, unsigned int)   x86
298__accept4:socketcall:18(int, struct sockaddr*, socklen_t*, int)  x86
299__recvmmsg:socketcall:19(int, struct mmsghdr*, unsigned int, int, const struct timespec*)   x86
300__sendmmsg:socketcall:20(int, struct mmsghdr*, unsigned int, int)   x86
301
302# scheduler & real-time
303sched_get_priority_max(int policy) all
304sched_get_priority_min(int policy) all
305__sched_getaffinity:sched_getaffinity(pid_t, size_t, cpu_set_t*) all
306sched_getattr(pid_t, sched_attr*, unsigned, unsigned) all
307sched_getparam(pid_t, sched_param*) all
308sched_getscheduler(pid_t) all
309sched_rr_get_interval(pid_t, timespec*) all
310sched_setaffinity(pid_t, size_t, const cpu_set_t*) all
311sched_setattr(pid_t, sched_attr*, unsigned) all
312sched_setparam(pid_t, const sched_param*) all
313sched_setscheduler(pid_t, int, const sched_param*)  all
314sched_yield(void) all
315
316# other
317uname(struct utsname*)  all
318umask(mode_t)  all
319__reboot:reboot(int, int, int, void*)  all
320init_module(void*, unsigned long, const char*)  all
321delete_module(const char*, unsigned int)   all
322klogctl:syslog(int, char*, int)   all
323sysinfo(struct sysinfo*)  all
324personality(unsigned long)  all
325
326setns(int, int) all
327unshare(int) all
328
329__getcpu:getcpu(unsigned*, unsigned*, void*) all
330
331bpf(int, union bpf_attr *, unsigned int) all
332
333tee(int, int, size_t, unsigned int)  all
334splice(int, off64_t*, int, off64_t*, size_t, unsigned int)  all
335vmsplice(int, const struct iovec*, size_t, unsigned int)  all
336
337__epoll_create1:epoll_create1(int)  all
338epoll_ctl(int, int op, int, struct epoll_event*)  all
339__epoll_pwait:epoll_pwait(int, struct epoll_event*, int, int, const sigset64_t*, size_t)  all
340__epoll_pwait2:epoll_pwait2(int, struct epoll_event*, int, const timespec64*, const sigset64_t*, size_t)  all
341
342__eventfd:eventfd2(unsigned int, int)  all
343
344_exit|_Exit:exit_group(int)  all
345__exit:exit(int)  all
346
347inotify_init1(int)  all
348inotify_add_watch(int, const char*, unsigned int)  all
349inotify_rm_watch(int, unsigned int)  all
350
351__pselect6:pselect6(int, fd_set*, fd_set*, fd_set*, timespec*, void*)  all
352__ppoll:ppoll(pollfd*, unsigned int, timespec*, const sigset64_t*, size_t)  all
353
354process_vm_readv(pid_t, const struct iovec*, unsigned long, const struct iovec*, unsigned long, unsigned long)  all
355process_vm_writev(pid_t, const struct iovec*, unsigned long, const struct iovec*, unsigned long, unsigned long)  all
356
357quotactl(int, const char*, int, char*)  all
358
359__set_tid_address:set_tid_address(int*)  all
360
361setdomainname(const char*, size_t)  all
362sethostname(const char*, size_t)  all
363
364sync_file_range(int, off64_t, off64_t, unsigned int) x86,lp64
365__sync_file_range2:sync_file_range2(int, unsigned int, off64_t, off64_t) arm
366
367wait4(pid_t, int*, int, struct rusage*)  all
368__waitid:waitid(int, pid_t, siginfo_t*, int, void*)  all
369
370# ARM-specific
371__set_tls:__ARM_NR_set_tls(void*)                                 arm
372cacheflush:__ARM_NR_cacheflush(long start, long end, long flags)  arm
373
374# riscv64-specific
375__riscv_flush_icache:riscv_flush_icache(void*, void*, unsigned long) riscv64
376
377# x86-specific
378__set_thread_area:set_thread_area(void*) x86
379arch_prctl(int, unsigned long) x86_64
380
381# vdso stuff.
382__clock_getres:clock_getres(clockid_t, struct timespec*) all
383__clock_gettime:clock_gettime(clockid_t, struct timespec*) all
384__gettimeofday:gettimeofday(struct timeval*, struct timezone*) all
385
386# <sys/random.h>
387getrandom(void*, size_t, unsigned) all
388
389# <sys/pidfd.h>
390__pidfd_open:pidfd_open(pid_t, unsigned int) all
391__pidfd_getfd:pidfd_getfd(int, int, unsigned int) all
392pidfd_send_signal(int, int, siginfo_t*, unsigned int) all
393