^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Just process the CPP output from systbl_chk.c and complain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # if anything is out of order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # Copyright © 2008 IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) awk 'BEGIN { num = -1; } # Ignore the beginning of the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /^#/ { next; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /^[ \t]*$/ { next; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /^START_TABLE/ { num = 0; next; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /^END_TABLE/ {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) if (num != $2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) printf "Error: NR_syscalls (%s) is not one more than the last syscall (%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) $2, num - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) num = -1; # Ignore the rest of the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (num == -1) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) if (($1 != -1) && ($1 != num)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) printf "Error: Syscall %s out of order (expected %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) $1, num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) num++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }' "$1"