| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 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 |
| Ian Wienand | c53309e | 2006-06-19 14:20:05 +0200 | [diff] [blame] | 5 | # It should work OK on i386,m68k,arm,ia64 |
| 6 | # It does NOT work in mips, s390 |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 7 | # It is untested in other architectures |
| 8 | |
| 9 | BEGIN { |
| 10 | max=0; |
| Ian Wienand | c53309e | 2006-06-19 14:20:05 +0200 | [diff] [blame] | 11 | FS="[ \t\n()+]+"; |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | { |
| Ian Wienand | c53309e | 2006-06-19 14:20:05 +0200 | [diff] [blame] | 15 | #debug |
| 16 | #printf("/%s/%s/%s/%s/\n", $1, $2, $3, $4); |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 17 | if (($1 ~ /^#define$/) && ($2 ~ /^__NR_/)) { |
| Ian Wienand | c53309e | 2006-06-19 14:20:05 +0200 | [diff] [blame] | 18 | #ia64 syscalls are > 1000 (lower for x86 compat) |
| 19 | if (($3>=0) && ($3<=2000)) { |
| Juan Cespedes | 1b9cfd6 | 1999-08-30 19:34:50 +0200 | [diff] [blame] | 20 | SYSCALL[$3]=substr($2,6); |
| 21 | if ($3 > max) { |
| 22 | max=$3; |
| 23 | } |
| 24 | } else if (($3 ~ /^__NR_SYSCALL_BASE$/) && ($4>=0) && ($4<=1000)) { |
| 25 | SYSCALL[$4]=substr($2,6); |
| 26 | if ($4 > max) { |
| 27 | max=$4; |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | END { |
| 34 | for(i=0; i<=max; i++) { |
| 35 | if (!SYSCALL[i]) { |
| 36 | SYSCALL[i] = i; |
| 37 | } |
| 38 | pad = 32 - length(SYSCALL[i]); |
| 39 | if (pad<1) { |
| 40 | pad=1; |
| 41 | } |
| 42 | printf("\t\"%s\",%*s/* %d */\n", SYSCALL[i], pad, "", i); |
| 43 | } |
| 44 | } |
| 45 | |