Index: sys/kern/makesyscalls.sh =================================================================== --- sys/kern/makesyscalls.sh +++ sys/kern/makesyscalls.sh @@ -6,11 +6,7 @@ # name of compat options: compat=COMPAT_43 -compat4=COMPAT_FREEBSD4 -compat6=COMPAT_FREEBSD6 -compat7=COMPAT_FREEBSD7 -compat10=COMPAT_FREEBSD10 -compat11=COMPAT_FREEBSD11 +stdcompat="FREEBSD4 FREEBSD6 FREEBSD7 FREEBSD10 FREEBSD11" # output files: sysnames="syscalls.c" @@ -29,16 +25,71 @@ sysdcl="sysent.dcl.$$" syscompat="sysent.compat.$$" syscompatdcl="sysent.compatdcl.$$" -syscompat4="sysent.compat4.$$" -syscompat4dcl="sysent.compat4dcl.$$" -syscompat6="sysent.compat6.$$" -syscompat6dcl="sysent.compat6dcl.$$" -syscompat7="sysent.compat7.$$" -syscompat7dcl="sysent.compat7dcl.$$" -syscompat10="sysent.compat10.$$" -syscompat10dcl="sysent.compat10dcl.$$" -syscompat11="sysent.compat11.$$" -syscompat11dcl="sysent.compat11dcl.$$" +sysstdcompat="" +sysstdcompatdcl="" + +# The following generates all of the boilerplate awk that we use for every +# standard compat option after COMPAT_43. New COMPAT options should be added +# to stdcompat above. +section_compatdef="" +section_compatprint="" +section_compatalias="" +conditional_compatcheck="" +section_compatflagged="" +section_ncompat="" +section_finishdcl="" +cat_sysproto="" +for stdc in ${stdcompat}; do + lowprefix=$(echo $stdc | tr '[[:upper:]]' '[[:lower:]]') + compatflag=$(echo $stdc | sed 's/FREEBSD/COMPAT/') + lowcompat=$(echo $compatflag | tr '[[:upper:]]' '[[:lower:]]') + sysent="sysent.$stdc.$$" + sysentdcl="sysent.${stdc}cl.$$" + sysstdcompat="$sysstdcompat $sysent" + sysstdcompatdcl="$sysstdcompatdcl $sysentdcl" + cat_sysproto="$cat_sysproto $sysent $sysentdcl" + + section_compatdef="$section_compatdef + printf \"\\n#ifdef COMPAT_${stdc}\\n\\n\" > \"$sysent\"; + " + + section_compatprint="$section_compatprint + print > \"${sysent}\" + " + + section_compatalias="$section_compatalias + if (flag(\"$compatflag\")) + argalias = \"${lowprefix}_\" argalias + " + + if [ x"$conditional_compatcheck" != x"" ]; then + conditional_compatcheck="$conditional_compatcheck ||" + fi + conditional_compatcheck="$conditional_compatcheck type(\"$compatflag\")" + + section_compatflagged="$section_compatflagged else if (flag(\"$compatflag\")) { + n$lowcompat++ + out = \"$sysent\" + outdcl = \"$sysentdcl\" + wrap = \"$lowcompat\" + prefix = \"${lowprefix}_\" + descr = \"$lowprefix\" + }" + + section_ncompat="$section_ncompat + if (n$lowcompat != 0) { + printf \"\\n#ifdef COMPAT_$stdc\\n\" > sysinc + printf \"#define $lowcompat(n, name) n, (sy_call_t *)__CONCAT(${lowprefix}_,name)\\n\" > sysinc + printf \"#else\\n\" > sysinc + printf \"#define $lowcompat(n, name) 0, (sy_call_t *)nosys\\n\" > sysinc + printf \"#endif\\n\" > sysinc + }" + + section_finishdcl="$section_finishdcl + printf(\"\\n#endif /* COMPAT_$stdc */\\n\\n\") > \"$sysentdcl\" + " +done + sysent="sysent.switch.$$" sysinc="sysinc.switch.$$" sysarg="sysarg.switch.$$" @@ -47,9 +98,9 @@ systraceret="systraceret.$$" capabilities_conf="capabilities.conf" -trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 +trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $sysstdcompat $sysstdcompatdcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 -touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret +touch $sysaue $sysdcl $syscompat $syscompatdcl $sysstdcompat $sysstdcompatdcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret case $# in 0) echo "usage: $0 input-file " 1>&2 @@ -108,16 +159,6 @@ sysproto_h = \"$sysproto_h\" syscompat = \"$syscompat\" syscompatdcl = \"$syscompatdcl\" - syscompat4 = \"$syscompat4\" - syscompat4dcl = \"$syscompat4dcl\" - syscompat6 = \"$syscompat6\" - syscompat6dcl = \"$syscompat6dcl\" - syscompat7 = \"$syscompat7\" - syscompat7dcl = \"$syscompat7dcl\" - syscompat10 = \"$syscompat10\" - syscompat10dcl = \"$syscompat10dcl\" - syscompat11 = \"$syscompat11\" - syscompat11dcl = \"$syscompat11dcl\" sysent = \"$sysent\" syssw = \"$syssw\" sysinc = \"$sysinc\" @@ -129,11 +170,6 @@ systracetmp = \"$systracetmp\" systraceret = \"$systraceret\" compat = \"$compat\" - compat4 = \"$compat4\" - compat6 = \"$compat6\" - compat7 = \"$compat7\" - compat10 = \"$compat10\" - compat11 = \"$compat11\" syscallprefix = \"$syscallprefix\" switchname = \"$switchname\" namesname = \"$namesname\" @@ -183,11 +219,9 @@ printf "#endif\n\n" > sysarg printf "\n#ifdef %s\n\n", compat > syscompat - printf "\n#ifdef %s\n\n", compat4 > syscompat4 - printf "\n#ifdef %s\n\n", compat6 > syscompat6 - printf "\n#ifdef %s\n\n", compat7 > syscompat7 - printf "\n#ifdef %s\n\n", compat10 > syscompat10 - printf "\n#ifdef %s\n\n", compat11 > syscompat11 + '" + $section_compatdef + "' printf "/*\n * System call names.\n *\n" > sysnames printf " * DO NOT EDIT-- this file is automatically " generated ".\n" > sysnames @@ -234,11 +268,9 @@ print > sysdcl print > sysarg print > syscompat - print > syscompat4 - print > syscompat6 - print > syscompat7 - print > syscompat10 - print > syscompat11 + '" + $section_compatprint + "' print > sysnames print > systrace print > systracetmp @@ -251,11 +283,9 @@ print > sysdcl print > sysarg print > syscompat - print > syscompat4 - print > syscompat6 - print > syscompat7 - print > syscompat10 - print > syscompat11 + '" + $section_compatprint + "' print > sysnames print > systrace print > systracetmp @@ -268,11 +298,9 @@ print > sysdcl print > sysarg print > syscompat - print > syscompat4 - print > syscompat6 - print > syscompat7 - print > syscompat10 - print > syscompat11 + '" + $section_compatprint + "' print > sysnames print > systrace print > systracetmp @@ -399,16 +427,9 @@ argalias = funcname "_args" if (flag("COMPAT")) argalias = "o" argalias - if (flag("COMPAT4")) - argalias = "freebsd4_" argalias - if (flag("COMPAT6")) - argalias = "freebsd6_" argalias - if (flag("COMPAT7")) - argalias = "freebsd7_" argalias - if (flag("COMPAT10")) - argalias = "freebsd10_" argalias - if (flag("COMPAT11")) - argalias = "freebsd11_" argalias + '" + $section_compatalias + "' } f++ @@ -568,8 +589,7 @@ syscall++ next } - type("COMPAT") || type("COMPAT4") || type("COMPAT6") || \ - type("COMPAT7") || type("COMPAT10") || type("COMPAT11") { + type("COMPAT") || '" $conditional_compatcheck "' { if (flag("COMPAT")) { ncompat++ out = syscompat @@ -577,42 +597,7 @@ wrap = "compat" prefix = "o" descr = "old" - } else if (flag("COMPAT4")) { - ncompat4++ - out = syscompat4 - outdcl = syscompat4dcl - wrap = "compat4" - prefix = "freebsd4_" - descr = "freebsd4" - } else if (flag("COMPAT6")) { - ncompat6++ - out = syscompat6 - outdcl = syscompat6dcl - wrap = "compat6" - prefix = "freebsd6_" - descr = "freebsd6" - } else if (flag("COMPAT7")) { - ncompat7++ - out = syscompat7 - outdcl = syscompat7dcl - wrap = "compat7" - prefix = "freebsd7_" - descr = "freebsd7" - } else if (flag("COMPAT10")) { - ncompat10++ - out = syscompat10 - outdcl = syscompat10dcl - wrap = "compat10" - prefix = "freebsd10_" - descr = "freebsd10" - } else if (flag("COMPAT11")) { - ncompat11++ - out = syscompat11 - outdcl = syscompat11dcl - wrap = "compat11" - prefix = "freebsd11_" - descr = "freebsd11" - } + } '" $section_compatflagged "' parseline() if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \ !flag("NODEF")) { @@ -696,51 +681,12 @@ printf "#define compat(n, name) 0, (sy_call_t *)nosys\n" > sysinc printf "#endif\n" > sysinc } - - if (ncompat4 != 0) { - printf "\n#ifdef %s\n", compat4 > sysinc - printf "#define compat4(n, name) n, (sy_call_t *)__CONCAT(freebsd4_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat4(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - - if (ncompat6 != 0) { - printf "\n#ifdef %s\n", compat6 > sysinc - printf "#define compat6(n, name) n, (sy_call_t *)__CONCAT(freebsd6_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat6(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - - if (ncompat7 != 0) { - printf "\n#ifdef %s\n", compat7 > sysinc - printf "#define compat7(n, name) n, (sy_call_t *)__CONCAT(freebsd7_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat7(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - if (ncompat10 != 0) { - printf "\n#ifdef %s\n", compat10 > sysinc - printf "#define compat10(n, name) n, (sy_call_t *)__CONCAT(freebsd10_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat10(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - if (ncompat11 != 0) { - printf "\n#ifdef %s\n", compat11 > sysinc - printf "#define compat11(n, name) n, (sy_call_t *)__CONCAT(freebsd11_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat11(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } + '" $section_ncompat "' printf("\n#endif /* %s */\n\n", compat) > syscompatdcl - printf("\n#endif /* %s */\n\n", compat4) > syscompat4dcl - printf("\n#endif /* %s */\n\n", compat6) > syscompat6dcl - printf("\n#endif /* %s */\n\n", compat7) > syscompat7dcl - printf("\n#endif /* %s */\n\n", compat10) > syscompat10dcl - printf("\n#endif /* %s */\n\n", compat11) > syscompat11dcl + '" + $section_finishdcl + "' printf("\n#undef PAD_\n") > sysprotoend printf("#undef PADL_\n") > sysprotoend @@ -760,11 +706,7 @@ cat $sysinc $sysent >> $syssw cat $sysarg $sysdcl \ $syscompat $syscompatdcl \ - $syscompat4 $syscompat4dcl \ - $syscompat6 $syscompat6dcl \ - $syscompat7 $syscompat7dcl \ - $syscompat10 $syscompat10dcl \ - $syscompat11 $syscompat11dcl \ + $cat_sysproto \ $sysaue $sysprotoend > $sysproto cat $systracetmp >> $systrace cat $systraceret >> $systrace