]> git.saurik.com Git - apple/xnu.git/blob - bsd/kern/makesyscalls.sh
xnu-792.18.15.tar.gz
[apple/xnu.git] / bsd / kern / makesyscalls.sh
1 #! /bin/sh -
2 # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
3 # $FreeBSD: src/sys/kern/makesyscalls.sh,v 1.60 2003/04/01 01:12:24 jeff Exp $
4 #
5 # Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
6 #
7 # @APPLE_LICENSE_HEADER_START@
8 #
9 # The contents of this file constitute Original Code as defined in and
10 # are subject to the Apple Public Source License Version 1.1 (the
11 # "License"). You may not use this file except in compliance with the
12 # License. Please obtain a copy of the License at
13 # http://www.apple.com/publicsource and read it before using this file.
14 #
15 # This Original Code and all software distributed under the License are
16 # distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
20 # License for the specific language governing rights and limitations
21 # under the License.
22 #
23 # @APPLE_LICENSE_HEADER_END@
24 #
25
26 set -e
27
28 # output files:
29 syscallnamesfile="syscalls.c"
30 sysprotofile="../sys/sysproto.h"
31 sysproto_h=_SYS_SYSPROTO_H_
32 syshdrfile="../sys/syscall.h"
33 syscall_h=_SYS_SYSCALL_H_
34 syscalltablefile="init_sysent.c"
35 syscallprefix="SYS_"
36 switchname="sysent"
37 namesname="syscallnames"
38
39 # tmp files:
40 syslegal="sysent.syslegal.$$"
41 sysent="sysent.switch.$$"
42 sysinc="sysinc.switch.$$"
43 sysarg="sysarg.switch.$$"
44 sysprotoend="sysprotoend.$$"
45 syscallnamestempfile="syscallnamesfile.$$"
46 syshdrtempfile="syshdrtempfile.$$"
47
48 trap "rm $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile" 0
49
50 touch $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile
51
52 case $# in
53 0) echo "usage: $0 input-file <config-file>" 1>&2
54 exit 1
55 ;;
56 esac
57
58 if [ -n "$2" -a -f "$2" ]; then
59 . $2
60 fi
61
62 sed -e '
63 s/\$//g
64 :join
65 /\\$/{a\
66
67 N
68 s/\\\n//
69 b join
70 }
71 2,${
72 /^#/!s/\([{}()*,]\)/ \1 /g
73 }
74 ' < $1 | awk "
75 BEGIN {
76 syslegal = \"$syslegal\"
77 sysprotofile = \"$sysprotofile\"
78 sysprotoend = \"$sysprotoend\"
79 sysproto_h = \"$sysproto_h\"
80 syscall_h = \"$syscall_h\"
81 sysent = \"$sysent\"
82 syscalltablefile = \"$syscalltablefile\"
83 sysinc = \"$sysinc\"
84 sysarg = \"$sysarg\"
85 syscallnamesfile = \"$syscallnamesfile\"
86 syscallnamestempfile = \"$syscallnamestempfile\"
87 syshdrfile = \"$syshdrfile\"
88 syshdrtempfile = \"$syshdrtempfile\"
89 syscallprefix = \"$syscallprefix\"
90 switchname = \"$switchname\"
91 namesname = \"$namesname\"
92 infile = \"$1\"
93 "'
94
95 printf "/*\n" > syslegal
96 printf " * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.\n" > syslegal
97 printf " * \n" > syslegal
98 printf " * @APPLE_LICENSE_HEADER_START@ \n" > syslegal
99 printf " * \n" > syslegal
100 printf " * The contents of this file constitute Original Code as defined in and \n" > syslegal
101 printf " * are subject to the Apple Public Source License Version 1.1 (the \n" > syslegal
102 printf " * \"License\"). You may not use this file except in compliance with the \n" > syslegal
103 printf " * License. Please obtain a copy of the License at \n" > syslegal
104 printf " * http://www.apple.com/publicsource and read it before using this file. \n" > syslegal
105 printf " * \n" > syslegal
106 printf " * This Original Code and all software distributed under the License are \n" > syslegal
107 printf " * distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, EITHER \n" > syslegal
108 printf " * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, \n" > syslegal
109 printf " * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, \n" > syslegal
110 printf " * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the \n" > syslegal
111 printf " * License for the specific language governing rights and limitations \n" > syslegal
112 printf " * under the License. \n" > syslegal
113 printf " * \n" > syslegal
114 printf " * @APPLE_LICENSE_HEADER_END@ \n" > syslegal
115 printf " * \n" > syslegal
116 printf " * \n" > syslegal
117 printf " * System call switch table.\n *\n" > syslegal
118 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syslegal
119 printf " * created from %s\n */\n\n", infile > syslegal
120 }
121 NR == 1 {
122 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
123 printf "__private_extern__ struct sysent %s[] = {\n",switchname > sysent
124
125 printf "#ifndef %s\n", sysproto_h > sysarg
126 printf "#define\t%s\n\n", sysproto_h > sysarg
127 printf "#ifndef %s\n", syscall_h > syshdrtempfile
128 printf "#define\t%s\n\n", syscall_h > syshdrtempfile
129 printf "#include <sys/appleapiopts.h>\n" > syshdrtempfile
130 printf "#ifdef __APPLE_API_PRIVATE\n" > syshdrtempfile
131 printf "#include <sys/appleapiopts.h>\n" > sysarg
132 printf "#include <sys/cdefs.h>\n" > sysarg
133 printf "#include <sys/mount_internal.h>\n" > sysarg
134 printf "#include <sys/types.h>\n" > sysarg
135 printf "#include <sys/sem_internal.h>\n" > sysarg
136 printf "#include <sys/semaphore.h>\n" > sysarg
137 printf "#include <sys/wait.h>\n" > sysarg
138 printf "#include <mach/shared_memory_server.h>\n" > sysarg
139 printf "\n#ifdef KERNEL\n" > sysarg
140 printf "#ifdef __APPLE_API_PRIVATE\n" > sysarg
141 printf "#define\tPAD_(t)\t(sizeof(uint64_t) <= sizeof(t) \\\n " > sysarg
142 printf "\t\t? 0 : sizeof(uint64_t) - sizeof(t))\n" > sysarg
143 printf "#if BYTE_ORDER == LITTLE_ENDIAN\n"> sysarg
144 printf "#define\tPADL_(t)\t0\n" > sysarg
145 printf "#define\tPADR_(t)\tPAD_(t)\n" > sysarg
146 printf "#else\n" > sysarg
147 printf "#define\tPADL_(t)\tPAD_(t)\n" > sysarg
148 printf "#define\tPADR_(t)\t0\n" > sysarg
149 printf "#endif\n" > sysarg
150 printf "\n__BEGIN_DECLS\n" > sysarg
151 printf "#ifndef __MUNGE_ONCE\n" > sysarg
152 printf "#define __MUNGE_ONCE\n" > sysarg
153 printf "void munge_w(const void *, void *); \n" > sysarg
154 printf "void munge_ww(const void *, void *); \n" > sysarg
155 printf "void munge_www(const void *, void *); \n" > sysarg
156 printf "void munge_wwww(const void *, void *); \n" > sysarg
157 printf "void munge_wwwww(const void *, void *); \n" > sysarg
158 printf "void munge_wwwwww(const void *, void *); \n" > sysarg
159 printf "void munge_wwwwwww(const void *, void *); \n" > sysarg
160 printf "void munge_wwwwwwww(const void *, void *); \n" > sysarg
161 printf "void munge_wl(const void *, void *); \n" > sysarg
162 printf "void munge_wlw(const void *, void *); \n" > sysarg
163 printf "void munge_wwwl(const void *, void *); \n" > sysarg
164 printf "void munge_wwwlww(const void *, void *); \n" > sysarg
165 printf "void munge_wwwwl(const void *, void *); \n" > sysarg
166 printf "void munge_wwwwwl(const void *, void *); \n" > sysarg
167 printf "void munge_wsw(const void *, void *); \n" > sysarg
168 printf "void munge_wws(const void *, void *); \n" > sysarg
169 printf "void munge_wwwsw(const void *, void *); \n" > sysarg
170 printf "#ifdef __ppc__\n" > sysarg
171 printf "void munge_d(const void *, void *); \n" > sysarg
172 printf "void munge_dd(const void *, void *); \n" > sysarg
173 printf "void munge_ddd(const void *, void *); \n" > sysarg
174 printf "void munge_dddd(const void *, void *); \n" > sysarg
175 printf "void munge_ddddd(const void *, void *); \n" > sysarg
176 printf "void munge_dddddd(const void *, void *); \n" > sysarg
177 printf "void munge_ddddddd(const void *, void *); \n" > sysarg
178 printf "void munge_dddddddd(const void *, void *); \n" > sysarg
179 printf "#else \n" > sysarg
180 printf "#define munge_d NULL \n" > sysarg
181 printf "#define munge_dd NULL \n" > sysarg
182 printf "#define munge_ddd NULL \n" > sysarg
183 printf "#define munge_dddd NULL \n" > sysarg
184 printf "#define munge_ddddd NULL \n" > sysarg
185 printf "#define munge_dddddd NULL \n" > sysarg
186 printf "#define munge_ddddddd NULL \n" > sysarg
187 printf "#define munge_dddddddd NULL \n" > sysarg
188 printf "#endif // __ppc__\n" > sysarg
189 printf "#endif /* !__MUNGE_ONCE */\n" > sysarg
190
191 printf "\n" > sysarg
192
193 printf "const char *%s[] = {\n", namesname > syscallnamestempfile
194 next
195 }
196 NF == 0 || $1 ~ /^;/ {
197 next
198 }
199 $1 ~ /^#[ ]*include/ {
200 print > sysinc
201 next
202 }
203 $1 ~ /^#[ ]*if/ {
204 print > sysent
205 print > sysarg
206 print > syscallnamestempfile
207 print > syshdrtempfile
208 print > sysprotoend
209 savesyscall = syscall
210 next
211 }
212 $1 ~ /^#[ ]*else/ {
213 print > sysent
214 print > sysarg
215 print > syscallnamestempfile
216 print > syshdrtempfile
217 print > sysprotoend
218 syscall = savesyscall
219 next
220 }
221 $1 ~ /^#/ {
222 print > sysent
223 print > sysarg
224 print > syscallnamestempfile
225 print > syshdrtempfile
226 print > sysprotoend
227 next
228 }
229 syscall != $1 {
230 printf "%s: line %d: syscall number out of sync at %d\n",
231 infile, NR, syscall
232 printf "line is:\n"
233 print
234 exit 1
235 }
236 function align_comment(linesize, location, thefile) {
237 printf(" ") > thefile
238 while (linesize < location) {
239 printf(" ") > thefile
240 linesize++
241 }
242 }
243 function parserr(was, wanted) {
244 printf "%s: line %d: unexpected %s (expected %s)\n",
245 infile, NR, was, wanted
246 exit 1
247 }
248
249 function parseline() {
250 funcname = ""
251 current_field = 5
252 args_start = 0
253 args_end = 0
254 comments_start = 0
255 comments_end = 0
256 argc = 0
257 argssize = "0"
258 additional_comments = " "
259
260 # find start and end of call name and arguments
261 if ($current_field != "{")
262 parserr($current_field, "{")
263 args_start = current_field
264 current_field++
265 while (current_field <= NF) {
266 if ($current_field == "}") {
267 args_end = current_field
268 break
269 }
270 current_field++
271 }
272 if (args_end == 0) {
273 printf "%s: line %d: invalid call name and arguments\n",
274 infile, NR
275 exit 1
276 }
277
278 # find start and end of optional comments
279 current_field++
280 if (current_field < NF && $current_field == "{") {
281 comments_start = current_field
282 while (current_field <= NF) {
283 if ($current_field == "}") {
284 comments_end = current_field
285 break
286 }
287 current_field++
288 }
289 if (comments_end == 0) {
290 printf "%s: line %d: invalid comments \n",
291 infile, NR
292 exit 1
293 }
294 }
295
296 if ($args_end != "}")
297 parserr($args_end, "}")
298 args_end--
299 if ($args_end != ";")
300 parserr($args_end, ";")
301 args_end--
302 if ($args_end != ")")
303 parserr($args_end, ")")
304 args_end--
305
306 # extract additional comments
307 if (comments_start != 0) {
308 current_field = comments_start + 1
309 while (current_field < comments_end) {
310 additional_comments = additional_comments $current_field " "
311 current_field++
312 }
313 }
314
315 # get function return type
316 current_field = args_start + 1
317 returntype = $current_field
318
319 # get function name and set up to get arguments
320 current_field++
321 funcname = $current_field
322 argalias = funcname "_args"
323 current_field++ # bump past function name
324
325 if ($current_field != "(")
326 parserr($current_field, "(")
327 current_field++
328
329 if (current_field == args_end) {
330 if ($current_field != "void")
331 parserr($current_field, "argument definition")
332 return
333 }
334
335 # extract argument types and names
336 while (current_field <= args_end) {
337 argc++
338 argtype[argc]=""
339 ext_argtype[argc]=""
340 oldf=""
341 while (current_field < args_end && $(current_field + 1) != ",") {
342 if (argtype[argc] != "" && oldf != "*") {
343 argtype[argc] = argtype[argc] " ";
344 }
345 argtype[argc] = argtype[argc] $current_field;
346 ext_argtype[argc] = argtype[argc];
347 oldf = $current_field;
348 current_field++
349 }
350 if (argtype[argc] == "")
351 parserr($current_field, "argument definition")
352 argname[argc] = $current_field;
353 current_field += 2; # skip name, and any comma
354 }
355 if (argc > 8) {
356 printf "%s: line %d: too many arguments!\n", infile, NR
357 exit 1
358 }
359 if (argc != 0)
360 argssize = "AC(" argalias ")"
361 }
362
363 {
364 add_sysent_entry = 1
365 add_sysnames_entry = 1
366 add_sysheader_entry = 1
367 add_sysproto_entry = 1
368 add_64bit_unsafe = 0
369 add_64bit_fakesafe = 0
370 add_cancel_enable = "0"
371
372 if ($2 == "NONE") {
373 add_cancel_enable = "_SYSCALL_CANCEL_NONE"
374 }
375 else if ($2 == "PRE") {
376 add_cancel_enable = "_SYSCALL_CANCEL_PRE"
377 }
378 else if ($2 == "POST") {
379 add_cancel_enable = "_SYSCALL_CANCEL_POST"
380 }
381 else {
382 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
383 exit 1
384
385 }
386
387 if ($3 == "KERN") {
388 my_funnel = "KERNEL_FUNNEL"
389 }
390 else if ($3 == "NONE") {
391 my_funnel = "NO_FUNNEL"
392 }
393 else {
394 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $3
395 exit 1
396 }
397
398 if ($4 != "ALL" && $4 != "UALL") {
399 files_keyword_OK = 0
400 add_sysent_entry = 0
401 add_sysnames_entry = 0
402 add_sysheader_entry = 0
403 add_sysproto_entry = 0
404
405 if (match($4, "[T]") != 0) {
406 add_sysent_entry = 1
407 files_keyword_OK = 1
408 }
409 if (match($4, "[N]") != 0) {
410 add_sysnames_entry = 1
411 files_keyword_OK = 1
412 }
413 if (match($4, "[H]") != 0) {
414 add_sysheader_entry = 1
415 files_keyword_OK = 1
416 }
417 if (match($4, "[P]") != 0) {
418 add_sysproto_entry = 1
419 files_keyword_OK = 1
420 }
421 if (match($4, "[U]") != 0) {
422 add_64bit_unsafe = 1
423 }
424 if (match($4, "[F]") != 0) {
425 add_64bit_fakesafe = 1
426 }
427
428 if (files_keyword_OK == 0) {
429 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $4
430 exit 1
431 }
432 }
433 else if ($4 == "UALL") {
434 add_64bit_unsafe = 1;
435 }
436
437
438 parseline()
439
440 # output function argument structures to sysproto.h and build the
441 # name of the appropriate argument mungers
442 munge32 = "NULL"
443 munge64 = "NULL"
444 if (funcname != "nosys" || (syscall == 0 && funcname == "nosys")) {
445 if (argc != 0) {
446 if (add_sysproto_entry == 1) {
447 printf("struct %s {\n", argalias) > sysarg
448 }
449 munge32 = "munge_"
450 munge64 = "munge_"
451 for (i = 1; i <= argc; i++) {
452 # Build name of argument munger.
453 # We account for all sys call argument types here.
454 # This is where you add any new types. With LP64 support
455 # each argument consumes 64-bits.
456 # see .../xnu/bsd/dev/ppc/munge.s for munge argument types.
457 if (argtype[i] == "long") {
458 if (add_64bit_unsafe == 0)
459 ext_argtype[i] = "user_long_t";
460 munge32 = munge32 "s"
461 munge64 = munge64 "d"
462 }
463 else if (argtype[i] == "u_long") {
464 if (add_64bit_unsafe == 0)
465 ext_argtype[i] = "user_ulong_t";
466 munge32 = munge32 "w"
467 munge64 = munge64 "d"
468 }
469 else if (argtype[i] == "size_t") {
470 if (add_64bit_unsafe == 0)
471 ext_argtype[i] = "user_size_t";
472 munge32 = munge32 "w"
473 munge64 = munge64 "d"
474 }
475 else if (argtype[i] == "ssize_t") {
476 if (add_64bit_unsafe == 0)
477 ext_argtype[i] = "user_ssize_t";
478 munge32 = munge32 "s"
479 munge64 = munge64 "d"
480 }
481 else if (argtype[i] == "user_ssize_t" || argtype[i] == "user_long_t") {
482 munge32 = munge32 "s"
483 munge64 = munge64 "d"
484 }
485 else if (argtype[i] == "user_addr_t" || argtype[i] == "user_size_t" ||
486 argtype[i] == "user_ulong_t") {
487 munge32 = munge32 "w"
488 munge64 = munge64 "d"
489 }
490 else if (argtype[i] == "caddr_t" || argtype[i] == "semun_t" ||
491 match(argtype[i], "[\*]") != 0) {
492 if (add_64bit_unsafe == 0)
493 ext_argtype[i] = "user_addr_t";
494 munge32 = munge32 "w"
495 munge64 = munge64 "d"
496 }
497 else if (argtype[i] == "int" || argtype[i] == "u_int" ||
498 argtype[i] == "uid_t" || argtype[i] == "pid_t" ||
499 argtype[i] == "id_t" || argtype[i] == "idtype_t" ||
500 argtype[i] == "socklen_t" || argtype[i] == "uint32_t" || argtype[i] == "int32_t" ||
501 argtype[i] == "sigset_t" || argtype[i] == "gid_t" ||
502 argtype[i] == "mode_t" || argtype[i] == "key_t" || argtype[i] == "time_t") {
503 munge32 = munge32 "w"
504 munge64 = munge64 "d"
505 }
506 else if (argtype[i] == "off_t" || argtype[i] == "int64_t" || argtype[i] == "uint64_t") {
507 munge32 = munge32 "l"
508 munge64 = munge64 "d"
509 }
510 else {
511 printf "%s: line %d: invalid type \"%s\" \n",
512 infile, NR, argtype[i]
513 printf "You need to add \"%s\" into the type checking code. \n",
514 argtype[i]
515 exit 1
516 }
517 if (add_sysproto_entry == 1) {
518 printf("\tchar %s_l_[PADL_(%s)]; " \
519 "%s %s; char %s_r_[PADR_(%s)];\n",
520 argname[i], ext_argtype[i],
521 ext_argtype[i], argname[i],
522 argname[i], ext_argtype[i]) > sysarg
523 }
524 }
525 if (add_sysproto_entry == 1) {
526 printf("};\n") > sysarg
527 }
528 }
529 else if (add_sysproto_entry == 1) {
530 printf("struct %s {\n\tregister_t dummy;\n};\n", argalias) > sysarg
531 }
532 }
533
534 # output to init_sysent.c
535 tempname = funcname
536 if (add_sysent_entry == 0) {
537 argssize = "0"
538 munge32 = "NULL"
539 munge64 = "NULL"
540 munge_ret = "_SYSCALL_RET_NONE"
541 tempname = "nosys"
542 }
543 else {
544 # figure out which return value type to munge
545 if (returntype == "user_addr_t") {
546 munge_ret = "_SYSCALL_RET_ADDR_T"
547 }
548 else if (returntype == "user_ssize_t") {
549 munge_ret = "_SYSCALL_RET_SSIZE_T"
550 }
551 else if (returntype == "user_size_t") {
552 munge_ret = "_SYSCALL_RET_SIZE_T"
553 }
554 else if (returntype == "int") {
555 munge_ret = "_SYSCALL_RET_INT_T"
556 }
557 else if (returntype == "u_int") {
558 munge_ret = "_SYSCALL_RET_UINT_T"
559 }
560 else if (returntype == "off_t") {
561 munge_ret = "_SYSCALL_RET_OFF_T"
562 }
563 else if (returntype == "void") {
564 munge_ret = "_SYSCALL_RET_NONE"
565 }
566 else {
567 printf "%s: line %d: invalid return type \"%s\" \n",
568 infile, NR, returntype
569 printf "You need to add \"%s\" into the return type checking code. \n",
570 returntype
571 exit 1
572 }
573 }
574
575 if (add_64bit_unsafe == 1 && add_64bit_fakesafe == 0)
576 my_funnel = my_funnel "|UNSAFE_64BIT";
577
578 printf("\t{%s, %s, %s, \(sy_call_t *\)%s, %s, %s, %s},",
579 argssize, add_cancel_enable, my_funnel, tempname, munge32, munge64, munge_ret) > sysent
580 linesize = length(argssize) + length(add_cancel_enable) + length(my_funnel) + length(tempname) + \
581 length(munge32) + length(munge64) + length(munge_ret) + 28
582 align_comment(linesize, 88, sysent)
583 printf("/* %d = %s%s*/\n", syscall, funcname, additional_comments) > sysent
584
585 # output to syscalls.c
586 if (add_sysnames_entry == 1) {
587 tempname = funcname
588 if (funcname == "nosys") {
589 if (syscall == 0)
590 tempname = "syscall"
591 else
592 tempname = "#" syscall
593 }
594 printf("\t\"%s\", ", tempname) > syscallnamestempfile
595 linesize = length(tempname) + 8
596 align_comment(linesize, 25, syscallnamestempfile)
597 if (substr(tempname,1,1) == "#") {
598 printf("/* %d =%s*/\n", syscall, additional_comments) > syscallnamestempfile
599 }
600 else {
601 printf("/* %d = %s%s*/\n", syscall, tempname, additional_comments) > syscallnamestempfile
602 }
603 }
604
605 # output to syscalls.h
606 if (add_sysheader_entry == 1) {
607 tempname = funcname
608 if (syscall == 0) {
609 tempname = "syscall"
610 }
611 if (tempname != "nosys") {
612 printf("#define\t%s%s", syscallprefix, tempname) > syshdrtempfile
613 linesize = length(syscallprefix) + length(tempname) + 12
614 align_comment(linesize, 30, syshdrtempfile)
615 printf("%d\n", syscall) > syshdrtempfile
616 # special case for gettimeofday on ppc - cctools project uses old name
617 if (tempname == "ppc_gettimeofday") {
618 printf("#define\t%s%s", syscallprefix, "gettimeofday") > syshdrtempfile
619 linesize = length(syscallprefix) + length(tempname) + 12
620 align_comment(linesize, 30, syshdrtempfile)
621 printf("%d\n", syscall) > syshdrtempfile
622 }
623 }
624 else {
625 printf("\t\t\t/* %d %s*/\n", syscall, additional_comments) > syshdrtempfile
626 }
627 }
628
629 # output function prototypes to sysproto.h
630 if (add_sysproto_entry == 1) {
631 if (funcname =="exit") {
632 printf("void %s(struct proc *, struct %s *, int *);\n",
633 funcname, argalias) > sysprotoend
634 }
635 else if (funcname != "nosys" || (syscall == 0 && funcname == "nosys")) {
636 printf("int %s(struct proc *, struct %s *, %s *);\n",
637 funcname, argalias, returntype) > sysprotoend
638 }
639 }
640
641 syscall++
642 next
643 }
644
645 END {
646 printf "#define AC(name) (sizeof(struct name) / sizeof(uint64_t))\n" > sysinc
647 printf "\n" > sysinc
648
649 printf("\n__END_DECLS\n") > sysprotoend
650 printf("#undef PAD_\n") > sysprotoend
651 printf("#undef PADL_\n") > sysprotoend
652 printf("#undef PADR_\n") > sysprotoend
653 printf "\n#endif /* __APPLE_API_PRIVATE */\n" > sysprotoend
654 printf "#endif /* KERNEL */\n" > sysprotoend
655 printf("\n#endif /* !%s */\n", sysproto_h) > sysprotoend
656
657 printf("};\n") > sysent
658 printf("int nsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
659
660 printf("};\n") > syscallnamestempfile
661 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
662 > syshdrtempfile
663 printf("\n#endif /* __APPLE_API_PRIVATE */\n") > syshdrtempfile
664 printf("#endif /* !%s */\n", syscall_h) > syshdrtempfile
665 } '
666
667 cat $syslegal $sysinc $sysent > $syscalltablefile
668 cat $syslegal $sysarg $sysprotoend > $sysprotofile
669 cat $syslegal $syscallnamestempfile > $syscallnamesfile
670 cat $syslegal $syshdrtempfile > $syshdrfile