mksyscallent revision 1cd999a32728f41208dc30f38a125d7bb7063625
1#!/usr/bin/awk -f
2
3# hack expression to generate arch/syscallent.h from <asm/unistd.h>
4# It reads from stdin and writes to stdout
5# Currently (linux-2.2.3), it works OK on i386,m68k,arm
6# It does NOT work in mips
7# It is untested in other architectures
8
9BEGIN {
10	max=0;
11	FS="[ \t\n()\+]+";
12}
13
14{
15#	printf("/%s/%s/%s/%s/\n", $1, $2, $3, $4);
16	if (($1 ~ /^#define$/) && ($2 ~ /^__NR_/)) {
17		if (($3>=0) && ($3<=1000)) {
18			SYSCALL[$3]=substr($2,6);
19			if ($3 > max) {
20				max=$3;
21			}
22		} else if (($3 ~ /^__NR_SYSCALL_BASE$/) && ($4>=0) && ($4<=1000)) {
23			SYSCALL[$4]=substr($2,6);
24			if ($4 > max) {
25				max=$4;
26			}
27		}
28	}
29}
30
31END {
32	for(i=0; i<=max; i++) {
33		if (!SYSCALL[i]) {
34			SYSCALL[i] = i;
35		}
36		pad = 32 - length(SYSCALL[i]);
37		if (pad<1) {
38			pad=1;
39		}
40		printf("\t\"%s\",%*s/* %d */\n", SYSCALL[i], pad, "", i);
41	}
42}
43
44