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" > sysarg
88 printf "#include <sys/signal.h>\n" > sysarg
89 printf "#include <sys/acl.h>\n" > sysarg
90 printf "#include <sys/cpumask.h>\n" > sysarg
91 printf "#include <sys/mqueue.h>\n" > sysarg
92 printf "#include <sys/msgport.h>\n" > sysarg
93 printf "#include <sys/sysmsg.h>\n" > sysarg
94 printf "#include <sys/procctl.h>\n\n" > sysarg
95 printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg
96 printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg
98 printf "/*\n * System call names.\n *\n" > sysnames
99 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysnames
100 printf " * by running make sysent in the same directory.\n" > sysnames
101 printf " */\n\n" > sysnames
102 printf "const char *%s[] = {\n", namesname > sysnames
104 printf "/*\n * System call numbers.\n *\n" > syshdr
105 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > syshdr
106 printf " * by running make sysent in the same directory.\n" > syshdr
107 printf " */\n\n" > syshdr
109 printf "# DragonFly system call names.\n" > sysmk
110 printf "# DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysmk
111 printf "# by running make sysent in the same directory.\n" > sysmk
112 printf "MIASM = " > sysmk
114 printf "/*\n * Union of syscall args for messaging.\n *\n" > sysun
115 printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysun
116 printf " * by running make sysent in the same directory.\n" > sysun
117 printf " */\n\n" > sysun
118 printf "union sysunion {\n" > sysun
119 printf "#ifdef _KERNEL /* header only applies in kernel */\n" > sysun
120 #printf "\tstruct\tlwkt_msg lmsg;\n" > sysun
121 printf "\tstruct\tsysmsg sysmsg;\n" > sysun
122 printf "#endif\n" > sysun
124 printf "\n/* The casts are bogus but will do for now. */\n" > sysent
125 printf "struct sysent %s[] = {\n",switchname > sysent
127 printf "\n#ifdef _KERNEL\n\n" > sysdcl
128 printf "\n#ifdef _KERNEL\n\n" > syscompatdcl
130 NF == 0 || $1 ~ /^;/ {
133 $1 ~ /^#[ ]*include/ {
144 savesyscall = syscall
154 syscall = savesyscall
167 printf "%s: line %d: syscall number out of sync at %d\n",
173 function align_sysent_comment(column) {
174 printf("\t") > sysent
175 column = column + 8 - column % 8
176 while (column < 56) {
177 printf("\t") > sysent
181 function parserr(was, wanted) {
182 printf "%s: line %d: unexpected %s (expected %s)\n",
183 infile, NR, was, wanted
186 function parseline() {
187 f=3 # toss number and type
203 argssize = "AS(" $5 ")"
219 f++ #function return type
225 if (argalias == "") {
226 argalias = funcname "_args"
227 if ($2 == "COMPAT") {
228 argalias = "o" argalias
229 usefuncname = "sys_o" funcname
240 parserr($f, "argument definition")
248 while (f < end && $(f+1) != ",") {
249 if (argtype[argc] != "" && oldf != "*")
250 argtype[argc] = argtype[argc]" ";
251 argtype[argc] = argtype[argc]$f;
255 if (argtype[argc] == "")
256 parserr($f, "argument definition")
258 f += 2; # skip name, and any comma
261 argssize = "AS(" argalias ")"
265 for (i = 4; i <= NF; i++)
266 comment = comment " " $i
268 $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "NOPROTO" \
271 if ((!nosys || funcname != "nosys") && \
272 (funcname != "lkmnosys")) {
273 if (argc != 0 && $2 != "NOARGS" && $2 != "NOPROTO") {
274 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
275 printf("struct\t%s {\n", argalias) > sysarg
276 printf("#ifdef _KERNEL\n") > sysarg
277 printf("\tstruct sysmsg sysmsg;\n") > sysarg
278 printf("#endif\n") > sysarg
279 for (i = 1; i <= argc; i++)
280 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
281 argtype[i], argname[i],
282 argname[i], argtype[i]) > sysarg
283 printf("};\n") > sysarg
285 else if ($2 != "NOARGS" && $2 != "NOPROTO" && \
287 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
288 printf("struct\t%s {\n", argalias) > sysarg
289 printf("#ifdef _KERNEL\n") > sysarg
290 printf("\tstruct sysmsg sysmsg;\n") > sysarg
291 printf("#endif\n") > sysarg
292 printf("\tregister_t dummy;\n") > sysarg
293 printf("};\n") > sysarg
296 if (($2 != "NOPROTO" && $2 != "NODEF" && \
297 (funcname != "nosys" || !nosys)) || \
298 (funcname == "lkmnosys" && !lkmnosys) || \
299 funcname == "lkmressys") {
300 printf("%s\tsys_%s (struct %s *)",
301 rettype, funcname, argalias) > sysdcl
302 printf(";\n") > sysdcl
304 if (funcname == "nosys")
306 if (funcname == "lkmnosys")
308 printf("\t{ %s, (sy_call_t *)", argssize) > sysent
309 column = 8 + 2 + length(argssize) + 15
310 if ($2 != "NOIMPL") {
311 printf("sys_%s },", funcname) > sysent
312 column = column + length(funcname) + 7
314 printf("sys_%s },", "nosys") > sysent
315 column = column + length("nosys") + 7
317 align_sysent_comment(column)
318 printf("/* %d = %s */\n", syscall, funcalias) > sysent
319 printf("\t\"%s\",\t\t\t/* %d = %s */\n",
320 funcalias, syscall, funcalias) > sysnames
322 printf("#define\t%s%s\t%d\n", syscallprefix,
323 funcalias, syscall) > syshdr
324 printf(" \\\n\t%s.o", funcalias) > sysmk
329 $2 == "COMPAT" || $2 == "CPT_NOA" {
332 if (argc != 0 && $2 != "CPT_NOA") {
333 printf("struct\t%s {\n", argalias) > syscompat
334 printf("#ifdef _KERNEL\n") > syscompat
335 printf("\tstruct sysmsg sysmsg;\n") > syscompat
336 printf("#endif\n") > syscompat
337 for (i = 1; i <= argc; i++)
338 printf("\t%s\t%s;\tchar %s_[PAD_(%s)];\n",
339 argtype[i], argname[i],
340 argname[i], argtype[i]) > syscompat
341 printf("};\n") > syscompat
343 else if($2 != "CPT_NOA") {
344 printf("\tstruct\t%s %s;\n", argalias, usefuncname) > sysun
345 printf("struct\t%s {\n", argalias) > sysarg
346 printf("#ifdef _KERNEL\n") > sysarg
347 printf("\tstruct sysmsg sysmsg;\n") > sysarg
348 printf("#endif\n") > sysarg
349 printf("\tregister_t dummy;\n") > sysarg
350 printf("};\n") > sysarg
352 printf("%s\tsys_o%s (struct %s *);\n",
353 rettype, funcname, argalias) > syscompatdcl
354 printf("\t{ compat(%s,%s) },",
355 argssize, funcname) > sysent
356 align_sysent_comment(8 + 9 + \
357 length(argssize) + 1 + length(funcname) + 4)
358 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
359 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
360 funcalias, syscall, funcalias) > sysnames
361 printf("\t\t\t\t/* %d is old %s */\n",
362 syscall, funcalias) > syshdr
369 printf("%s\tsys_o%s();\n", rettype, funcname) > syscompatdcl
370 printf("\t{ compat(%s,%s) },",
371 argssize, funcname) > sysent
372 align_sysent_comment(8 + 9 + \
373 length(argssize) + 1 + length(funcname) + 4)
374 printf("/* %d = old %s */\n", syscall, funcalias) > sysent
375 printf("\t\"old.%s\",\t\t/* %d = old %s */\n",
376 funcalias, syscall, funcalias) > sysnames
377 printf("#define\t%s%s\t%d\t/* compatibility; still used by libc */\n",
378 syscallprefix, funcalias, syscall) > syshdr
379 printf(" \\\n\t%s.o", funcalias) > sysmk
384 printf("\t{ 0, (sy_call_t *)sys_nosys },") > sysent
385 align_sysent_comment(37)
386 printf("/* %d = obsolete %s */\n", syscall, comment) > sysent
387 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n",
388 $3, syscall, comment) > sysnames
389 printf("\t\t\t\t/* %d is obsolete %s */\n",
390 syscall, comment) > syshdr
395 printf("\t{ 0, (sy_call_t *)sys_nosys },\t\t\t/* %d = %s */\n",
396 syscall, comment) > sysent
397 printf("\t\"#%d\",\t\t\t/* %d = %s */\n",
398 syscall, syscall, comment) > sysnames
403 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
407 printf "\n#define AS(name) ((sizeof(struct name) - sizeof(struct sysmsg)) / sizeof(register_t))\n" > sysinc
409 printf "#define compat(n, name) 0, (sy_call_t *)sys_nosys\n" > sysinc
411 printf("\n#endif /* _KERNEL */\n") > syscompatdcl
414 printf("};\n") > sysent
415 printf("};\n") > sysnames
416 printf("};\n") > sysun
417 printf("\n#endif /* !%s */\n", sysproto_h) > sysdcl
418 printf("#undef PAD_\n") > sysdcl
419 printf("\n#endif /* _KERNEL */\n") > sysdcl
420 printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \
424 cat $sysinc $sysent >> $syssw
425 cat $sysarg $syscompat $syscompatdcl $sysdcl > $sysproto
426 cat $sysun > $sysunion