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