1#!/bin/sh
2#
3# Just process the CPP output from systbl_chk.c and complain
4# if anything is out of order.
5#
6# Copyright © 2008 IBM Corporation
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version
11# 2 of the License, or (at your option) any later version.
12
13awk	'BEGIN { num = -1; }	# Ignore the beginning of the file
14	/^#/ { next; }
15	/^[ \t]*$/ { next; }
16	/^START_TABLE/ { num = 0; next; }
17	/^END_TABLE/ {
18		if (num != $2) {
19			printf "__NR_syscalls (%s) is not one more than the last syscall (%s)\n",
20				$2, num - 1;
21			exit(1);
22		}
23		num = -1;	# Ignore the rest of the file
24	}
25	{
26		if (num == -1) next;
27		if (($1 != -1) && ($1 != num)) {
28			printf "Syscall %s out of order (expected %s)\n",
29				$1, num;
30			exit(1);
31		};
32		num++;
33	}' "$1"
34