1994-05-24 10:09:53 +00:00
|
|
|
#! /bin/sh -
|
|
|
|
# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
|
1995-03-16 18:17:34 +00:00
|
|
|
# $Id: makesyscalls.sh,v 1.11 1995/02/14 19:22:29 sos Exp $
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# name of compat option:
|
|
|
|
compat=COMPAT_43
|
|
|
|
|
|
|
|
# output files:
|
|
|
|
sysnames="syscalls.c"
|
|
|
|
syshdr="../sys/syscall.h"
|
|
|
|
syssw="init_sysent.c"
|
1994-09-13 02:21:48 +00:00
|
|
|
syshide="../sys/syscall-hide.h"
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
# tmp files:
|
|
|
|
sysdcl="sysent.dcl"
|
|
|
|
syscompat="sysent.compat"
|
|
|
|
sysent="sysent.switch"
|
|
|
|
|
|
|
|
trap "rm $sysdcl $syscompat $sysent" 0
|
|
|
|
|
|
|
|
case $# in
|
|
|
|
0) echo "Usage: $0 input-file" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
awk < $1 "
|
|
|
|
BEGIN {
|
|
|
|
sysdcl = \"$sysdcl\"
|
|
|
|
syscompat = \"$syscompat\"
|
|
|
|
sysent = \"$sysent\"
|
|
|
|
sysnames = \"$sysnames\"
|
|
|
|
syshdr = \"$syshdr\"
|
|
|
|
compat = \"$compat\"
|
1994-09-13 02:21:48 +00:00
|
|
|
syshide = \"$syshide\"
|
1994-05-24 10:09:53 +00:00
|
|
|
infile = \"$1\"
|
|
|
|
"'
|
|
|
|
|
|
|
|
printf "/*\n * System call switch table.\n *\n" > sysdcl
|
|
|
|
printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
|
|
|
|
|
|
|
|
printf "\n#ifdef %s\n", compat > syscompat
|
|
|
|
printf "#define compat(n, name) n, __CONCAT(o,name)\n\n" > syscompat
|
|
|
|
|
|
|
|
printf "/*\n * System call names.\n *\n" > sysnames
|
|
|
|
printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
|
|
|
|
|
|
|
|
printf "/*\n * System call numbers.\n *\n" > syshdr
|
|
|
|
printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
|
1994-09-13 02:21:48 +00:00
|
|
|
printf "/*\n * System call hiders.\n *\n" > syshide
|
|
|
|
printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshide
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
NR == 1 {
|
|
|
|
printf " * created from%s\n */\n\n", $0 > sysdcl
|
|
|
|
printf "#include <sys/param.h>\n" > sysdcl
|
1994-08-26 09:33:37 +00:00
|
|
|
printf "#include <sys/sysent.h>\n\n" > sysdcl
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
printf "struct sysent sysent[] = {\n" > sysent
|
|
|
|
|
|
|
|
printf " * created from%s\n */\n\n", $0 > sysnames
|
|
|
|
printf "char *syscallnames[] = {\n" > sysnames
|
|
|
|
|
|
|
|
printf " * created from%s\n */\n\n", $0 > syshdr
|
1994-09-13 02:21:48 +00:00
|
|
|
|
|
|
|
printf " * created from%s\n */\n\n", $0 > syshide
|
1994-05-24 10:09:53 +00:00
|
|
|
next
|
|
|
|
}
|
|
|
|
NF == 0 || $1 ~ /^;/ {
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 ~ /^#[ ]*if/ {
|
|
|
|
print > sysent
|
|
|
|
print > sysdcl
|
|
|
|
print > syscompat
|
|
|
|
print > sysnames
|
1994-09-13 02:21:48 +00:00
|
|
|
print > syshide
|
1994-05-24 10:09:53 +00:00
|
|
|
savesyscall = syscall
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 ~ /^#[ ]*else/ {
|
|
|
|
print > sysent
|
|
|
|
print > sysdcl
|
|
|
|
print > syscompat
|
|
|
|
print > sysnames
|
1994-09-13 02:21:48 +00:00
|
|
|
print > syshide
|
1994-05-24 10:09:53 +00:00
|
|
|
syscall = savesyscall
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 ~ /^#/ {
|
|
|
|
print > sysent
|
|
|
|
print > sysdcl
|
|
|
|
print > syscompat
|
|
|
|
print > sysnames
|
1994-09-13 02:21:48 +00:00
|
|
|
print > syshide
|
1994-05-24 10:09:53 +00:00
|
|
|
next
|
|
|
|
}
|
|
|
|
syscall != $1 {
|
|
|
|
printf "%s: line %d: syscall number out of sync at %d\n", \
|
|
|
|
infile, NR, syscall
|
|
|
|
printf "line is:\n"
|
|
|
|
print
|
|
|
|
exit 1
|
|
|
|
}
|
1994-09-13 02:21:48 +00:00
|
|
|
{ comment = $5
|
|
|
|
for (i = 6; i <= NF; i++)
|
1994-05-24 10:09:53 +00:00
|
|
|
comment = comment " " $i
|
1994-09-13 02:21:48 +00:00
|
|
|
if (NF < 6)
|
|
|
|
$6 = $5
|
|
|
|
if ($4 != "NOHIDE")
|
|
|
|
printf("HIDE_%s(%s)\n", $4, $5) > syshide
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1994-08-19 11:45:29 +00:00
|
|
|
$2 == "STD" || $2 == "NODEF" {
|
1994-11-06 21:57:16 +00:00
|
|
|
if (( !nosys || $5 != "nosys" ) && ( !lkmnosys ||
|
|
|
|
$5 != "lkmnosys"))
|
1994-09-13 02:21:48 +00:00
|
|
|
printf("int\t%s();\n", $5) > sysdcl
|
|
|
|
if ($5 == "nosys")
|
1994-09-11 20:45:34 +00:00
|
|
|
nosys = 1
|
1994-11-06 21:57:16 +00:00
|
|
|
if ($5 == "lkmnosys")
|
|
|
|
lkmnosys = 1
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t{ %d, %s },\t\t\t/* %d = %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$3, $5, syscall, $6) > sysent
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$6, syscall, $6) > sysnames
|
1994-08-19 11:45:29 +00:00
|
|
|
if ($2 == "STD")
|
|
|
|
printf("#define\tSYS_%s\t%d\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$6, syscall) > syshdr
|
1994-05-24 10:09:53 +00:00
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "COMPAT" {
|
1994-09-13 02:21:48 +00:00
|
|
|
printf("int\to%s();\n", $5) > syscompat
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$3, $5, syscall, $6) > sysent
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$6, syscall, $6) > sysnames
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t\t\t\t/* %d is old %s */\n", \
|
|
|
|
syscall, comment) > syshdr
|
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "LIBCOMPAT" {
|
1994-09-13 02:21:48 +00:00
|
|
|
printf("int\to%s();\n", $5) > syscompat
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$3, $5, syscall, $6) > sysent
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$6, syscall, $6) > sysnames
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$6, syscall) > syshdr
|
1994-05-24 10:09:53 +00:00
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "OBSOL" {
|
|
|
|
printf("\t{ 0, nosys },\t\t\t/* %d = obsolete %s */\n", \
|
|
|
|
syscall, comment) > sysent
|
|
|
|
printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
|
1994-09-13 02:21:48 +00:00
|
|
|
$5, syscall, comment) > sysnames
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("\t\t\t\t/* %d is obsolete %s */\n", \
|
|
|
|
syscall, comment) > syshdr
|
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "UNIMPL" {
|
|
|
|
printf("\t{ 0, nosys },\t\t\t/* %d = %s */\n", \
|
|
|
|
syscall, comment) > sysent
|
|
|
|
printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
|
|
|
|
syscall, syscall, comment) > sysnames
|
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
{
|
|
|
|
printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
END {
|
|
|
|
printf("\n#else /* %s */\n", compat) > syscompat
|
|
|
|
printf("#define compat(n, name) 0, nosys\n") > syscompat
|
|
|
|
printf("#endif /* %s */\n\n", compat) > syscompat
|
|
|
|
|
|
|
|
printf("};\n\n") > sysent
|
1994-08-24 11:52:21 +00:00
|
|
|
printf ("struct sysentvec aout_sysvec = {\n") > sysent
|
|
|
|
printf ("\tsizeof (sysent) / sizeof (sysent[0]),\n") > sysent
|
|
|
|
printf ("\tsysent,\n") > sysent
|
1995-02-14 19:23:22 +00:00
|
|
|
printf ("\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0\n};\n") > sysent
|
1994-05-24 10:09:53 +00:00
|
|
|
printf("};\n") > sysnames
|
|
|
|
} '
|
|
|
|
|
|
|
|
cat $sysdcl $syscompat $sysent >$syssw
|
|
|
|
|
1994-09-13 02:21:48 +00:00
|
|
|
chmod 444 $sysnames $syshdr $syssw $syshide
|
|
|
|
|