makesyscalls.sh revision 1.80 1 #! /bin/sh -
2 # $NetBSD: makesyscalls.sh,v 1.80 2009/01/23 19:27:18 pooka Exp $
3 #
4 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed for the NetBSD Project
18 # by Christopher G. Demetriou.
19 # 4. The name of the author may not be used to endorse or promote products
20 # derived from this software without specific prior written permission
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
34
35 set -e
36
37 case $# in
38 2) ;;
39 *) echo "Usage: $0 config-file input-file" 1>&2
40 exit 1
41 ;;
42 esac
43
44 # the config file sets the following variables:
45 # sysalign check for alignment of off_t
46 # sysnames the syscall names file
47 # sysnumhdr the syscall numbers file
48 # syssw the syscall switch 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 # registertype the type for register_t
55 # nsysent the size of the sysent table
56 # sys_nosys [optional] name of function called for unsupported
57 # syscalls, if not sys_nosys()
58 # maxsysargs [optiona] the maximum number or arguments
59 #
60 # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'.
61
62 # source the config file.
63 sys_nosys="sys_nosys" # default is sys_nosys(), if not specified otherwise
64 maxsysargs=8 # default limit is 8 (32bit) arguments
65 rumpcalls="/dev/null"
66 rumpcallshdr="/dev/null"
67 . ./$1
68
69 # tmp files:
70 sysdcl="sysent.dcl"
71 sysprotos="sys.protos"
72 syscompat_pref="sysent."
73 sysent="sysent.switch"
74 sysnamesbottom="sysnames.bottom"
75
76 trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom" 0
77
78 # Awk program (must support nawk extensions)
79 # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
80 awk=${AWK:-awk}
81
82 # Does this awk have a "toupper" function?
83 have_toupper=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null`
84
85 # If this awk does not define "toupper" then define our own.
86 if [ "$have_toupper" = TRUE ] ; then
87 # Used awk (GNU awk or nawk) provides it
88 toupper=
89 else
90 # Provide our own toupper()
91 toupper='
92 function toupper(str) {
93 _toupper_cmd = "echo "str" |tr a-z A-Z"
94 _toupper_cmd | getline _toupper_str;
95 close(_toupper_cmd);
96 return _toupper_str;
97 }'
98 fi
99
100 # before handing it off to awk, make a few adjustments:
101 # (1) insert spaces around {, }, (, ), *, and commas.
102 # (2) get rid of any and all dollar signs (so that rcs id use safe)
103 #
104 # The awk script will deal with blank lines and lines that
105 # start with the comment character (';').
106
107 sed -e '
108 s/\$//g
109 :join
110 /\\$/{a\
111
112 N
113 s/\\\n//
114 b join
115 }
116 2,${
117 /^#/!s/\([{}()*,|]\)/ \1 /g
118 }
119 ' < $2 | $awk "
120 $toupper
121 BEGIN {
122 # Create a NetBSD tag that does not get expanded when checking
123 # this script out of CVS. (This part of the awk script is in a
124 # shell double-quoted string, so the backslashes are eaten by
125 # the shell.)
126 tag = \"\$\" \"NetBSD\" \"\$\"
127
128 # to allow nested #if/#else/#endif sets
129 savedepth = 0
130 # to track already processed syscalls
131
132 sysnames = \"$sysnames\"
133 sysprotos = \"$sysprotos\"
134 sysnumhdr = \"$sysnumhdr\"
135 sysarghdr = \"$sysarghdr\"
136 rumpcalls = \"$rumpcalls\"
137 rumpcallshdr = \"$rumpcallshdr\"
138 switchname = \"$switchname\"
139 namesname = \"$namesname\"
140 constprefix = \"$constprefix\"
141 registertype = \"$registertype\"
142 sysalign=\"$sysalign\"
143 if (!registertype) {
144 registertype = \"register_t\"
145 }
146 nsysent = \"$nsysent\"
147
148 sysdcl = \"$sysdcl\"
149 syscompat_pref = \"$syscompat_pref\"
150 sysent = \"$sysent\"
151 sysnamesbottom = \"$sysnamesbottom\"
152 sys_nosys = \"$sys_nosys\"
153 maxsysargs = \"$maxsysargs\"
154 infile = \"$2\"
155
156 compatopts = \"$compatopts\"
157 "'
158
159 printf "/* %s */\n\n", tag > sysdcl
160 printf "/*\n * System call switch table.\n *\n" > sysdcl
161 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
162
163 ncompat = split(compatopts,compat)
164 for (i = 1; i <= ncompat; i++) {
165 compat_upper[i] = toupper(compat[i])
166
167 printf "\n#ifdef %s\n", compat_upper[i] > sysent
168 printf "#define %s(func) __CONCAT(%s_,func)\n", compat[i], \
169 compat[i] > sysent
170 printf "#else\n" > sysent
171 printf "#define %s(func) %s\n", compat[i], sys_nosys > sysent
172 printf "#endif\n" > sysent
173 }
174
175 printf "\n#define\ts(type)\tsizeof(type)\n" > sysent
176 printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent
177 printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > sysent
178 printf "struct sysent %s[] = {\n",switchname > sysent
179
180 printf "/* %s */\n\n", tag > sysnames
181 printf "/*\n * System call names.\n *\n" > sysnames
182 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
183
184 printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos
185
186 printf "/* %s */\n\n", tag > sysnumhdr
187 printf "/*\n * System call numbers.\n *\n" > sysnumhdr
188 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr
189
190 printf "/* %s */\n\n", tag > sysarghdr
191 printf "/*\n * System call argument lists.\n *\n" > sysarghdr
192 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr
193
194 printf "/* %s */\n\n", tag > rumpcalls
195 printf "/*\n * System call marshalling for rump.\n *\n" > rumpcalls
196 printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls
197
198 printf "/* %s */\n\n", tag > rumpcallshdr
199 printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
200 printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
201 }
202 NR == 1 {
203 sub(/ $/, "")
204 printf " * created from%s\n */\n\n", $0 > sysdcl
205 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysdcl
206
207 printf " * created from%s\n */\n\n", $0 > sysnames
208 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames
209
210 printf " * created from%s\n */\n\n", $0 > rumpcalls
211 printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > rumpcalls
212 printf "#include <sys/types.h>\n" > rumpcalls
213 printf "#include <sys/param.h>\n" > rumpcalls
214 printf "#include <sys/proc.h>\n" > rumpcalls
215 printf "#include <sys/syscallargs.h>\n" > rumpcalls
216 printf "#include <rump/rumpuser.h>\n" > rumpcalls
217 printf "#include \"rump_private.h\"\n\n" > rumpcalls
218 printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
219 printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
220 printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
221 printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
222 printf "#endif\n\n" > rumpcalls
223 printf "int rump_enosys(void);\n" > rumpcalls
224 printf "int\nrump_enosys()\n{\n\n\treturn ENOSYS;\n}\n" > rumpcalls
225
226 # System call names are included by userland (kdump(1)), so
227 # hide the include files from it.
228 printf "#if defined(_KERNEL_OPT)\n" > sysnames
229
230 printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom
231 printf "const char *const %s[] = {\n",namesname > sysnamesbottom
232
233 printf " * created from%s\n */\n\n", $0 > sysnumhdr
234
235 printf " * created from%s\n */\n\n", $0 > sysarghdr
236
237 printf " * created from%s\n */\n\n", $0 > rumpcallshdr
238 printf "#ifdef _RUMPKERNEL\n" > rumpcallshdr
239 printf "#error Interface not supported inside rump kernel\n" > rumpcallshdr
240 printf "#endif /* _RUMPKERNEL */\n\n" > rumpcallshdr
241
242 printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
243 printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr
244 printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
245 printf "#define _" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr
246 # Write max number of system call arguments to both headers
247 printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
248 > sysnumhdr
249 printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
250 > sysarghdr
251 printf "#undef\tsyscallarg\n" > sysarghdr
252 printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr
253 printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr
254 printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr
255 printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr
256 printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \
257 > sysarghdr
258 printf "\t\t\tint8_t pad[ /* CONSTCOND */\t\t\t\\\n" > sysarghdr
259 printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \
260 registertype > sysarghdr
261 printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr
262 printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \
263 registertype > sysarghdr
264 printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr
265 printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr
266 printf "\t}\n" > sysarghdr
267 printf("\n#undef check_syscall_args\n") >sysarghdr
268 printf("#define check_syscall_args(call) \\\n" \
269 "\ttypedef char call##_check_args" \
270 "[sizeof (struct call##_args) \\\n" \
271 "\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
272 constprefix, registertype) >sysarghdr
273 next
274 }
275 NF == 0 || $1 ~ /^;/ {
276 next
277 }
278 $0 ~ /^%%$/ {
279 intable = 1
280 next
281 }
282 $1 ~ /^#[ ]*include/ {
283 print > sysdcl
284 print > sysnames
285 next
286 }
287 $1 ~ /^#/ && !intable {
288 print > sysdcl
289 print > sysnames
290 next
291 }
292 $1 ~ /^#/ && intable {
293 if ($1 ~ /^#[ ]*if/) {
294 savedepth++
295 savesyscall[savedepth] = syscall
296 }
297 if ($1 ~ /^#[ ]*else/) {
298 if (savedepth <= 0) {
299 printf("%s: line %d: unbalanced #else\n", \
300 infile, NR)
301 exit 1
302 }
303 syscall = savesyscall[savedepth]
304 }
305 if ($1 ~ /^#[ ]*endif/) {
306 if (savedepth <= 0) {
307 printf("%s: line %d: unbalanced #endif\n", \
308 infile, NR)
309 exit 1
310 }
311 savedepth--
312 }
313 print > sysent
314 print > sysarghdr
315 print > sysnumhdr
316 print > sysprotos
317 print > sysnamesbottom
318 next
319 }
320 syscall != $1 {
321 printf "%s: line %d: syscall number out of sync at %d\n", \
322 infile, NR, syscall
323 printf "line is:\n"
324 print
325 exit 1
326 }
327 function parserr(was, wanted) {
328 printf "%s: line %d: unexpected %s (expected <%s>)\n", \
329 infile, NR, was, wanted
330 printf "line is:\n"
331 print
332 exit 1
333 }
334 function parseline() {
335 f=3 # toss number and type
336 if ($2 == "INDIR")
337 sycall_flags="SYCALL_INDIRECT"
338 else
339 sycall_flags="0"
340 if ($NF != "}") {
341 funcalias=$NF
342 end=NF-1
343 } else {
344 funcalias=""
345 end=NF
346 }
347 if ($f == "INDIR") { # allow for "NOARG INDIR"
348 sycall_flags = "SYCALL_INDIRECT | " sycall_flags
349 f++
350 }
351 if ($f == "MODULAR") { # registered at runtime
352 modular = 1
353 f++
354 } else {
355 modular = 0;
356 }
357 if ($f == "RUMP") {
358 rumpable = 1
359 f++
360 } else {
361 rumpable = 0
362 }
363 if ($f ~ /^[a-z0-9_]*$/) { # allow syscall alias
364 funcalias=$f
365 f++
366 }
367 if ($f != "{")
368 parserr($f, "{")
369 f++
370 if ($end != "}")
371 parserr($end, "}")
372 end--
373 if ($end != ";")
374 parserr($end, ";")
375 end--
376 if ($end != ")")
377 parserr($end, ")")
378 end--
379
380 returntype = oldf = "";
381 do {
382 if (returntype != "" && oldf != "*")
383 returntype = returntype" ";
384 returntype = returntype$f;
385 oldf = $f;
386 f++
387 } while ($f != "|" && f < (end-1))
388 if (f == (end - 1)) {
389 parserr($f, "function argument definition (maybe \"|\"?)");
390 }
391 f++
392
393 fprefix=$f
394 f++
395 if ($f != "|") {
396 parserr($f, "function compat delimiter (maybe \"|\"?)");
397 }
398 f++
399
400 fcompat=""
401 if ($f != "|") {
402 fcompat=$f
403 f++
404 }
405
406 if ($f != "|") {
407 parserr($f, "function name delimiter (maybe \"|\"?)");
408 }
409 f++
410 fbase=$f
411
412 funcstdname=fprefix "_" fbase
413 if (fcompat != "") {
414 funcname=fprefix "___" fbase "" fcompat
415 wantrename=1
416 } else {
417 funcname=funcstdname
418 wantrename=0
419 }
420
421 if (funcalias == "") {
422 funcalias=funcname
423 sub(/^([^_]+_)*sys_/, "", funcalias)
424 }
425 f++
426
427 if ($f != "(")
428 parserr($f, "(")
429 f++
430
431 argc=0;
432 argalign=0;
433 if (f == end) {
434 if ($f != "void")
435 parserr($f, "argument definition")
436 isvarargs = 0;
437 varargc = 0;
438 argtype[0]="void";
439 return
440 }
441
442 # some system calls (open() and fcntl()) can accept a variable
443 # number of arguments. If syscalls accept a variable number of
444 # arguments, they must still have arguments specified for
445 # the remaining argument "positions," because of the way the
446 # kernel system call argument handling works.
447 #
448 # Indirect system calls, e.g. syscall(), are exceptions to this
449 # rule, since they are handled entirely by machine-dependent code
450 # and do not need argument structures built.
451
452 isvarargs = 0;
453 while (f <= end) {
454 if ($f == "...") {
455 f++;
456 isvarargs = 1;
457 varargc = argc;
458 continue;
459 }
460 argc++
461 argtype[argc]=""
462 oldf=""
463 while (f < end && $(f+1) != ",") {
464 if (argtype[argc] != "" && oldf != "*")
465 argtype[argc] = argtype[argc]" ";
466 argtype[argc] = argtype[argc]$f;
467 oldf = $f;
468 f++
469 }
470 if (argtype[argc] == "")
471 parserr($f, "argument definition")
472 if (argtype[argc] == "off_t") {
473 if ((argalign % 2) != 0 && sysalign &&
474 funcname != "sys_posix_fadvise") # XXX for now
475 parserr($f, "a padding argument")
476 } else {
477 argalign++;
478 }
479 argname[argc]=$f;
480 f += 2; # skip name, and any comma
481 }
482 # must see another argument after varargs notice.
483 if (isvarargs) {
484 if (argc == varargc)
485 parserr($f, "argument definition")
486 } else
487 varargc = argc;
488 }
489
490 function printproto(wrap) {
491 printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
492 returntype) > sysnumhdr
493 for (i = 1; i <= varargc; i++)
494 printf(" \"%s\"", argtype[i]) > sysnumhdr
495 if (isvarargs)
496 printf(" \"...\"") > sysnumhdr
497 printf(" */\n") > sysnumhdr
498 printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
499 syscall) > sysnumhdr
500
501 # rumpalooza
502 if (!rumpable)
503 return
504
505 printf("%s rump_%s(", returntype, funcstdname) > rumpcallshdr
506 for (i = 1; i < argc; i++)
507 printf("%s, ", argtype[i]) > rumpcallshdr
508 print argtype[argc]
509 printf("%s)", argtype[argc]) > rumpcallshdr
510 if (wantrename)
511 printf(" __RENAME(rump_%s)", funcname) > rumpcallshdr
512 printf(";\n") > rumpcallshdr
513 }
514
515 function putent(type, compatwrap) {
516 # output syscall declaration for switch table.
517 if (compatwrap == "")
518 compatwrap_ = ""
519 else
520 compatwrap_ = compatwrap "_"
521 if (argc == 0)
522 arg_type = "void";
523 else {
524 arg_type = "struct " compatwrap_ funcname "_args";
525 }
526 proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \
527 arg_type " *, register_t *);\n"
528 if (sysmap[proto] != 1) {
529 sysmap[proto] = 1;
530 print proto > sysprotos;
531 }
532
533 # output syscall switch entry
534 printf("\t{ ") > sysent
535 if (argc == 0) {
536 printf("0, 0, ") > sysent
537 } else {
538 printf("ns(struct %s%s_args), ", compatwrap_, funcname) > sysent
539 }
540 if (modular)
541 wfn = "(sy_call_t *)sys_nomodule";
542 else if (compatwrap == "")
543 wfn = "(sy_call_t *)" funcname;
544 else
545 wfn = "(sy_call_t *)" compatwrap "(" funcname ")";
546 printf("%s,\n\t %s },", sycall_flags, wfn) > sysent
547 for (i = 0; i < (33 - length(wfn)) / 8; i++)
548 printf("\t") > sysent
549 printf("/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent
550
551 # output syscall name for names table
552 printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \
553 > sysnamesbottom
554
555 # output syscall number of header, if appropriate
556 if (type == "STD" || type == "NOARGS" || type == "INDIR") {
557 # output a prototype, to be used to generate lint stubs in
558 # libc.
559 printproto("")
560 } else if (type == "COMPAT") {
561 # Just define the syscall number with a comment. These
562 # may be used by compatibility stubs in libc.
563 printproto(compatwrap_)
564 }
565
566 # output syscall argument structure, if it has arguments
567 if (argc != 0) {
568 printf("\nstruct %s%s_args", compatwrap_, funcname) > sysarghdr
569 if (type != "NOARGS") {
570 print " {" >sysarghdr;
571 for (i = 1; i <= argc; i++)
572 printf("\tsyscallarg(%s) %s;\n", argtype[i],
573 argname[i]) > sysarghdr
574 printf "}" >sysarghdr;
575 }
576 printf(";\n") > sysarghdr
577 if (type != "NOARGS" && type != "INDIR") {
578 printf("check_syscall_args(%s%s)\n", compatwrap_,
579 funcname) >sysarghdr
580 }
581 }
582
583 # output rump marshalling code if necessary
584 if (!rumpable)
585 return
586
587 # need a local prototype, we export the re-re-named one in .h
588 printf("\n%s rump_%s(", returntype, funcname) > rumpcalls
589 for (i = 1; i < argc; i++) {
590 printf("%s, ", argtype[i]) > rumpcalls
591 }
592 printf("%s);", argtype[argc]) > rumpcalls
593
594 printf("\n%s\nrump_%s(", returntype, funcname) > rumpcalls
595 for (i = 1; i < argc; i++) {
596 printf("%s %s, ", argtype[i], argname[i]) > rumpcalls
597 }
598 printf("%s %s)\n", argtype[argc], argname[argc]) > rumpcalls
599 printf("{\n\tregister_t retval = 0;\n\tint error = 0;\n") > rumpcalls
600
601 argarg = "NULL"
602 if (argc) {
603 argarg = "&arg"
604 printf("\tstruct %s%s_args arg;\n\n", funcname, compatwrap_) \
605 > rumpcalls
606 for (i = 1; i <= argc; i++) {
607 printf("\tSPARG(&arg, %s) = %s;\n", \
608 argname[i], argname[i]) > rumpcalls
609 }
610 printf("\n") > rumpcalls
611 } else {
612 printf("\n") > rumpcalls
613 }
614 printf("\terror = %s(curlwp, %s, &retval);\n", funcname, argarg) \
615 > rumpcalls
616 printf("\tif (error) {\n\t\tretval = -1;\n") > rumpcalls
617 if (returntype != "void") {
618 printf("\t\trumpuser_seterrno(error);\n\t}\n") > rumpcalls
619 printf("\treturn retval;\n") > rumpcalls
620 } else {
621 printf("\t}\n") > rumpcalls
622 }
623 printf("}\n") > rumpcalls
624 printf("__weak_alias(%s,rump_enosys);\n", funcname) > rumpcalls
625 }
626 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" {
627 parseline()
628 putent($2, "")
629 syscall++
630 next
631 }
632 $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" {
633 if ($2 == "OBSOL")
634 comment="obsolete"
635 else if ($2 == "EXCL")
636 comment="excluded"
637 else if ($2 == "IGNORED")
638 comment="ignored"
639 else
640 comment="unimplemented"
641 for (i = 3; i <= NF; i++)
642 comment=comment " " $i
643
644 if ($2 == "IGNORED")
645 sys_stub = "(sy_call_t *)nullop";
646 else
647 sys_stub = sys_nosys;
648
649 printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = %s */\n", \
650 sys_stub, syscall, comment) > sysent
651 printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \
652 > sysnamesbottom
653 if ($2 != "UNIMPL")
654 printf("\t\t\t\t/* %d is %s */\n", syscall, comment) > sysnumhdr
655 syscall++
656 next
657 }
658 {
659 for (i = 1; i <= ncompat; i++) {
660 if ($2 == compat_upper[i]) {
661 parseline();
662 putent("COMPAT", compat[i])
663 syscall++
664 next
665 }
666 }
667 printf("%s: line %d: unrecognized keyword %s\n", infile, NR, $2)
668 exit 1
669 }
670 END {
671 maxsyscall = syscall
672 if (nsysent) {
673 if (syscall > nsysent) {
674 printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)
675 exit 1
676 }
677 while (syscall < nsysent) {
678 printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = filler */\n", \
679 sys_nosys, syscall) > sysent
680 syscall++
681 }
682 }
683 printf("};\n\n") > sysent
684 printf("};\n") > sysnamesbottom
685 printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
686 if (nsysent)
687 printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
688 } '
689
690 cat $sysprotos >> $sysarghdr
691 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
692 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
693 cat $sysdcl $sysent > $syssw
694 cat $sysnamesbottom >> $sysnames
695
696 #chmod 444 $sysnames $sysnumhdr $syssw
697