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 $syscompatdcldf12 $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 " */\n\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 " */\n\n" > sysarg
96 printf "#ifndef %s\n", sysproto_h > sysarg
97 printf "#define\t%s\n\n", sysproto_h > sysarg
98 printf "#include <sys/select.h>\n\n" > sysarg
99 printf "#include <sys/signal.h>\n\n" > sysarg
100 printf "#include <sys/acl.h>\n\n" > sysarg
101 printf "#include <sys/msgport.h>\n\n" > sysarg
102 printf "#include <sys/sysmsg.h>\n\n" > sysarg
103 printf "#include <sys/syslink.h>\n\n" > sysarg
104 printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg
105 printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg
107 printf "\n#ifdef %s\n\n", compat > syscompat
108 printf "\n#ifdef %s\n\n", compatdf12 > syscompatdf12
110 printf "/*\n * System call names.\n *\n" > sysnames
111 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
112 printf " */\n\n" > sysnames
113 printf "const char *%s[] = {\n", namesname > sysnames
115 printf "/*\n * System call numbers.\n *\n" > syshdr
116 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
117 printf " */\n\n" > syshdr
119 printf "# DragonFly system call names.\n" > sysmk
120 printf "# DO NOT EDIT-- this file is automatically generated.\n" > sysmk
121 printf "MIASM = " > sysmk
123 printf "/*\n * System call hiders.\n *\n" > syshide
124 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshide
125 printf " */\n\n" > syshide
127 printf "/*\n * Union of syscall args for messaging.\n *\n" > sysun
128 printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysun
129 printf " */\n\n" > sysun
130 printf "union sysunion {\n" > sysun
131 printf "#ifdef _KERNEL /* header only applies in kernel */\n" > sysun
132 printf "\tstruct\tlwkt_msg lmsg;\n" > sysun
133 printf "\tstruct\tsysmsg sysmsg;\n" > sysun
134 printf "#endif\n" > sysun
136 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
137 printf "struct sysent %s[] = {\n",switchname > sysent
139 printf "\n#ifdef _KERNEL\n\n" > sysdcl
140 printf "\n#ifdef _KERNEL\n\n" > syscompatdcl
141 printf "\n#ifdef _KERNEL\n\n" > syscompatdcldf12
143 NF == 0 || $1 ~ /^;/ {
146 $1 ~ /^#[ ]*include/ {
155 print > syscompatdf12
159 savesyscall = syscall
168 print > syscompatdf12
171 syscall = savesyscall
180 print > syscompatdf12
186 printf "%s: line %d: syscall number out of sync at %d\n",
192 function align_sysent_comment(column) {
193 printf("\t") > sysent
194 column = column + 8 - column % 8
195 while (column < 56) {
196 printf("\t") > sysent
200 function parserr(was, wanted) {
201 printf "%s: line %d: unexpected %s (expected %s)\n",
202 infile, NR, was, wanted
205 function parseline() {
206 f=4 # toss number and type
222 argssize = "AS(" $6 ")"
238 f++ #function return type
244 if (argalias == "") {
245 argalias = funcname "_args"
246 if ($2 == "COMPAT") {
247 argalias = "o" argalias
248 usefuncname = "sys_o" funcname
250 if ($2 == "COMPAT_DF12") {
251 argalias = "dfbsd12_" argalias
252 usefuncname = "sys_dfbsd12_" funcname
263 parserr($f, "argument definition")
271 while (f < end && $(f+1) != ",") {
272 if (argtype[argc] != "" && oldf != "*")
273 argtype[argc] = argtype[argc]" ";
274 argtype[argc] = argtype[argc]$f;
278 if (argtype[argc] == "")
279 parserr($f, "argument definition")
281 f += 2; # skip name, and any comma
284 argssize = "AS(" argalias ")"
288 for (i = 5; i <= NF; i++)
289 comment = comment " " $i
291 # if the "MPSAFE" keyword is found, note it and shift the line
294 for (i = 2; i <= NF; i++)
297 mpsafe = "SYF_MPSAFE | "
299 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "NOPROTO" \
302 if ((!nosys || funcname != "nosys") && \
303 (funcname != "lkmnosys")) {
304 if (argc != 0 && $2 != "NOARGS" && $2 != "NOPROTO") {
305 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
306 printf("struct\t%s {\n", argalias) > sysarg
307 printf("#ifdef _KERNEL\n") > sysarg
308 printf("\tstruct sysmsg sysmsg;\n") > sysarg
309 printf("#endif\n") > sysarg
310 for (i = 1; i <= argc; i++)
311 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
312 argtype[i], argname[i],
313 argname[i], argtype[i]) > sysarg
314 printf("};\n") > sysarg
316 else if ($2 != "NOARGS" && $2 != "NOPROTO" && \
318 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
319 printf("struct\t%s {\n", argalias) > sysarg
320 printf("#ifdef _KERNEL\n") > sysarg
321 printf("\tstruct sysmsg sysmsg;\n") > sysarg
322 printf("#endif\n") > sysarg
323 printf("\tregister_t dummy;\n") > sysarg
324 printf("};\n") > sysarg
327 if (($2 != "NOPROTO" && $2 != "NODEF" && \
328 (funcname != "nosys" || !nosys)) || \
329 (funcname == "lkmnosys" && !lkmnosys) || \
330 funcname == "lkmressys") {
331 printf("%s\tsys_%s (struct %s *)",
332 rettype, funcname, argalias) > sysdcl
333 printf(";\n") > sysdcl
335 if (funcname == "nosys")
337 if (funcname == "lkmnosys")
339 printf("\t{ %s%s, (sy_call_t *)", mpsafe, argssize) > sysent
340 column = 8 + 2 + length(mpsafe) + length(argssize) + 15
341 if ($2 != "NOIMPL") {
342 printf("sys_%s },", funcname) > sysent
343 column = column + length(funcname) + 7
345 printf("sys_%s },", "nosys") > sysent
346 column = column + length("nosys") + 7
348 align_sysent_comment(column)
349 printf("/* %d = %s */\n", syscall, funcalias) > sysent
350 printf("\t\"%s\",\t\t\t/* %d = %s */\n",
351 funcalias, syscall, funcalias) > sysnames
353 printf("#define\t%s%s\t%d\n", syscallprefix,
354 funcalias, syscall) > syshdr
355 printf(" \\\n\t%s.o", funcalias) > sysmk
358 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
362 $2 == "COMPAT" || $2 == "CPT_NOA" {
365 if (argc != 0 && $2 != "CPT_NOA") {
366 printf("#ifdef %s\n", compat) > sysun
367 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
368 printf("#endif\n") > sysun
369 printf("struct\t%s {\n", argalias) > syscompat
370 printf("#ifdef _KERNEL\n") > syscompat
371 printf("\tstruct sysmsg sysmsg;\n") > syscompat
372 printf("#endif\n") > syscompat
373 for (i = 1; i <= argc; i++)
374 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
375 argtype[i], argname[i],
376 argname[i], argtype[i]) > syscompat
377 printf("};\n") > syscompat
379 else if($2 != "CPT_NOA") {
380 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
381 printf("struct\t%s {\n", argalias) > sysarg
382 printf("#ifdef _KERNEL\n") > sysarg
383 printf("\tstruct sysmsg sysmsg;\n") > sysarg
384 printf("#endif\n") > sysarg
385 printf("\tregister_t dummy;\n") > sysarg
386 printf("};\n") > sysarg
388 printf("%s\tsys_o%s (struct %s *);\n",
389 rettype, funcname, argalias) > syscompatdcl
390 printf("\t{ compat(%s%s,%s) },",
391 mpsafe, argssize, funcname) > sysent
392 align_sysent_comment(8 + 9 + length(mpsafe) + \
393 length(argssize) + 1 + length(funcname) + 4)
394 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
395 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
396 funcalias, syscall, funcalias) > sysnames
397 printf("\t\t\t\t/* %d is old %s */\n",
398 syscall, funcalias) > syshdr
400 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
404 $2 == "COMPAT_DF12" {
408 printf("#ifdef %s\n", compatdf12) > sysun
409 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
410 printf("#endif\n") > sysun
411 printf("struct\t%s {\n", argalias) > syscompatdf12
412 printf("#ifdef _KERNEL\n") > syscompatdf12
413 printf("\tstruct sysmsg sysmsg;\n") > syscompatdf12
414 printf("#endif\n") > syscompatdf12
415 for (i = 1; i <= argc; i++)
416 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
417 argtype[i], argname[i],
418 argname[i], argtype[i]) > syscompatdf12
419 printf("};\n") > syscompatdf12
422 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
423 printf("struct\t%s {\n", argalias) > sysarg
424 printf("#ifdef _KERNEL\n") > sysarg
425 printf("\tstruct sysmsg sysmsg;\n") > sysarg
426 printf("#endif\n") > sysarg
427 printf("\tregister_t dummy;\n") > sysarg
428 printf("};\n") > sysarg
430 printf("%s\tsys_dfbsd12_%s (struct %s *);\n",
431 rettype, funcname, argalias) > syscompatdcldf12
432 printf("\t{ compatdf12(%s%s,%s) },",
433 mpsafe, argssize, funcname) > sysent
434 align_sysent_comment(8 + 9 + length(mpsafe) + \
435 length(argssize) + 1 + length(funcname) + 4)
436 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
437 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
438 funcalias, syscall, funcalias) > sysnames
439 printf("\t\t\t\t/* %d is old %s */\n",
440 syscall, funcalias) > syshdr
442 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
449 printf("%s\tsys_o%s();\n", rettype, funcname) > syscompatdcl
450 printf("\t{ compat(%s%s,%s) },",
451 mpsafe, argssize, funcname) > sysent
452 align_sysent_comment(8 + 9 + length(mpsafe) + \
453 length(argssize) + 1 + length(funcname) + 4)
454 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
455 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
456 funcalias, syscall, funcalias) > sysnames
457 printf("#define\t%s%s\t%d\t/* compatibility; still used by libc */\n",
458 syscallprefix, funcalias, syscall) > syshdr
459 printf(" \\\n\t%s.o", funcalias) > sysmk
461 printf("HIDE_%s(%s)\n", $3, funcname) > syshide
466 printf("\t{ 0, (sy_call_t *)sys_nosys },") > sysent
467 align_sysent_comment(37)
468 printf("/* %d = obsolete %s */\n", syscall, comment) > sysent
469 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n",
470 $4, syscall, comment) > sysnames
471 printf("\t\t\t\t/* %d is obsolete %s */\n",
472 syscall, comment) > syshdr
474 printf("HIDE_%s(%s)\n", $3, $4) > syshide
479 printf("\t{ 0, (sy_call_t *)sys_nosys },\t\t\t/* %d = %s */\n",
480 syscall, comment) > sysent
481 printf("\t\"#%d\",\t\t\t/* %d = %s */\n",
482 syscall, syscall, comment) > sysnames
484 printf("HIDE_%s(%s)\n", $3, $4) > syshide
489 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
493 printf "\n#define AS(name) ((sizeof(struct name) - sizeof(struct sysmsg)) / sizeof(register_t))\n" > sysinc
495 printf "#include \"opt_compat.h\"\n\n" > syssw
496 printf "\n#ifdef %s\n", compat > sysinc
497 printf "#define compat(n, name) n, (sy_call_t *)__CONCAT(sys_,__CONCAT(o,name))\n" > sysinc
498 printf "#else\n" > sysinc
499 printf "#define compat(n, name) 0, (sy_call_t *)sys_nosys\n" > sysinc
500 printf "#endif\n" > sysinc
503 if (ncompatdf12 != 0) {
504 printf "#include \"opt_compatdf12.h\"\n\n" > syssw
505 printf "\n#ifdef %s\n", compatdf12 > sysinc
506 printf "#define compatdf12(n, name) n, (sy_call_t *)__CONCAT(sys_,__CONCAT(dfbsd12_,name))\n" > sysinc
507 printf "#else\n" > sysinc
508 printf "#define compatdf12(n, name) 0, (sy_call_t *)sys_nosys\n" > sysinc
509 printf "#endif\n" > sysinc
512 printf("\n#endif /* _KERNEL */\n") > syscompatdcl
513 printf("\n#endif /* _KERNEL */\n") > syscompatdcldf12
514 printf("\n#endif /* %s */\n\n", compat) > syscompatdcl
515 printf("\n#endif /* %s */\n\n", compatdf12) > syscompatdcldf12
518 printf("};\n") > sysent
519 printf("};\n") > sysnames
520 printf("};\n") > sysun
521 printf("\n#endif /* !%s */\n", sysproto_h) > sysdcl
522 printf("#undef PAD_\n") > sysdcl
523 printf("\n#endif /* _KERNEL */\n") > sysdcl
524 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
528 cat $sysinc $sysent >> $syssw
529 cat $sysarg $syscompat $syscompatdcl $syscompatdf12 $syscompatdcldf12 $sysdcl > $sysproto
530 cat $sysun > $sysunion