makesyscalls.sh revision 1.63.6.4 1 #! /bin/sh -
2 # $NetBSD: makesyscalls.sh,v 1.63.6.4 2009/01/17 13:29:19 mjf 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_private.h\"\n\n" > rumpcalls
217 printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls
218 printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls
219 printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls
220 printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls
221 printf "#endif\n\n" > rumpcalls
222 printf "int rump_enosys(void);\n" > rumpcalls
223 printf "int\nrump_enosys()\n{\n\n\treturn ENOSYS;\n}\n" > rumpcalls
224
225 # System call names are included by userland (kdump(1)), so
226 # hide the include files from it.
227 printf "#if defined(_KERNEL_OPT)\n" > sysnames
228
229 printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom
230 printf "const char *const %s[] = {\n",namesname > sysnamesbottom
231
232 printf " * created from%s\n */\n\n", $0 > sysnumhdr
233
234 printf " * created from%s\n */\n\n", $0 > sysarghdr
235
236 printf " * created from%s\n */\n\n", $0 > rumpcallshdr
237 printf "#ifdef _RUMPKERNEL\n" > rumpcallshdr
238 printf "#error Interface not supported inside rump kernel\n" > rumpcallshdr
239 printf "#endif /* _RUMPKERNEL */\n\n" > rumpcallshdr
240
241 printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr
242 printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr
243 printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr
244 printf "#define _" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr
245 # Write max number of system call arguments to both headers
246 printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
247 > sysnumhdr
248 printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \
249 > sysarghdr
250 printf "#undef\tsyscallarg\n" > sysarghdr
251 printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr
252 printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr
253 printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr
254 printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr
255 printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \
256 > sysarghdr
257 printf "\t\t\tint8_t pad[ /* CONSTCOND */\t\t\t\\\n" > sysarghdr
258 printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \
259 registertype > sysarghdr
260 printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr
261 printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \
262 registertype > sysarghdr
263 printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr
264 printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr
265 printf "\t}\n" > sysarghdr
266 printf("\n#undef check_syscall_args\n") >sysarghdr
267 printf("#define check_syscall_args(call) \\\n" \
268 "\ttypedef char call##_check_args" \
269 "[sizeof (struct call##_args) \\\n" \
270 "\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
271 constprefix, registertype) >sysarghdr
272 next
273 }
274 NF == 0 || $1 ~ /^;/ {
275 next
276 }
277 $0 ~ /^%%$/ {
278 intable = 1
279 next
280 }
281 $1 ~ /^#[ ]*include/ {
282 print > sysdcl
283 print > sysnames
284 next
285 }
286 $1 ~ /^#/ && !intable {
287 print > sysdcl
288 print > sysnames
289 next
290 }
291 $1 ~ /^#/ && intable {
292 if ($1 ~ /^#[ ]*if/) {
293 savedepth++
294 savesyscall[savedepth] = syscall
295 }
296 if ($1 ~ /^#[ ]*else/) {
297 if (savedepth <= 0) {
298 printf("%s: line %d: unbalanced #else\n", \
299 infile, NR)
300 exit 1
301 }
302 syscall = savesyscall[savedepth]
303 }
304 if ($1 ~ /^#[ ]*endif/) {
305 if (savedepth <= 0) {
306 printf("%s: line %d: unbalanced #endif\n", \
307 infile, NR)
308 exit 1
309 }
310 savedepth--
311 }
312 print > sysent
313 print > sysarghdr
314 print > sysnumhdr
315 print > sysprotos
316 print > sysnamesbottom
317 next
318 }
319 syscall != $1 {
320 printf "%s: line %d: syscall number out of sync at %d\n", \
321 infile, NR, syscall
322 printf "line is:\n"
323 print
324 exit 1
325 }
326 function parserr(was, wanted) {
327 printf "%s: line %d: unexpected %s (expected <%s>)\n", \
328 infile, NR, was, wanted
329 printf "line is:\n"
330 print
331 exit 1
332 }
333 function parseline() {
334 f=3 # toss number and type
335 if ($2 == "INDIR")
336 sycall_flags="SYCALL_INDIRECT"
337 else
338 sycall_flags="0"
339 if ($NF != "}") {
340 funcalias=$NF
341 end=NF-1
342 } else {
343 funcalias=""
344 end=NF
345 }
346 if ($f == "INDIR") { # allow for "NOARG INDIR"
347 sycall_flags = "SYCALL_INDIRECT | " sycall_flags
348 f++
349 }
350 if ($f == "MODULAR") { # registered at runtime
351 modular = 1
352 f++
353 } else {
354 modular = 0;
355 }
356 if ($f == "RUMP") {
357 rumpable = 1
358 f++
359 } else {
360 rumpable = 0
361 }
362 if ($f ~ /^[a-z0-9_]*$/) { # allow syscall alias
363 funcalias=$f
364 f++
365 }
366 if ($f != "{")
367 parserr($f, "{")
368 f++
369 if ($end != "}")
370 parserr($end, "}")
371 end--
372 if ($end != ";")
373 parserr($end, ";")
374 end--
375 if ($end != ")")
376 parserr($end, ")")
377 end--
378
379 returntype = oldf = "";
380 do {
381 if (returntype != "" && oldf != "*")
382 returntype = returntype" ";
383 returntype = returntype$f;
384 oldf = $f;
385 f++
386 } while ($f != "|" && f < (end-1))
387 if (f == (end - 1)) {
388 parserr($f, "function argument definition (maybe \"|\"?)");
389 }
390 f++
391
392 fprefix=$f
393 f++
394 if ($f != "|") {
395 parserr($f, "function compat delimiter (maybe \"|\"?)");
396 }
397 f++
398
399 fcompat=""
400 if ($f != "|") {
401 fcompat=$f
402 f++
403 }
404
405 if ($f != "|") {
406 parserr($f, "function name delimiter (maybe \"|\"?)");
407 }
408 f++
409 fbase=$f
410
411 funcstdname=fprefix "_" fbase
412 if (fcompat != "") {
413 funcname=fprefix "___" fbase "" fcompat
414 wantrename=1
415 } else {
416 funcname=funcstdname
417 wantrename=0
418 }
419
420 if (funcalias == "") {
421 funcalias=funcname
422 sub(/^([^_]+_)*sys_/, "", funcalias)
423 }
424 f++
425
426 if ($f != "(")
427 parserr($f, "(")
428 f++
429
430 argc=0;
431 argalign=0;
432 if (f == end) {
433 if ($f != "void")
434 parserr($f, "argument definition")
435 isvarargs = 0;
436 varargc = 0;
437 return
438 }
439
440 # some system calls (open() and fcntl()) can accept a variable
441 # number of arguments. If syscalls accept a variable number of
442 # arguments, they must still have arguments specified for
443 # the remaining argument "positions," because of the way the
444 # kernel system call argument handling works.
445 #
446 # Indirect system calls, e.g. syscall(), are exceptions to this
447 # rule, since they are handled entirely by machine-dependent code
448 # and do not need argument structures built.
449
450 isvarargs = 0;
451 while (f <= end) {
452 if ($f == "...") {
453 f++;
454 isvarargs = 1;
455 varargc = argc;
456 continue;
457 }
458 argc++
459 argtype[argc]=""
460 oldf=""
461 while (f < end && $(f+1) != ",") {
462 if (argtype[argc] != "" && oldf != "*")
463 argtype[argc] = argtype[argc]" ";
464 argtype[argc] = argtype[argc]$f;
465 oldf = $f;
466 f++
467 }
468 if (argtype[argc] == "")
469 parserr($f, "argument definition")
470 if (argtype[argc] == "off_t") {
471 if ((argalign % 2) != 0 && sysalign &&
472 funcname != "sys_posix_fadvise") # XXX for now
473 parserr($f, "a padding argument")
474 } else {
475 argalign++;
476 }
477 argname[argc]=$f;
478 f += 2; # skip name, and any comma
479 }
480 # must see another argument after varargs notice.
481 if (isvarargs) {
482 if (argc == varargc)
483 parserr($f, "argument definition")
484 } else
485 varargc = argc;
486 }
487
488 function printproto(wrap) {
489 printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
490 returntype) > sysnumhdr
491 for (i = 1; i <= varargc; i++)
492 printf(" \"%s\"", argtype[i]) > sysnumhdr
493 if (isvarargs)
494 printf(" \"...\"") > sysnumhdr
495 printf(" */\n") > sysnumhdr
496 printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias,
497 syscall) > sysnumhdr
498
499 # rumpalooza
500 if (!rumpable)
501 return
502
503 printf("%s rump_%s(", returntype, funcstdname) > rumpcallshdr
504 for (i = 1; i <= argc; i++)
505 printf("%s, ", argtype[i]) > rumpcallshdr
506 printf("int *)") > rumpcallshdr
507 if (wantrename)
508 printf(" __RENAME(rump_%s)", funcname) > rumpcallshdr
509 printf(";\n") > rumpcallshdr
510 }
511
512 function putent(type, compatwrap) {
513 # output syscall declaration for switch table.
514 if (compatwrap == "")
515 compatwrap_ = ""
516 else
517 compatwrap_ = compatwrap "_"
518 if (argc == 0)
519 arg_type = "void";
520 else {
521 arg_type = "struct " compatwrap_ funcname "_args";
522 }
523 proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \
524 arg_type " *, register_t *);\n"
525 if (sysmap[proto] != 1) {
526 sysmap[proto] = 1;
527 print proto > sysprotos;
528 }
529
530 # output syscall switch entry
531 printf("\t{ ") > sysent
532 if (argc == 0) {
533 printf("0, 0, ") > sysent
534 } else {
535 printf("ns(struct %s%s_args), ", compatwrap_, funcname) > sysent
536 }
537 if (modular)
538 wfn = "(sy_call_t *)sys_nomodule";
539 else if (compatwrap == "")
540 wfn = "(sy_call_t *)" funcname;
541 else
542 wfn = "(sy_call_t *)" compatwrap "(" funcname ")";
543 printf("%s,\n\t %s },", sycall_flags, wfn) > sysent
544 for (i = 0; i < (33 - length(wfn)) / 8; i++)
545 printf("\t") > sysent
546 printf("/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent
547
548 # output syscall name for names table
549 printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \
550 > sysnamesbottom
551
552 # output syscall number of header, if appropriate
553 if (type == "STD" || type == "NOARGS" || type == "INDIR") {
554 # output a prototype, to be used to generate lint stubs in
555 # libc.
556 printproto("")
557 } else if (type == "COMPAT") {
558 # Just define the syscall number with a comment. These
559 # may be used by compatibility stubs in libc.
560 printproto(compatwrap_)
561 }
562
563 # output syscall argument structure, if it has arguments
564 if (argc != 0) {
565 printf("\nstruct %s%s_args", compatwrap_, funcname) > sysarghdr
566 if (type != "NOARGS") {
567 print " {" >sysarghdr;
568 for (i = 1; i <= argc; i++)
569 printf("\tsyscallarg(%s) %s;\n", argtype[i],
570 argname[i]) > sysarghdr
571 printf "}" >sysarghdr;
572 }
573 printf(";\n") > sysarghdr
574 if (type != "NOARGS" && type != "INDIR") {
575 printf("check_syscall_args(%s%s)\n", compatwrap_,
576 funcname) >sysarghdr
577 }
578 }
579
580 # output rump marshalling code if necessary
581 if (!rumpable)
582 return
583
584 # need a local prototype, we export the re-re-named one in .h
585 printf("\n%s rump_%s(", returntype, funcname) > rumpcalls
586 for (i = 1; i <= argc; i++) {
587 printf("%s, ", argtype[i]) > rumpcalls
588 }
589 printf("int *);") > rumpcalls
590
591 printf("\n%s\nrump_%s(", returntype, funcname) > rumpcalls
592 for (i = 1; i <= argc; i++) {
593 printf("%s %s, ", argtype[i], argname[i]) > rumpcalls
594 }
595 printf("int *error)\n") > rumpcalls
596 printf("{\n\tregister_t retval = 0;\n") > rumpcalls
597
598 argarg = "NULL"
599 if (argc) {
600 argarg = "&arg"
601 printf("\tstruct %s%s_args arg;\n\n", funcname, compatwrap_) \
602 > rumpcalls
603 for (i = 1; i <= argc; i++) {
604 printf("\tSPARG(&arg, %s) = %s;\n", \
605 argname[i], argname[i]) > rumpcalls
606 }
607 printf("\n") > rumpcalls
608 } else {
609 printf("\n") > rumpcalls
610 }
611 printf("\t*error = %s(curlwp, %s, &retval);\n", funcname, argarg) \
612 > rumpcalls
613 printf("\tif (*error)\n\t\tretval = -1;\n") > rumpcalls
614 if (returntype != "void")
615 printf("\treturn retval;\n") > rumpcalls
616 printf("}\n") > rumpcalls
617 printf("__weak_alias(%s,rump_enosys);\n", funcname) > rumpcalls
618 }
619 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" {
620 parseline()
621 putent($2, "")
622 syscall++
623 next
624 }
625 $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" {
626 if ($2 == "OBSOL")
627 comment="obsolete"
628 else if ($2 == "EXCL")
629 comment="excluded"
630 else if ($2 == "IGNORED")
631 comment="ignored"
632 else
633 comment="unimplemented"
634 for (i = 3; i <= NF; i++)
635 comment=comment " " $i
636
637 if ($2 == "IGNORED")
638 sys_stub = "(sy_call_t *)nullop";
639 else
640 sys_stub = sys_nosys;
641
642 printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = %s */\n", \
643 sys_stub, syscall, comment) > sysent
644 printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \
645 > sysnamesbottom
646 if ($2 != "UNIMPL")
647 printf("\t\t\t\t/* %d is %s */\n", syscall, comment) > sysnumhdr
648 syscall++
649 next
650 }
651 {
652 for (i = 1; i <= ncompat; i++) {
653 if ($2 == compat_upper[i]) {
654 parseline();
655 putent("COMPAT", compat[i])
656 syscall++
657 next
658 }
659 }
660 printf("%s: line %d: unrecognized keyword %s\n", infile, NR, $2)
661 exit 1
662 }
663 END {
664 maxsyscall = syscall
665 if (nsysent) {
666 if (syscall > nsysent) {
667 printf("%s: line %d: too many syscalls [%d > %d]\n", infile, NR, syscall, nsysent)
668 exit 1
669 }
670 while (syscall < nsysent) {
671 printf("\t{ 0, 0, 0,\n\t %s },\t\t\t/* %d = filler */\n", \
672 sys_nosys, syscall) > sysent
673 syscall++
674 }
675 }
676 printf("};\n\n") > sysent
677 printf("};\n") > sysnamesbottom
678 printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
679 if (nsysent)
680 printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
681 } '
682
683 cat $sysprotos >> $sysarghdr
684 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
685 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
686 cat $sysdcl $sysent > $syssw
687 cat $sysnamesbottom >> $sysnames
688
689 #chmod 444 $sysnames $sysnumhdr $syssw
690