|
|
1.1 root 1: #! /bin/sh - 1.1.1.2 ! root 2: # from: @(#)makesyscalls.sh 7.6 (Berkeley) 4/20/91 ! 3: # makesyscalls.sh,v 1.5 1993/06/07 19:52:40 cgd Exp 1.1 root 4: 5: set -e 6: 7: # name of compat option: 8: compat=COMPAT_43 9: 10: # output files: 11: sysnames="syscalls.c" 12: syshdr="../sys/syscall.h" 13: syssw="init_sysent.c" 14: 15: # tmp files: 16: sysdcl="sysent.dcl" 17: syscompat="sysent.compat" 18: sysent="sysent.switch" 19: 20: trap "rm $sysdcl $syscompat $sysent" 0 21: 22: case $# in 23: 0) echo "Usage: $0 input-file" 1>&2 24: exit 1 25: ;; 26: esac 27: 28: awk < $1 " 29: BEGIN { 30: sysdcl = \"$sysdcl\" 31: syscompat = \"$syscompat\" 32: sysent = \"$sysent\" 33: sysnames = \"$sysnames\" 34: syshdr = \"$syshdr\" 35: compat = \"$compat\" 36: infile = \"$1\" 37: "' 38: 39: printf "/*\n * System call switch table.\n *\n" > sysdcl 40: printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl 41: 42: printf "\n#ifdef %s\n", compat > syscompat 43: printf "#define compat(n, name) n, __CONCAT(o,name)\n\n" > syscompat 44: 45: printf "/*\n * System call names.\n *\n" > sysnames 46: printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames 47: 48: printf "/*\n * System call numbers.\n *\n" > syshdr 49: printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr 50: } 51: NR == 1 { 1.1.1.2 ! root 52: printf " * created from: %s %s %s %s\n */\n\n",$2,$3,$4,$5 > sysdcl 1.1 root 53: printf "#include \"param.h\"\n" > sysdcl 54: printf "#include \"systm.h\"\n\n" > sysdcl 55: printf "int\tnosys();\n\n" > sysdcl 56: 57: printf "struct sysent sysent[] = {\n" > sysent 58: 1.1.1.2 ! root 59: printf " * created from: %s %s %s %s\n */\n\n",$2,$3,$4,$5 > sysnames 1.1 root 60: printf "char *syscallnames[] = {\n" > sysnames 61: 1.1.1.2 ! root 62: printf " * created from: %s %s %s %s\n */\n\n",$2,$3,$4,$5 > syshdr ! 63: printf "#ifndef _SYS_SYSCALL_H\n" > syshdr ! 64: printf "#define _SYS_SYSCALL_H\n" > syshdr ! 65: printf "\n" > syshdr 1.1 root 66: next 67: } 68: NF == 0 || $1 ~ /^;/ { 69: next 70: } 71: $1 ~ /^#[ ]*if/ { 72: print > sysent 73: print > sysdcl 74: print > syscompat 75: print > sysnames 76: savesyscall = syscall 77: next 78: } 79: $1 ~ /^#[ ]*else/ { 80: print > sysent 81: print > sysdcl 82: print > syscompat 83: print > sysnames 84: syscall = savesyscall 85: next 86: } 87: $1 ~ /^#/ { 88: print > sysent 89: print > sysdcl 90: print > syscompat 91: print > sysnames 92: next 93: } 94: syscall != $1 { 95: printf "%s: line %d: syscall number out of sync at %d\n", \ 96: infile, NR, syscall 97: printf "line is:\n" 98: print 99: exit 1 100: } 101: { comment = $4 102: for (i = 5; i <= NF; i++) 103: comment = comment " " $i 104: if (NF < 5) 105: $5 = $4 106: } 1.1.1.2 ! root 107: $2 == "STD" || $2 == "NODEF" { 1.1 root 108: printf("int\t%s();\n", $4) > sysdcl 109: printf("\t%d, %s,\t\t\t/* %d = %s */\n", \ 110: $3, $4, syscall, $5) > sysent 111: printf("\t\"%s\",\t\t\t/* %d = %s */\n", \ 112: $5, syscall, $5) > sysnames 1.1.1.2 ! root 113: if ($2 == "STD") ! 114: printf("#define\tSYS_%s\t%d\n", \ ! 115: $5, syscall) > syshdr 1.1 root 116: syscall++ 117: next 118: } 119: $2 == "COMPAT" { 120: printf("int\to%s();\n", $4) > syscompat 121: printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \ 122: $3, $4, syscall, $5) > sysent 123: printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \ 124: $5, syscall, $5) > sysnames 125: printf("\t\t\t\t/* %d is old %s */\n", \ 126: syscall, comment) > syshdr 127: syscall++ 128: next 129: } 130: $2 == "LIBCOMPAT" { 131: printf("int\to%s();\n", $4) > syscompat 132: printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \ 133: $3, $4, syscall, $5) > sysent 134: printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \ 135: $5, syscall, $5) > sysnames 136: printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \ 137: $5, syscall) > syshdr 138: syscall++ 139: next 140: } 141: $2 == "OBSOL" { 142: printf("\t0, nosys,\t\t\t/* %d = obsolete %s */\n", \ 143: syscall, comment) > sysent 144: printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \ 145: $4, syscall, comment) > sysnames 146: printf("\t\t\t\t/* %d is obsolete %s */\n", \ 147: syscall, comment) > syshdr 148: syscall++ 149: next 150: } 151: $2 == "UNIMPL" { 152: printf("\t0, nosys,\t\t\t/* %d = %s */\n", \ 153: syscall, comment) > sysent 154: printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \ 155: syscall, syscall, comment) > sysnames 156: syscall++ 157: next 158: } 159: { 160: printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2 161: exit 1 162: } 163: END { 164: printf("\n#else /* %s */\n", compat) > syscompat 165: printf("#define compat(n, name) 0, nosys\n") > syscompat 166: printf("#endif /* %s */\n\n", compat) > syscompat 167: 168: printf("};\n\n") > sysent 169: printf("int\tnsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent 170: 171: printf("};\n") > sysnames 1.1.1.2 ! root 172: ! 173: printf "\n" > syshdr ! 174: printf "#endif /* _SYS_SYSCALL_H */\n" > syshdr 1.1 root 175: } ' 176: 177: cat $sysdcl $syscompat $sysent >$syssw 178: 1.1.1.2 ! root 179: #chmod 444 $sysnames $syshdr $syssw
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.