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