1993-04-06 14:37:09 +04:00
|
|
|
#! /bin/sh -
|
1993-05-20 06:54:09 +04:00
|
|
|
# from: @(#)makesyscalls.sh 7.6 (Berkeley) 4/20/91
|
1994-03-18 22:08:28 +03:00
|
|
|
# $Id: makesyscalls.sh,v 1.6 1994/03/18 19:18:07 mycroft Exp $
|
1993-04-06 14:37:09 +04:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# name of compat option:
|
|
|
|
compat=COMPAT_43
|
|
|
|
|
|
|
|
# output files:
|
|
|
|
sysnames="syscalls.c"
|
|
|
|
syshdr="../sys/syscall.h"
|
|
|
|
syssw="init_sysent.c"
|
|
|
|
|
|
|
|
# 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\"
|
|
|
|
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
|
|
|
|
}
|
|
|
|
NR == 1 {
|
1993-05-20 20:17:38 +04:00
|
|
|
printf " * created from: %s %s %s %s\n */\n\n",$2,$3,$4,$5 > sysdcl
|
1994-03-18 22:08:28 +03:00
|
|
|
printf "#include <sys/param.h>\n" > sysdcl
|
|
|
|
printf "#include <sys/systm.h>\n\n" > sysdcl
|
1993-04-06 14:37:09 +04:00
|
|
|
printf "int\tnosys();\n\n" > sysdcl
|
|
|
|
|
|
|
|
printf "struct sysent sysent[] = {\n" > sysent
|
|
|
|
|
1993-05-20 20:17:38 +04:00
|
|
|
printf " * created from: %s %s %s %s\n */\n\n",$2,$3,$4,$5 > sysnames
|
1993-04-06 14:37:09 +04:00
|
|
|
printf "char *syscallnames[] = {\n" > sysnames
|
|
|
|
|
1993-05-20 20:17:38 +04:00
|
|
|
printf " * created from: %s %s %s %s\n */\n\n",$2,$3,$4,$5 > syshdr
|
|
|
|
printf "#ifndef _SYS_SYSCALL_H\n" > syshdr
|
|
|
|
printf "#define _SYS_SYSCALL_H\n" > syshdr
|
|
|
|
printf "\n" > syshdr
|
1993-04-06 14:37:09 +04:00
|
|
|
next
|
|
|
|
}
|
|
|
|
NF == 0 || $1 ~ /^;/ {
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 ~ /^#[ ]*if/ {
|
|
|
|
print > sysent
|
|
|
|
print > sysdcl
|
|
|
|
print > syscompat
|
|
|
|
print > sysnames
|
|
|
|
savesyscall = syscall
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 ~ /^#[ ]*else/ {
|
|
|
|
print > sysent
|
|
|
|
print > sysdcl
|
|
|
|
print > syscompat
|
|
|
|
print > sysnames
|
|
|
|
syscall = savesyscall
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 ~ /^#/ {
|
|
|
|
print > sysent
|
|
|
|
print > sysdcl
|
|
|
|
print > syscompat
|
|
|
|
print > sysnames
|
|
|
|
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
|
|
|
|
}
|
|
|
|
{ comment = $4
|
|
|
|
for (i = 5; i <= NF; i++)
|
|
|
|
comment = comment " " $i
|
|
|
|
if (NF < 5)
|
|
|
|
$5 = $4
|
|
|
|
}
|
1993-06-07 23:51:59 +04:00
|
|
|
$2 == "STD" || $2 == "NODEF" {
|
1993-04-06 14:37:09 +04:00
|
|
|
printf("int\t%s();\n", $4) > sysdcl
|
|
|
|
printf("\t%d, %s,\t\t\t/* %d = %s */\n", \
|
|
|
|
$3, $4, syscall, $5) > sysent
|
|
|
|
printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
|
|
|
|
$5, syscall, $5) > sysnames
|
1993-06-07 23:51:59 +04:00
|
|
|
if ($2 == "STD")
|
|
|
|
printf("#define\tSYS_%s\t%d\n", \
|
|
|
|
$5, syscall) > syshdr
|
1993-04-06 14:37:09 +04:00
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "COMPAT" {
|
|
|
|
printf("int\to%s();\n", $4) > syscompat
|
|
|
|
printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \
|
|
|
|
$3, $4, syscall, $5) > sysent
|
|
|
|
printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
|
|
|
|
$5, syscall, $5) > sysnames
|
|
|
|
printf("\t\t\t\t/* %d is old %s */\n", \
|
|
|
|
syscall, comment) > syshdr
|
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "LIBCOMPAT" {
|
|
|
|
printf("int\to%s();\n", $4) > syscompat
|
|
|
|
printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \
|
|
|
|
$3, $4, syscall, $5) > sysent
|
|
|
|
printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
|
|
|
|
$5, syscall, $5) > sysnames
|
|
|
|
printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
|
|
|
|
$5, syscall) > syshdr
|
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "OBSOL" {
|
|
|
|
printf("\t0, nosys,\t\t\t/* %d = obsolete %s */\n", \
|
|
|
|
syscall, comment) > sysent
|
|
|
|
printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
|
|
|
|
$4, syscall, comment) > sysnames
|
|
|
|
printf("\t\t\t\t/* %d is obsolete %s */\n", \
|
|
|
|
syscall, comment) > syshdr
|
|
|
|
syscall++
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$2 == "UNIMPL" {
|
|
|
|
printf("\t0, 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
|
|
|
|
printf("int\tnsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
|
|
|
|
|
|
|
|
printf("};\n") > sysnames
|
1993-05-20 20:17:38 +04:00
|
|
|
|
|
|
|
printf "\n" > syshdr
|
|
|
|
printf "#endif /* _SYS_SYSCALL_H */\n" > syshdr
|
1993-04-06 14:37:09 +04:00
|
|
|
} '
|
|
|
|
|
|
|
|
cat $sysdcl $syscompat $sysent >$syssw
|
|
|
|
|
1993-05-20 06:57:57 +04:00
|
|
|
#chmod 444 $sysnames $syshdr $syssw
|