1#! /bin/sh - 2# @(#)makesyscalls.sh 7.4 (Berkeley) 05/23/90 3 4# name of compat option: 5compat=COMPAT_43 6 7# output files: 8sysnames="syscalls.c" 9syshdr="../sys/syscall.h" 10syssw="init_sysent.c" 11 12# tmp files: 13sysdcl="sysent.dcl" 14syscompat="sysent.compat" 15sysent="sysent.switch" 16 17case $# in 18 0) echo "Usage: $0 input-file" 1>&2 19 exit 1 20 ;; 21esac 22 23awk < $1 " 24 BEGIN { 25 sysdcl = \"$sysdcl\" 26 syscompat = \"$syscompat\" 27 sysent = \"$sysent\" 28 sysnames = \"$sysnames\" 29 syshdr = \"$syshdr\" 30 compat = \"$compat\" 31 "' 32 33 printf "/*\n * System call switch table.\n *\n" > sysdcl 34 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl 35 36 printf "\n#ifdef %s\n", compat > syscompat 37 printf "#define compat(n, name) n, o/**/name\n\n" > syscompat 38 39 printf "/*\n * System call names.\n *\n" > sysnames 40 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames 41 42 printf "/*\n * System call numbers.\n *\n" > syshdr 43 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr 44 } 45 NR == 1 { 46 printf " * created from%s\n */\n\n", $0 > sysdcl 47 printf "#include \"param.h\"\n" > sysdcl 48 printf "#include \"systm.h\"\n\n" > sysdcl 49 printf "int\tnosys();\n\n" > sysdcl 50 51 printf "struct sysent sysent[] = {\n" > sysent 52 53 printf " * created from%s\n */\n\n", $0 > sysnames 54 printf "char *syscallnames[] = {\n" > sysnames 55 56 printf " * created from%s\n */\n\n", $0 > syshdr 57 next 58 } 59 NF == 0 || $1 ~ /^;/ { 60 next 61 } 62 $1 ~ /^#[ ]*if/ { 63 print > sysent 64 print > sysdcl 65 print > syscompat 66 print > sysnames 67 savesyscall = syscall 68 next 69 } 70 $1 ~ /^#[ ]*else/ { 71 print > sysent 72 print > sysdcl 73 print > syscompat 74 print > sysnames 75 syscall = savesyscall 76 next 77 } 78 $1 ~ /^#/ { 79 print > sysent 80 print > sysdcl 81 print > syscompat 82 print > sysnames 83 next 84 } 85 syscall != $1 { 86 printf "syscall number out of sync at %d; line is:\n", syscall 87 print 88 exit 1 89 } 90 { comment = $4 91 for (i = 5; i <= NF; i++) 92 comment = comment " " $i 93 if (NF < 5) 94 $5 = $4 95 } 96 $2 == "STD" { 97 printf("int\t%s();\n", $4) > sysdcl 98 printf("\t%d, %s,\t\t\t/* %d = %s */\n", \ 99 $3, $4, syscall, $5) > sysent 100 printf("\t\"%s\",\t\t\t/* %d = %s */\n", \ 101 $5, syscall, $5) > sysnames 102 printf("#define\tSYS_%s\t%d\n", \ 103 $5, syscall) > syshdr 104 } 105 $2 == "COMPAT" { 106 printf("int\to%s();\n", $4) > syscompat 107 printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \ 108 $3, $4, syscall, $5) > sysent 109 printf("\t\"old_%s\",\t\t/* %d = old %s */\n", \ 110 $5, syscall, $5) > sysnames 111 printf("\t\t\t\t/* %d is old_%s */\n", \ 112 syscall, comment) > syshdr 113 } 114 $2 == "OBSOL" { 115 printf("\t0, nosys,\t\t\t/* %d = obsolete %s */\n", \ 116 syscall, comment) > sysent 117 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \ 118 $4, syscall, comment) > sysnames 119 printf("\t\t\t\t/* %d is obsolete %s */\n", \ 120 syscall, comment) > syshdr 121 } 122 $2 == "UNIMPL" { 123 printf("\t0, nosys,\t\t\t/* %d = %s */\n", \ 124 syscall, comment) > sysent 125 printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \ 126 syscall, syscall, comment) > sysnames 127 } 128 { syscall++ } 129 END { 130 printf("\n#else /* %s */\n", compat) > syscompat 131 printf("#define compat(n, name) 0, nosys\n") > syscompat 132 printf("#endif /* %s */\n\n", compat) > syscompat 133 134 printf("};\n\n") > sysent 135 printf("int\tnsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent 136 137 printf("};\n") > sysnames 138 } ' 139 140cat $sysdcl $syscompat $sysent >$syssw 141rm $sysdcl $syscompat $sysent 142 143chmod 444 $sysnames $syshdr $syssw 144