1994-05-24 10:09:53 +00:00
|
|
|
#! /bin/sh -
|
|
|
|
# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
|
1995-09-19 13:50:26 +00:00
|
|
|
# $Id: makesyscalls.sh,v 1.13 1995/09/19 13:30:51 bde Exp $
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# name of compat option:
|
|
|
|
compat=COMPAT_43
|
|
|
|
|
|
|
|
# output files:
|
|
|
|
sysnames="syscalls.c"
|
1995-09-19 13:31:04 +00:00
|
|
|
sysproto="../sys/sysproto.h"
|
|
|
|
sysproto_h=_SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
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\"
|
1995-09-19 13:31:04 +00:00
|
|
|
sysproto = \"$sysproto\"
|
|
|
|
sysproto_h = \"$sysproto_h\"
|
1994-05-24 10:09:53 +00:00
|
|
|
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\"
|
|
|
|
"'
|
|
|
|
|
1995-09-19 13:31:04 +00:00
|
|
|
printf "/*\n * System call switch table.\n *\n" > sysent
|
|
|
|
printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysent
|
|
|
|
|
|
|
|
printf "/*\n * System call prototypes.\n *\n" > sysdcl
|
1994-05-24 10:09:53 +00:00
|
|
|
printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
|
|
|
|
|
1995-09-19 13:31:04 +00:00
|
|
|
printf "\n#ifdef %s\n\n", compat > syscompat
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
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 {
|
1995-09-19 13:50:26 +00:00
|
|
|
gsub("[$]Id: ", "", $0)
|
|
|
|
gsub(" [$]", "", $0)
|
1995-09-19 13:31:04 +00:00
|
|
|
printf " * created from%s\n */\n\n", $0 > sysent
|
|
|
|
printf "#include <sys/param.h>\n" > sysent
|
|
|
|
printf "#include <sys/sysent.h>\n" > sysent
|
|
|
|
printf "#include <sys/sysproto.h>\n\n" > sysent
|
|
|
|
printf "#ifdef %s\n", compat > sysent
|
|
|
|
printf "#define compat(n, name) n, (sy_call_t *)__CONCAT(o,name)\n" > sysent
|
|
|
|
printf("#else\n") > sysent
|
|
|
|
printf("#define compat(n, name) 0, (sy_call_t *)nosys\n") > sysent
|
|
|
|
printf("#endif\n\n") > sysent
|
|
|
|
printf("/* The casts are bogus but will do for now. */\n") > sysent
|
1994-05-24 10:09:53 +00:00
|
|
|
printf "struct sysent sysent[] = {\n" > sysent
|
|
|
|
|
1995-09-19 13:31:04 +00:00
|
|
|
printf " * created from%s\n */\n\n", $0 > sysdcl
|
|
|
|
printf("#ifndef %s\n", sysproto_h) > sysdcl
|
|
|
|
printf("#define\t%s\n\n", sysproto_h) > sysdcl
|
|
|
|
printf "#include <sys/types.h>\n\n", $0 > sysdcl
|
|
|
|
printf "struct proc;\n\n", $0 > sysdcl
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
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
|
1995-09-19 13:31:04 +00:00
|
|
|
if (NF < 8)
|
|
|
|
for (i = 6; i <= NF; i++)
|
|
|
|
comment = comment " " $i
|
|
|
|
if (NF < 6) {
|
1994-09-13 02:21:48 +00:00
|
|
|
$6 = $5
|
1995-09-19 13:31:04 +00:00
|
|
|
$7 = $5 "_args"
|
|
|
|
if ($2 == "COMPAT")
|
|
|
|
$7 = "o" $7
|
|
|
|
$8 = "int"
|
|
|
|
}
|
1994-09-13 02:21:48 +00:00
|
|
|
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 ||
|
1995-09-19 13:31:04 +00:00
|
|
|
$5 != "lkmnosys")) {
|
|
|
|
printf("struct\t%s;\n", $7) > sysdcl
|
|
|
|
if ($5 == "exit")
|
|
|
|
printf("__dead ") > sysdcl
|
|
|
|
printf("%s\t%s __P((struct proc *, struct %s *, int []));\n", \
|
|
|
|
$8, $5, $7) > sysdcl
|
|
|
|
}
|
1994-09-13 02:21:48 +00:00
|
|
|
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
|
1995-09-19 13:31:04 +00:00
|
|
|
printf("\t{ %d, (sy_call_t *)%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" {
|
1995-09-19 13:31:04 +00:00
|
|
|
printf("struct\t%s;\n", $7) > syscompat
|
|
|
|
printf("%s\to%s __P((struct proc *, struct %s *, int []));\n", \
|
|
|
|
$8, $5, $7) > 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" {
|
1995-09-19 13:31:04 +00:00
|
|
|
printf("%s\to%s();\n", $8, $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" {
|
1995-09-19 13:31:04 +00:00
|
|
|
printf("\t{ 0, (sy_call_t *)nosys },\t\t\t/* %d = obsolete %s */\n", \
|
1994-05-24 10:09:53 +00:00
|
|
|
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" {
|
1995-09-19 13:31:04 +00:00
|
|
|
printf("\t{ 0, (sy_call_t *)nosys },\t\t\t/* %d = %s */\n", \
|
1994-05-24 10:09:53 +00:00
|
|
|
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 {
|
1995-09-19 13:31:04 +00:00
|
|
|
printf("\n#endif /* %s */\n", compat) > syscompat
|
|
|
|
printf("\n#endif /* !%s */\n", sysproto_h) > syscompat
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
} '
|
|
|
|
|
1995-09-19 13:31:04 +00:00
|
|
|
cat $sysent >$syssw
|
|
|
|
cat $sysdcl $syscompat >$sysproto
|