2 # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
3 # $FreeBSD: src/sys/kern/makesyscalls.sh,v 1.39.2.4 2001/10/20 09:01:24 marcel Exp $
4 # $DragonFly: src/sys/kern/makesyscalls.sh,v 1.17 2008/05/19 10:19:49 corecode Exp $
8 # name of compat option:
10 # name of DragonFly 1.2 compat option
11 compatdf12
=COMPAT_DF12
15 sysproto
="../sys/sysproto.h"
16 sysunion
="../sys/sysunion.h"
17 sysproto_h
=_SYS_SYSPROTO_H_
18 syshdr
="../sys/syscall.h"
19 sysmk
="../sys/syscall.mk"
21 syshide
="../sys/syscall-hide.h"
24 namesname
="syscallnames"
27 sysdcl
="sysent.dcl.$$"
28 syscompat
="sysent.compat.$$"
29 syscompatdf12
="sysent.compatdf12.$$"
30 syscompatdcl
="sysent.compatdcl.$$"
31 syscompatdcldf12
="sysent.compatdcldf12.$$"
32 sysent
="sysent.switch.$$"
33 sysinc
="sysinc.switch.$$"
34 sysarg
="sysarg.switch.$$"
35 sysun
="sysunion.switch.$$"
37 trap "rm $sysdcl $syscompat $syscompatdf12 $syscompatdcl $syscompatdcldf12 $sysent $sysinc $sysarg $sysun" 0
39 touch $sysdcl $syscompat $syscompatdf12 $syscompatdcl $syscompatdf12 $sysent $sysinc $sysarg $sysun
42 0) echo "Usage: $0 input-file <config-file>" 1>&2
47 if [ -n "$2" -a -f "$2" ]; then
61 /^#/!s/\([{}()*,]\)/ \1 /g
66 sysproto = \"$sysproto\"
67 sysproto_h = \"$sysproto_h\"
68 syscompat = \"$syscompat\"
69 syscompatdf12 = \"$syscompatdf12\"
70 syscompatdcl = \"$syscompatdcl\"
71 syscompatdcldf12 = \"$syscompatdcldf12\"
77 sysnames = \"$sysnames\"
81 compatdf12 = \"$compatdf12\"
82 syshide = \"$syshide\"
83 syscallprefix = \"$syscallprefix\"
84 switchname = \"$switchname\"
85 namesname = \"$namesname\"
89 printf "/*\n * System call switch table.\n *\n" > syssw
90 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syssw
91 printf " * \$\DragonFly\$\n" > syssw
93 printf "/*\n * System call prototypes.\n *\n" > sysarg
94 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarg
95 printf " * \$\DragonFly\$\n" > sysarg
97 printf "\n#ifdef %s\n\n", compat > syscompat
98 printf "\n#ifdef %s\n\n", compatdf12 > syscompatdf12
100 printf "/*\n * System call names.\n *\n" > sysnames
101 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
102 printf " * \$\DragonFly\$\n" > sysnames
104 printf "/*\n * System call numbers.\n *\n" > syshdr
105 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
106 printf " * \$\DragonFly\$\n" > syshdr
107 printf "# DragonFly system call names.\n" > sysmk
108 printf "# DO NOT EDIT-- this file is automatically generated.\n" > sysmk
109 printf "# \$\DragonFly\$\n" > sysmk
110 printf "/*\n * System call hiders.\n *\n" > syshide
111 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshide
112 printf " * \$\DragonFly\$\n" > syshide
114 printf "/*\n * Union of syscall args for messaging.\n *\n" > sysun
115 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysun
116 printf " * \$\DragonFly\$\n" > sysun
117 printf "\n#ifdef _KERNEL\n\n" > sysdcl
118 printf "\n#ifdef _KERNEL\n\n" > syscompatdcl
119 printf "\n#ifdef _KERNEL\n\n" > syscompatdcldf12
122 gsub("[$]DragonFly: ", "", $0)
125 printf " * created from%s\n */\n\n", $0 > syssw
127 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
128 printf "struct sysent %s[] = {\n",switchname > sysent
130 printf " * created from%s\n */\n\n", $0 > sysarg
131 printf "#ifndef %s\n", sysproto_h > sysarg
132 printf "#define\t%s\n\n", sysproto_h > sysarg
133 printf "#include <sys/select.h>\n\n" > sysarg
134 printf "#include <sys/signal.h>\n\n" > sysarg
135 printf "#include <sys/acl.h>\n\n" > sysarg
136 printf "#include <sys/msgport.h>\n\n" > sysarg
137 printf "#include <sys/sysmsg.h>\n\n" > sysarg
138 printf "#include <sys/syslink.h>\n\n" > sysarg
139 printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg
140 printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg
142 printf " * created from%s\n */\n\n", $0 > sysnames
143 printf "char *%s[] = {\n", namesname > sysnames
145 printf " * created from%s\n */\n\n", $0 > syshdr
147 printf "# created from%s\nMIASM = ", $0 > sysmk
149 printf " * created from%s\n */\n\n", $0 > syshide
150 printf " * created from%s\n */\n\n", $0 > sysun
151 printf "union sysunion {\n" > sysun
152 printf "#ifdef _KERNEL /* header only applies in kernel */\n" > sysun
153 printf "\tstruct\tlwkt_msg lmsg;\n" > sysun
154 printf "\tstruct\tsysmsg sysmsg;\n" > sysun
155 printf "#endif\n" > sysun
159 NF == 0 || $1 ~ /^;/ {
162 $1 ~ /^#[ ]*include/ {
171 print > syscompatdf12
175 savesyscall = syscall
184 print > syscompatdf12
187 syscall = savesyscall
196 print > syscompatdf12
202 printf "%s: line %d: syscall number out of sync at %d\n",
208 function align_sysent_comment(column) {
209 printf("\t") > sysent
210 column = column + 8 - column % 8
211 while (column < 56) {
212 printf("\t") > sysent
216 function parserr(was, wanted) {
217 printf "%s: line %d: unexpected %s (expected %s)\n",
218 infile, NR, was, wanted
221 function parseline() {
222 f=4 # toss number and type
238 argssize = "AS(" $6 ")"
254 f++ #function return type
260 if (argalias == "") {
261 argalias = funcname "_args"
262 if ($2 == "COMPAT") {
263 argalias = "o" argalias
264 usefuncname = "sys_o" funcname
266 if ($2 == "COMPAT_DF12") {
267 argalias = "dfbsd12_" argalias
268 usefuncname = "sys_dfbsd12_" funcname
279 parserr($f, "argument definition")
287 while (f < end && $(f+1) != ",") {
288 if (argtype[argc] != "" && oldf != "*")
289 argtype[argc] = argtype[argc]" ";
290 argtype[argc] = argtype[argc]$f;
294 if (argtype[argc] == "")
295 parserr($f, "argument definition")
297 f += 2; # skip name, and any comma
300 argssize = "AS(" argalias ")"
304 for (i = 5; i <= NF; i++)
305 comment = comment " " $i
307 # if the "MPSAFE" keyword is found, note it and shift the line
310 for (i = 2; i <= NF; i++)
313 mpsafe = "SYF_MPSAFE | "
315 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "NOPROTO" \
318 if ((!nosys || funcname != "nosys") && \
319 (funcname != "lkmnosys")) {
320 if (argc != 0 && $2 != "NOARGS" && $2 != "NOPROTO") {
321 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
322 printf("struct\t%s {\n", argalias) > sysarg
323 printf("#ifdef _KERNEL\n") > sysarg
324 printf("\tstruct sysmsg sysmsg;\n") > sysarg
325 printf("#endif\n") > sysarg
326 for (i = 1; i <= argc; i++)
327 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
328 argtype[i], argname[i],
329 argname[i], argtype[i]) > sysarg
330 printf("};\n") > sysarg
332 else if ($2 != "NOARGS" && $2 != "NOPROTO" && \
334 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
335 printf("struct\t%s {\n", argalias) > sysarg
336 printf("#ifdef _KERNEL\n") > sysarg
337 printf("\tstruct sysmsg sysmsg;\n") > sysarg
338 printf("#endif\n") > sysarg
339 printf("\tregister_t dummy;\n") > sysarg
340 printf("};\n") > sysarg
343 if (($2 != "NOPROTO" && $2 != "NODEF" && \
344 (funcname != "nosys" || !nosys)) || \
345 (funcname == "lkmnosys" && !lkmnosys) || \
346 funcname == "lkmressys") {
347 printf("%s\tsys_%s (struct %s *)",
348 rettype, funcname, argalias) > sysdcl
349 printf(";\n") > sysdcl
351 if (funcname == "nosys")
353 if (funcname == "lkmnosys")
355 printf("\t{ %s%s, (sy_call_t *)", mpsafe, argssize) > sysent
356 column = 8 + 2 + length(mpsafe) + length(argssize) + 15
357 if ($2 != "NOIMPL") {
358 printf("sys_%s },", funcname) > sysent
359 column = column + length(funcname) + 7
361 printf("sys_%s },", "nosys") > sysent
362 column = column + length("nosys") + 7
364 align_sysent_comment(column)
365 printf("/* %d = %s */\n", syscall, funcalias) > sysent
366 printf("\t\"%s\",\t\t\t/* %d = %s */\n",
367 funcalias, syscall, funcalias) > sysnames
369 printf("#define\t%s%s\t%d\n", syscallprefix,
370 funcalias, syscall) > syshdr
371 printf(" \\\n\t%s.o", funcalias) > sysmk
374 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
378 $2 == "COMPAT" || $2 == "CPT_NOA" {
381 if (argc != 0 && $2 != "CPT_NOA") {
382 printf("#ifdef %s\n", compat) > sysun
383 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
384 printf("#endif\n") > sysun
385 printf("struct\t%s {\n", argalias) > syscompat
386 printf("#ifdef _KERNEL\n") > syscompat
387 printf("\tstruct sysmsg sysmsg;\n") > syscompat
388 printf("#endif\n") > syscompat
389 for (i = 1; i <= argc; i++)
390 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
391 argtype[i], argname[i],
392 argname[i], argtype[i]) > syscompat
393 printf("};\n") > syscompat
395 else if($2 != "CPT_NOA") {
396 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
397 printf("struct\t%s {\n", argalias) > sysarg
398 printf("#ifdef _KERNEL\n") > sysarg
399 printf("\tstruct sysmsg sysmsg;\n") > sysarg
400 printf("#endif\n") > sysarg
401 printf("\tregister_t dummy;\n") > sysarg
402 printf("};\n") > sysarg
404 printf("%s\tsys_o%s (struct %s *);\n",
405 rettype, funcname, argalias) > syscompatdcl
406 printf("\t{ compat(%s%s,%s) },",
407 mpsafe, argssize, funcname) > sysent
408 align_sysent_comment(8 + 9 + length(mpsafe) + \
409 length(argssize) + 1 + length(funcname) + 4)
410 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
411 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
412 funcalias, syscall, funcalias) > sysnames
413 printf("\t\t\t\t/* %d is old %s */\n",
414 syscall, funcalias) > syshdr
416 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
420 $2 == "COMPAT_DF12" {
424 printf("#ifdef %s\n", compatdf12) > sysun
425 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
426 printf("#endif\n") > sysun
427 printf("struct\t%s {\n", argalias) > syscompatdf12
428 printf("#ifdef _KERNEL\n") > syscompatdf12
429 printf("\tstruct sysmsg sysmsg;\n") > syscompatdf12
430 printf("#endif\n") > syscompatdf12
431 for (i = 1; i <= argc; i++)
432 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
433 argtype[i], argname[i],
434 argname[i], argtype[i]) > syscompatdf12
435 printf("};\n") > syscompatdf12
438 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
439 printf("struct\t%s {\n", argalias) > sysarg
440 printf("#ifdef _KERNEL\n") > sysarg
441 printf("\tstruct sysmsg sysmsg;\n") > sysarg
442 printf("#endif\n") > sysarg
443 printf("\tregister_t dummy;\n") > sysarg
444 printf("};\n") > sysarg
446 printf("%s\tsys_dfbsd12_%s (struct %s *);\n",
447 rettype, funcname, argalias) > syscompatdcldf12
448 printf("\t{ compatdf12(%s%s,%s) },",
449 mpsafe, argssize, funcname) > sysent
450 align_sysent_comment(8 + 9 + length(mpsafe) + \
451 length(argssize) + 1 + length(funcname) + 4)
452 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
453 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
454 funcalias, syscall, funcalias) > sysnames
455 printf("\t\t\t\t/* %d is old %s */\n",
456 syscall, funcalias) > syshdr
458 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
465 printf("%s\tsys_o%s();\n", rettype, funcname) > syscompatdcl
466 printf("\t{ compat(%s%s,%s) },",
467 mpsafe, argssize, funcname) > sysent
468 align_sysent_comment(8 + 9 + length(mpsafe) + \
469 length(argssize) + 1 + length(funcname) + 4)
470 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
471 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
472 funcalias, syscall, funcalias) > sysnames
473 printf("#define\t%s%s\t%d\t/* compatibility; still used by libc */\n",
474 syscallprefix, funcalias, syscall) > syshdr
475 printf(" \\\n\t%s.o", funcalias) > sysmk
477 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
482 printf("\t{ 0, (sy_call_t *)sys_nosys },") > sysent
483 align_sysent_comment(37)
484 printf("/* %d = obsolete %s */\n", syscall, comment) > sysent
485 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n",
486 $4, syscall, comment) > sysnames
487 printf("\t\t\t\t/* %d is obsolete %s */\n",
488 syscall, comment) > syshdr
490 printf("HIDE_%s(%s)\n", $3, $4) > syshide
495 printf("\t{ 0, (sy_call_t *)sys_nosys },\t\t\t/* %d = %s */\n",
496 syscall, comment) > sysent
497 printf("\t\"#%d\",\t\t\t/* %d = %s */\n",
498 syscall, syscall, comment) > sysnames
500 printf("HIDE_%s(%s)\n", $3, $4) > syshide
505 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
509 printf "\n#define AS(name) ((sizeof(struct name) - sizeof(struct sysmsg)) / sizeof(register_t))\n" > sysinc
511 printf "#include \"opt_compat.h\"\n\n" > syssw
512 printf "\n#ifdef %s\n", compat > sysinc
513 printf "#define compat(n, name) n, (sy_call_t *)__CONCAT(sys_,__CONCAT(o,name))\n" > sysinc
514 printf "#else\n" > sysinc
515 printf "#define compat(n, name) 0, (sy_call_t *)sys_nosys\n" > sysinc
516 printf "#endif\n" > sysinc
519 if (ncompatdf12 != 0) {
520 printf "#include \"opt_compatdf12.h\"\n\n" > syssw
521 printf "\n#ifdef %s\n", compatdf12 > sysinc
522 printf "#define compatdf12(n, name) n, (sy_call_t *)__CONCAT(sys_,__CONCAT(dfbsd12_,name))\n" > sysinc
523 printf "#else\n" > sysinc
524 printf "#define compatdf12(n, name) 0, (sy_call_t *)sys_nosys\n" > sysinc
525 printf "#endif\n" > sysinc
528 printf("\n#endif /* _KERNEL */\n") > syscompatdcl
529 printf("\n#endif /* _KERNEL */\n") > syscompatdcldf12
530 printf("\n#endif /* %s */\n\n", compat) > syscompatdcl
531 printf("\n#endif /* %s */\n\n", compatdf12) > syscompatdcldf12
534 printf("};\n") > sysent
535 printf("};\n") > sysnames
536 printf("};\n") > sysun
537 printf("\n#endif /* !%s */\n", sysproto_h) > sysdcl
538 printf("#undef PAD_\n") > sysdcl
539 printf("\n#endif /* _KERNEL */\n") > sysdcl
540 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
544 cat $sysinc $sysent >> $syssw
545 cat $sysarg $syscompat $syscompatdcl $syscompatdf12 $syscompatdcldf12 $sysdcl > $sysproto
546 cat $sysun > $sysunion