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