linux/arch/arm/tools/syscallnr.sh
<<
>>
Prefs
   1#!/bin/sh
   2# SPDX-License-Identifier: GPL-2.0
   3in="$1"
   4out="$2"
   5my_abis=`echo "($3)" | tr ',' '|'`
   6align=1
   7
   8fileguard=_ASM_ARM_`basename "$out" | sed \
   9    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
  10    -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
  11
  12grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | tail -n1 | (
  13    echo "#ifndef ${fileguard}
  14#define ${fileguard} 1
  15
  16/*
  17 * This needs to be greater than __NR_last_syscall+1 in order to account
  18 * for the padding in the syscall table.
  19 */
  20"
  21
  22    while read nr abi name entry; do
  23        nr=$(($nr + 1))
  24        while [ "$(($nr / (256 * $align) ))" -gt 0 ]; do
  25            align=$(( $align * 4 ))
  26        done
  27        nr=$(( ($nr + $align - 1) & ~($align - 1) ))
  28        echo "/* aligned to $align */"
  29        echo "#define __NR_syscalls $nr"
  30    done
  31
  32    echo ""
  33    echo "#endif /* ${fileguard} */"
  34) > "$out"
  35