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