# @(#)makesyscalls.sh 8.3 (Berkeley) %G%
sysnames
="hpux_syscalls.c"
syscompat
="sysent.compat"
trap "rm $sysdcl $syscompat $sysent" 0
0) echo "Usage: $0 input-file" 1>&2
syscompat = \"$syscompat\"
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, n * 4, __CONCAT(compat_43_,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
printf " * created from%s\n */\n\n", $0 > sysdcl
printf "#include <sys/param.h>\n" > sysdcl
printf "#include <sys/systm.h>\n\n" > sysdcl
printf "int\tnosys(),notimp();\n\n" > sysdcl
printf "struct sysent hpuxsysent[] = {\n" > sysent
printf " * created from%s\n */\n\n", $0 > sysnames
printf "char *hpuxsyscallnames[] = {\n" > sysnames
printf " * created from%s\n */\n\n", $0 > syshdr
printf "%s: line %d: syscall number out of sync at %d\n", \
for (i = 5; i <= NF; i++)
printf("int\t%s();\n", $4) > sysdcl
printf("\t{ %d, %d, %s },\t\t\t/* %d = %s */\n", \
$3, $3 * 4, $4, syscall, $5) > sysent
printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
$5, syscall, $5) > sysnames
printf("#define\tSYS_%s\t%d\n", \
printf("int\tcompat_43_%s();\n", $4) > syscompat
printf("\t{ compat(%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
printf("int\tcompat_43_%s();\n", $4) > syscompat
printf("\t{ compat(%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", \
printf("\t{ 0, 0, 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
printf("\t{ 0, 0, nosys },\t\t\t/* %d = %s */\n", \
syscall, comment) > sysent
printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
syscall, syscall, comment) > sysnames
printf("\t{ %d, %d, notimp },\t\t\t/* %d = %s (unimplemented) */\n", \
$3, $3 * 4, syscall, comment) > sysent
printf("\t\"%s\",\t\t\t/* %d = %s (unimplemented) */\n", \
$4, syscall, comment) > sysnames
printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
printf("\n#else /* %s */\n", compat) > syscompat
printf("#define compat(n, name) 0, 0, nosys\n") > syscompat
printf("#endif /* %s */\n\n", compat) > syscompat
printf("};\n\n") > sysent
printf("int\thpuxnsysent = sizeof(hpuxsysent) / sizeof(hpuxsysent[0]);\n") > sysent
printf("};\n") > sysnames
cat $sysdcl $syscompat $sysent >$syssw
chmod 444 $sysnames $syshdr $syssw