[PATCH v5 10/13] syscalls: Add an option for offsetting the common table
André Almeida <[email protected]>
| Newsgroups | org.kernel.vger.linux-alpha,dev.linux.lists.soc,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel,org.kernel.vger.linux-mips,org.kernel.vger.linux-s390 |
|---|---|
| Message-ID | <[email protected]> |
To better support architectures that doesn't share the same syscall numbers, but have them in the same sequence, add an new option to offset the common syscall table numbers by a value. This make it possible to reuse the common syscall table for alpha. Signed-off-by: André Almeida <[email protected]> --- Changes from v4: - I was reusing the logic from --offset to apply the --common-offset, but the logic is different: --offset does a string concat, and --common-offset does a addition to the number --- scripts/syscallhdr.sh | 27 +++++++++++++++++++-------- scripts/syscalltbl.sh | 24 +++++++++++++++++++----- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/scripts/syscallhdr.sh b/scripts/syscallhdr.sh index 54e09d3e686c..ce6819111c27 100755 --- a/scripts/syscallhdr.sh +++ b/scripts/syscallhdr.sh @@ -16,17 +16,18 @@ set -e usage() { - echo >&2 "usage: $0 [--abis ABIS] [--emit-nr] [--offset OFFSET] [--prefix PREFIX] [--common-tbl PATH] INFILE OUTFILE" >&2 + echo >&2 "usage: $0 [--abis ABIS] [--emit-nr] [--offset OFFSET] [--prefix PREFIX] [--common-tbl PATH] [--common-offset NR] INFILE OUTFILE" >&2 echo >&2 echo >&2 " INFILE input syscall table" echo >&2 " OUTFILE output header file" echo >&2 echo >&2 "options:" - echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)" - echo >&2 " --emit-nr Emit the macro of the number of syscalls (__NR_syscalls)" - echo >&2 " --offset OFFSET The offset of syscall numbers" - echo >&2 " --prefix PREFIX The prefix to the macro like __NR_<PREFIX><NAME>" - echo >&2 " --common-tbl PATH Use the common number table" + echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)" + echo >&2 " --emit-nr Emit the macro of the number of syscalls (__NR_syscalls)" + echo >&2 " --offset OFFSET The offset of syscall numbers" + echo >&2 " --prefix PREFIX The prefix to the macro like __NR_<PREFIX><NAME>" + echo >&2 " --common-tbl PATH Use the common number table" + echo >&2 " --common-offset NR Add an offset for the numbers of the common table" exit 1 } @@ -34,6 +35,7 @@ usage() { abis= emit_nr= offset= +common_offset= prefix= common_tbl= common_tbl_path= @@ -57,6 +59,9 @@ do common_tbl=1 common_tbl_path=$2 shift 2;; + --common-offset) + common_offset=$2 + shift 2;; -*) echo "$1: unknown option" >&2 usage;; @@ -98,18 +103,24 @@ emit_end_guard() { } max=0 -# gen_hdr(infile) +# gen_hdr(infile, offset_nr) gen_hdr() { input=$1 + offset_nr=$2 while read nr abi name native compat; do max=$nr + if [ -n "$offset_nr" ]; then + nr=$((nr + offset_nr)) + fi + if [ -n "$offset" ]; then nr="($offset + $nr)" fi + echo "#define __NR_$prefix$name $nr" done < <(grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$input") @@ -120,7 +131,7 @@ emit_start_guard > $outfile gen_hdr $infile >> $outfile if [ -n "$common_tbl" ]; then - gen_hdr $common_tbl_path >> "$outfile" + gen_hdr $common_tbl_path $common_offset >> "$outfile" fi if [ -n "$emit_nr" ]; then diff --git a/scripts/syscalltbl.sh b/scripts/syscalltbl.sh index 91c135143b22..aea00834dd5a 100755 --- a/scripts/syscalltbl.sh +++ b/scripts/syscalltbl.sh @@ -16,14 +16,15 @@ set -e usage() { - echo >&2 "usage: $0 [--abis ABIS] [--common-tbl PATH] INFILE OUTFILE" >&2 + echo >&2 "usage: $0 [--abis ABIS] [--common-tbl PATH] [--common-offset NR] INFILE OUTFILE" >&2 echo >&2 echo >&2 " INFILE input syscall table" echo >&2 " OUTFILE output header file" echo >&2 echo >&2 "options:" - echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)" - echo >&2 " --common-tbl PATH Use the common syscall number table" + echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)" + echo >&2 " --common-tbl PATH Use the common syscall number table" + echo >&2 " --common-offset OFFSET Add an offset for the numbers of the common table" exit 1 } @@ -31,6 +32,7 @@ usage() { abis= common_tbl= common_tbl_path= +common_offset= while [ $# -gt 0 ] do @@ -42,6 +44,9 @@ do common_tbl=1 common_tbl_path=$2 shift 2;; + --common-offset) + common_offset=$2 + shift 2;; -*) echo "$1: unknown option" >&2 usage;; @@ -59,12 +64,21 @@ outfile="$2" nxt=0 -# gen_tbl(infile) +# gen_tbl(infile, offset_nr) gen_tbl() { input=$1 + offset_nr=$2 while read nr abi name native compat noreturn; do + if [ -n "$offset_nr" ]; then + nr=$((nr + offset_nr)) + fi + + if [ -n "$offset" ]; then + nr="($offset + $nr)" + fi + if [ $nxt -gt $nr ]; then echo "error: $input: syscall table is not sorted or duplicates the same syscall number" >&2 exit 1 @@ -105,5 +119,5 @@ gen_tbl() { gen_tbl $infile > "$outfile" if [ -n "$common_tbl" ]; then - gen_tbl $common_tbl_path >> "$outfile" + gen_tbl $common_tbl_path $common_offset >> "$outfile" fi -- 2.55.0