makesyscalls.sh revision 4216
11541Srgrimes#! /bin/sh - 21541Srgrimes# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93 34216Sats# $Id: makesyscalls.sh,v 1.9 1994/10/09 22:07:37 sos Exp $ 41541Srgrimes 51541Srgrimesset -e 61541Srgrimes 71541Srgrimes# name of compat option: 81541Srgrimescompat=COMPAT_43 91541Srgrimes 101541Srgrimes# output files: 111541Srgrimessysnames="syscalls.c" 121541Srgrimessyshdr="../sys/syscall.h" 131541Srgrimessyssw="init_sysent.c" 142700Swollmansyshide="../sys/syscall-hide.h" 151541Srgrimes 161541Srgrimes# tmp files: 171541Srgrimessysdcl="sysent.dcl" 181541Srgrimessyscompat="sysent.compat" 191541Srgrimessysent="sysent.switch" 201541Srgrimes 211541Srgrimestrap "rm $sysdcl $syscompat $sysent" 0 221541Srgrimes 231541Srgrimescase $# in 241541Srgrimes 0) echo "Usage: $0 input-file" 1>&2 251541Srgrimes exit 1 261541Srgrimes ;; 271541Srgrimesesac 281541Srgrimes 291541Srgrimesawk < $1 " 301541Srgrimes BEGIN { 311541Srgrimes sysdcl = \"$sysdcl\" 321541Srgrimes syscompat = \"$syscompat\" 331541Srgrimes sysent = \"$sysent\" 341541Srgrimes sysnames = \"$sysnames\" 351541Srgrimes syshdr = \"$syshdr\" 361541Srgrimes compat = \"$compat\" 372700Swollman syshide = \"$syshide\" 381541Srgrimes infile = \"$1\" 391541Srgrimes "' 401541Srgrimes 411541Srgrimes printf "/*\n * System call switch table.\n *\n" > sysdcl 421541Srgrimes printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl 431541Srgrimes 441541Srgrimes printf "\n#ifdef %s\n", compat > syscompat 451541Srgrimes printf "#define compat(n, name) n, __CONCAT(o,name)\n\n" > syscompat 461541Srgrimes 471541Srgrimes printf "/*\n * System call names.\n *\n" > sysnames 481541Srgrimes printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames 491541Srgrimes 501541Srgrimes printf "/*\n * System call numbers.\n *\n" > syshdr 511541Srgrimes printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr 522700Swollman printf "/*\n * System call hiders.\n *\n" > syshide 532700Swollman printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshide 541541Srgrimes } 551541Srgrimes NR == 1 { 561541Srgrimes printf " * created from%s\n */\n\n", $0 > sysdcl 571541Srgrimes printf "#include <sys/param.h>\n" > sysdcl 582293Ssos printf "#include <sys/systm.h>\n" > sysdcl 592293Ssos printf "#include <sys/sysent.h>\n\n" > sysdcl 601541Srgrimes 611541Srgrimes printf "struct sysent sysent[] = {\n" > sysent 621541Srgrimes 631541Srgrimes printf " * created from%s\n */\n\n", $0 > sysnames 641541Srgrimes printf "char *syscallnames[] = {\n" > sysnames 651541Srgrimes 661541Srgrimes printf " * created from%s\n */\n\n", $0 > syshdr 672700Swollman 682700Swollman printf " * created from%s\n */\n\n", $0 > syshide 691541Srgrimes next 701541Srgrimes } 711541Srgrimes NF == 0 || $1 ~ /^;/ { 721541Srgrimes next 731541Srgrimes } 741541Srgrimes $1 ~ /^#[ ]*if/ { 751541Srgrimes print > sysent 761541Srgrimes print > sysdcl 771541Srgrimes print > syscompat 781541Srgrimes print > sysnames 792700Swollman print > syshide 801541Srgrimes savesyscall = syscall 811541Srgrimes next 821541Srgrimes } 831541Srgrimes $1 ~ /^#[ ]*else/ { 841541Srgrimes print > sysent 851541Srgrimes print > sysdcl 861541Srgrimes print > syscompat 871541Srgrimes print > sysnames 882700Swollman print > syshide 891541Srgrimes syscall = savesyscall 901541Srgrimes next 911541Srgrimes } 921541Srgrimes $1 ~ /^#/ { 931541Srgrimes print > sysent 941541Srgrimes print > sysdcl 951541Srgrimes print > syscompat 961541Srgrimes print > sysnames 972700Swollman print > syshide 981541Srgrimes next 991541Srgrimes } 1001541Srgrimes syscall != $1 { 1011541Srgrimes printf "%s: line %d: syscall number out of sync at %d\n", \ 1021541Srgrimes infile, NR, syscall 1031541Srgrimes printf "line is:\n" 1041541Srgrimes print 1051541Srgrimes exit 1 1061541Srgrimes } 1072700Swollman { comment = $5 1082700Swollman for (i = 6; i <= NF; i++) 1091541Srgrimes comment = comment " " $i 1102700Swollman if (NF < 6) 1112700Swollman $6 = $5 1122700Swollman if ($4 != "NOHIDE") 1132700Swollman printf("HIDE_%s(%s)\n", $4, $5) > syshide 1141541Srgrimes } 1152124Sdg $2 == "STD" || $2 == "NODEF" { 1164216Sats if (( !nosys || $5 != "nosys" ) && ( !lkmnosys || 1174216Sats $5 != "lkmnosys")) 1182700Swollman printf("int\t%s();\n", $5) > sysdcl 1192700Swollman if ($5 == "nosys") 1202671Sats nosys = 1 1214216Sats if ($5 == "lkmnosys") 1224216Sats lkmnosys = 1 1231541Srgrimes printf("\t{ %d, %s },\t\t\t/* %d = %s */\n", \ 1242700Swollman $3, $5, syscall, $6) > sysent 1251541Srgrimes printf("\t\"%s\",\t\t\t/* %d = %s */\n", \ 1262700Swollman $6, syscall, $6) > sysnames 1272124Sdg if ($2 == "STD") 1282124Sdg printf("#define\tSYS_%s\t%d\n", \ 1292700Swollman $6, syscall) > syshdr 1301541Srgrimes syscall++ 1311541Srgrimes next 1321541Srgrimes } 1331541Srgrimes $2 == "COMPAT" { 1342700Swollman printf("int\to%s();\n", $5) > syscompat 1351541Srgrimes printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \ 1362700Swollman $3, $5, syscall, $6) > sysent 1371541Srgrimes printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \ 1382700Swollman $6, syscall, $6) > sysnames 1391541Srgrimes printf("\t\t\t\t/* %d is old %s */\n", \ 1401541Srgrimes syscall, comment) > syshdr 1411541Srgrimes syscall++ 1421541Srgrimes next 1431541Srgrimes } 1441541Srgrimes $2 == "LIBCOMPAT" { 1452700Swollman printf("int\to%s();\n", $5) > syscompat 1461541Srgrimes printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \ 1472700Swollman $3, $5, syscall, $6) > sysent 1481541Srgrimes printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \ 1492700Swollman $6, syscall, $6) > sysnames 1501541Srgrimes printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \ 1512700Swollman $6, syscall) > syshdr 1521541Srgrimes syscall++ 1531541Srgrimes next 1541541Srgrimes } 1551541Srgrimes $2 == "OBSOL" { 1561541Srgrimes printf("\t{ 0, nosys },\t\t\t/* %d = obsolete %s */\n", \ 1571541Srgrimes syscall, comment) > sysent 1581541Srgrimes printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \ 1592700Swollman $5, syscall, comment) > sysnames 1601541Srgrimes printf("\t\t\t\t/* %d is obsolete %s */\n", \ 1611541Srgrimes syscall, comment) > syshdr 1621541Srgrimes syscall++ 1631541Srgrimes next 1641541Srgrimes } 1651541Srgrimes $2 == "UNIMPL" { 1661541Srgrimes printf("\t{ 0, nosys },\t\t\t/* %d = %s */\n", \ 1671541Srgrimes syscall, comment) > sysent 1681541Srgrimes printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \ 1691541Srgrimes syscall, syscall, comment) > sysnames 1701541Srgrimes syscall++ 1711541Srgrimes next 1721541Srgrimes } 1731541Srgrimes { 1741541Srgrimes printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2 1751541Srgrimes exit 1 1761541Srgrimes } 1771541Srgrimes END { 1781541Srgrimes printf("\n#else /* %s */\n", compat) > syscompat 1791541Srgrimes printf("#define compat(n, name) 0, nosys\n") > syscompat 1801541Srgrimes printf("#endif /* %s */\n\n", compat) > syscompat 1811541Srgrimes 1821541Srgrimes printf("};\n\n") > sysent 1832257Ssos printf ("struct sysentvec aout_sysvec = {\n") > sysent 1842257Ssos printf ("\tsizeof (sysent) / sizeof (sysent[0]),\n") > sysent 1852257Ssos printf ("\tsysent,\n") > sysent 1863478Ssos printf ("\t0,\n\t0,\n\t0,\n\t0,\n\t0\n};\n") > sysent 1871541Srgrimes printf("};\n") > sysnames 1881541Srgrimes } ' 1891541Srgrimes 1901541Srgrimescat $sysdcl $syscompat $sysent >$syssw 1911541Srgrimes 1922700Swollmanchmod 444 $sysnames $syshdr $syssw $syshide 1932700Swollman 194