Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/syscalls: Switch to generic syscallhdr.sh

Many architectures duplicate similar shell scripts.

Converts x86 to use scripts/syscallhdr.sh.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210517073815.97426-7-masahiroy@kernel.org

authored by

Masahiro Yamada and committed by
Thomas Gleixner
3cba325b 49f731f1

+13 -48
+13 -13
arch/x86/entry/syscalls/Makefile
··· 9 9 syscall32 := $(src)/syscall_32.tbl 10 10 syscall64 := $(src)/syscall_64.tbl 11 11 12 - syshdr := $(srctree)/$(src)/syscallhdr.sh 12 + syshdr := $(srctree)/scripts/syscallhdr.sh 13 13 systbl := $(srctree)/scripts/syscalltbl.sh 14 14 15 15 quiet_cmd_syshdr = SYSHDR $@ 16 - cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ 17 - '$(syshdr_abi_$(basetarget))' \ 18 - '$(syshdr_pfx_$(basetarget))' \ 19 - '$(syshdr_offset_$(basetarget))' 16 + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --abis $(abis) --emit-nr \ 17 + $(if $(offset),--offset $(offset)) \ 18 + $(if $(prefix),--prefix $(prefix)) \ 19 + $< $@ 20 20 quiet_cmd_systbl = SYSTBL $@ 21 21 cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis $(abis) $< $@ 22 22 23 23 quiet_cmd_hypercalls = HYPERCALLS $@ 24 24 cmd_hypercalls = $(CONFIG_SHELL) '$<' $@ $(filter-out $<, $(real-prereqs)) 25 25 26 - syshdr_abi_unistd_32 := i386 26 + $(uapi)/unistd_32.h: abis := i386 27 27 $(uapi)/unistd_32.h: $(syscall32) $(syshdr) FORCE 28 28 $(call if_changed,syshdr) 29 29 30 - syshdr_abi_unistd_32_ia32 := i386 31 - syshdr_pfx_unistd_32_ia32 := ia32_ 30 + $(out)/unistd_32_ia32.h: abis := i386 31 + $(out)/unistd_32_ia32.h: prefix := ia32_ 32 32 $(out)/unistd_32_ia32.h: $(syscall32) $(syshdr) FORCE 33 33 $(call if_changed,syshdr) 34 34 35 - syshdr_abi_unistd_x32 := common,x32 36 - syshdr_offset_unistd_x32 := __X32_SYSCALL_BIT 35 + $(uapi)/unistd_x32.h: abis := common,x32 36 + $(uapi)/unistd_x32.h: offset := __X32_SYSCALL_BIT 37 37 $(uapi)/unistd_x32.h: $(syscall64) $(syshdr) FORCE 38 38 $(call if_changed,syshdr) 39 39 40 - syshdr_abi_unistd_64 := common,64 40 + $(uapi)/unistd_64.h: abis := common,64 41 41 $(uapi)/unistd_64.h: $(syscall64) $(syshdr) FORCE 42 42 $(call if_changed,syshdr) 43 43 44 - syshdr_abi_unistd_64_x32 := x32 45 - syshdr_pfx_unistd_64_x32 := x32_ 44 + $(out)/unistd_64_x32.h: abis := x32 45 + $(out)/unistd_64_x32.h: prefix := x32_ 46 46 $(out)/unistd_64_x32.h: $(syscall64) $(syshdr) FORCE 47 47 $(call if_changed,syshdr) 48 48
-35
arch/x86/entry/syscalls/syscallhdr.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - in="$1" 5 - out="$2" 6 - my_abis=`echo "($3)" | tr ',' '|'` 7 - prefix="$4" 8 - offset="$5" 9 - 10 - fileguard=_ASM_X86_`basename "$out" | sed \ 11 - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ 12 - -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` 13 - grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( 14 - echo "#ifndef ${fileguard}" 15 - echo "#define ${fileguard} 1" 16 - echo "" 17 - 18 - max=0 19 - while read nr abi name entry ; do 20 - if [ -z "$offset" ]; then 21 - echo "#define __NR_${prefix}${name} $nr" 22 - else 23 - echo "#define __NR_${prefix}${name} ($offset + $nr)" 24 - fi 25 - 26 - max=$nr 27 - done 28 - 29 - echo "" 30 - echo "#ifdef __KERNEL__" 31 - echo "#define __NR_${prefix}syscalls $(($max + 1))" 32 - echo "#endif" 33 - echo "" 34 - echo "#endif /* ${fileguard} */" 35 - ) > "$out"