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 $
9 sysproto
="../sys/sysproto.h"
10 sysunion
="../sys/sysunion.h"
11 sysproto_h
=_SYS_SYSPROTO_H_
12 syshdr
="../sys/syscall.h"
13 sysmk
="../sys/syscall.mk"
17 namesname
="syscallnames"
20 sysdcl
="sysent.dcl.$$"
21 syscompat
="sysent.compat.$$"
22 syscompatdcl
="sysent.compatdcl.$$"
23 sysent
="sysent.switch.$$"
24 sysinc
="sysinc.switch.$$"
25 sysarg
="sysarg.switch.$$"
26 sysun
="sysunion.switch.$$"
28 trap "rm $sysdcl $syscompat $syscompatdcl $sysent $sysinc $sysarg $sysun" 0
30 touch $sysdcl $syscompat $syscompatdcl $sysent $sysinc $sysarg $sysun
33 0) echo "Usage: $0 input-file <config-file>" 1>&2
38 if [ -n "$2" -a -f "$2" ]; then
52 /^#/!s/\([{}()*,]\)/ \1 /g
57 sysproto = \"$sysproto\"
58 sysproto_h = \"$sysproto_h\"
59 syscompat = \"$syscompat\"
60 syscompatdcl = \"$syscompatdcl\"
66 sysnames = \"$sysnames\"
70 syscallprefix = \"$syscallprefix\"
71 switchname = \"$switchname\"
72 namesname = \"$namesname\"
76 printf "/*\n * System call switch table.\n *\n" > syssw
77 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > syssw
78 printf " * by running make sysent in the same directory.\n" > syssw
79 printf " */\n\n" > syssw
81 printf "/*\n * System call prototypes.\n *\n" > sysarg
82 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysarg
83 printf " * by running make sysent in the same directory.\n" > sysarg
84 printf " */\n\n" > sysarg
85 printf "#ifndef %s\n", sysproto_h > sysarg
86 printf "#define\t%s\n\n", sysproto_h > sysarg
87 printf "#include <sys/select.h>\n\n" > sysarg
88 printf "#include <sys/signal.h>\n\n" > sysarg
89 printf "#include <sys/acl.h>\n\n" > sysarg
90 printf "#include <sys/msgport.h>\n\n" > sysarg
91 printf "#include <sys/sysmsg.h>\n\n" > sysarg
92 printf "#include <sys/procctl.h>\n\n" > sysarg
93 printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg
94 printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg
96 printf "/*\n * System call names.\n *\n" > sysnames
97 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysnames
98 printf " * by running make sysent in the same directory.\n" > sysnames
99 printf " */\n\n" > sysnames
100 printf "const char *%s[] = {\n", namesname > sysnames
102 printf "/*\n * System call numbers.\n *\n" > syshdr
103 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > syshdr
104 printf " * by running make sysent in the same directory.\n" > syshdr
105 printf " */\n\n" > syshdr
107 printf "# DragonFly system call names.\n" > sysmk
108 printf "# DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysmk
109 printf "# by running make sysent in the same directory.\n" > sysmk
110 printf "MIASM = " > sysmk
112 printf "/*\n * Union of syscall args for messaging.\n *\n" > sysun
113 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysun
114 printf " * by running make sysent in the same directory.\n" > sysun
115 printf " */\n\n" > sysun
116 printf "union sysunion {\n" > sysun
117 printf "#ifdef _KERNEL /* header only applies in kernel */\n" > sysun
118 printf "\tstruct\tlwkt_msg lmsg;\n" > sysun
119 printf "\tstruct\tsysmsg sysmsg;\n" > sysun
120 printf "#endif\n" > sysun
122 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
123 printf "struct sysent %s[] = {\n",switchname > sysent
125 printf "\n#ifdef _KERNEL\n\n" > sysdcl
126 printf "\n#ifdef _KERNEL\n\n" > syscompatdcl
128 NF == 0 || $1 ~ /^;/ {
131 $1 ~ /^#[ ]*include/ {
142 savesyscall = syscall
152 syscall = savesyscall
165 printf "%s: line %d: syscall number out of sync at %d\n",
171 function align_sysent_comment(column) {
172 printf("\t") > sysent
173 column = column + 8 - column % 8
174 while (column < 56) {
175 printf("\t") > sysent
179 function parserr(was, wanted) {
180 printf "%s: line %d: unexpected %s (expected %s)\n",
181 infile, NR, was, wanted
184 function parseline() {
185 f=3 # toss number and type
201 argssize = "AS(" $5 ")"
217 f++ #function return type
223 if (argalias == "") {
224 argalias = funcname "_args"
225 if ($2 == "COMPAT") {
226 argalias = "o" argalias
227 usefuncname = "sys_o" funcname
238 parserr($f, "argument definition")
246 while (f < end && $(f+1) != ",") {
247 if (argtype[argc] != "" && oldf != "*")
248 argtype[argc] = argtype[argc]" ";
249 argtype[argc] = argtype[argc]$f;
253 if (argtype[argc] == "")
254 parserr($f, "argument definition")
256 f += 2; # skip name, and any comma
259 argssize = "AS(" argalias ")"
263 for (i = 4; i <= NF; i++)
264 comment = comment " " $i
266 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "NOPROTO" \
269 if ((!nosys || funcname != "nosys") && \
270 (funcname != "lkmnosys")) {
271 if (argc != 0 && $2 != "NOARGS" && $2 != "NOPROTO") {
272 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
273 printf("struct\t%s {\n", argalias) > sysarg
274 printf("#ifdef _KERNEL\n") > sysarg
275 printf("\tstruct sysmsg sysmsg;\n") > sysarg
276 printf("#endif\n") > sysarg
277 for (i = 1; i <= argc; i++)
278 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
279 argtype[i], argname[i],
280 argname[i], argtype[i]) > sysarg
281 printf("};\n") > sysarg
283 else if ($2 != "NOARGS" && $2 != "NOPROTO" && \
285 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
286 printf("struct\t%s {\n", argalias) > sysarg
287 printf("#ifdef _KERNEL\n") > sysarg
288 printf("\tstruct sysmsg sysmsg;\n") > sysarg
289 printf("#endif\n") > sysarg
290 printf("\tregister_t dummy;\n") > sysarg
291 printf("};\n") > sysarg
294 if (($2 != "NOPROTO" && $2 != "NODEF" && \
295 (funcname != "nosys" || !nosys)) || \
296 (funcname == "lkmnosys" && !lkmnosys) || \
297 funcname == "lkmressys") {
298 printf("%s\tsys_%s (struct %s *)",
299 rettype, funcname, argalias) > sysdcl
300 printf(";\n") > sysdcl
302 if (funcname == "nosys")
304 if (funcname == "lkmnosys")
306 printf("\t{ %s, (sy_call_t *)", argssize) > sysent
307 column = 8 + 2 + length(argssize) + 15
308 if ($2 != "NOIMPL") {
309 printf("sys_%s },", funcname) > sysent
310 column = column + length(funcname) + 7
312 printf("sys_%s },", "nosys") > sysent
313 column = column + length("nosys") + 7
315 align_sysent_comment(column)
316 printf("/* %d = %s */\n", syscall, funcalias) > sysent
317 printf("\t\"%s\",\t\t\t/* %d = %s */\n",
318 funcalias, syscall, funcalias) > sysnames
320 printf("#define\t%s%s\t%d\n", syscallprefix,
321 funcalias, syscall) > syshdr
322 printf(" \\\n\t%s.o", funcalias) > sysmk
327 $2 == "COMPAT" || $2 == "CPT_NOA" {
330 if (argc != 0 && $2 != "CPT_NOA") {
331 printf("struct\t%s {\n", argalias) > syscompat
332 printf("#ifdef _KERNEL\n") > syscompat
333 printf("\tstruct sysmsg sysmsg;\n") > syscompat
334 printf("#endif\n") > syscompat
335 for (i = 1; i <= argc; i++)
336 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
337 argtype[i], argname[i],
338 argname[i], argtype[i]) > syscompat
339 printf("};\n") > syscompat
341 else if($2 != "CPT_NOA") {
342 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
343 printf("struct\t%s {\n", argalias) > sysarg
344 printf("#ifdef _KERNEL\n") > sysarg
345 printf("\tstruct sysmsg sysmsg;\n") > sysarg
346 printf("#endif\n") > sysarg
347 printf("\tregister_t dummy;\n") > sysarg
348 printf("};\n") > sysarg
350 printf("%s\tsys_o%s (struct %s *);\n",
351 rettype, funcname, argalias) > syscompatdcl
352 printf("\t{ compat(%s,%s) },",
353 argssize, funcname) > sysent
354 align_sysent_comment(8 + 9 + \
355 length(argssize) + 1 + length(funcname) + 4)
356 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
357 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
358 funcalias, syscall, funcalias) > sysnames
359 printf("\t\t\t\t/* %d is old %s */\n",
360 syscall, funcalias) > syshdr
367 printf("%s\tsys_o%s();\n", rettype, funcname) > syscompatdcl
368 printf("\t{ compat(%s,%s) },",
369 argssize, funcname) > sysent
370 align_sysent_comment(8 + 9 + \
371 length(argssize) + 1 + length(funcname) + 4)
372 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
373 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
374 funcalias, syscall, funcalias) > sysnames
375 printf("#define\t%s%s\t%d\t/* compatibility; still used by libc */\n",
376 syscallprefix, funcalias, syscall) > syshdr
377 printf(" \\\n\t%s.o", funcalias) > sysmk
382 printf("\t{ 0, (sy_call_t *)sys_nosys },") > sysent
383 align_sysent_comment(37)
384 printf("/* %d = obsolete %s */\n", syscall, comment) > sysent
385 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n",
386 $3, syscall, comment) > sysnames
387 printf("\t\t\t\t/* %d is obsolete %s */\n",
388 syscall, comment) > syshdr
393 printf("\t{ 0, (sy_call_t *)sys_nosys },\t\t\t/* %d = %s */\n",
394 syscall, comment) > sysent
395 printf("\t\"#%d\",\t\t\t/* %d = %s */\n",
396 syscall, syscall, comment) > sysnames
401 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
405 printf "\n#define AS(name) ((sizeof(struct name) - sizeof(struct sysmsg)) / sizeof(register_t))\n" > sysinc
407 printf "#define compat(n, name) 0, (sy_call_t *)sys_nosys\n" > sysinc
409 printf("\n#endif /* _KERNEL */\n") > syscompatdcl
412 printf("};\n") > sysent
413 printf("};\n") > sysnames
414 printf("};\n") > sysun
415 printf("\n#endif /* !%s */\n", sysproto_h) > sysdcl
416 printf("#undef PAD_\n") > sysdcl
417 printf("\n#endif /* _KERNEL */\n") > sysdcl
418 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
422 cat $sysinc $sysent >> $syssw
423 cat $sysarg $syscompat $syscompatdcl $sysdcl > $sysproto
424 cat $sysun > $sysunion