Home | History | Annotate | Line # | Download | only in kern
makesyscalls.sh revision 1.145.4.2
      1  1.145.4.2     skrll #	$NetBSD: makesyscalls.sh,v 1.145.4.2 2015/06/06 14:40:21 skrll Exp $
      2        1.9       cgd #
      3       1.37       cgd # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
      4       1.12       cgd # All rights reserved.
      5       1.12       cgd #
      6       1.12       cgd # Redistribution and use in source and binary forms, with or without
      7       1.12       cgd # modification, are permitted provided that the following conditions
      8       1.12       cgd # are met:
      9       1.12       cgd # 1. Redistributions of source code must retain the above copyright
     10       1.12       cgd #    notice, this list of conditions and the following disclaimer.
     11       1.12       cgd # 2. Redistributions in binary form must reproduce the above copyright
     12       1.12       cgd #    notice, this list of conditions and the following disclaimer in the
     13       1.12       cgd #    documentation and/or other materials provided with the distribution.
     14       1.12       cgd # 3. All advertising materials mentioning features or use of this software
     15       1.12       cgd #    must display the following acknowledgement:
     16       1.12       cgd #      This product includes software developed for the NetBSD Project
     17       1.12       cgd #      by Christopher G. Demetriou.
     18       1.12       cgd # 4. The name of the author may not be used to endorse or promote products
     19       1.12       cgd #    derived from this software without specific prior written permission
     20       1.12       cgd #
     21       1.12       cgd # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.12       cgd # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.12       cgd # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24       1.12       cgd # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.12       cgd # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.12       cgd # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.12       cgd # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.12       cgd # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.12       cgd # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.12       cgd # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.14       cgd 
     32       1.14       cgd #	@(#)makesyscalls.sh	8.1 (Berkeley) 6/10/93
     33        1.1     glass 
     34        1.1     glass set -e
     35        1.1     glass 
     36       1.11       cgd case $# in
     37       1.11       cgd     2)	;;
     38       1.11       cgd     *)	echo "Usage: $0 config-file input-file" 1>&2
     39       1.11       cgd 	exit 1
     40       1.11       cgd 	;;
     41       1.11       cgd esac
     42       1.11       cgd 
     43       1.11       cgd # the config file sets the following variables:
     44      1.134     njoly #	sysalign	check for alignment of off_t/dev_t/time_t
     45       1.11       cgd #	sysnames	the syscall names file
     46       1.11       cgd #	sysnumhdr	the syscall numbers file
     47       1.11       cgd #	syssw		the syscall switch file
     48  1.145.4.2     skrll #	sysautoload	the syscall autoload definitions file
     49       1.11       cgd #	sysarghdr	the syscall argument struct definitions
     50       1.11       cgd #	compatopts	those syscall types that are for 'compat' syscalls
     51       1.11       cgd #	switchname	the name for the 'struct sysent' we define
     52       1.40   mycroft #	namesname	the name for the 'const char *[]' we define
     53       1.11       cgd #	constprefix	the prefix for the system call constants
     54       1.30       eeh #	registertype	the type for register_t
     55       1.40   mycroft #	nsysent		the size of the sysent table
     56       1.46  jdolecek #	sys_nosys	[optional] name of function called for unsupported
     57       1.46  jdolecek #			syscalls, if not sys_nosys()
     58       1.60       dsl #       maxsysargs	[optiona] the maximum number or arguments
     59       1.11       cgd #
     60       1.56     lukem # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'.
     61        1.1     glass 
     62       1.46  jdolecek # source the config file.
     63       1.46  jdolecek sys_nosys="sys_nosys"	# default is sys_nosys(), if not specified otherwise
     64       1.60       dsl maxsysargs=8		# default limit is 8 (32bit) arguments
     65  1.145.4.1     skrll systrace="/dev/null"
     66  1.145.4.2     skrll sysautoload="/dev/null"
     67       1.67     njoly rumpcalls="/dev/null"
     68       1.67     njoly rumpcallshdr="/dev/null"
     69      1.142     pooka rumpsysmap="/dev/null"
     70       1.83     pooka rumpsysent="rumpsysent.tmp"
     71  1.145.4.1     skrll rumpnoflags="\n\t\t.sy_flags = SYCALL_NOSYS,"
     72  1.145.4.1     skrll rumpnosys="(sy_call_t *)rumpns_enosys"
     73  1.145.4.1     skrll rumpnomodule="(sy_call_t *)rumpns_sys_nomodule"
     74  1.145.4.1     skrll 
     75  1.145.4.1     skrll case $1 in
     76  1.145.4.1     skrll /*)	. $1;;
     77  1.145.4.1     skrll *)	. ./$1;;
     78  1.145.4.1     skrll esac
     79       1.46  jdolecek 
     80        1.1     glass # tmp files:
     81        1.1     glass sysdcl="sysent.dcl"
     82       1.16   thorpej sysprotos="sys.protos"
     83       1.11       cgd syscompat_pref="sysent."
     84        1.1     glass sysent="sysent.switch"
     85       1.27   thorpej sysnamesbottom="sysnames.bottom"
     86      1.109     pooka rumptypes="rumphdr.types"
     87      1.109     pooka rumpprotos="rumphdr.protos"
     88  1.145.4.1     skrll systracetmp="systrace.$$"
     89  1.145.4.1     skrll systraceret="systraceret.$$"
     90        1.1     glass 
     91  1.145.4.1     skrll trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom $rumpsysent $rumptypes $rumpprotos $systracetmp $systraceret" 0
     92       1.11       cgd 
     93       1.11       cgd # Awk program (must support nawk extensions)
     94       1.11       cgd # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
     95       1.11       cgd awk=${AWK:-awk}
     96       1.11       cgd 
     97       1.57  jdolecek # Does this awk have a "toupper" function?
     98  1.145.4.1     skrll have_toupper="$($awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null)"
     99       1.11       cgd 
    100       1.11       cgd # If this awk does not define "toupper" then define our own.
    101       1.57  jdolecek if [ "$have_toupper" = TRUE ] ; then
    102       1.57  jdolecek 	# Used awk (GNU awk or nawk) provides it
    103       1.11       cgd 	toupper=
    104       1.11       cgd else
    105       1.11       cgd 	# Provide our own toupper()
    106       1.11       cgd 	toupper='
    107       1.11       cgd function toupper(str) {
    108       1.11       cgd 	_toupper_cmd = "echo "str" |tr a-z A-Z"
    109       1.11       cgd 	_toupper_cmd | getline _toupper_str;
    110       1.11       cgd 	close(_toupper_cmd);
    111       1.11       cgd 	return _toupper_str;
    112       1.11       cgd }'
    113       1.11       cgd fi
    114       1.11       cgd 
    115       1.11       cgd # before handing it off to awk, make a few adjustments:
    116       1.11       cgd #	(1) insert spaces around {, }, (, ), *, and commas.
    117       1.11       cgd #	(2) get rid of any and all dollar signs (so that rcs id use safe)
    118       1.11       cgd #
    119       1.11       cgd # The awk script will deal with blank lines and lines that
    120       1.11       cgd # start with the comment character (';').
    121        1.1     glass 
    122       1.11       cgd sed -e '
    123       1.11       cgd s/\$//g
    124       1.11       cgd :join
    125       1.11       cgd 	/\\$/{a\
    126       1.11       cgd 
    127       1.11       cgd 	N
    128       1.11       cgd 	s/\\\n//
    129       1.11       cgd 	b join
    130       1.11       cgd 	}
    131       1.11       cgd 2,${
    132       1.78     pooka 	/^#/!s/\([{}()*,|]\)/ \1 /g
    133       1.11       cgd }
    134       1.11       cgd ' < $2 | $awk "
    135       1.11       cgd $toupper
    136       1.11       cgd BEGIN {
    137       1.70       apb 	# Create a NetBSD tag that does not get expanded when checking
    138       1.70       apb 	# this script out of CVS.  (This part of the awk script is in a
    139       1.70       apb 	# shell double-quoted string, so the backslashes are eaten by
    140       1.70       apb 	# the shell.)
    141       1.70       apb 	tag = \"\$\" \"NetBSD\" \"\$\"
    142       1.70       apb 
    143       1.18       cgd 	# to allow nested #if/#else/#endif sets
    144       1.18       cgd 	savedepth = 0
    145  1.145.4.2     skrll 	auto_skip = 0
    146       1.44  jdolecek 	# to track already processed syscalls
    147       1.18       cgd 
    148       1.11       cgd 	sysnames = \"$sysnames\"
    149       1.16   thorpej 	sysprotos = \"$sysprotos\"
    150       1.11       cgd 	sysnumhdr = \"$sysnumhdr\"
    151       1.11       cgd 	sysarghdr = \"$sysarghdr\"
    152       1.94     pooka 	sysarghdrextra = \"$sysarghdrextra\"
    153  1.145.4.1     skrll 	systrace = \"$systrace\"
    154  1.145.4.1     skrll 	systracetmp = \"$systracetmp\"
    155  1.145.4.1     skrll 	systraceret = \"$systraceret\"
    156  1.145.4.2     skrll 	sysautoload = \"$sysautoload\"
    157       1.66     pooka 	rumpcalls = \"$rumpcalls\"
    158       1.66     pooka 	rumpcallshdr = \"$rumpcallshdr\"
    159       1.83     pooka 	rumpsysent = \"$rumpsysent\"
    160      1.142     pooka 	rumpsysmap = \"$rumpsysmap\"
    161       1.11       cgd 	switchname = \"$switchname\"
    162       1.11       cgd 	namesname = \"$namesname\"
    163       1.11       cgd 	constprefix = \"$constprefix\"
    164       1.30       eeh 	registertype = \"$registertype\"
    165       1.68  christos 	sysalign=\"$sysalign\"
    166       1.30       eeh 	if (!registertype) {
    167       1.30       eeh 	    registertype = \"register_t\"
    168       1.30       eeh 	}
    169       1.40   mycroft 	nsysent = \"$nsysent\"
    170       1.11       cgd 
    171       1.11       cgd 	sysdcl = \"$sysdcl\"
    172       1.11       cgd 	syscompat_pref = \"$syscompat_pref\"
    173       1.11       cgd 	sysent = \"$sysent\"
    174       1.27   thorpej 	sysnamesbottom = \"$sysnamesbottom\"
    175      1.109     pooka 	rumpprotos = \"$rumpprotos\"
    176      1.109     pooka 	rumptypes = \"$rumptypes\"
    177       1.46  jdolecek 	sys_nosys = \"$sys_nosys\"
    178       1.60       dsl 	maxsysargs = \"$maxsysargs\"
    179  1.145.4.1     skrll 	rumpnoflags=\"$rumpnoflags\"
    180  1.145.4.1     skrll 	rumpnosys=\"$rumpnosys\"
    181  1.145.4.1     skrll 	rumpnomodule=\"$rumpnomodule\"
    182       1.11       cgd 	infile = \"$2\"
    183       1.11       cgd 
    184       1.11       cgd 	compatopts = \"$compatopts\"
    185       1.11       cgd 	"'
    186       1.11       cgd 
    187      1.124     pooka 	if (rumpcalls != "/dev/null")
    188      1.124     pooka 		haverumpcalls = 1
    189      1.124     pooka 
    190       1.70       apb 	printf "/* %s */\n\n", tag > sysdcl
    191       1.11       cgd 	printf "/*\n * System call switch table.\n *\n" > sysdcl
    192       1.11       cgd 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
    193       1.11       cgd 
    194       1.11       cgd 	ncompat = split(compatopts,compat)
    195       1.11       cgd 	for (i = 1; i <= ncompat; i++) {
    196       1.11       cgd 		compat_upper[i] = toupper(compat[i])
    197       1.11       cgd 
    198       1.17   mycroft 		printf "\n#ifdef %s\n", compat_upper[i] > sysent
    199       1.47     lukem 		printf "#define	%s(func) __CONCAT(%s_,func)\n", compat[i], \
    200       1.17   mycroft 		    compat[i] > sysent
    201       1.17   mycroft 		printf "#else\n" > sysent
    202       1.47     lukem 		printf "#define	%s(func) %s\n", compat[i], sys_nosys > sysent
    203       1.17   mycroft 		printf "#endif\n" > sysent
    204       1.11       cgd 	}
    205       1.11       cgd 
    206       1.60       dsl 	printf "\n#define\ts(type)\tsizeof(type)\n" > sysent
    207       1.60       dsl 	printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent
    208  1.145.4.1     skrll 	printf "#define\tns(type)\t.sy_narg = n(type), .sy_argsize = s(type)\n\n", registertype > sysent
    209       1.17   mycroft 	printf "struct sysent %s[] = {\n",switchname > sysent
    210       1.17   mycroft 
    211       1.70       apb 	printf "/* %s */\n\n", tag > sysnames
    212       1.11       cgd 	printf "/*\n * System call names.\n *\n" > sysnames
    213       1.11       cgd 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
    214       1.11       cgd 
    215       1.16   thorpej 	printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos
    216      1.124     pooka 	if (haverumpcalls)
    217      1.124     pooka 		printf("#ifndef RUMP_CLIENT\n") > sysprotos
    218       1.16   thorpej 
    219       1.70       apb 	printf "/* %s */\n\n", tag > sysnumhdr
    220       1.11       cgd 	printf "/*\n * System call numbers.\n *\n" > sysnumhdr
    221       1.11       cgd 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr
    222       1.11       cgd 
    223       1.70       apb 	printf "/* %s */\n\n", tag > sysarghdr
    224       1.13   mycroft 	printf "/*\n * System call argument lists.\n *\n" > sysarghdr
    225       1.11       cgd 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
    226       1.66     pooka 
    227  1.145.4.2     skrll 	printf "/* %s */\n\n", tag > sysautoload
    228  1.145.4.2     skrll 	printf "/*\n * System call autoload table.\n *\n" > sysautoload
    229  1.145.4.2     skrll 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysautoload
    230  1.145.4.2     skrll 
    231       1.70       apb 	printf "/* %s */\n\n", tag > rumpcalls
    232       1.83     pooka 	printf "/*\n * System call vector and marshalling for rump.\n *\n" > rumpcalls
    233       1.66     pooka 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
    234       1.66     pooka 
    235       1.70       apb 	printf "/* %s */\n\n", tag > rumpcallshdr
    236       1.66     pooka 	printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
    237       1.66     pooka 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
    238  1.145.4.1     skrll 
    239  1.145.4.1     skrll 	printf "/* %s */\n\n", tag > systrace
    240  1.145.4.1     skrll 	printf "/*\n * System call argument to DTrace register array converstion.\n *\n" > systrace
    241  1.145.4.1     skrll 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > systrace
    242       1.11       cgd }
    243       1.11       cgd NR == 1 {
    244       1.58     perry 	sub(/ $/, "")
    245       1.11       cgd 	printf " * created from%s\n */\n\n", $0 > sysdcl
    246       1.70       apb 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysdcl
    247       1.11       cgd 
    248       1.11       cgd 	printf " * created from%s\n */\n\n", $0 > sysnames
    249       1.70       apb 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames
    250       1.28   thorpej 
    251  1.145.4.2     skrll 	printf " * created from%s\n */\n\n", $0 > sysautoload
    252  1.145.4.2     skrll 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload
    253  1.145.4.2     skrll 	printf("static struct {\n")			> sysautoload
    254  1.145.4.2     skrll 	printf("\tu_int\t\tal_code;\n")			> sysautoload
    255  1.145.4.2     skrll 	printf("\tconst char\t*al_module;\n")		> sysautoload
    256  1.145.4.2     skrll 	printf("} const syscalls_autoload[] = {\n")	> sysautoload
    257  1.145.4.2     skrll 
    258       1.66     pooka 	printf " * created from%s\n */\n\n", $0 > rumpcalls
    259      1.127     pooka 	printf "#ifdef RUMP_CLIENT\n" > rumpcalls
    260      1.133     pooka 	printf "#include <rump/rumpuser_port.h>\n" > rumpcalls
    261      1.127     pooka 	printf "#endif /* RUMP_CLIENT */\n\n" > rumpcalls
    262      1.124     pooka 	printf "#include <sys/param.h>\n\n" > rumpcalls
    263      1.124     pooka 	printf "#ifdef __NetBSD__\n" > rumpcalls
    264       1.70       apb 	printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > rumpcalls
    265      1.102     pooka 
    266      1.102     pooka 	printf "#include <sys/fstypes.h>\n" > rumpcalls
    267       1.66     pooka 	printf "#include <sys/proc.h>\n" > rumpcalls
    268      1.124     pooka 	printf "#endif /* __NetBSD__ */\n\n" > rumpcalls
    269      1.102     pooka 	printf "#ifdef RUMP_CLIENT\n" > rumpcalls
    270      1.124     pooka 	printf "#include <errno.h>\n" > rumpcalls
    271      1.124     pooka 	printf "#include <stdint.h>\n" > rumpcalls
    272      1.139     pooka 	printf "#include <stdlib.h>\n" > rumpcalls
    273      1.138     pooka 	printf "#include <string.h>\n\n" > rumpcalls
    274      1.117     pooka 	printf "#include <srcsys/syscall.h>\n" > rumpcalls
    275      1.117     pooka 	printf "#include <srcsys/syscallargs.h>\n\n" > rumpcalls
    276      1.102     pooka 	printf "#include <rump/rumpclient.h>\n\n" > rumpcalls
    277      1.102     pooka 	printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls
    278      1.102     pooka 	printf "    rumpclient_syscall(num, data, dlen, retval)\n" > rumpcalls
    279      1.102     pooka 	printf "#define rsys_seterrno(error) errno = error\n" > rumpcalls
    280      1.131     pooka 	printf "#else\n" > rumpcalls
    281      1.117     pooka 	printf "#include <sys/syscall.h>\n" > rumpcalls
    282      1.117     pooka 	printf "#include <sys/syscallargs.h>\n\n" > rumpcalls
    283      1.103     pooka 	printf "#include <sys/syscallvar.h>\n\n" > rumpcalls
    284       1.80     pooka 	printf "#include <rump/rumpuser.h>\n" > rumpcalls
    285       1.72     pooka 	printf "#include \"rump_private.h\"\n\n" > rumpcalls
    286      1.130     pooka 	printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls
    287      1.130     pooka 	printf "    rump_syscall(num, data, dlen, retval)\n\n" > rumpcalls
    288      1.131     pooka 	printf "#define rsys_seterrno(error) rumpuser_seterrno(error)\n" \
    289      1.131     pooka 	    > rumpcalls
    290      1.131     pooka 	printf "#endif\n\n" > rumpcalls
    291      1.102     pooka 
    292      1.145     pooka 	printf "#ifndef RUMP_KERNEL_IS_LIBC\n" > rumpcalls
    293      1.145     pooka 	printf "#define RUMP_SYS_COMPAT\n" > rumpcalls
    294      1.145     pooka 	printf "#endif\n\n" > rumpcalls
    295      1.132     pooka 
    296       1.66     pooka 	printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
    297       1.66     pooka 	printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
    298       1.66     pooka 	printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
    299       1.66     pooka 	printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
    300       1.73     pooka 	printf "#endif\n\n" > rumpcalls
    301      1.131     pooka 	printf "\nvoid rumpns_sys_nomodule(void);\n" > rumpcalls
    302       1.66     pooka 
    303      1.102     pooka 	printf "\n#ifndef RUMP_CLIENT\n" > rumpsysent
    304      1.141     pooka 	printf "int rumpns_enosys(void);\n" > rumpsysent
    305      1.102     pooka 	printf "#define\ts(type)\tsizeof(type)\n" > rumpsysent
    306       1.83     pooka 	printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > rumpsysent
    307       1.83     pooka 	printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > rumpsysent
    308       1.83     pooka 	printf "struct sysent rump_sysent[] = {\n" > rumpsysent
    309       1.83     pooka 
    310       1.28   thorpej 	# System call names are included by userland (kdump(1)), so
    311       1.28   thorpej 	# hide the include files from it.
    312       1.48       mrg 	printf "#if defined(_KERNEL_OPT)\n" > sysnames
    313       1.28   thorpej 
    314       1.48       mrg 	printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom
    315       1.41   mycroft 	printf "const char *const %s[] = {\n",namesname > sysnamesbottom
    316       1.11       cgd 
    317       1.11       cgd 	printf " * created from%s\n */\n\n", $0 > sysnumhdr
    318       1.97     njoly 	printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
    319       1.97     njoly 	printf "#define	_" constprefix "SYSCALL_H_\n\n" > sysnumhdr
    320       1.11       cgd 
    321       1.11       cgd 	printf " * created from%s\n */\n\n", $0 > sysarghdr
    322       1.97     njoly 	printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
    323       1.97     njoly 	printf "#define	_" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr
    324       1.66     pooka 
    325       1.66     pooka 	printf " * created from%s\n */\n\n", $0 > rumpcallshdr
    326       1.97     njoly 	printf "#ifndef _RUMP_RUMP_SYSCALLS_H_\n" > rumpcallshdr
    327       1.97     njoly 	printf "#define _RUMP_RUMP_SYSCALLS_H_\n\n" > rumpcallshdr
    328       1.96     pooka 	printf "#ifdef _KERNEL\n" > rumpcallshdr
    329       1.96     pooka 	printf "#error Interface not supported inside kernel\n" > rumpcallshdr
    330       1.96     pooka 	printf "#endif /* _KERNEL */\n\n" > rumpcallshdr
    331      1.109     pooka 	printf "#include <rump/rump_syscalls_compat.h>\n\n" > rumpcallshdr
    332       1.66     pooka 
    333       1.94     pooka 	printf "%s", sysarghdrextra > sysarghdr
    334       1.60       dsl 	# Write max number of system call arguments to both headers
    335       1.60       dsl 	printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
    336       1.60       dsl 		> sysnumhdr
    337       1.60       dsl 	printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
    338       1.60       dsl 		> sysarghdr
    339       1.30       eeh 	printf "#undef\tsyscallarg\n" > sysarghdr
    340       1.35   thorpej 	printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr
    341       1.35   thorpej 	printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr
    342       1.35   thorpej 	printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr
    343       1.35   thorpej 	printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr
    344       1.51      manu 	printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \
    345       1.51      manu 		> sysarghdr
    346       1.51      manu 	printf "\t\t\tint8_t pad[  /* CONSTCOND */\t\t\t\\\n" > sysarghdr
    347       1.51      manu 	printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \
    348       1.30       eeh 		registertype > sysarghdr
    349       1.35   thorpej 	printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr
    350       1.35   thorpej 	printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \
    351       1.30       eeh 		registertype > sysarghdr
    352       1.35   thorpej 	printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr
    353       1.35   thorpej 	printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr
    354       1.35   thorpej 	printf "\t}\n" > sysarghdr
    355       1.60       dsl 	printf("\n#undef check_syscall_args\n") >sysarghdr
    356      1.101     pooka 	printf("#define check_syscall_args(call) /*LINTED*/ \\\n" \
    357       1.60       dsl 		"\ttypedef char call##_check_args" \
    358       1.60       dsl 		    "[sizeof (struct call##_args) \\\n" \
    359       1.60       dsl 		"\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
    360       1.60       dsl 		constprefix, registertype) >sysarghdr
    361      1.109     pooka 
    362  1.145.4.1     skrll 	printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace
    363  1.145.4.1     skrll 	printf "static void\nsystrace_args(register_t sysnum, const void *params, uintptr_t *uarg, size_t *n_args)\n{\n" > systrace
    364  1.145.4.1     skrll 	printf "\tintptr_t *iarg  = (intptr_t *)uarg;\n" > systrace
    365  1.145.4.1     skrll 	printf "\tswitch (sysnum) {\n" > systrace
    366  1.145.4.1     skrll 
    367  1.145.4.1     skrll 	printf "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp
    368  1.145.4.1     skrll 	printf "\tswitch (sysnum) {\n" > systracetmp
    369  1.145.4.1     skrll 
    370  1.145.4.1     skrll 	printf "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceret
    371  1.145.4.1     skrll 	printf "\tswitch (sysnum) {\n" > systraceret
    372  1.145.4.1     skrll 
    373      1.109     pooka 	# compat types from syscalls.master.  this is slightly ugly,
    374      1.109     pooka 	# but given that we have so few compats from over 17 years,
    375      1.109     pooka 	# a more complicated solution is not currently warranted.
    376      1.109     pooka 	uncompattypes["struct timeval50"] = "struct timeval";
    377      1.109     pooka 	uncompattypes["struct timespec50"] = "struct timespec";
    378      1.109     pooka 	uncompattypes["struct stat30"] = "struct stat";
    379      1.109     pooka 
    380       1.11       cgd 	next
    381       1.11       cgd }
    382       1.11       cgd NF == 0 || $1 ~ /^;/ {
    383       1.11       cgd 	next
    384       1.11       cgd }
    385       1.40   mycroft $0 ~ /^%%$/ {
    386       1.40   mycroft 	intable = 1
    387       1.40   mycroft 	next
    388       1.40   mycroft }
    389       1.11       cgd $1 ~ /^#[ 	]*include/ {
    390       1.11       cgd 	print > sysdcl
    391       1.27   thorpej 	print > sysnames
    392       1.11       cgd 	next
    393       1.11       cgd }
    394       1.40   mycroft $1 ~ /^#/ && !intable {
    395       1.40   mycroft 	print > sysdcl
    396       1.40   mycroft 	print > sysnames
    397       1.11       cgd 	next
    398       1.11       cgd }
    399       1.40   mycroft $1 ~ /^#/ && intable {
    400       1.40   mycroft 	if ($1 ~ /^#[ 	]*if/) {
    401       1.40   mycroft 		savedepth++
    402       1.40   mycroft 		savesyscall[savedepth] = syscall
    403  1.145.4.2     skrll 		skip_auto[savedepth] = auto_skip
    404  1.145.4.2     skrll 		auto_skip = 0
    405  1.145.4.2     skrll 
    406  1.145.4.2     skrll 		# Special handling for sysautoload conditionals
    407  1.145.4.2     skrll 		#
    408  1.145.4.2     skrll 		# We ignore all conditions other than those for
    409  1.145.4.2     skrll 		# !defined(_LP64) which are used for SYSV* syscalls
    410  1.145.4.2     skrll 		# only
    411  1.145.4.2     skrll 
    412  1.145.4.2     skrll 		if ($0 ~ /!defined\(_LP64\)/) {
    413  1.145.4.2     skrll 			printf("#if !defined(_LP64)\n") > sysautoload
    414  1.145.4.2     skrll 			auto_skip = savedepth
    415  1.145.4.2     skrll 		}
    416       1.40   mycroft 	}
    417       1.40   mycroft 	if ($1 ~ /^#[ 	]*else/) {
    418       1.40   mycroft 		if (savedepth <= 0) {
    419       1.40   mycroft 			printf("%s: line %d: unbalanced #else\n", \
    420       1.40   mycroft 			    infile, NR)
    421       1.40   mycroft 			exit 1
    422       1.40   mycroft 		}
    423  1.145.4.2     skrll 		if (auto_skip == savedepth) {
    424  1.145.4.2     skrll 			print > sysautoload
    425  1.145.4.2     skrll 		}
    426       1.40   mycroft 		syscall = savesyscall[savedepth]
    427       1.18       cgd 	}
    428       1.18       cgd 	if ($1 ~ /^#[       ]*endif/) {
    429       1.18       cgd 		if (savedepth <= 0) {
    430       1.40   mycroft 			printf("%s: line %d: unbalanced #endif\n", \
    431       1.40   mycroft 			    infile, NR)
    432       1.18       cgd 			exit 1
    433       1.18       cgd 		}
    434  1.145.4.2     skrll 		if (auto_skip == savedepth) {
    435  1.145.4.2     skrll 			print > sysautoload
    436  1.145.4.2     skrll 		}
    437  1.145.4.2     skrll 		auto_skip = skip_auto[savedepth];
    438       1.40   mycroft 		savedepth--
    439       1.18       cgd 	}
    440       1.11       cgd 	print > sysent
    441       1.54  christos 	print > sysarghdr
    442       1.54  christos 	print > sysnumhdr
    443       1.16   thorpej 	print > sysprotos
    444       1.27   thorpej 	print > sysnamesbottom
    445  1.145.4.1     skrll 	print > systrace
    446  1.145.4.1     skrll 	print > systracetmp
    447  1.145.4.1     skrll 	print > systraceret
    448       1.83     pooka 
    449       1.83     pooka 	# XXX: technically we do not want to have conditionals in rump,
    450       1.83     pooka 	# but it is easier to just let the cpp handle them than try to
    451       1.83     pooka 	# figure out what we want here in this script
    452       1.83     pooka 	print > rumpsysent
    453       1.11       cgd 	next
    454       1.11       cgd }
    455       1.11       cgd syscall != $1 {
    456       1.11       cgd 	printf "%s: line %d: syscall number out of sync at %d\n", \
    457       1.11       cgd 	   infile, NR, syscall
    458       1.11       cgd 	printf "line is:\n"
    459       1.11       cgd 	print
    460       1.11       cgd 	exit 1
    461       1.11       cgd }
    462       1.11       cgd function parserr(was, wanted) {
    463       1.77     pooka 	printf "%s: line %d: unexpected %s (expected <%s>)\n", \
    464       1.11       cgd 	    infile, NR, was, wanted
    465       1.32  christos 	printf "line is:\n"
    466       1.32  christos 	print
    467       1.11       cgd 	exit 1
    468       1.11       cgd }
    469  1.145.4.1     skrll function fillerpsysent(syscall, flags, name, comment) {
    470  1.145.4.1     skrll 	return sprintf("\t{%s\n\t\t.sy_call = %s,\n\t},\t\t/* %d = filler */",\
    471  1.145.4.1     skrll 	    flags, name, syscall, comment);
    472  1.145.4.1     skrll }
    473       1.11       cgd function parseline() {
    474       1.11       cgd 	f=3			# toss number and type
    475       1.60       dsl 	if ($2 == "INDIR")
    476       1.60       dsl 		sycall_flags="SYCALL_INDIRECT"
    477       1.60       dsl 	else
    478       1.60       dsl 		sycall_flags="0"
    479       1.11       cgd 	if ($NF != "}") {
    480       1.11       cgd 		funcalias=$NF
    481       1.11       cgd 		end=NF-1
    482       1.11       cgd 	} else {
    483       1.11       cgd 		funcalias=""
    484       1.11       cgd 		end=NF
    485       1.43  jdolecek 	}
    486       1.61       dsl 	if ($f == "INDIR") {		# allow for "NOARG INDIR"
    487       1.61       dsl 		sycall_flags = "SYCALL_INDIRECT | " sycall_flags
    488       1.61       dsl 		f++
    489       1.61       dsl 	}
    490       1.74        ad 	if ($f == "MODULAR") {		# registered at runtime
    491       1.74        ad 		modular = 1
    492       1.74        ad 		f++
    493  1.145.4.2     skrll 		modname = $f
    494  1.145.4.2     skrll 		f++
    495       1.74        ad 	} else {
    496       1.74        ad 		modular =  0;
    497       1.74        ad 	}
    498       1.66     pooka 	if ($f == "RUMP") {
    499       1.66     pooka 		rumpable = 1
    500       1.66     pooka 		f++
    501       1.66     pooka 	} else {
    502       1.66     pooka 		rumpable = 0
    503       1.66     pooka 	}
    504       1.43  jdolecek 	if ($f ~ /^[a-z0-9_]*$/) {	# allow syscall alias
    505       1.43  jdolecek 		funcalias=$f
    506       1.43  jdolecek 		f++
    507       1.11       cgd 	}
    508       1.11       cgd 	if ($f != "{")
    509       1.11       cgd 		parserr($f, "{")
    510       1.11       cgd 	f++
    511       1.11       cgd 	if ($end != "}")
    512       1.11       cgd 		parserr($end, "}")
    513       1.11       cgd 	end--
    514       1.11       cgd 	if ($end != ";")
    515       1.11       cgd 		parserr($end, ";")
    516       1.11       cgd 	end--
    517       1.11       cgd 	if ($end != ")")
    518       1.11       cgd 		parserr($end, ")")
    519       1.11       cgd 	end--
    520       1.11       cgd 
    521       1.19       cgd 	returntype = oldf = "";
    522       1.19       cgd 	do {
    523       1.19       cgd 		if (returntype != "" && oldf != "*")
    524       1.19       cgd 			returntype = returntype" ";
    525       1.19       cgd 		returntype = returntype$f;
    526       1.19       cgd 		oldf = $f;
    527       1.19       cgd 		f++
    528       1.78     pooka 	} while ($f != "|" && f < (end-1))
    529       1.19       cgd 	if (f == (end - 1)) {
    530       1.78     pooka 		parserr($f, "function argument definition (maybe \"|\"?)");
    531       1.78     pooka 	}
    532       1.78     pooka 	f++
    533       1.78     pooka 
    534       1.78     pooka 	fprefix=$f
    535       1.78     pooka 	f++
    536       1.78     pooka 	if ($f != "|") {
    537       1.78     pooka 		parserr($f, "function compat delimiter (maybe \"|\"?)");
    538       1.78     pooka 	}
    539       1.78     pooka 	f++
    540       1.78     pooka 
    541       1.78     pooka 	fcompat=""
    542       1.78     pooka 	if ($f != "|") {
    543       1.78     pooka 		fcompat=$f
    544       1.78     pooka 		f++
    545       1.78     pooka 	}
    546       1.78     pooka 
    547       1.78     pooka 	if ($f != "|") {
    548       1.78     pooka 		parserr($f, "function name delimiter (maybe \"|\"?)");
    549       1.78     pooka 	}
    550       1.78     pooka 	f++
    551       1.78     pooka 	fbase=$f
    552       1.78     pooka 
    553       1.90     pooka 	# pipe is special in how to returns its values.
    554       1.90     pooka 	# So just generate it manually if present.
    555       1.90     pooka 	if (rumpable == 1 && fbase == "pipe") {
    556       1.90     pooka 		rumpable = 0;
    557       1.90     pooka 		rumphaspipe = 1;
    558       1.90     pooka 	}
    559       1.90     pooka 
    560       1.78     pooka 	if (fcompat != "") {
    561       1.78     pooka 		funcname=fprefix "___" fbase "" fcompat
    562       1.78     pooka 	} else {
    563      1.109     pooka 		funcname=fprefix "_" fbase
    564       1.19       cgd 	}
    565       1.92      matt 	if (returntype == "quad_t" || returntype == "off_t") {
    566       1.92      matt 		if (sycall_flags == "0")
    567       1.92      matt 			sycall_flags = "SYCALL_RET_64";
    568       1.92      matt 		else
    569       1.92      matt 			sycall_flags = "SYCALL_RET_64 | " sycall_flags;
    570       1.92      matt 	}
    571       1.11       cgd 
    572       1.17   mycroft 	if (funcalias == "") {
    573       1.11       cgd 		funcalias=funcname
    574       1.17   mycroft 		sub(/^([^_]+_)*sys_/, "", funcalias)
    575      1.109     pooka 		realname=fbase
    576      1.109     pooka 	} else {
    577      1.109     pooka 		realname=funcalias
    578       1.17   mycroft 	}
    579      1.109     pooka 	rumpfname=realname "" fcompat
    580       1.11       cgd 	f++
    581       1.11       cgd 
    582       1.11       cgd 	if ($f != "(")
    583       1.76     pooka 		parserr($f, "(")
    584       1.11       cgd 	f++
    585       1.11       cgd 
    586       1.19       cgd 	argc=0;
    587       1.63      yamt 	argalign=0;
    588       1.11       cgd 	if (f == end) {
    589       1.11       cgd 		if ($f != "void")
    590       1.11       cgd 			parserr($f, "argument definition")
    591       1.19       cgd 		isvarargs = 0;
    592       1.19       cgd 		varargc = 0;
    593       1.80     pooka 		argtype[0]="void";
    594       1.11       cgd 		return
    595       1.11       cgd 	}
    596       1.11       cgd 
    597       1.19       cgd 	# some system calls (open() and fcntl()) can accept a variable
    598       1.19       cgd 	# number of arguments.  If syscalls accept a variable number of
    599       1.19       cgd 	# arguments, they must still have arguments specified for
    600       1.19       cgd 	# the remaining argument "positions," because of the way the
    601       1.19       cgd 	# kernel system call argument handling works.
    602       1.19       cgd 	#
    603       1.19       cgd 	# Indirect system calls, e.g. syscall(), are exceptions to this
    604       1.19       cgd 	# rule, since they are handled entirely by machine-dependent code
    605       1.19       cgd 	# and do not need argument structures built.
    606       1.19       cgd 
    607       1.19       cgd 	isvarargs = 0;
    608       1.92      matt 	args64 = 0;
    609      1.125      matt 	ptr = 0;
    610       1.11       cgd 	while (f <= end) {
    611       1.19       cgd 		if ($f == "...") {
    612       1.19       cgd 			f++;
    613       1.19       cgd 			isvarargs = 1;
    614       1.19       cgd 			varargc = argc;
    615       1.19       cgd 			continue;
    616       1.19       cgd 		}
    617       1.11       cgd 		argc++
    618       1.11       cgd 		argtype[argc]=""
    619       1.14       cgd 		oldf=""
    620       1.11       cgd 		while (f < end && $(f+1) != ",") {
    621       1.14       cgd 			if (argtype[argc] != "" && oldf != "*")
    622       1.11       cgd 				argtype[argc] = argtype[argc]" ";
    623       1.11       cgd 			argtype[argc] = argtype[argc]$f;
    624       1.14       cgd 			oldf = $f;
    625       1.11       cgd 			f++
    626       1.11       cgd 		}
    627       1.11       cgd 		if (argtype[argc] == "")
    628       1.11       cgd 			parserr($f, "argument definition")
    629       1.86     pooka 		if (argtype[argc] == "off_t"  \
    630       1.86     pooka 		  || argtype[argc] == "dev_t" \
    631       1.86     pooka 		  || argtype[argc] == "time_t") {
    632       1.68  christos 			if ((argalign % 2) != 0 && sysalign &&
    633       1.63      yamt 			    funcname != "sys_posix_fadvise") # XXX for now
    634       1.63      yamt 				parserr($f, "a padding argument")
    635       1.63      yamt 		} else {
    636       1.63      yamt 			argalign++;
    637       1.63      yamt 		}
    638       1.93     skrll 		if (argtype[argc] == "quad_t" || argtype[argc] == "off_t" \
    639       1.93     skrll 		  || argtype[argc] == "dev_t" || argtype[argc] == "time_t") {
    640       1.92      matt 			if (sycall_flags == "0")
    641       1.92      matt 				sycall_flags = "SYCALL_ARG"argc-1"_64";
    642       1.92      matt 			else
    643       1.92      matt 				sycall_flags = "SYCALL_ARG"argc-1"_64 | " sycall_flags;
    644       1.92      matt 			args64++;
    645       1.92      matt 		}
    646      1.125      matt 		if (index(argtype[argc], "*") != 0 && ptr == 0) {
    647      1.125      matt 			if (sycall_flags == "0")
    648      1.125      matt 				sycall_flags = "SYCALL_ARG_PTR";
    649      1.125      matt 			else
    650      1.125      matt 				sycall_flags = "SYCALL_ARG_PTR | " sycall_flags;
    651      1.125      matt 			ptr = 1;
    652      1.125      matt 		}
    653       1.11       cgd 		argname[argc]=$f;
    654       1.11       cgd 		f += 2;			# skip name, and any comma
    655       1.11       cgd 	}
    656       1.92      matt 	if (args64 > 0)
    657       1.92      matt 		sycall_flags = "SYCALL_NARGS64_VAL("args64") | " sycall_flags;
    658       1.19       cgd 	# must see another argument after varargs notice.
    659       1.19       cgd 	if (isvarargs) {
    660       1.61       dsl 		if (argc == varargc)
    661       1.19       cgd 			parserr($f, "argument definition")
    662       1.19       cgd 	} else
    663       1.19       cgd 		varargc = argc;
    664       1.11       cgd }
    665       1.54  christos 
    666       1.54  christos function printproto(wrap) {
    667       1.54  christos 	printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
    668       1.54  christos 	    returntype) > sysnumhdr
    669       1.54  christos 	for (i = 1; i <= varargc; i++)
    670       1.54  christos 		printf(" \"%s\"", argtype[i]) > sysnumhdr
    671       1.54  christos 	if (isvarargs)
    672       1.54  christos 		printf(" \"...\"") > sysnumhdr
    673       1.54  christos 	printf(" */\n") > sysnumhdr
    674       1.54  christos 	printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
    675       1.54  christos 	    syscall) > sysnumhdr
    676       1.66     pooka 
    677  1.145.4.2     skrll 	# output entry for syscall autoload table, if modular
    678  1.145.4.2     skrll 	if (modular ) {
    679  1.145.4.2     skrll 		printf("\t    { %s%s%s, \"%s\" },\n", constprefix, wrap,
    680  1.145.4.2     skrll 		    funcalias, modname) > sysautoload
    681  1.145.4.2     skrll 	}
    682  1.145.4.2     skrll 
    683  1.145.4.2     skrll 
    684       1.66     pooka 	# rumpalooza
    685       1.66     pooka 	if (!rumpable)
    686       1.66     pooka 		return
    687       1.66     pooka 
    688      1.109     pooka 	# accumulate fbases we have seen.  we want the last
    689      1.109     pooka 	# occurence for the default __RENAME()
    690      1.109     pooka 	seen = funcseen[fbase]
    691      1.109     pooka 	funcseen[fbase] = rumpfname
    692      1.143    justin 	# special case for mknod as type of last argument changed from
    693      1.143    justin 	# uint32_t to dev_t
    694      1.143    justin 	if ((seen && fbase != "mknod") || (!seen && fbase == "mknod"))
    695      1.109     pooka 		return
    696      1.109     pooka 
    697      1.109     pooka 	printf("%s rump_sys_%s(", returntype, realname) > rumpprotos
    698      1.109     pooka 
    699       1.88     pooka 	for (i = 1; i < varargc; i++)
    700       1.87     pooka 		if (argname[i] != "PAD")
    701      1.109     pooka 			printf("%s, ", uncompattype(argtype[i])) > rumpprotos
    702      1.109     pooka 
    703       1.88     pooka 	if (isvarargs)
    704      1.109     pooka 		printf("%s, ...)", uncompattype(argtype[varargc]))>rumpprotos
    705       1.88     pooka 	else
    706      1.109     pooka 		printf("%s)", uncompattype(argtype[argc])) > rumpprotos
    707      1.109     pooka 
    708      1.109     pooka 	printf(" __RENAME(RUMP_SYS_RENAME_%s)", toupper(fbase))> rumpprotos
    709      1.109     pooka 	printf(";\n") > rumpprotos
    710      1.109     pooka 
    711      1.109     pooka 	# generate forward-declares for types, apart from the
    712      1.109     pooka 	# braindead typedef jungle we cannot easily handle here
    713      1.109     pooka 	for (i = 1; i <= varargc; i++) {
    714      1.109     pooka 		type=uncompattype(argtype[i])
    715      1.109     pooka 		sub("const ", "", type)
    716      1.140     pooka 		ntype=type
    717      1.140     pooka 		sub(" *\\*.*", "", ntype);
    718      1.140     pooka 		if (!typeseen[ntype] && \
    719      1.109     pooka 		    match(type, "struct") && match(type, "\\*")) {
    720      1.140     pooka 			typeseen[ntype] = 1
    721      1.140     pooka 			printf("%s;\n", ntype) > rumptypes
    722      1.109     pooka 		}
    723      1.109     pooka 	}
    724       1.54  christos }
    725       1.54  christos 
    726       1.90     pooka function printrumpsysent(insysent, compatwrap) {
    727  1.145.4.1     skrll 	if (modular) {
    728  1.145.4.1     skrll 		fn = rumpnomodule
    729  1.145.4.1     skrll 		flags = rumpnoflags
    730  1.145.4.1     skrll 	} else {
    731  1.145.4.1     skrll 		fn = rumpnosys
    732  1.145.4.1     skrll 		flags = ""
    733  1.145.4.1     skrll 	}
    734       1.90     pooka 	if (!insysent) {
    735  1.145.4.1     skrll 		printf("\t{%s\n\t\t.sy_call = %s,\n},\t\t/* %d = %s */\n", \
    736  1.145.4.1     skrll 		    flags, fn, syscall, funcalias) > rumpsysent
    737       1.90     pooka 		return
    738       1.90     pooka 	}
    739       1.90     pooka 
    740  1.145.4.1     skrll 	printf("\t{") > rumpsysent
    741  1.145.4.1     skrll 	if (argc != 0) {
    742  1.145.4.1     skrll 		printf("\n\t\tns(struct %ssys_%s_args),", compatwrap_, funcalias) > rumpsysent
    743      1.109     pooka 	}
    744      1.109     pooka 
    745  1.145.4.1     skrll 	printf("\n\t\t.sy_call = %s,\n\t},", fn) > rumpsysent
    746  1.145.4.1     skrll 	printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > rumpsysent
    747       1.90     pooka }
    748       1.90     pooka 
    749      1.109     pooka function iscompattype(type) {
    750      1.109     pooka 	for (var in uncompattypes) {
    751      1.109     pooka 		if (match(type, var)) {
    752      1.109     pooka 			return 1
    753      1.109     pooka 		}
    754      1.109     pooka 	}
    755      1.109     pooka 
    756      1.109     pooka 	return 0
    757      1.109     pooka }
    758      1.109     pooka 
    759      1.109     pooka function uncompattype(type) {
    760      1.109     pooka 	for (var in uncompattypes) {
    761      1.109     pooka 		if (match(type, var)) {
    762      1.109     pooka 			sub(var, uncompattypes[var], type)
    763      1.109     pooka 			return type
    764      1.109     pooka 		}
    765      1.109     pooka 	}
    766      1.109     pooka 
    767      1.109     pooka 	return type
    768      1.109     pooka }
    769      1.109     pooka 
    770      1.142     pooka function printrumpsysmap(syscall, wfn, funcalias, rumpentry) {
    771      1.142     pooka 	printf("%-4d %-22s %-18s %s\n",
    772      1.142     pooka 	    syscall, wfn, funcalias, rumpentry) > rumpsysmap
    773      1.142     pooka }
    774      1.142     pooka 
    775  1.145.4.1     skrll function putsystrace(type, compatwrap_) {
    776  1.145.4.1     skrll 	printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace
    777  1.145.4.1     skrll 	printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp
    778  1.145.4.1     skrll 	printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systraceret
    779  1.145.4.1     skrll 	if (argc > 0) {
    780  1.145.4.1     skrll 		printf("\t\tswitch(ndx) {\n") > systracetmp
    781  1.145.4.1     skrll 		printf("\t\tstruct %s%s_args *p = params;\n", compatwrap_, funcname) > systrace
    782  1.145.4.1     skrll 		for (i = 1; i <= argc; i++) {
    783  1.145.4.1     skrll 			arg = argtype[i]
    784  1.145.4.1     skrll 			sub("__restrict$", "", arg)
    785  1.145.4.1     skrll 			printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp
    786  1.145.4.1     skrll 			if (arg ~ /.*p_t$/ || arg ~ /.*p$/ || arg ~ /.*_t_p$/ ||
    787  1.145.4.1     skrll 			    arg ~ /.*_pointer_t$/)
    788  1.145.4.1     skrll 				printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s).i32; /* %s */\n", \
    789  1.145.4.1     skrll 				     i - 1, \
    790  1.145.4.1     skrll 				     argname[i], arg) > systrace
    791  1.145.4.1     skrll 			else if (index(arg, "*") > 0 || arg == "caddr_t")
    792  1.145.4.1     skrll 				printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s); /* %s */\n", \
    793  1.145.4.1     skrll 				     i - 1, \
    794  1.145.4.1     skrll 				     argname[i], arg) > systrace
    795  1.145.4.1     skrll 			else if (substr(arg, 1, 1) == "u" || arg == "size_t")
    796  1.145.4.1     skrll 				printf("\t\tuarg[%d] = SCARG(p, %s); /* %s */\n", \
    797  1.145.4.1     skrll 				     i - 1, \
    798  1.145.4.1     skrll 				     argname[i], arg) > systrace
    799  1.145.4.1     skrll 			else
    800  1.145.4.1     skrll 				printf("\t\tiarg[%d] = SCARG(p, %s); /* %s */\n", \
    801  1.145.4.1     skrll 				     i - 1, \
    802  1.145.4.1     skrll 				     argname[i], arg) > systrace
    803  1.145.4.1     skrll 		}
    804  1.145.4.1     skrll 		printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp
    805  1.145.4.1     skrll 
    806  1.145.4.1     skrll 		printf("\t\tif (ndx == 0 || ndx == 1)\n") > systraceret
    807  1.145.4.1     skrll 		printf("\t\t\tp = \"%s\";\n", returntype) > systraceret
    808  1.145.4.1     skrll 		printf("\t\tbreak;\n") > systraceret
    809  1.145.4.1     skrll 	}
    810  1.145.4.1     skrll 	printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace
    811  1.145.4.1     skrll 	printf("\t\tbreak;\n") > systracetmp
    812  1.145.4.1     skrll }
    813  1.145.4.1     skrll 
    814       1.61       dsl function putent(type, compatwrap) {
    815       1.60       dsl 	# output syscall declaration for switch table.
    816       1.60       dsl 	if (compatwrap == "")
    817       1.60       dsl 		compatwrap_ = ""
    818       1.60       dsl 	else
    819       1.60       dsl 		compatwrap_ = compatwrap "_"
    820       1.62       dsl 	if (argc == 0)
    821       1.62       dsl 		arg_type = "void";
    822       1.62       dsl 	else {
    823       1.62       dsl 		arg_type = "struct " compatwrap_ funcname "_args";
    824       1.62       dsl 	}
    825  1.145.4.1     skrll 	putsystrace(type, compatwrap_)
    826       1.62       dsl 	proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \
    827       1.62       dsl 	    arg_type " *, register_t *);\n"
    828       1.60       dsl 	if (sysmap[proto] != 1) {
    829       1.60       dsl 		sysmap[proto] = 1;
    830       1.60       dsl 		print proto > sysprotos;
    831       1.21       cgd 	}
    832       1.11       cgd 
    833       1.11       cgd 	# output syscall switch entry
    834  1.145.4.1     skrll 	printf("\t{") > sysent
    835  1.145.4.1     skrll 	if (argc != 0) {
    836  1.145.4.1     skrll 		printf("\n\t\tns(struct %s%s_args),", compatwrap_, funcname) > sysent
    837       1.19       cgd 	}
    838  1.145.4.2     skrll 	if (modular)
    839      1.141     pooka 		wfn = "sys_nomodule";
    840       1.74        ad 	else if (compatwrap == "")
    841      1.141     pooka 		wfn = funcname;
    842       1.60       dsl 	else
    843      1.141     pooka 		wfn = compatwrap "(" funcname ")";
    844      1.141     pooka 	wfn_cast="(sy_call_t *)" wfn
    845  1.145.4.1     skrll 	if (sycall_flags != "0")
    846  1.145.4.1     skrll 		flags = "\n\t\t.sy_flags = " sycall_flags ","
    847  1.145.4.1     skrll 	else
    848  1.145.4.1     skrll 		flags = ""
    849  1.145.4.1     skrll 	printf("%s\n\t\t.sy_call = %s\n\t},", flags, wfn_cast) > sysent
    850  1.145.4.1     skrll 	printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent
    851       1.11       cgd 
    852       1.11       cgd 	# output syscall name for names table
    853       1.60       dsl 	printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \
    854       1.60       dsl 	    > sysnamesbottom
    855       1.11       cgd 
    856       1.11       cgd 	# output syscall number of header, if appropriate
    857      1.111     pooka 	if (type == "STD" || type == "NOARGS" || type == "INDIR" || \
    858      1.111     pooka 	    type == "NOERR") {
    859       1.19       cgd 		# output a prototype, to be used to generate lint stubs in
    860       1.19       cgd 		# libc.
    861       1.54  christos 		printproto("")
    862      1.120  christos 	} else if (type == "COMPAT" || type == "EXTERN") {
    863       1.29   thorpej 		# Just define the syscall number with a comment.  These
    864       1.29   thorpej 		# may be used by compatibility stubs in libc.
    865       1.60       dsl 		printproto(compatwrap_)
    866       1.60       dsl 	}
    867       1.11       cgd 
    868       1.11       cgd 	# output syscall argument structure, if it has arguments
    869       1.62       dsl 	if (argc != 0) {
    870      1.124     pooka 		printf("\n") > sysarghdr
    871      1.124     pooka 		if (haverumpcalls && !rumpable)
    872      1.124     pooka 			printf("#ifndef RUMP_CLIENT\n") > sysarghdr
    873      1.124     pooka 		printf("struct %s%s_args", compatwrap_, funcname) > sysarghdr
    874       1.62       dsl 		if (type != "NOARGS") {
    875       1.62       dsl 			print " {" >sysarghdr;
    876       1.62       dsl 			for (i = 1; i <= argc; i++)
    877       1.62       dsl 				printf("\tsyscallarg(%s) %s;\n", argtype[i],
    878       1.62       dsl 				    argname[i]) > sysarghdr
    879       1.62       dsl 			printf "}" >sysarghdr;
    880       1.62       dsl 		}
    881       1.62       dsl 		printf(";\n") > sysarghdr
    882       1.62       dsl 		if (type != "NOARGS" && type != "INDIR") {
    883       1.60       dsl 			printf("check_syscall_args(%s%s)\n", compatwrap_,
    884       1.60       dsl 			    funcname) >sysarghdr
    885       1.60       dsl 		}
    886      1.124     pooka 		if (haverumpcalls && !rumpable)
    887      1.124     pooka 			printf("#endif /* !RUMP_CLIENT */\n") > sysarghdr
    888       1.11       cgd 	}
    889       1.66     pooka 
    890       1.90     pooka 	if (!rumpable) {
    891      1.142     pooka 		if (funcname == "sys_pipe" && rumphaspipe == 1) {
    892       1.90     pooka 			insysent = 1
    893      1.142     pooka 			printrumpsysmap(syscall,
    894      1.142     pooka 			    funcname, funcalias, "rump_sys_pipe")
    895      1.142     pooka 		} else {
    896       1.90     pooka 			insysent = 0
    897      1.142     pooka 		}
    898       1.90     pooka 	} else {
    899       1.90     pooka 		insysent = 1
    900       1.90     pooka 	}
    901       1.90     pooka 	printrumpsysent(insysent, compatwrap)
    902       1.90     pooka 
    903       1.66     pooka 	# output rump marshalling code if necessary
    904       1.83     pooka 	if (!rumpable) {
    905       1.66     pooka 		return
    906       1.83     pooka 	}
    907       1.66     pooka 
    908      1.142     pooka 	printrumpsysmap(syscall, wfn, funcalias, "rump___sysimpl_" rumpfname)
    909      1.142     pooka 
    910      1.145     pooka 	printf("\n") > rumpcalls
    911      1.145     pooka 
    912      1.145     pooka 	if (compatwrap)
    913      1.145     pooka 		printf("#ifdef RUMP_SYS_COMPAT\n") > rumpcalls
    914      1.145     pooka 
    915       1.78     pooka 	# need a local prototype, we export the re-re-named one in .h
    916      1.145     pooka 	printf("%s rump___sysimpl_%s(", returntype, rumpfname) \
    917      1.109     pooka 	    > rumpcalls
    918       1.80     pooka 	for (i = 1; i < argc; i++) {
    919       1.87     pooka 		if (argname[i] != "PAD")
    920      1.109     pooka 			printf("%s, ", uncompattype(argtype[i])) > rumpcalls
    921       1.78     pooka 	}
    922      1.109     pooka 	printf("%s);", uncompattype(argtype[argc])) > rumpcalls
    923       1.78     pooka 
    924      1.109     pooka 	printf("\n%s\nrump___sysimpl_%s(", returntype, rumpfname) > rumpcalls
    925       1.80     pooka 	for (i = 1; i < argc; i++) {
    926       1.87     pooka 		if (argname[i] != "PAD")
    927      1.109     pooka 			printf("%s %s, ", uncompattype(argtype[i]), \
    928      1.109     pooka 			    argname[i]) > rumpcalls
    929       1.66     pooka 	}
    930      1.109     pooka 	printf("%s %s)\n", uncompattype(argtype[argc]), argname[argc]) \
    931      1.109     pooka 	    > rumpcalls
    932      1.135     pooka 	printf("{\n\tregister_t retval[2];\n") > rumpcalls
    933      1.115     pooka 	if (returntype != "void") {
    934      1.115     pooka 		if (type != "NOERR") {
    935      1.115     pooka 			printf("\tint error = 0;\n") > rumpcalls
    936      1.115     pooka 		}
    937      1.115     pooka 		# assume rumpcalls return only integral types
    938      1.115     pooka 		printf("\t%s rv = -1;\n", returntype) > rumpcalls
    939      1.115     pooka 	}
    940       1.78     pooka 
    941       1.66     pooka 	argarg = "NULL"
    942       1.83     pooka 	argsize = 0;
    943       1.66     pooka 	if (argc) {
    944       1.84     pooka 		argarg = "&callarg"
    945       1.84     pooka 		argsize = "sizeof(callarg)"
    946       1.84     pooka 		printf("\tstruct %s%s_args callarg;\n\n",compatwrap_,funcname) \
    947       1.66     pooka 		    > rumpcalls
    948      1.137     pooka 		printf "\tmemset(&callarg, 0, sizeof(callarg));\n" > rumpcalls
    949       1.66     pooka 		for (i = 1; i <= argc; i++) {
    950       1.87     pooka 			if (argname[i] == "PAD") {
    951       1.87     pooka 				printf("\tSPARG(&callarg, %s) = 0;\n", \
    952       1.87     pooka 				    argname[i]) > rumpcalls
    953       1.87     pooka 			} else {
    954      1.109     pooka 				if (iscompattype(argtype[i])) {
    955      1.109     pooka 					printf("\tSPARG(&callarg, %s) = "    \
    956      1.109     pooka 					"(%s)%s;\n", argname[i], argtype[i], \
    957      1.109     pooka 					argname[i]) > rumpcalls
    958      1.109     pooka 				} else {
    959      1.109     pooka 					printf("\tSPARG(&callarg, %s) = %s;\n",\
    960      1.109     pooka 					    argname[i], argname[i]) > rumpcalls
    961      1.109     pooka 				}
    962       1.87     pooka 			}
    963       1.66     pooka 		}
    964       1.66     pooka 		printf("\n") > rumpcalls
    965       1.66     pooka 	} else {
    966       1.66     pooka 		printf("\n") > rumpcalls
    967       1.66     pooka 	}
    968      1.111     pooka 	printf("\t") > rumpcalls
    969      1.112     pooka 	if (returntype != "void" && type != "NOERR")
    970      1.111     pooka 		printf("error = ") > rumpcalls
    971      1.111     pooka 	printf("rsys_syscall(%s%s%s, " \
    972      1.115     pooka 	    "%s, %s, retval);\n", constprefix, compatwrap_, funcalias, \
    973       1.83     pooka 	    argarg, argsize) > rumpcalls
    974      1.111     pooka 	if (type != "NOERR") {
    975      1.111     pooka 		printf("\trsys_seterrno(error);\n") > rumpcalls
    976      1.115     pooka 		printf("\tif (error == 0) {\n") > rumpcalls
    977      1.115     pooka 		indent="\t\t"
    978      1.115     pooka 		ending="\t}\n"
    979      1.115     pooka 	} else {
    980      1.115     pooka 		indent="\t"
    981      1.115     pooka 		ending=""
    982      1.111     pooka 	}
    983       1.80     pooka 	if (returntype != "void") {
    984      1.115     pooka 		printf("%sif (sizeof(%s) > sizeof(register_t))\n", \
    985      1.115     pooka 		    indent, returntype) > rumpcalls
    986      1.115     pooka 		printf("%s\trv = *(%s *)retval;\n", \
    987      1.115     pooka 		    indent, returntype) > rumpcalls
    988      1.115     pooka 		printf("%selse\n", indent, indent) > rumpcalls
    989      1.116     pooka 		printf("%s\trv = *retval;\n", indent, returntype) > rumpcalls
    990      1.115     pooka 		printf("%s", ending) > rumpcalls
    991      1.115     pooka 		printf("\treturn rv;\n") > rumpcalls
    992       1.80     pooka 	}
    993       1.72     pooka 	printf("}\n") > rumpcalls
    994      1.145     pooka 
    995      1.145     pooka 	printf("#ifdef RUMP_KERNEL_IS_LIBC\n") > rumpcalls
    996      1.145     pooka 
    997      1.145     pooka 	# create the bog-standard, non-renamed public name.
    998      1.145     pooka 	# this way we get e.g. select instead of just __select50
    999      1.145     pooka 	if (fcompat)
   1000      1.145     pooka 		printf("__weak_alias(%s,rump___sysimpl_%s);\n", \
   1001      1.145     pooka 		    fbase, rumpfname) > rumpcalls
   1002      1.145     pooka 
   1003      1.145     pooka 	printf("__weak_alias(%s,rump___sysimpl_%s);\n", \
   1004      1.145     pooka 	    funcalias, rumpfname) > rumpcalls
   1005      1.145     pooka 	printf("__weak_alias(_%s,rump___sysimpl_%s);\n", \
   1006      1.145     pooka 	    funcalias, rumpfname) > rumpcalls
   1007      1.145     pooka 	printf("__strong_alias(_sys_%s,rump___sysimpl_%s);\n", \
   1008      1.145     pooka 	    funcalias, rumpfname) >rumpcalls
   1009      1.145     pooka 
   1010      1.145     pooka 	printf("#endif /* RUMP_KERNEL_IS_LIBC */\n") > rumpcalls
   1011      1.145     pooka 
   1012      1.145     pooka 	if (compatwrap)
   1013      1.145     pooka 		printf("#endif /* RUMP_SYS_COMPAT */\n") > rumpcalls
   1014       1.83     pooka 
   1015       1.11       cgd }
   1016      1.111     pooka $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" \
   1017      1.111     pooka     || $2 == "NOERR" {
   1018       1.11       cgd 	parseline()
   1019       1.17   mycroft 	putent($2, "")
   1020       1.11       cgd 	syscall++
   1021       1.11       cgd 	next
   1022       1.11       cgd }
   1023       1.64    martin $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" {
   1024       1.11       cgd 	if ($2 == "OBSOL")
   1025       1.11       cgd 		comment="obsolete"
   1026       1.34  christos 	else if ($2 == "EXCL")
   1027       1.34  christos 		comment="excluded"
   1028       1.64    martin 	else if ($2 == "IGNORED")
   1029       1.64    martin 		comment="ignored"
   1030       1.11       cgd 	else
   1031       1.11       cgd 		comment="unimplemented"
   1032       1.11       cgd 	for (i = 3; i <= NF; i++)
   1033       1.11       cgd 		comment=comment " " $i
   1034       1.11       cgd 
   1035       1.64    martin 	if ($2 == "IGNORED")
   1036       1.64    martin 		sys_stub = "(sy_call_t *)nullop";
   1037       1.64    martin 	else
   1038       1.65     njoly 		sys_stub = sys_nosys;
   1039       1.64    martin 
   1040  1.145.4.1     skrll 	print fillerpsysent(syscall, "", sys_stub, comment) > sysent
   1041  1.145.4.1     skrll 	print fillerpsysent(syscall, rumpnoflags, rumpnosys, comment) > rumpsysent
   1042       1.60       dsl 	printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \
   1043       1.60       dsl 	    > sysnamesbottom
   1044       1.11       cgd 	if ($2 != "UNIMPL")
   1045       1.11       cgd 		printf("\t\t\t\t/* %d is %s */\n", syscall, comment) > sysnumhdr
   1046       1.11       cgd 	syscall++
   1047       1.11       cgd 	next
   1048       1.11       cgd }
   1049      1.120  christos $2 == "EXTERN" {
   1050      1.120  christos 	parseline()
   1051      1.120  christos 	putent("EXTERN", "")
   1052      1.120  christos 	syscall++
   1053      1.120  christos 	next
   1054      1.120  christos }
   1055       1.11       cgd {
   1056       1.11       cgd 	for (i = 1; i <= ncompat; i++) {
   1057       1.11       cgd 		if ($2 == compat_upper[i]) {
   1058       1.11       cgd 			parseline();
   1059       1.29   thorpej 			putent("COMPAT", compat[i])
   1060       1.11       cgd 			syscall++
   1061       1.11       cgd 			next
   1062       1.11       cgd 		}
   1063       1.11       cgd 	}
   1064       1.40   mycroft 	printf("%s: line %d: unrecognized keyword %s\n", infile, NR, $2)
   1065        1.1     glass 	exit 1
   1066       1.11       cgd }
   1067       1.11       cgd END {
   1068      1.115     pooka 	# output pipe() syscall with its special retval[2] handling
   1069       1.90     pooka 	if (rumphaspipe) {
   1070      1.109     pooka 		printf("int rump_sys_pipe(int *);\n") > rumpprotos
   1071       1.90     pooka 		printf("\nint rump_sys_pipe(int *);\n") > rumpcalls
   1072       1.90     pooka 		printf("int\nrump_sys_pipe(int *fd)\n{\n") > rumpcalls
   1073      1.135     pooka 		printf("\tregister_t retval[2];\n") > rumpcalls
   1074       1.90     pooka 		printf("\tint error = 0;\n") > rumpcalls
   1075      1.102     pooka 		printf("\n\terror = rsys_syscall(SYS_pipe, ") > rumpcalls
   1076      1.115     pooka 		printf("NULL, 0, retval);\n") > rumpcalls
   1077       1.90     pooka 		printf("\tif (error) {\n") > rumpcalls
   1078      1.102     pooka 		printf("\t\trsys_seterrno(error);\n") > rumpcalls
   1079      1.115     pooka 		printf("\t} else {\n\t\tfd[0] = retval[0];\n") > rumpcalls
   1080      1.115     pooka 		printf("\t\tfd[1] = retval[1];\n\t}\n") > rumpcalls
   1081       1.90     pooka 		printf("\treturn error ? -1 : 0;\n}\n") > rumpcalls
   1082      1.145     pooka 		printf("#ifdef RUMP_KERNEL_IS_LIBC\n") > rumpcalls
   1083      1.145     pooka 		printf("__weak_alias(pipe,rump_sys_pipe);\n") > rumpcalls
   1084      1.145     pooka 		printf("__weak_alias(_pipe,rump_sys_pipe);\n") > rumpcalls
   1085      1.145     pooka 		printf("__strong_alias(_sys_pipe,rump_sys_pipe);\n") > rumpcalls
   1086      1.145     pooka 		printf("#endif\n") > rumpcalls
   1087       1.90     pooka 	}
   1088       1.90     pooka 
   1089      1.109     pooka 	# print default rump syscall interfaces
   1090      1.109     pooka 	for (var in funcseen) {
   1091      1.109     pooka 		printf("#ifndef RUMP_SYS_RENAME_%s\n", \
   1092      1.109     pooka 		    toupper(var)) > rumpcallshdr
   1093      1.109     pooka 		printf("#define RUMP_SYS_RENAME_%s rump___sysimpl_%s\n", \
   1094      1.109     pooka 		    toupper(var), funcseen[var]) > rumpcallshdr
   1095      1.109     pooka 		printf("#endif\n\n") > rumpcallshdr
   1096      1.109     pooka 	}
   1097      1.109     pooka 
   1098       1.40   mycroft 	maxsyscall = syscall
   1099       1.40   mycroft 	if (nsysent) {
   1100       1.40   mycroft 		if (syscall > nsysent) {
   1101       1.50       wiz 			printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)
   1102       1.40   mycroft 			exit 1
   1103       1.40   mycroft 		}
   1104       1.40   mycroft 		while (syscall < nsysent) {
   1105  1.145.4.1     skrll 			print fillerpsysent(syscall, "", sys_nosys, "filler") > sysent
   1106  1.145.4.1     skrll 			print fillerpsysent(syscall, rumpnoflags, rumpnosys, "filler") > rumpsysent
   1107      1.105     pooka 			printf("\t/* %3d */\t\"# filler\",\n", syscall) \
   1108      1.105     pooka 			    > sysnamesbottom
   1109       1.40   mycroft 			syscall++
   1110       1.40   mycroft 		}
   1111       1.40   mycroft 	}
   1112       1.82     pooka 	printf("};\n") > sysent
   1113       1.83     pooka 	printf("};\n") > rumpsysent
   1114       1.83     pooka 	printf("CTASSERT(__arraycount(rump_sysent) == SYS_NSYSENT);\n") > rumpsysent
   1115      1.131     pooka 	printf("__strong_alias(rumpns_sysent,rump_sysent);\n") > rumpsysent
   1116      1.102     pooka 	printf("#endif /* RUMP_CLIENT */\n") > rumpsysent
   1117      1.124     pooka 	if (haverumpcalls)
   1118      1.124     pooka 		printf("#endif /* !RUMP_CLIENT */\n") > sysprotos
   1119       1.27   thorpej 	printf("};\n") > sysnamesbottom
   1120       1.40   mycroft 	printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
   1121       1.40   mycroft 	if (nsysent)
   1122       1.40   mycroft 		printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
   1123  1.145.4.1     skrll 	printf "\tdefault:\n\t\t*n_args = 0;\n\t\tbreak;\n\t};\n}\n" > systrace
   1124  1.145.4.1     skrll 	printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracetmp
   1125  1.145.4.1     skrll 	printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systraceret
   1126       1.11       cgd } '
   1127        1.1     glass 
   1128       1.17   mycroft cat $sysprotos >> $sysarghdr
   1129       1.59  christos echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
   1130       1.59  christos echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
   1131  1.145.4.2     skrll echo "};" >> $sysautoload
   1132      1.109     pooka printf "\n#endif /* _RUMP_RUMP_SYSCALLS_H_ */\n" >> $rumpprotos
   1133       1.16   thorpej cat $sysdcl $sysent > $syssw
   1134       1.27   thorpej cat $sysnamesbottom >> $sysnames
   1135       1.83     pooka cat $rumpsysent >> $rumpcalls
   1136        1.1     glass 
   1137      1.118     njoly touch $rumptypes
   1138      1.109     pooka cat $rumptypes >> $rumpcallshdr
   1139      1.109     pooka echo >> $rumpcallshdr
   1140      1.109     pooka cat $rumpprotos >> $rumpcallshdr
   1141      1.109     pooka 
   1142       1.15  christos #chmod 444 $sysnames $sysnumhdr $syssw
   1143      1.136     pooka 
   1144  1.145.4.1     skrll cat $systracetmp >> $systrace
   1145  1.145.4.1     skrll cat $systraceret >> $systrace
   1146  1.145.4.1     skrll 
   1147      1.136     pooka echo Generated following files:
   1148  1.145.4.2     skrll echo $sysarghdr $sysnumhdr $syssw $sysnames $sysautoload $systrace $rumpcalls $rumpcallshdr $rumpsysmap
   1149