#!/usr/bin/awk -f

# hack expression to generate arch/syscallent.h from <asm/unistd.h>
# It reads from stdin and writes to stdout
# resulting blurb still needs editing!

BEGIN {
	max=0;
}

{
	if (($1 ~ /^#define$/) && (substr($2,1,5) ~ /^__NR_$/) && ($3>=0) && ($3<=1000)) {
		SYSCALL[$3]=substr($2,6);
		if ($3 > max) {
			max=$3;
		}
	}
}

END {
	for(i=0; i<=max; i++) {
		if (SYSCALL[i]) {
			if (length(SYSCALL[i])<5) {
				pad="\t\t\t";
			} else if (length(SYSCALL[i])<13) {
				pad="\t\t";
			} else {
				pad="\t";
			}
			printf("\t\"%s\",%s/* %d */\n", SYSCALL[i], pad, i);
		} else {
			printf("\t\"(NONE)\",\t\t/* %d */\n", i);
		}
	}
}

