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