]>
git.saurik.com Git - apple/xnu.git/blob - bsd/kern/makesyscalls.sh
411d5ce6183a2e8c8b452b70eff22f8f82260a91
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 $
5 # Copyright (c) 2004-2008 Apple Inc. All rights reserved.
7 # @APPLE_OSREFERENCE_LICENSE_HEADER_START@
9 # This file contains Original Code and/or Modifications of Original Code
10 # as defined in and that are subject to the Apple Public Source License
11 # Version 2.0 (the 'License'). You may not use this file except in
12 # compliance with the License. Please obtain a copy of the License at
13 # http://www.opensource.apple.com/apsl/ and read it before using this
16 # The Original Code and all software distributed under the License are
17 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
18 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
19 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
21 # Please see the License for the specific language governing rights and
22 # limitations under the License.
24 # @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 input_file
="" # first argument
32 output_syscallnamesfile
=0
35 output_syscalltablefile
=0
43 syscallnamesfile
="syscalls.c"
44 sysprotofile
="sysproto.h"
45 sysproto_h
=_SYS_SYSPROTO_H_
46 syshdrfile
="syscall.h"
47 syscall_h
=_SYS_SYSCALL_H_
48 syscalltablefile
="init_sysent.c"
49 auditevfile
="audit_kevents.c"
52 namesname
="syscallnames"
53 tracecodename
="syscall.codes"
54 systraceargsfile
="systrace_args.c"
56 syslegal
="sysent.syslegal.$$"
57 sysent
="sysent.switch.$$"
58 sysinc
="sysinc.switch.$$"
59 sysarg
="sysarg.switch.$$"
60 sysprotoend
="sysprotoend.$$"
61 syscallnamestempfile
="syscallnamesfile.$$"
62 syshdrtempfile
="syshdrtempfile.$$"
63 audittempfile
="audittempfile.$$"
64 tracecodetempfile
="tracecodetempfile.$$"
65 systraceargstempfile
="systraceargstempfile.$$"
66 systraceargdesctempfile
="systraceargdesctempfile.$$"
67 systracerettempfile
="systracerettempfile.$$"
69 trap "rm $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile $audittempfile $tracecodetempfile $systraceargstempfile $systraceargdesctempfile $systracerettempfile" 0
71 touch $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile $audittempfile $tracecodetempfile $systraceargstempfile $systraceargdesctempfile $systracerettempfile
75 echo "usage: $0 input-file [<names|proto|header|table|audit|trace> [<config-file>]]" 1>&2
86 output_syscallnamesfile
=1
95 output_syscalltablefile
=1
110 output_syscallnamesfile
=1
111 output_sysprotofile
=1
113 output_syscalltablefile
=1
118 if [ -n "$1" -a -f "$1" ]; then
134 /^#/!s/\([{}()*,;]\)/ \1 /g
136 ' < "$input_file" | awk "
138 syslegal = \"$syslegal\"
139 sysprotofile = \"$sysprotofile\"
140 sysprotoend = \"$sysprotoend\"
141 sysproto_h = \"$sysproto_h\"
142 syscall_h = \"$syscall_h\"
144 syscalltablefile = \"$syscalltablefile\"
147 syscallnamesfile = \"$syscallnamesfile\"
148 syscallnamestempfile = \"$syscallnamestempfile\"
149 syshdrfile = \"$syshdrfile\"
150 syshdrtempfile = \"$syshdrtempfile\"
151 systraceargstempfile = \"$systraceargstempfile\"
152 systraceargdesctempfile = \"$systraceargdesctempfile\"
153 systracerettempfile = \"$systracerettempfile\"
154 audittempfile = \"$audittempfile\"
155 tracecodetempfile = \"$tracecodetempfile\"
156 syscallprefix = \"$syscallprefix\"
157 switchname = \"$switchname\"
158 namesname = \"$namesname\"
159 infile = \"$input_file\"
162 printf "/*\n" > syslegal
163 printf " * Copyright (c) 2004-2008 Apple Inc. All rights reserved.\n" > syslegal
164 printf " * \n" > syslegal
165 printf " * @APPLE_OSREFERENCE_LICENSE_HEADER_START@\n" > syslegal
166 printf " * \n" > syslegal
167 printf " * This file contains Original Code and/or Modifications of Original Code\n" > syslegal
168 printf " * as defined in and that are subject to the Apple Public Source License\n" > syslegal
169 printf " * Version 2.0 (the \047License\047). You may not use this file except in\n" > syslegal
170 printf " * compliance with the License. The rights granted to you under the License\n" > syslegal
171 printf " * may not be used to create, or enable the creation or redistribution of,\n" > syslegal
172 printf " * unlawful or unlicensed copies of an Apple operating system, or to\n" > syslegal
173 printf " * circumvent, violate, or enable the circumvention or violation of, any\n" > syslegal
174 printf " * terms of an Apple operating system software license agreement.\n" > syslegal
175 printf " * \n" > syslegal
176 printf " * Please obtain a copy of the License at\n" > syslegal
177 printf " * http://www.opensource.apple.com/apsl/ and read it before using this file.\n" > syslegal
178 printf " * \n" > syslegal
179 printf " * The Original Code and all software distributed under the License are\n" > syslegal
180 printf " * distributed on an \047AS IS\047 basis, WITHOUT WARRANTY OF ANY KIND, EITHER\n" > syslegal
181 printf " * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\n" > syslegal
182 printf " * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,\n" > syslegal
183 printf " * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.\n" > syslegal
184 printf " * Please see the License for the specific language governing rights and\n" > syslegal
185 printf " * limitations under the License.\n" > syslegal
186 printf " * \n" > syslegal
187 printf " * @APPLE_OSREFERENCE_LICENSE_HEADER_END@\n" > syslegal
188 printf " * \n" > syslegal
189 printf " * \n" > syslegal
190 printf " * System call switch table.\n *\n" > syslegal
191 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syslegal
192 printf " * created from %s\n */\n\n", infile > syslegal
195 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
196 printf "__private_extern__ const struct sysent %s[] = {\n",switchname > sysent
198 printf "#ifndef %s\n", sysproto_h > sysarg
199 printf "#define\t%s\n\n", sysproto_h > sysarg
200 printf "#ifndef %s\n", syscall_h > syshdrtempfile
201 printf "#define\t%s\n\n", syscall_h > syshdrtempfile
202 printf "#include <sys/appleapiopts.h>\n" > syshdrtempfile
203 printf "#ifdef __APPLE_API_PRIVATE\n" > syshdrtempfile
204 printf "#include <sys/appleapiopts.h>\n" > sysarg
205 printf "#include <sys/cdefs.h>\n" > sysarg
206 printf "#include <sys/mount_internal.h>\n" > sysarg
207 printf "#include <sys/types.h>\n" > sysarg
208 printf "#include <sys/sem_internal.h>\n" > sysarg
209 printf "#include <sys/semaphore.h>\n" > sysarg
210 printf "#include <sys/wait.h>\n" > sysarg
211 printf "#include <mach/shared_region.h>\n" > sysarg
212 printf "\n#ifdef KERNEL\n" > sysarg
213 printf "#ifdef __APPLE_API_PRIVATE\n" > sysarg
214 printf "/*\n" > sysarg
215 printf " * The kernel may support multiple userspace ABIs, and must use\n" > sysarg
216 printf " * argument structures with elements large enough for any of them.\n" > sysarg
217 printf "*/\n" > sysarg
219 printf "#if CONFIG_REQUIRES_U32_MUNGING\n" > sysarg
220 printf "#define\tPAD_(t)\t(sizeof(uint64_t) <= sizeof(t) \\\n " > sysarg
221 printf "\t\t? 0 : sizeof(uint64_t) - sizeof(t))\n" > sysarg
222 printf "#else\n" > sysarg
223 printf "#define\tPAD_(t)\t(sizeof(uint32_t) <= sizeof(t) \\\n" > sysarg
224 printf " ? 0 : sizeof(uint32_t) - sizeof(t))\n" > sysarg
225 printf "#endif\n" > sysarg
226 printf "#if BYTE_ORDER == LITTLE_ENDIAN\n"> sysarg
227 printf "#define\tPADL_(t)\t0\n" > sysarg
228 printf "#define\tPADR_(t)\tPAD_(t)\n" > sysarg
229 printf "#else\n" > sysarg
230 printf "#define\tPADL_(t)\tPAD_(t)\n" > sysarg
231 printf "#define\tPADR_(t)\t0\n" > sysarg
232 printf "#endif\n" > sysarg
233 printf "\n__BEGIN_DECLS\n" > sysarg
234 printf "#include <sys/munge.h>\n" > sysarg
238 printf "const char *%s[] = {\n", namesname > syscallnamestempfile
240 printf "#include <sys/param.h>\n" > audittempfile
241 printf "#include <sys/types.h>\n\n" > audittempfile
242 printf "#include <bsm/audit.h>\n" > audittempfile
243 printf "#include <bsm/audit_kevents.h>\n\n" > audittempfile
244 printf "#if CONFIG_AUDIT\n\n" > audittempfile
245 printf "au_event_t sys_au_event[] = {\n" > audittempfile
247 printf "/*\n * System call argument to DTrace register array conversion.\n */\n" > systraceargstempfile
248 printf "#include <sys/systrace_args.h>\n" > systraceargstempfile
249 printf "void\nsystrace_args(int sysnum, void *params, uint64_t *uarg)\n{\n" > systraceargstempfile
250 printf "\tint64_t *iarg = (int64_t *) uarg;\n" > systraceargstempfile
251 printf "\tswitch (sysnum) {\n" > systraceargstempfile
253 printf "void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceargdesctempfile
254 printf "\tswitch (sysnum) {\n" > systraceargdesctempfile
256 printf "void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracerettempfile
257 printf "\tswitch (sysnum) {\n" > systracerettempfile
261 NF == 0 || $1 ~ /^;/ {
264 $1 ~ /^#[ ]*include/ {
271 print > syscallnamestempfile
273 print > audittempfile
274 print > systraceargstempfile
275 print > systraceargdesctempfile
276 print > systracerettempfile
277 savesyscall = syscall_num
284 print > syscallnamestempfile
286 print > audittempfile
287 print > systraceargstempfile
288 print > systraceargdesctempfile
289 print > systracerettempfile
290 syscall_num = savesyscall
297 print > syscallnamestempfile
299 print > audittempfile
300 print > systraceargstempfile
301 print > systraceargdesctempfile
302 print > systracerettempfile
307 printf "%s: line %d: syscall number out of sync at %d\n",
308 infile, NR, syscall_num
313 function align_comment(linesize, location, thefile) {
314 printf(" ") > thefile
315 while (linesize < location) {
316 printf(" ") > thefile
320 function parserr(was, wanted) {
321 printf "%s: line %d: unexpected %s (expected %s)\n",
322 infile, NR, was, wanted
326 function parseline() {
328 current_field = 4 # skip number, audit event, type
335 additional_comments = " "
338 # find start and end of call name and arguments
339 if ($current_field != "{")
340 parserr($current_field, "{")
341 args_start = current_field
343 while (current_field <= NF) {
344 if ($current_field == "}") {
345 args_end = current_field
351 printf "%s: line %d: invalid call name and arguments\n",
356 # find start and end of optional comments
358 if (current_field < NF && $current_field == "{") {
359 comments_start = current_field
360 while (current_field <= NF) {
361 if ($current_field == "}") {
362 comments_end = current_field
367 if (comments_end == 0) {
368 printf "%s: line %d: invalid comments \n",
374 if ($args_end != "}")
375 parserr($args_end, "}")
377 if ($args_end != ";")
378 parserr($args_end, ";")
381 # skip any NO_SYSCALL_STUB qualifier
382 if ($args_end == "NO_SYSCALL_STUB")
385 if ($args_end != ")")
386 parserr($args_end, ")")
389 # extract additional comments
390 if (comments_start != 0) {
391 current_field = comments_start + 1
392 while (current_field < comments_end) {
393 additional_comments = additional_comments $current_field " "
394 obs_comments = obs_comments $current_field "_"
398 sub(/old/, "obs", obs_comments)
399 obs_comments = substr(obs_comments, 1, length(obs_comments)-1)
400 if (obs_comments == "_") {
404 # get function return type
405 current_field = args_start + 1
406 returntype = $current_field
408 # get function name and set up to get arguments
410 funcname = $current_field
411 argalias = funcname "_args"
412 current_field++ # bump past function name
414 if ($current_field != "(")
415 parserr($current_field, "(")
418 if (current_field == args_end) {
419 if ($current_field != "void")
420 parserr($current_field, "argument definition")
424 # extract argument types and names
425 while (current_field <= args_end) {
430 while (current_field < args_end && $(current_field + 1) != ",") {
431 if (argtype[argc] != "" && oldf != "*") {
432 argtype[argc] = argtype[argc] " ";
434 argtype[argc] = argtype[argc] $current_field;
435 ext_argtype[argc] = argtype[argc];
436 oldf = $current_field;
439 if (argtype[argc] == "")
440 parserr($current_field, "argument definition")
441 argname[argc] = $current_field;
442 current_field += 2; # skip name, and any comma
445 printf "%s: line %d: too many arguments!\n", infile, NR
449 argssize = "AC(" argalias ")"
458 add_sysnames_entry = 1
459 add_sysheader_entry = 1
460 add_sysproto_entry = 1
466 add_sysnames_entry = 0
467 add_sysheader_entry = 0
468 add_sysproto_entry = 0
470 if (match($3, "[T]") != 0) {
474 if (match($3, "[N]") != 0) {
475 add_sysnames_entry = 1
478 if (match($3, "[H]") != 0) {
479 add_sysheader_entry = 1
482 if (match($3, "[P]") != 0) {
483 add_sysproto_entry = 1
487 if (files_keyword_OK == 0) {
488 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
496 # output function argument structures to sysproto.h and build the
497 # name of the appropriate argument mungers
501 if ((funcname != "nosys" && funcname != "enosys") || (syscall_num == 0 && funcname == "nosys")) {
502 printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall_num) > systraceargstempfile
503 printf("\t/* %s */\n\tcase %d:\n", funcname, syscall_num) > systraceargdesctempfile
504 printf("\t/* %s */\n\tcase %d:\n", funcname, syscall_num) > systracerettempfile
506 printf("\t\tswitch(ndx) {\n") > systraceargdesctempfile
507 printf("\t\tstruct %s *p = params;\n", argalias) > systraceargstempfile
508 for (i = 1; i <= argc; i++) {
510 sub("__restrict$", "", arg)
511 if (index(arg, "*") > 0)
512 printf("\t\tcase %d:\n\t\t\tp = \"userland %s\";\n\t\t\tbreak;\n", i - 1, arg) > systraceargdesctempfile
514 printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systraceargdesctempfile
515 if (index(arg, "*") > 0 || arg == "caddr_t")
516 printf("\t\tuarg[%d] = (intptr_t) p->%s; /* %s */\n", \
518 argname[i], arg) > systraceargstempfile
519 else if (substr(arg, 1, 1) == "u" || arg == "size_t")
520 printf("\t\tuarg[%d] = p->%s; /* %s */\n", \
522 argname[i], arg) > systraceargstempfile
524 printf("\t\tiarg[%d] = p->%s; /* %s */\n", \
526 argname[i], arg) > systraceargstempfile
528 printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systraceargdesctempfile
531 printf("\t\tbreak;\n\t}\n", argc) > systraceargstempfile
532 printf("\t\tif (ndx == 0 || ndx == 1)\n") > systracerettempfile
533 printf("\t\t\tp = \"%s\";\n", returntype) > systracerettempfile
534 printf("\t\tbreak;\n") > systracerettempfile
535 printf("\t\tbreak;\n") > systraceargdesctempfile
537 if (add_sysproto_entry == 1) {
538 printf("struct %s {\n", argalias) > sysarg
541 for (i = 1; i <= argc; i++) {
542 # Build name of argument munger.
543 # We account for all sys call argument types here.
544 # This is where you add any new types. With LP64 support
545 # each argument consumes 64-bits.
546 # see .../xnu/bsd/dev/munge.c for munge argument types.
547 if (argtype[i] == "long") {
548 ext_argtype[i] = "user_long_t";
549 munge32 = munge32 "s"
552 else if (argtype[i] == "u_long") {
553 ext_argtype[i] = "user_ulong_t";
554 munge32 = munge32 "w"
557 else if (argtype[i] == "size_t") {
558 ext_argtype[i] = "user_size_t";
559 munge32 = munge32 "w"
562 else if (argtype[i] == "ssize_t") {
563 ext_argtype[i] = "user_ssize_t";
564 munge32 = munge32 "s"
567 else if (argtype[i] == "user_ssize_t" || argtype[i] == "user_long_t") {
568 munge32 = munge32 "s"
571 else if (argtype[i] == "user_addr_t" || argtype[i] == "user_size_t" ||
572 argtype[i] == "user_ulong_t") {
573 munge32 = munge32 "w"
576 else if (argtype[i] == "caddr_t" || argtype[i] == "semun_t" ||
577 argtype[i] == "uuid_t" || match(argtype[i], "[\*]") != 0) {
578 ext_argtype[i] = "user_addr_t";
579 munge32 = munge32 "w"
582 else if (argtype[i] == "int" || argtype[i] == "u_int" ||
583 argtype[i] == "uid_t" || argtype[i] == "pid_t" ||
584 argtype[i] == "id_t" || argtype[i] == "idtype_t" ||
585 argtype[i] == "socklen_t" || argtype[i] == "uint32_t" || argtype[i] == "int32_t" ||
586 argtype[i] == "sigset_t" || argtype[i] == "gid_t" || argtype[i] == "unsigned int" ||
587 argtype[i] == "mode_t" || argtype[i] == "key_t" ||
588 argtype[i] == "mach_port_name_t" || argtype[i] == "au_asid_t" ||
589 argtype[i] == "sae_associd_t" || argtype[i] == "sae_connid_t") {
590 munge32 = munge32 "w"
593 else if (argtype[i] == "off_t" || argtype[i] == "int64_t" || argtype[i] == "uint64_t") {
594 munge32 = munge32 "l"
598 printf "%s: line %d: invalid type \"%s\" \n",
599 infile, NR, argtype[i]
600 printf "You need to add \"%s\" into the type checking code. \n",
604 if (add_sysproto_entry == 1) {
605 printf("\tchar %s_l_[PADL_(%s)]; " \
606 "%s %s; char %s_r_[PADR_(%s)];\n",
607 argname[i], ext_argtype[i],
608 ext_argtype[i], argname[i],
609 argname[i], ext_argtype[i]) > sysarg
612 if (add_sysproto_entry == 1) {
613 printf("};\n") > sysarg
616 else if (add_sysproto_entry == 1) {
617 printf("struct %s {\n\tint32_t dummy;\n};\n", argalias) > sysarg
621 # output to init_sysent.c
623 if (add_sysent_entry == 0) {
626 munge_ret = "_SYSCALL_RET_NONE"
627 if (tempname != "enosys") {
632 # figure out which return value type to munge
633 if (returntype == "user_addr_t") {
634 munge_ret = "_SYSCALL_RET_ADDR_T"
636 else if (returntype == "user_ssize_t") {
637 munge_ret = "_SYSCALL_RET_SSIZE_T"
639 else if (returntype == "user_size_t") {
640 munge_ret = "_SYSCALL_RET_SIZE_T"
642 else if (returntype == "int") {
643 munge_ret = "_SYSCALL_RET_INT_T"
645 else if (returntype == "u_int" || returntype == "mach_port_name_t") {
646 munge_ret = "_SYSCALL_RET_UINT_T"
648 else if (returntype == "uint32_t") {
649 munge_ret = "_SYSCALL_RET_UINT_T"
651 else if (returntype == "uint64_t") {
652 munge_ret = "_SYSCALL_RET_UINT64_T"
654 else if (returntype == "off_t") {
655 munge_ret = "_SYSCALL_RET_OFF_T"
657 else if (returntype == "void") {
658 munge_ret = "_SYSCALL_RET_NONE"
661 printf "%s: line %d: invalid return type \"%s\" \n",
662 infile, NR, returntype
663 printf "You need to add \"%s\" into the return type checking code. \n",
669 printf("#if CONFIG_REQUIRES_U32_MUNGING || (__arm__ && (__BIGGEST_ALIGNMENT__ > 4))\n") > sysent
670 printf("\t{ \(sy_call_t *\)%s, %s, %s, %s, %s},",
671 tempname, munge32, munge_ret, argssize, size32) > sysent
672 linesize = length(tempname) + length(munge32) + \
673 length(munge_ret) + length(argssize) + length(size32) + 28
674 align_comment(linesize, 88, sysent)
675 printf("/* %d = %s%s*/\n", syscall_num, funcname, additional_comments) > sysent
676 printf("#else\n") > sysent
677 printf("\t{ \(sy_call_t *\)%s, %s, %s, %s},\n",
678 tempname, munge_ret, argssize, size32) > sysent
679 printf("#endif\n") > sysent
681 # output to syscalls.c
682 if (add_sysnames_entry == 1) {
684 if (funcname == "nosys" || funcname == "enosys") {
685 if (syscall_num == 0)
688 tempname = "#" syscall_num
690 printf("\t\"%s\", ", tempname) > syscallnamestempfile
691 linesize = length(tempname) + 8
692 align_comment(linesize, 25, syscallnamestempfile)
693 if (substr(tempname,1,1) == "#") {
694 printf("/* %d =%s*/\n", syscall_num, additional_comments) > syscallnamestempfile
697 printf("/* %d = %s%s*/\n", syscall_num, tempname, additional_comments) > syscallnamestempfile
701 # output to syscalls.h
702 if (add_sysheader_entry == 1) {
704 if (syscall_num == 0) {
707 if (tempname != "nosys" && tempname != "enosys") {
708 printf("#define\t%s%s", syscallprefix, tempname) > syshdrtempfile
709 linesize = length(syscallprefix) + length(tempname) + 12
710 align_comment(linesize, 30, syshdrtempfile)
711 printf("%d\n", syscall_num) > syshdrtempfile
713 else if (skip_for_header == 0) {
714 printf("\t\t\t/* %d %s*/\n", syscall_num, additional_comments) > syshdrtempfile
718 # output function prototypes to sysproto.h
719 if (add_sysproto_entry == 1) {
720 if (funcname =="exit") {
721 printf("void %s(struct proc *, struct %s *, int32_t *);\n",
722 funcname, argalias) > sysprotoend
724 else if ((funcname != "nosys" && funcname != "enosys") || (syscall_num == 0 && funcname == "nosys")) {
725 printf("int %s(struct proc *, struct %s *, %s *);\n",
726 funcname, argalias, returntype) > sysprotoend
730 # output to audit_kevents.c
731 printf("\t%s,\t\t", auditev) > audittempfile
732 printf("/* %d = %s%s*/\n", syscall_num, tempname, additional_comments) > audittempfile
735 if (skip_for_header == 0) {
736 if (tempname == "nosys" || tempname == "enosys") {
737 if (obs_comments == "") {
738 printf("0x40c%04x\tBSC_#%d%s\n", (syscall_num*4), syscall_num, obs_comments) > tracecodetempfile
740 printf("0x40c%04x\tBSC%s\n", (syscall_num*4), obs_comments) > tracecodetempfile
743 sub(/^_+/, "", tempname)
744 printf("0x40c%04x\tBSC_%s\n", (syscall_num*4), tempname) > tracecodetempfile
753 printf "#define AC(name) (sizeof(struct name) / sizeof(syscall_arg_t))\n" > sysinc
756 printf("\n__END_DECLS\n") > sysprotoend
757 printf("#undef PAD_\n") > sysprotoend
758 printf("#undef PADL_\n") > sysprotoend
759 printf("#undef PADR_\n") > sysprotoend
760 printf "\n#endif /* __APPLE_API_PRIVATE */\n" > sysprotoend
761 printf "#endif /* KERNEL */\n" > sysprotoend
762 printf("\n#endif /* !%s */\n", sysproto_h) > sysprotoend
764 printf("};\n") > sysent
765 printf("unsigned int nsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
767 printf("};\n") > syscallnamestempfile
768 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall_num) \
770 printf("#define\t%sinvalid\t%d\n", syscallprefix, 63) \
772 printf("\n#endif /* __APPLE_API_PRIVATE */\n") > syshdrtempfile
773 printf("#endif /* !%s */\n", syscall_h) > syshdrtempfile
774 printf("};\n\n") > audittempfile
775 printf("#endif /* AUDIT */\n") > audittempfile
777 printf "\tdefault:\n\t\tbreak;\n\t};\n}\n" > systraceargstempfile
778 printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systraceargdesctempfile
779 printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracerettempfile
782 # define value in syscall table file to permit redifintion because of the way
783 # __private_extern__ (doesn't) work.
784 if [ $output_syscalltablefile -eq 1 ]; then
785 cat $syslegal > $syscalltablefile
786 printf "#define __INIT_SYSENT_C__ 1\n" >> $syscalltablefile
787 cat $sysinc $sysent >> $syscalltablefile
790 if [ $output_syscallnamesfile -eq 1 ]; then
791 cat $syslegal $syscallnamestempfile > $syscallnamesfile
794 if [ $output_sysprotofile -eq 1 ]; then
795 cat $syslegal $sysarg $sysprotoend > $sysprotofile
798 if [ $output_syshdrfile -eq 1 ]; then
799 cat $syslegal $syshdrtempfile > $syshdrfile
802 if [ $output_auditevfile -eq 1 ]; then
803 cat $syslegal $audittempfile > $auditevfile
806 if [ $output_systrace -eq 1 ]; then
807 cat $systraceargstempfile > $systraceargsfile
808 cat $systraceargdesctempfile >> $systraceargsfile
809 cat $systracerettempfile >> $systraceargsfile
812 if [ $output_tracecodes -eq 1 ]; then
813 if [ $use_stdout -eq 1 ]; then
814 cat $tracecodetempfile
816 cat $tracecodetempfile > $tracecodename