mksyscallent_mips revision 0aac3525a48a5485ee82f966e7a0af40420b99bf
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# It should work OK on i386,m68k,arm,ia64
6# It does NOT work in mips, s390
7# It is untested in other architectures
8
9BEGIN {
10	max=0;
11	FS="[ \t\n()+]+";
12}
13
14{
15	#debug
16	#printf("/%s/%s/%s/%s/\n", $1, $2, $3, $4);
17	if ($2 ~ /__NR_Linux/ && $3 ~ /4000/) {
18		syscall=1;
19	}
20	if ($2 ~ /__NR_Linux_syscalls/) {
21		syscall=0;
22	}
23	if (syscall && ($1 ~ /^#define$/) && ($2 ~ /^__NR_/)) {
24			SYSCALL[$4]=substr($2,6);
25			if ($4 > max) {
26				max=$4;
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