162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
362306a36Sopenharmony_ci#
462306a36Sopenharmony_ci# Check if current architecture are missing any function calls compared
562306a36Sopenharmony_ci# to i386.
662306a36Sopenharmony_ci# i386 define a number of legacy system calls that are i386 specific
762306a36Sopenharmony_ci# and listed below so they are ignored.
862306a36Sopenharmony_ci#
962306a36Sopenharmony_ci# Usage:
1062306a36Sopenharmony_ci# checksyscalls.sh gcc gcc-options
1162306a36Sopenharmony_ci#
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciignore_list() {
1462306a36Sopenharmony_cicat << EOF
1562306a36Sopenharmony_ci#include <asm/types.h>
1662306a36Sopenharmony_ci#include <asm/unistd.h>
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* *at */
1962306a36Sopenharmony_ci#define __IGNORE_open		/* openat */
2062306a36Sopenharmony_ci#define __IGNORE_link		/* linkat */
2162306a36Sopenharmony_ci#define __IGNORE_unlink		/* unlinkat */
2262306a36Sopenharmony_ci#define __IGNORE_mknod		/* mknodat */
2362306a36Sopenharmony_ci#define __IGNORE_chmod		/* fchmodat */
2462306a36Sopenharmony_ci#define __IGNORE_chown		/* fchownat */
2562306a36Sopenharmony_ci#define __IGNORE_mkdir		/* mkdirat */
2662306a36Sopenharmony_ci#define __IGNORE_rmdir		/* unlinkat */
2762306a36Sopenharmony_ci#define __IGNORE_lchown		/* fchownat */
2862306a36Sopenharmony_ci#define __IGNORE_access		/* faccessat */
2962306a36Sopenharmony_ci#define __IGNORE_rename		/* renameat2 */
3062306a36Sopenharmony_ci#define __IGNORE_readlink	/* readlinkat */
3162306a36Sopenharmony_ci#define __IGNORE_symlink	/* symlinkat */
3262306a36Sopenharmony_ci#define __IGNORE_utimes		/* futimesat */
3362306a36Sopenharmony_ci#define __IGNORE_stat		/* fstatat */
3462306a36Sopenharmony_ci#define __IGNORE_lstat		/* fstatat */
3562306a36Sopenharmony_ci#define __IGNORE_stat64		/* fstatat64 */
3662306a36Sopenharmony_ci#define __IGNORE_lstat64	/* fstatat64 */
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#ifndef __ARCH_WANT_SET_GET_RLIMIT
3962306a36Sopenharmony_ci#define __IGNORE_getrlimit	/* getrlimit */
4062306a36Sopenharmony_ci#define __IGNORE_setrlimit	/* setrlimit */
4162306a36Sopenharmony_ci#endif
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#ifndef __ARCH_WANT_MEMFD_SECRET
4462306a36Sopenharmony_ci#define __IGNORE_memfd_secret
4562306a36Sopenharmony_ci#endif
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/* Missing flags argument */
4862306a36Sopenharmony_ci#define __IGNORE_renameat	/* renameat2 */
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/* CLOEXEC flag */
5162306a36Sopenharmony_ci#define __IGNORE_pipe		/* pipe2 */
5262306a36Sopenharmony_ci#define __IGNORE_dup2		/* dup3 */
5362306a36Sopenharmony_ci#define __IGNORE_epoll_create	/* epoll_create1 */
5462306a36Sopenharmony_ci#define __IGNORE_inotify_init	/* inotify_init1 */
5562306a36Sopenharmony_ci#define __IGNORE_eventfd	/* eventfd2 */
5662306a36Sopenharmony_ci#define __IGNORE_signalfd	/* signalfd4 */
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* MMU */
5962306a36Sopenharmony_ci#ifndef CONFIG_MMU
6062306a36Sopenharmony_ci#define __IGNORE_madvise
6162306a36Sopenharmony_ci#define __IGNORE_mbind
6262306a36Sopenharmony_ci#define __IGNORE_mincore
6362306a36Sopenharmony_ci#define __IGNORE_mlock
6462306a36Sopenharmony_ci#define __IGNORE_mlockall
6562306a36Sopenharmony_ci#define __IGNORE_munlock
6662306a36Sopenharmony_ci#define __IGNORE_munlockall
6762306a36Sopenharmony_ci#define __IGNORE_mprotect
6862306a36Sopenharmony_ci#define __IGNORE_msync
6962306a36Sopenharmony_ci#define __IGNORE_migrate_pages
7062306a36Sopenharmony_ci#define __IGNORE_move_pages
7162306a36Sopenharmony_ci#define __IGNORE_remap_file_pages
7262306a36Sopenharmony_ci#define __IGNORE_get_mempolicy
7362306a36Sopenharmony_ci#define __IGNORE_set_mempolicy
7462306a36Sopenharmony_ci#define __IGNORE_swapoff
7562306a36Sopenharmony_ci#define __IGNORE_swapon
7662306a36Sopenharmony_ci#endif
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/* System calls for 32-bit kernels only */
7962306a36Sopenharmony_ci#if BITS_PER_LONG == 64
8062306a36Sopenharmony_ci#define __IGNORE_sendfile64
8162306a36Sopenharmony_ci#define __IGNORE_ftruncate64
8262306a36Sopenharmony_ci#define __IGNORE_truncate64
8362306a36Sopenharmony_ci#define __IGNORE_stat64
8462306a36Sopenharmony_ci#define __IGNORE_lstat64
8562306a36Sopenharmony_ci#define __IGNORE_fcntl64
8662306a36Sopenharmony_ci#define __IGNORE_fadvise64_64
8762306a36Sopenharmony_ci#define __IGNORE_fstatfs64
8862306a36Sopenharmony_ci#define __IGNORE_statfs64
8962306a36Sopenharmony_ci#define __IGNORE_llseek
9062306a36Sopenharmony_ci#define __IGNORE_mmap2
9162306a36Sopenharmony_ci#define __IGNORE_clock_gettime64
9262306a36Sopenharmony_ci#define __IGNORE_clock_settime64
9362306a36Sopenharmony_ci#define __IGNORE_clock_adjtime64
9462306a36Sopenharmony_ci#define __IGNORE_clock_getres_time64
9562306a36Sopenharmony_ci#define __IGNORE_clock_nanosleep_time64
9662306a36Sopenharmony_ci#define __IGNORE_timer_gettime64
9762306a36Sopenharmony_ci#define __IGNORE_timer_settime64
9862306a36Sopenharmony_ci#define __IGNORE_timerfd_gettime64
9962306a36Sopenharmony_ci#define __IGNORE_timerfd_settime64
10062306a36Sopenharmony_ci#define __IGNORE_utimensat_time64
10162306a36Sopenharmony_ci#define __IGNORE_pselect6_time64
10262306a36Sopenharmony_ci#define __IGNORE_ppoll_time64
10362306a36Sopenharmony_ci#define __IGNORE_io_pgetevents_time64
10462306a36Sopenharmony_ci#define __IGNORE_recvmmsg_time64
10562306a36Sopenharmony_ci#define __IGNORE_mq_timedsend_time64
10662306a36Sopenharmony_ci#define __IGNORE_mq_timedreceive_time64
10762306a36Sopenharmony_ci#define __IGNORE_semtimedop_time64
10862306a36Sopenharmony_ci#define __IGNORE_rt_sigtimedwait_time64
10962306a36Sopenharmony_ci#define __IGNORE_futex_time64
11062306a36Sopenharmony_ci#define __IGNORE_sched_rr_get_interval_time64
11162306a36Sopenharmony_ci#else
11262306a36Sopenharmony_ci#define __IGNORE_sendfile
11362306a36Sopenharmony_ci#define __IGNORE_ftruncate
11462306a36Sopenharmony_ci#define __IGNORE_truncate
11562306a36Sopenharmony_ci#define __IGNORE_stat
11662306a36Sopenharmony_ci#define __IGNORE_lstat
11762306a36Sopenharmony_ci#define __IGNORE_fcntl
11862306a36Sopenharmony_ci#define __IGNORE_fadvise64
11962306a36Sopenharmony_ci#define __IGNORE_newfstatat
12062306a36Sopenharmony_ci#define __IGNORE_fstatfs
12162306a36Sopenharmony_ci#define __IGNORE_statfs
12262306a36Sopenharmony_ci#define __IGNORE_lseek
12362306a36Sopenharmony_ci#define __IGNORE_mmap
12462306a36Sopenharmony_ci#define __IGNORE_clock_gettime
12562306a36Sopenharmony_ci#define __IGNORE_clock_settime
12662306a36Sopenharmony_ci#define __IGNORE_clock_adjtime
12762306a36Sopenharmony_ci#define __IGNORE_clock_getres
12862306a36Sopenharmony_ci#define __IGNORE_clock_nanosleep
12962306a36Sopenharmony_ci#define __IGNORE_timer_gettime
13062306a36Sopenharmony_ci#define __IGNORE_timer_settime
13162306a36Sopenharmony_ci#define __IGNORE_timerfd_gettime
13262306a36Sopenharmony_ci#define __IGNORE_timerfd_settime
13362306a36Sopenharmony_ci#define __IGNORE_utimensat
13462306a36Sopenharmony_ci#define __IGNORE_pselect6
13562306a36Sopenharmony_ci#define __IGNORE_ppoll
13662306a36Sopenharmony_ci#define __IGNORE_io_pgetevents
13762306a36Sopenharmony_ci#define __IGNORE_recvmmsg
13862306a36Sopenharmony_ci#define __IGNORE_mq_timedsend
13962306a36Sopenharmony_ci#define __IGNORE_mq_timedreceive
14062306a36Sopenharmony_ci#define __IGNORE_semtimedop
14162306a36Sopenharmony_ci#define __IGNORE_rt_sigtimedwait
14262306a36Sopenharmony_ci#define __IGNORE_futex
14362306a36Sopenharmony_ci#define __IGNORE_sched_rr_get_interval
14462306a36Sopenharmony_ci#define __IGNORE_gettimeofday
14562306a36Sopenharmony_ci#define __IGNORE_settimeofday
14662306a36Sopenharmony_ci#define __IGNORE_wait4
14762306a36Sopenharmony_ci#define __IGNORE_adjtimex
14862306a36Sopenharmony_ci#define __IGNORE_nanosleep
14962306a36Sopenharmony_ci#define __IGNORE_io_getevents
15062306a36Sopenharmony_ci#define __IGNORE_recvmmsg
15162306a36Sopenharmony_ci#endif
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci/* i386-specific or historical system calls */
15462306a36Sopenharmony_ci#define __IGNORE_break
15562306a36Sopenharmony_ci#define __IGNORE_stty
15662306a36Sopenharmony_ci#define __IGNORE_gtty
15762306a36Sopenharmony_ci#define __IGNORE_ftime
15862306a36Sopenharmony_ci#define __IGNORE_prof
15962306a36Sopenharmony_ci#define __IGNORE_lock
16062306a36Sopenharmony_ci#define __IGNORE_mpx
16162306a36Sopenharmony_ci#define __IGNORE_ulimit
16262306a36Sopenharmony_ci#define __IGNORE_profil
16362306a36Sopenharmony_ci#define __IGNORE_ioperm
16462306a36Sopenharmony_ci#define __IGNORE_iopl
16562306a36Sopenharmony_ci#define __IGNORE_idle
16662306a36Sopenharmony_ci#define __IGNORE_modify_ldt
16762306a36Sopenharmony_ci#define __IGNORE_ugetrlimit
16862306a36Sopenharmony_ci#define __IGNORE_vm86
16962306a36Sopenharmony_ci#define __IGNORE_vm86old
17062306a36Sopenharmony_ci#define __IGNORE_set_thread_area
17162306a36Sopenharmony_ci#define __IGNORE_get_thread_area
17262306a36Sopenharmony_ci#define __IGNORE_madvise1
17362306a36Sopenharmony_ci#define __IGNORE_oldstat
17462306a36Sopenharmony_ci#define __IGNORE_oldfstat
17562306a36Sopenharmony_ci#define __IGNORE_oldlstat
17662306a36Sopenharmony_ci#define __IGNORE_oldolduname
17762306a36Sopenharmony_ci#define __IGNORE_olduname
17862306a36Sopenharmony_ci#define __IGNORE_umount
17962306a36Sopenharmony_ci#define __IGNORE_waitpid
18062306a36Sopenharmony_ci#define __IGNORE_stime
18162306a36Sopenharmony_ci#define __IGNORE_nice
18262306a36Sopenharmony_ci#define __IGNORE_signal
18362306a36Sopenharmony_ci#define __IGNORE_sigaction
18462306a36Sopenharmony_ci#define __IGNORE_sgetmask
18562306a36Sopenharmony_ci#define __IGNORE_sigsuspend
18662306a36Sopenharmony_ci#define __IGNORE_sigpending
18762306a36Sopenharmony_ci#define __IGNORE_ssetmask
18862306a36Sopenharmony_ci#define __IGNORE_readdir
18962306a36Sopenharmony_ci#define __IGNORE_socketcall
19062306a36Sopenharmony_ci#define __IGNORE_ipc
19162306a36Sopenharmony_ci#define __IGNORE_sigreturn
19262306a36Sopenharmony_ci#define __IGNORE_sigprocmask
19362306a36Sopenharmony_ci#define __IGNORE_bdflush
19462306a36Sopenharmony_ci#define __IGNORE__llseek
19562306a36Sopenharmony_ci#define __IGNORE__newselect
19662306a36Sopenharmony_ci#define __IGNORE_create_module
19762306a36Sopenharmony_ci#define __IGNORE_query_module
19862306a36Sopenharmony_ci#define __IGNORE_get_kernel_syms
19962306a36Sopenharmony_ci#define __IGNORE_sysfs
20062306a36Sopenharmony_ci#define __IGNORE_uselib
20162306a36Sopenharmony_ci#define __IGNORE__sysctl
20262306a36Sopenharmony_ci#define __IGNORE_arch_prctl
20362306a36Sopenharmony_ci#define __IGNORE_nfsservctl
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci/* ... including the "new" 32-bit uid syscalls */
20662306a36Sopenharmony_ci#define __IGNORE_lchown32
20762306a36Sopenharmony_ci#define __IGNORE_getuid32
20862306a36Sopenharmony_ci#define __IGNORE_getgid32
20962306a36Sopenharmony_ci#define __IGNORE_geteuid32
21062306a36Sopenharmony_ci#define __IGNORE_getegid32
21162306a36Sopenharmony_ci#define __IGNORE_setreuid32
21262306a36Sopenharmony_ci#define __IGNORE_setregid32
21362306a36Sopenharmony_ci#define __IGNORE_getgroups32
21462306a36Sopenharmony_ci#define __IGNORE_setgroups32
21562306a36Sopenharmony_ci#define __IGNORE_fchown32
21662306a36Sopenharmony_ci#define __IGNORE_setresuid32
21762306a36Sopenharmony_ci#define __IGNORE_getresuid32
21862306a36Sopenharmony_ci#define __IGNORE_setresgid32
21962306a36Sopenharmony_ci#define __IGNORE_getresgid32
22062306a36Sopenharmony_ci#define __IGNORE_chown32
22162306a36Sopenharmony_ci#define __IGNORE_setuid32
22262306a36Sopenharmony_ci#define __IGNORE_setgid32
22362306a36Sopenharmony_ci#define __IGNORE_setfsuid32
22462306a36Sopenharmony_ci#define __IGNORE_setfsgid32
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci/* these can be expressed using other calls */
22762306a36Sopenharmony_ci#define __IGNORE_alarm		/* setitimer */
22862306a36Sopenharmony_ci#define __IGNORE_creat		/* open */
22962306a36Sopenharmony_ci#define __IGNORE_fork		/* clone */
23062306a36Sopenharmony_ci#define __IGNORE_futimesat	/* utimensat */
23162306a36Sopenharmony_ci#define __IGNORE_getpgrp	/* getpgid */
23262306a36Sopenharmony_ci#define __IGNORE_getdents	/* getdents64 */
23362306a36Sopenharmony_ci#define __IGNORE_pause		/* sigsuspend */
23462306a36Sopenharmony_ci#define __IGNORE_poll		/* ppoll */
23562306a36Sopenharmony_ci#define __IGNORE_select		/* pselect6 */
23662306a36Sopenharmony_ci#define __IGNORE_epoll_wait	/* epoll_pwait */
23762306a36Sopenharmony_ci#define __IGNORE_time		/* gettimeofday */
23862306a36Sopenharmony_ci#define __IGNORE_uname		/* newuname */
23962306a36Sopenharmony_ci#define __IGNORE_ustat		/* statfs */
24062306a36Sopenharmony_ci#define __IGNORE_utime		/* utimes */
24162306a36Sopenharmony_ci#define __IGNORE_vfork		/* clone */
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */
24462306a36Sopenharmony_ci#ifdef __NR_sync_file_range2
24562306a36Sopenharmony_ci#define __IGNORE_sync_file_range
24662306a36Sopenharmony_ci#endif
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci/* Unmerged syscalls for AFS, STREAMS, etc. */
24962306a36Sopenharmony_ci#define __IGNORE_afs_syscall
25062306a36Sopenharmony_ci#define __IGNORE_getpmsg
25162306a36Sopenharmony_ci#define __IGNORE_putpmsg
25262306a36Sopenharmony_ci#define __IGNORE_vserver
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/* 64-bit ports never needed these, and new 32-bit ports can use statx */
25562306a36Sopenharmony_ci#define __IGNORE_fstat64
25662306a36Sopenharmony_ci#define __IGNORE_fstatat64
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci/* Newer ports are not required to provide fstat in favor of statx */
25962306a36Sopenharmony_ci#define __IGNORE_fstat
26062306a36Sopenharmony_ciEOF
26162306a36Sopenharmony_ci}
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_cisyscall_list() {
26462306a36Sopenharmony_ci    grep '^[0-9]' "$1" | sort -n |
26562306a36Sopenharmony_ci	while read nr abi name entry ; do
26662306a36Sopenharmony_ci		echo "#if !defined(__NR_${name}) && !defined(__IGNORE_${name})"
26762306a36Sopenharmony_ci		echo "#warning syscall ${name} not implemented"
26862306a36Sopenharmony_ci		echo "#endif"
26962306a36Sopenharmony_ci	done
27062306a36Sopenharmony_ci}
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci(ignore_list && syscall_list $(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl) | \
27362306a36Sopenharmony_ci$* -Wno-error -Wno-unused-macros -E -x c - > /dev/null
274