Home | History | Annotate | Line # | Download | only in kern
makesyscalls.sh revision 1.68.2.1
      1 #! /bin/sh -
      2 #	$NetBSD: makesyscalls.sh,v 1.68.2.1 2008/05/18 12:35:09 yamt Exp $
      3 #
      4 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
      5 # All rights reserved.
      6 #
      7 # Redistribution and use in source and binary forms, with or without
      8 # modification, are permitted provided that the following conditions
      9 # are met:
     10 # 1. Redistributions of source code must retain the above copyright
     11 #    notice, this list of conditions and the following disclaimer.
     12 # 2. Redistributions in binary form must reproduce the above copyright
     13 #    notice, this list of conditions and the following disclaimer in the
     14 #    documentation and/or other materials provided with the distribution.
     15 # 3. All advertising materials mentioning features or use of this software
     16 #    must display the following acknowledgement:
     17 #      This product includes software developed for the NetBSD Project
     18 #      by Christopher G. Demetriou.
     19 # 4. The name of the author may not be used to endorse or promote products
     20 #    derived from this software without specific prior written permission
     21 #
     22 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 
     33 #	@(#)makesyscalls.sh	8.1 (Berkeley) 6/10/93
     34 
     35 set -e
     36 
     37 case $# in
     38     2)	;;
     39     *)	echo "Usage: $0 config-file input-file" 1>&2
     40 	exit 1
     41 	;;
     42 esac
     43 
     44 # the config file sets the following variables:
     45 #	sysalign	check for alignment of off_t
     46 #	sysnames	the syscall names file
     47 #	sysnumhdr	the syscall numbers file
     48 #	syssw		the syscall switch file
     49 #	sysarghdr	the syscall argument struct definitions
     50 #	compatopts	those syscall types that are for 'compat' syscalls
     51 #	switchname	the name for the 'struct sysent' we define
     52 #	namesname	the name for the 'const char *[]' we define
     53 #	constprefix	the prefix for the system call constants
     54 #	registertype	the type for register_t
     55 #	nsysent		the size of the sysent table
     56 #	sys_nosys	[optional] name of function called for unsupported
     57 #			syscalls, if not sys_nosys()
     58 #       maxsysargs	[optiona] the maximum number or arguments
     59 #
     60 # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'.
     61 
     62 # source the config file.
     63 sys_nosys="sys_nosys"	# default is sys_nosys(), if not specified otherwise
     64 maxsysargs=8		# default limit is 8 (32bit) arguments
     65 rumpcalls="/dev/null"
     66 rumpcallshdr="/dev/null"
     67 . ./$1
     68 
     69 # tmp files:
     70 sysdcl="sysent.dcl"
     71 sysprotos="sys.protos"
     72 syscompat_pref="sysent."
     73 sysent="sysent.switch"
     74 sysnamesbottom="sysnames.bottom"
     75 
     76 trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom" 0
     77 
     78 # Awk program (must support nawk extensions)
     79 # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
     80 awk=${AWK:-awk}
     81 
     82 # Does this awk have a "toupper" function?
     83 have_toupper=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null`
     84 
     85 # If this awk does not define "toupper" then define our own.
     86 if [ "$have_toupper" = TRUE ] ; then
     87 	# Used awk (GNU awk or nawk) provides it
     88 	toupper=
     89 else
     90 	# Provide our own toupper()
     91 	toupper='
     92 function toupper(str) {
     93 	_toupper_cmd = "echo "str" |tr a-z A-Z"
     94 	_toupper_cmd | getline _toupper_str;
     95 	close(_toupper_cmd);
     96 	return _toupper_str;
     97 }'
     98 fi
     99 
    100 # before handing it off to awk, make a few adjustments:
    101 #	(1) insert spaces around {, }, (, ), *, and commas.
    102 #	(2) get rid of any and all dollar signs (so that rcs id use safe)
    103 #
    104 # The awk script will deal with blank lines and lines that
    105 # start with the comment character (';').
    106 
    107 sed -e '
    108 s/\$//g
    109 :join
    110 	/\\$/{a\
    111 
    112 	N
    113 	s/\\\n//
    114 	b join
    115 	}
    116 2,${
    117 	/^#/!s/\([{}()*,]\)/ \1 /g
    118 }
    119 ' < $2 | $awk "
    120 $toupper
    121 BEGIN {
    122 	# to allow nested #if/#else/#endif sets
    123 	savedepth = 0
    124 	# to track already processed syscalls
    125 
    126 	sysnames = \"$sysnames\"
    127 	sysprotos = \"$sysprotos\"
    128 	sysnumhdr = \"$sysnumhdr\"
    129 	sysarghdr = \"$sysarghdr\"
    130 	rumpcalls = \"$rumpcalls\"
    131 	rumpcallshdr = \"$rumpcallshdr\"
    132 	switchname = \"$switchname\"
    133 	namesname = \"$namesname\"
    134 	constprefix = \"$constprefix\"
    135 	registertype = \"$registertype\"
    136 	sysalign=\"$sysalign\"
    137 	if (!registertype) {
    138 	    registertype = \"register_t\"
    139 	}
    140 	nsysent = \"$nsysent\"
    141 
    142 	sysdcl = \"$sysdcl\"
    143 	syscompat_pref = \"$syscompat_pref\"
    144 	sysent = \"$sysent\"
    145 	sysnamesbottom = \"$sysnamesbottom\"
    146 	sys_nosys = \"$sys_nosys\"
    147 	maxsysargs = \"$maxsysargs\"
    148 	infile = \"$2\"
    149 
    150 	compatopts = \"$compatopts\"
    151 	"'
    152 
    153 	printf "/* \$NetBSD\$ */\n\n" > sysdcl
    154 	printf "/*\n * System call switch table.\n *\n" > sysdcl
    155 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
    156 
    157 	ncompat = split(compatopts,compat)
    158 	for (i = 1; i <= ncompat; i++) {
    159 		compat_upper[i] = toupper(compat[i])
    160 
    161 		printf "\n#ifdef %s\n", compat_upper[i] > sysent
    162 		printf "#define	%s(func) __CONCAT(%s_,func)\n", compat[i], \
    163 		    compat[i] > sysent
    164 		printf "#else\n" > sysent
    165 		printf "#define	%s(func) %s\n", compat[i], sys_nosys > sysent
    166 		printf "#endif\n" > sysent
    167 	}
    168 
    169 	printf "\n#define\ts(type)\tsizeof(type)\n" > sysent
    170 	printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent
    171 	printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > sysent
    172 	printf "struct sysent %s[] = {\n",switchname > sysent
    173 
    174 	printf "/* \$NetBSD\$ */\n\n" > sysnames
    175 	printf "/*\n * System call names.\n *\n" > sysnames
    176 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
    177 
    178 	printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos
    179 
    180 	printf "/* \$NetBSD\$ */\n\n" > sysnumhdr
    181 	printf "/*\n * System call numbers.\n *\n" > sysnumhdr
    182 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr
    183 
    184 	printf "/* \$NetBSD\$ */\n\n" > sysarghdr
    185 	printf "/*\n * System call argument lists.\n *\n" > sysarghdr
    186 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
    187 
    188 	printf "/* \$NetBSD\$ */\n\n" > rumpcalls
    189 	printf "/*\n * System call marshalling for rump.\n *\n" > rumpcalls
    190 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
    191 
    192 	printf "/* \$NetBSD\$ */\n\n" > rumpcallshdr
    193 	printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
    194 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
    195 }
    196 NR == 1 {
    197 	sub(/ $/, "")
    198 	printf " * created from%s\n */\n\n", $0 > sysdcl
    199 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > sysdcl
    200 
    201 	printf " * created from%s\n */\n\n", $0 > sysnames
    202 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > sysnames
    203 
    204 	printf " * created from%s\n */\n\n", $0 > rumpcalls
    205 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"\$NetBSD\$\");\n\n" > rumpcalls
    206 	printf "#include <sys/types.h>\n" > rumpcalls
    207 	printf "#include <sys/param.h>\n" > rumpcalls
    208 	printf "#include <sys/proc.h>\n" > rumpcalls
    209 	printf "#include <sys/syscallargs.h>\n" > rumpcalls
    210 	printf "#include \"rump_syscalls.h\"\n\n" > rumpcalls
    211 	printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
    212 	printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
    213 	printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
    214 	printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
    215 	printf "#endif\n\n" > rumpcalls
    216 
    217 	# System call names are included by userland (kdump(1)), so
    218 	# hide the include files from it.
    219 	printf "#if defined(_KERNEL_OPT)\n" > sysnames
    220 
    221 	printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom
    222 	printf "const char *const %s[] = {\n",namesname > sysnamesbottom
    223 
    224 	printf " * created from%s\n */\n\n", $0 > sysnumhdr
    225 
    226 	printf " * created from%s\n */\n\n", $0 > sysarghdr
    227 
    228 	printf " * created from%s\n */\n\n", $0 > rumpcallshdr
    229 
    230 	printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
    231 	printf "#define	_" constprefix "SYSCALL_H_\n\n" > sysnumhdr
    232 	printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
    233 	printf "#define	_" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr
    234 	# Write max number of system call arguments to both headers
    235 	printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
    236 		> sysnumhdr
    237 	printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
    238 		> sysarghdr
    239 	printf "#undef\tsyscallarg\n" > sysarghdr
    240 	printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr
    241 	printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr
    242 	printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr
    243 	printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr
    244 	printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \
    245 		> sysarghdr
    246 	printf "\t\t\tint8_t pad[  /* CONSTCOND */\t\t\t\\\n" > sysarghdr
    247 	printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \
    248 		registertype > sysarghdr
    249 	printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr
    250 	printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \
    251 		registertype > sysarghdr
    252 	printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr
    253 	printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr
    254 	printf "\t}\n" > sysarghdr
    255 	printf("\n#undef check_syscall_args\n") >sysarghdr
    256 	printf("#define check_syscall_args(call) \\\n" \
    257 		"\ttypedef char call##_check_args" \
    258 		    "[sizeof (struct call##_args) \\\n" \
    259 		"\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
    260 		constprefix, registertype) >sysarghdr
    261 	next
    262 }
    263 NF == 0 || $1 ~ /^;/ {
    264 	next
    265 }
    266 $0 ~ /^%%$/ {
    267 	intable = 1
    268 	next
    269 }
    270 $1 ~ /^#[ 	]*include/ {
    271 	print > sysdcl
    272 	print > sysnames
    273 	next
    274 }
    275 $1 ~ /^#/ && !intable {
    276 	print > sysdcl
    277 	print > sysnames
    278 	next
    279 }
    280 $1 ~ /^#/ && intable {
    281 	if ($1 ~ /^#[ 	]*if/) {
    282 		savedepth++
    283 		savesyscall[savedepth] = syscall
    284 	}
    285 	if ($1 ~ /^#[ 	]*else/) {
    286 		if (savedepth <= 0) {
    287 			printf("%s: line %d: unbalanced #else\n", \
    288 			    infile, NR)
    289 			exit 1
    290 		}
    291 		syscall = savesyscall[savedepth]
    292 	}
    293 	if ($1 ~ /^#[       ]*endif/) {
    294 		if (savedepth <= 0) {
    295 			printf("%s: line %d: unbalanced #endif\n", \
    296 			    infile, NR)
    297 			exit 1
    298 		}
    299 		savedepth--
    300 	}
    301 	print > sysent
    302 	print > sysarghdr
    303 	print > sysnumhdr
    304 	print > sysprotos
    305 	print > sysnamesbottom
    306 	next
    307 }
    308 syscall != $1 {
    309 	printf "%s: line %d: syscall number out of sync at %d\n", \
    310 	   infile, NR, syscall
    311 	printf "line is:\n"
    312 	print
    313 	exit 1
    314 }
    315 function parserr(was, wanted) {
    316 	printf "%s: line %d: unexpected %s (expected %s)\n", \
    317 	    infile, NR, was, wanted
    318 	printf "line is:\n"
    319 	print
    320 	exit 1
    321 }
    322 function parseline() {
    323 	f=3			# toss number and type
    324 	if ($2 == "INDIR")
    325 		sycall_flags="SYCALL_INDIRECT"
    326 	else
    327 		sycall_flags="0"
    328 	if ($NF != "}") {
    329 		funcalias=$NF
    330 		end=NF-1
    331 	} else {
    332 		funcalias=""
    333 		end=NF
    334 	}
    335 	if ($f == "INDIR") {		# allow for "NOARG INDIR"
    336 		sycall_flags = "SYCALL_INDIRECT | " sycall_flags
    337 		f++
    338 	}
    339 	if ($f == "RUMP") {
    340 		rumpable = 1
    341 		f++
    342 	} else {
    343 		rumpable = 0
    344 	}
    345 	if ($f ~ /^[a-z0-9_]*$/) {	# allow syscall alias
    346 		funcalias=$f
    347 		f++
    348 	}
    349 	if ($f != "{")
    350 		parserr($f, "{")
    351 	f++
    352 	if ($end != "}")
    353 		parserr($end, "}")
    354 	end--
    355 	if ($end != ";")
    356 		parserr($end, ";")
    357 	end--
    358 	if ($end != ")")
    359 		parserr($end, ")")
    360 	end--
    361 
    362 	returntype = oldf = "";
    363 	do {
    364 		if (returntype != "" && oldf != "*")
    365 			returntype = returntype" ";
    366 		returntype = returntype$f;
    367 		oldf = $f;
    368 		f++
    369 	} while (f < (end - 1) && $(f+1) != "(");
    370 	if (f == (end - 1)) {
    371 		parserr($f, "function argument definition (maybe \"(\"?)");
    372 	}
    373 
    374 	funcname=$f
    375 	if (funcalias == "") {
    376 		funcalias=funcname
    377 		sub(/^([^_]+_)*sys_/, "", funcalias)
    378 	}
    379 	f++
    380 
    381 	if ($f != "(")
    382 		parserr($f, ")")
    383 	f++
    384 
    385 	argc=0;
    386 	argalign=0;
    387 	if (f == end) {
    388 		if ($f != "void")
    389 			parserr($f, "argument definition")
    390 		isvarargs = 0;
    391 		varargc = 0;
    392 		return
    393 	}
    394 
    395 	# some system calls (open() and fcntl()) can accept a variable
    396 	# number of arguments.  If syscalls accept a variable number of
    397 	# arguments, they must still have arguments specified for
    398 	# the remaining argument "positions," because of the way the
    399 	# kernel system call argument handling works.
    400 	#
    401 	# Indirect system calls, e.g. syscall(), are exceptions to this
    402 	# rule, since they are handled entirely by machine-dependent code
    403 	# and do not need argument structures built.
    404 
    405 	isvarargs = 0;
    406 	while (f <= end) {
    407 		if ($f == "...") {
    408 			f++;
    409 			isvarargs = 1;
    410 			varargc = argc;
    411 			continue;
    412 		}
    413 		argc++
    414 		argtype[argc]=""
    415 		oldf=""
    416 		while (f < end && $(f+1) != ",") {
    417 			if (argtype[argc] != "" && oldf != "*")
    418 				argtype[argc] = argtype[argc]" ";
    419 			argtype[argc] = argtype[argc]$f;
    420 			oldf = $f;
    421 			f++
    422 		}
    423 		if (argtype[argc] == "")
    424 			parserr($f, "argument definition")
    425 		if (argtype[argc] == "off_t") {
    426 			if ((argalign % 2) != 0 && sysalign &&
    427 			    funcname != "sys_posix_fadvise") # XXX for now
    428 				parserr($f, "a padding argument")
    429 		} else {
    430 			argalign++;
    431 		}
    432 		argname[argc]=$f;
    433 		f += 2;			# skip name, and any comma
    434 	}
    435 	# must see another argument after varargs notice.
    436 	if (isvarargs) {
    437 		if (argc == varargc)
    438 			parserr($f, "argument definition")
    439 	} else
    440 		varargc = argc;
    441 }
    442 
    443 function printproto(wrap) {
    444 	printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
    445 	    returntype) > sysnumhdr
    446 	for (i = 1; i <= varargc; i++)
    447 		printf(" \"%s\"", argtype[i]) > sysnumhdr
    448 	if (isvarargs)
    449 		printf(" \"...\"") > sysnumhdr
    450 	printf(" */\n") > sysnumhdr
    451 	printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
    452 	    syscall) > sysnumhdr
    453 
    454 	# rumpalooza
    455 	if (!rumpable)
    456 		return
    457 
    458 	if (wrap == "")
    459 		wrap = "sys"
    460 	printf("%s rump_%s_%s(", returntype, wrap, funcalias) > rumpcallshdr
    461 	for (i = 1; i <= argc; i++)
    462 		printf("%s, ", argtype[i]) > rumpcallshdr
    463 	printf("int *);\n") > rumpcallshdr
    464 }
    465 
    466 function putent(type, compatwrap) {
    467 	# output syscall declaration for switch table.
    468 	if (compatwrap == "")
    469 		compatwrap_ = ""
    470 	else
    471 		compatwrap_ = compatwrap "_"
    472 	if (argc == 0)
    473 		arg_type = "void";
    474 	else {
    475 		arg_type = "struct " compatwrap_ funcname "_args";
    476 	}
    477 	proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \
    478 	    arg_type " *, register_t *);\n"
    479 	if (sysmap[proto] != 1) {
    480 		sysmap[proto] = 1;
    481 		print proto > sysprotos;
    482 	}
    483 
    484 	# output syscall switch entry
    485 	printf("\t{ ") > sysent
    486 	if (argc == 0) {
    487 		printf("0, 0, ") > sysent
    488 	} else {
    489 		printf("ns(struct %s%s_args), ", compatwrap_, funcname) > sysent
    490 	}
    491 	if (compatwrap == "")
    492 		wfn = "(sy_call_t *)" funcname;
    493 	else
    494 		wfn = "(sy_call_t *)" compatwrap "(" funcname ")";
    495 	printf("%s,\n\t    %s },", sycall_flags, wfn) > sysent
    496 	for (i = 0; i < (33 - length(wfn)) / 8; i++)
    497 		printf("\t") > sysent
    498 	printf("/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent
    499 
    500 	# output syscall name for names table
    501 	printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \
    502 	    > sysnamesbottom
    503 
    504 	# output syscall number of header, if appropriate
    505 	if (type == "STD" || type == "NOARGS" || type == "INDIR") {
    506 		# output a prototype, to be used to generate lint stubs in
    507 		# libc.
    508 		printproto("")
    509 	} else if (type == "COMPAT") {
    510 		# Just define the syscall number with a comment.  These
    511 		# may be used by compatibility stubs in libc.
    512 		printproto(compatwrap_)
    513 	}
    514 
    515 	# output syscall argument structure, if it has arguments
    516 	if (argc != 0) {
    517 		printf("\nstruct %s%s_args", compatwrap_, funcname) > sysarghdr
    518 		if (type != "NOARGS") {
    519 			print " {" >sysarghdr;
    520 			for (i = 1; i <= argc; i++)
    521 				printf("\tsyscallarg(%s) %s;\n", argtype[i],
    522 				    argname[i]) > sysarghdr
    523 			printf "}" >sysarghdr;
    524 		}
    525 		printf(";\n") > sysarghdr
    526 		if (type != "NOARGS" && type != "INDIR") {
    527 			printf("check_syscall_args(%s%s)\n", compatwrap_,
    528 			    funcname) >sysarghdr
    529 		}
    530 	}
    531 
    532 	# output rump marshalling code if necessary
    533 	if (!rumpable)
    534 		return
    535 
    536 	printf("%s\nrump_%s(", returntype, funcname) > rumpcalls
    537 	for (i = 1; i <= argc; i++) {
    538 		printf("%s %s, ", argtype[i], argname[i]) > rumpcalls
    539 	}
    540 	printf("int *error)\n") > rumpcalls
    541 	printf("{\n\tregister_t retval;\n") > rumpcalls
    542 	argarg = "NULL"
    543 	if (argc) {
    544 		argarg = "&arg"
    545 		printf("\tstruct %s%s_args arg;\n\n", funcname, compatwrap_) \
    546 		    > rumpcalls
    547 		for (i = 1; i <= argc; i++) {
    548 			printf("\tSPARG(&arg, %s) = %s;\n", \
    549 			    argname[i], argname[i]) > rumpcalls
    550 		}
    551 		printf("\n") > rumpcalls
    552 	} else {
    553 		printf("\n") > rumpcalls
    554 	}
    555 	printf("\t*error = %s(curlwp, %s, &retval);\n", funcname, argarg) \
    556 	    > rumpcalls
    557 	if (returntype != "void")
    558 		printf("\treturn retval;\n") > rumpcalls
    559 	printf("}\n\n") > rumpcalls
    560 }
    561 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" {
    562 	parseline()
    563 	putent($2, "")
    564 	syscall++
    565 	next
    566 }
    567 $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" {
    568 	if ($2 == "OBSOL")
    569 		comment="obsolete"
    570 	else if ($2 == "EXCL")
    571 		comment="excluded"
    572 	else if ($2 == "IGNORED")
    573 		comment="ignored"
    574 	else
    575 		comment="unimplemented"
    576 	for (i = 3; i <= NF; i++)
    577 		comment=comment " " $i
    578 
    579 	if ($2 == "IGNORED")
    580 		sys_stub = "(sy_call_t *)nullop";
    581 	else
    582 		sys_stub = sys_nosys;
    583 
    584 	printf("\t{ 0, 0, 0,\n\t    %s },\t\t\t/* %d = %s */\n", \
    585 	    sys_stub, syscall, comment) > sysent
    586 	printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \
    587 	    > sysnamesbottom
    588 	if ($2 != "UNIMPL")
    589 		printf("\t\t\t\t/* %d is %s */\n", syscall, comment) > sysnumhdr
    590 	syscall++
    591 	next
    592 }
    593 {
    594 	for (i = 1; i <= ncompat; i++) {
    595 		if ($2 == compat_upper[i]) {
    596 			parseline();
    597 			putent("COMPAT", compat[i])
    598 			syscall++
    599 			next
    600 		}
    601 	}
    602 	printf("%s: line %d: unrecognized keyword %s\n", infile, NR, $2)
    603 	exit 1
    604 }
    605 END {
    606 	maxsyscall = syscall
    607 	if (nsysent) {
    608 		if (syscall > nsysent) {
    609 			printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)
    610 			exit 1
    611 		}
    612 		while (syscall < nsysent) {
    613 			printf("\t{ 0, 0, 0,\n\t    %s },\t\t\t/* %d = filler */\n", \
    614 			    sys_nosys, syscall) > sysent
    615 			syscall++
    616 		}
    617 	}
    618 	printf("};\n\n") > sysent
    619 	printf("};\n") > sysnamesbottom
    620 	printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
    621 	if (nsysent)
    622 		printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
    623 } '
    624 
    625 cat $sysprotos >> $sysarghdr
    626 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
    627 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
    628 cat $sysdcl $sysent > $syssw
    629 cat $sysnamesbottom >> $sysnames
    630 
    631 #chmod 444 $sysnames $sysnumhdr $syssw
    632