| @@ -1,1085 +1,1091 @@ | | | @@ -1,1085 +1,1091 @@ |
1 | # $NetBSD: makesyscalls.sh,v 1.171 2018/08/26 11:48:00 kre Exp $ | | 1 | # $NetBSD: makesyscalls.sh,v 1.172 2018/08/26 11:53:28 kre Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou | | 3 | # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # Redistribution and use in source and binary forms, with or without | | 6 | # Redistribution and use in source and binary forms, with or without |
7 | # modification, are permitted provided that the following conditions | | 7 | # modification, are permitted provided that the following conditions |
8 | # are met: | | 8 | # are met: |
9 | # 1. Redistributions of source code must retain the above copyright | | 9 | # 1. Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. | | 10 | # notice, this list of conditions and the following disclaimer. |
11 | # 2. Redistributions in binary form must reproduce the above copyright | | 11 | # 2. Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the | | 12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. | | 13 | # documentation and/or other materials provided with the distribution. |
14 | # 3. All advertising materials mentioning features or use of this software | | 14 | # 3. All advertising materials mentioning features or use of this software |
15 | # must display the following acknowledgement: | | 15 | # must display the following acknowledgement: |
16 | # This product includes software developed for the NetBSD Project | | 16 | # This product includes software developed for the NetBSD Project |
17 | # by Christopher G. Demetriou. | | 17 | # by Christopher G. Demetriou. |
18 | # 4. The name of the author may not be used to endorse or promote products | | 18 | # 4. The name of the author may not be used to endorse or promote products |
19 | # derived from this software without specific prior written permission | | 19 | # derived from this software without specific prior written permission |
20 | # | | 20 | # |
21 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 21 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
22 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 22 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
23 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 23 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
24 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 24 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
26 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 26 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
30 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | | | 31 | |
32 | # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93 | | 32 | # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93 |
33 | | | 33 | |
34 | set -e | | 34 | set -e |
35 | | | 35 | |
36 | case $# in | | 36 | case $# in |
37 | 2) ;; | | 37 | 2) ;; |
38 | *) echo "Usage: $0 config-file input-file" 1>&2 | | 38 | *) echo "Usage: $0 config-file input-file" 1>&2 |
39 | exit 1 | | 39 | exit 1 |
40 | ;; | | 40 | ;; |
41 | esac | | 41 | esac |
42 | | | 42 | |
43 | # the config file sets the following variables: | | 43 | # the config file sets the following variables: |
44 | # sysalign check for alignment of off_t/dev_t/time_t | | 44 | # sysalign check for alignment of off_t/dev_t/time_t |
45 | # sysnames the syscall names file | | 45 | # sysnames the syscall names file |
46 | # sysnumhdr the syscall numbers file | | 46 | # sysnumhdr the syscall numbers file |
47 | # syssw the syscall switch file | | 47 | # syssw the syscall switch file |
48 | # sysautoload the syscall autoload definitions file | | 48 | # sysautoload the syscall autoload definitions file |
49 | # sysarghdr the syscall argument struct definitions | | 49 | # sysarghdr the syscall argument struct definitions |
50 | # compatopts those syscall types that are for 'compat' syscalls | | 50 | # compatopts those syscall types that are for 'compat' syscalls |
51 | # switchname the name for the 'struct sysent' we define | | 51 | # switchname the name for the 'struct sysent' we define |
52 | # namesname the name for the 'const char *[]' we define | | 52 | # namesname the name for the 'const char *[]' we define |
53 | # constprefix the prefix for the system call constants | | 53 | # constprefix the prefix for the system call constants |
54 | # emulname the emulation name | | 54 | # emulname the emulation name |
55 | # registertype the type for register_t | | 55 | # registertype the type for register_t |
56 | # nsysent the size of the sysent table | | 56 | # nsysent the size of the sysent table |
57 | # sys_nosys [optional] name of function called for unsupported | | 57 | # sys_nosys [optional] name of function called for unsupported |
58 | # syscalls, if not sys_nosys() | | 58 | # syscalls, if not sys_nosys() |
59 | # maxsysargs [optiona] the maximum number or arguments | | 59 | # maxsysargs [optiona] the maximum number or arguments |
60 | # | | 60 | # |
61 | # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'. | | 61 | # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'SYSLIBCOMPAT'. |
62 | | | 62 | |
63 | # source the config file. | | 63 | # source the config file. |
64 | sys_nosys="sys_nosys" # default is sys_nosys(), if not specified otherwise | | 64 | sys_nosys="sys_nosys" # default is sys_nosys(), if not specified otherwise |
65 | maxsysargs=8 # default limit is 8 (32bit) arguments | | 65 | maxsysargs=8 # default limit is 8 (32bit) arguments |
66 | systrace="/dev/null" | | 66 | systrace="/dev/null" |
67 | sysautoload="/dev/null" | | 67 | sysautoload="/dev/null" |
68 | rumpcalls="/dev/null" | | 68 | rumpcalls="/dev/null" |
69 | rumpcallshdr="/dev/null" | | 69 | rumpcallshdr="/dev/null" |
70 | rumpsysmap="/dev/null" | | 70 | rumpsysmap="/dev/null" |
71 | rumpsysent="rumpsysent.tmp" | | 71 | rumpsysent="rumpsysent.tmp" |
72 | rumpnoflags="\n\t\t.sy_flags = SYCALL_NOSYS," | | 72 | rumpnoflags="\n\t\t.sy_flags = SYCALL_NOSYS," |
73 | rumpnosys="(sy_call_t *)rumpns_enosys" | | 73 | rumpnosys="(sy_call_t *)rumpns_enosys" |
74 | rumpnomodule="(sy_call_t *)rumpns_sys_nomodule" | | 74 | rumpnomodule="(sy_call_t *)rumpns_sys_nomodule" |
75 | | | 75 | |
76 | case $1 in | | 76 | case $1 in |
77 | /*) . $1;; | | 77 | /*) . $1;; |
78 | *) . ./$1;; | | 78 | *) . ./$1;; |
79 | esac | | 79 | esac |
80 | | | 80 | |
| | | 81 | errmsg() |
| | | 82 | { |
| | | 83 | fail=true; |
| | | 84 | printf '%s: %s\n' "$0" "$*" >&2 |
| | | 85 | } |
| | | 86 | |
81 | fail=false | | 87 | fail=false |
82 | case "${nsysent:-0}" in | | 88 | case "${nsysent:-0}" in |
83 | *[!0-9]*) fail=true; printf >&2 '%s\n' "Non numeric value for nsysent";; | | 89 | *[!0-9]*) errmsg "Non numeric value for nsysent:" "${nsysent}";; |
84 | esac | | 90 | esac |
85 | case "${maxsysargs:-0}" in | | 91 | case "${maxsysargs:-0}" in |
86 | *[!0-9]*) fail=true; printf >&2 '%s\n' "Non numeric value for maxsysargs";; | | 92 | *[!0-9]*) errmsg "Non numeric value for maxsysargs:" "${maxsysargs}";; |
87 | esac | | 93 | esac |
88 | $fail && exit 1 | | 94 | $fail && exit 1 |
89 | | | 95 | |
90 | # tmp files: | | 96 | # tmp files: |
91 | sysdcl="sysent.dcl" | | 97 | sysdcl="sysent.dcl" |
92 | sysprotos="sys.protos" | | 98 | sysprotos="sys.protos" |
93 | syscompat_pref="sysent." | | 99 | syscompat_pref="sysent." |
94 | sysent="sysent.switch" | | 100 | sysent="sysent.switch" |
95 | sysnamesbottom="$sysnames.bottom" | | 101 | sysnamesbottom="$sysnames.bottom" |
96 | sysnamesfriendly="$sysnames.friendly" | | 102 | sysnamesfriendly="$sysnames.friendly" |
97 | rumptypes="rumphdr.types" | | 103 | rumptypes="rumphdr.types" |
98 | rumpprotos="rumphdr.protos" | | 104 | rumpprotos="rumphdr.protos" |
99 | systracetmp="systrace.$$" | | 105 | systracetmp="systrace.$$" |
100 | systraceret="systraceret.$$" | | 106 | systraceret="systraceret.$$" |
101 | | | 107 | |
102 | cleanup() { | | 108 | cleanup() { |
103 | rm $sysdcl $sysprotos $sysent $sysnamesbottom $sysnamesfriendly $rumpsysent $rumptypes $rumpprotos $systracetmp $systraceret | | 109 | rm $sysdcl $sysprotos $sysent $sysnamesbottom $sysnamesfriendly $rumpsysent $rumptypes $rumpprotos $systracetmp $systraceret |
104 | } | | 110 | } |
105 | trap "cleanup" 0 | | 111 | trap "cleanup" 0 |
106 | | | 112 | |
107 | # Awk program (must support nawk extensions) | | 113 | # Awk program (must support nawk extensions) |
108 | # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere. | | 114 | # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere. |
109 | awk=${AWK:-awk} | | 115 | awk=${AWK:-awk} |
110 | | | 116 | |
111 | # Does this awk have a "toupper" function? | | 117 | # Does this awk have a "toupper" function? |
112 | have_toupper="$($awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null)" | | 118 | have_toupper="$($awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null)" |
113 | | | 119 | |
114 | # If this awk does not define "toupper" then define our own. | | 120 | # If this awk does not define "toupper" then define our own. |
115 | if [ "$have_toupper" = TRUE ] ; then | | 121 | if [ "$have_toupper" = TRUE ] ; then |
116 | # Used awk (GNU awk or nawk) provides it | | 122 | # Used awk (GNU awk or nawk) provides it |
117 | toupper= | | 123 | toupper= |
118 | else | | 124 | else |
119 | # Provide our own toupper() | | 125 | # Provide our own toupper() |
120 | toupper=' | | 126 | toupper=' |
121 | function toupper(str) { | | 127 | function toupper(str) { |
122 | _toupper_cmd = "echo "str" |tr a-z A-Z" | | 128 | _toupper_cmd = "echo "str" |tr a-z A-Z" |
123 | _toupper_cmd | getline _toupper_str; | | 129 | _toupper_cmd | getline _toupper_str; |
124 | close(_toupper_cmd); | | 130 | close(_toupper_cmd); |
125 | return _toupper_str; | | 131 | return _toupper_str; |
126 | }' | | 132 | }' |
127 | fi | | 133 | fi |
128 | | | 134 | |
129 | # before handing it off to awk, make a few adjustments: | | 135 | # before handing it off to awk, make a few adjustments: |
130 | # (1) insert spaces around {, }, (, ), *, and commas. | | 136 | # (1) insert spaces around {, }, (, ), *, and commas. |
131 | # (2) get rid of any and all dollar signs (so that rcs id use safe) | | 137 | # (2) get rid of any and all dollar signs (so that rcs id use safe) |
132 | # | | 138 | # |
133 | # The awk script will deal with blank lines and lines that | | 139 | # The awk script will deal with blank lines and lines that |
134 | # start with the comment character (';'). | | 140 | # start with the comment character (';'). |
135 | | | 141 | |
136 | sed -e ' | | 142 | sed -e ' |
137 | s/\$//g | | 143 | s/\$//g |
138 | :join | | 144 | :join |
139 | /\\$/{a\ | | 145 | /\\$/{a\ |
140 | | | 146 | |
141 | N | | 147 | N |
142 | s/\\\n// | | 148 | s/\\\n// |
143 | b join | | 149 | b join |
144 | } | | 150 | } |
145 | 2,${ | | 151 | 2,${ |
146 | /^#/!s/\([{}()*,|]\)/ \1 /g | | 152 | /^#/!s/\([{}()*,|]\)/ \1 /g |
147 | } | | 153 | } |
148 | ' < $2 | $awk " | | 154 | ' < $2 | $awk " |
149 | $toupper | | 155 | $toupper |
150 | BEGIN { | | 156 | BEGIN { |
151 | # Create a NetBSD tag that does not get expanded when checking | | 157 | # Create a NetBSD tag that does not get expanded when checking |
152 | # this script out of CVS. (This part of the awk script is in a | | 158 | # this script out of CVS. (This part of the awk script is in a |
153 | # shell double-quoted string, so the backslashes are eaten by | | 159 | # shell double-quoted string, so the backslashes are eaten by |
154 | # the shell.) | | 160 | # the shell.) |
155 | tag = \"\$\" \"NetBSD\" \"\$\" | | 161 | tag = \"\$\" \"NetBSD\" \"\$\" |
156 | | | 162 | |
157 | # to allow nested #if/#else/#endif sets | | 163 | # to allow nested #if/#else/#endif sets |
158 | savedepth = 0 | | 164 | savedepth = 0 |
159 | auto_skip = 0 | | 165 | auto_skip = 0 |
160 | # to track already processed syscalls | | 166 | # to track already processed syscalls |
161 | | | 167 | |
162 | sysnames = \"$sysnames\" | | 168 | sysnames = \"$sysnames\" |
163 | sysprotos = \"$sysprotos\" | | 169 | sysprotos = \"$sysprotos\" |
164 | sysnumhdr = \"$sysnumhdr\" | | 170 | sysnumhdr = \"$sysnumhdr\" |
165 | sysarghdr = \"$sysarghdr\" | | 171 | sysarghdr = \"$sysarghdr\" |
166 | sysarghdrextra = \"$sysarghdrextra\" | | 172 | sysarghdrextra = \"$sysarghdrextra\" |
167 | systrace = \"$systrace\" | | 173 | systrace = \"$systrace\" |
168 | systracetmp = \"$systracetmp\" | | 174 | systracetmp = \"$systracetmp\" |
169 | systraceret = \"$systraceret\" | | 175 | systraceret = \"$systraceret\" |
170 | sysautoload = \"$sysautoload\" | | 176 | sysautoload = \"$sysautoload\" |
171 | rumpcalls = \"$rumpcalls\" | | 177 | rumpcalls = \"$rumpcalls\" |
172 | rumpcallshdr = \"$rumpcallshdr\" | | 178 | rumpcallshdr = \"$rumpcallshdr\" |
173 | rumpsysent = \"$rumpsysent\" | | 179 | rumpsysent = \"$rumpsysent\" |
174 | rumpsysmap = \"$rumpsysmap\" | | 180 | rumpsysmap = \"$rumpsysmap\" |
175 | switchname = \"$switchname\" | | 181 | switchname = \"$switchname\" |
176 | namesname = \"$namesname\" | | 182 | namesname = \"$namesname\" |
177 | constprefix = \"$constprefix\" | | 183 | constprefix = \"$constprefix\" |
178 | emulname = \"$emulname\" | | 184 | emulname = \"$emulname\" |
179 | registertype = \"$registertype\" | | 185 | registertype = \"$registertype\" |
180 | sysalign=\"$sysalign\" | | 186 | sysalign=\"$sysalign\" |
181 | if (!registertype) { | | 187 | if (!registertype) { |
182 | registertype = \"register_t\" | | 188 | registertype = \"register_t\" |
183 | } | | 189 | } |
184 | nsysent = ${nsysent:-0} | | 190 | nsysent = ${nsysent:-0} |
185 | | | 191 | |
186 | sysdcl = \"$sysdcl\" | | 192 | sysdcl = \"$sysdcl\" |
187 | syscompat_pref = \"$syscompat_pref\" | | 193 | syscompat_pref = \"$syscompat_pref\" |
188 | sysent = \"$sysent\" | | 194 | sysent = \"$sysent\" |
189 | sysnamesbottom = \"${sysnames}.bottom\" | | 195 | sysnamesbottom = \"${sysnames}.bottom\" |
190 | sysnamesfriendly = \"${sysnames}.friendly\" | | 196 | sysnamesfriendly = \"${sysnames}.friendly\" |
191 | rumpprotos = \"$rumpprotos\" | | 197 | rumpprotos = \"$rumpprotos\" |
192 | rumptypes = \"$rumptypes\" | | 198 | rumptypes = \"$rumptypes\" |
193 | sys_nosys = \"$sys_nosys\" | | 199 | sys_nosys = \"$sys_nosys\" |
194 | maxsysargs = ${maxsysargs:-8} | | 200 | maxsysargs = ${maxsysargs:-8} |
195 | rumpnoflags=\"$rumpnoflags\" | | 201 | rumpnoflags=\"$rumpnoflags\" |
196 | rumpnosys=\"$rumpnosys\" | | 202 | rumpnosys=\"$rumpnosys\" |
197 | rumpnomodule=\"$rumpnomodule\" | | 203 | rumpnomodule=\"$rumpnomodule\" |
198 | infile = \"$2\" | | 204 | infile = \"$2\" |
199 | | | 205 | |
200 | compatopts = \"$compatopts\" | | 206 | compatopts = \"$compatopts\" |
201 | "' | | 207 | "' |
202 | | | 208 | |
203 | if (rumpcalls != "/dev/null") | | 209 | if (rumpcalls != "/dev/null") |
204 | haverumpcalls = 1 | | 210 | haverumpcalls = 1 |
205 | | | 211 | |
206 | printf "/* %s */\n\n", tag > sysdcl | | 212 | printf "/* %s */\n\n", tag > sysdcl |
207 | printf "/*\n * System call switch table.\n *\n" > sysdcl | | 213 | printf "/*\n * System call switch table.\n *\n" > sysdcl |
208 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl | | 214 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl |
209 | | | 215 | |
210 | ncompat = split(compatopts,compat) | | 216 | ncompat = split(compatopts,compat) |
211 | for (i = 1; i <= ncompat; i++) { | | 217 | for (i = 1; i <= ncompat; i++) { |
212 | compat_upper[i] = toupper(compat[i]) | | 218 | compat_upper[i] = toupper(compat[i]) |
213 | | | 219 | |
214 | printf "\n#ifdef %s\n", compat_upper[i] > sysent | | 220 | printf "\n#ifdef %s\n", compat_upper[i] > sysent |
215 | printf "#define %s(func) __CONCAT(%s_,func)\n", compat[i], \ | | 221 | printf "#define %s(func) __CONCAT(%s_,func)\n", compat[i], \ |
216 | compat[i] > sysent | | 222 | compat[i] > sysent |
217 | printf "#else\n" > sysent | | 223 | printf "#else\n" > sysent |
218 | printf "#define %s(func) %s\n", compat[i], sys_nosys > sysent | | 224 | printf "#define %s(func) %s\n", compat[i], sys_nosys > sysent |
219 | printf "#endif\n" > sysent | | 225 | printf "#endif\n" > sysent |
220 | } | | 226 | } |
221 | | | 227 | |
222 | printf "\n#define\ts(type)\tsizeof(type)\n" > sysent | | 228 | printf "\n#define\ts(type)\tsizeof(type)\n" > sysent |
223 | printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent | | 229 | printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > sysent |
224 | printf "#define\tns(type)\t.sy_narg = n(type), .sy_argsize = s(type)\n\n", registertype > sysent | | 230 | printf "#define\tns(type)\t.sy_narg = n(type), .sy_argsize = s(type)\n\n", registertype > sysent |
225 | printf "struct sysent %s[] = {\n",switchname > sysent | | 231 | printf "struct sysent %s[] = {\n",switchname > sysent |
226 | | | 232 | |
227 | printf "/* %s */\n\n", tag > sysnames | | 233 | printf "/* %s */\n\n", tag > sysnames |
228 | printf "/*\n * System call names.\n *\n" > sysnames | | 234 | printf "/*\n * System call names.\n *\n" > sysnames |
229 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames | | 235 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames |
230 | | | 236 | |
231 | printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos | | 237 | printf "\n/*\n * System call prototypes.\n */\n\n" > sysprotos |
232 | if (haverumpcalls) | | 238 | if (haverumpcalls) |
233 | printf("#ifndef RUMP_CLIENT\n") > sysprotos | | 239 | printf("#ifndef RUMP_CLIENT\n") > sysprotos |
234 | | | 240 | |
235 | printf "/* %s */\n\n", tag > sysnumhdr | | 241 | printf "/* %s */\n\n", tag > sysnumhdr |
236 | printf "/*\n * System call numbers.\n *\n" > sysnumhdr | | 242 | printf "/*\n * System call numbers.\n *\n" > sysnumhdr |
237 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr | | 243 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnumhdr |
238 | | | 244 | |
239 | printf "/* %s */\n\n", tag > sysarghdr | | 245 | printf "/* %s */\n\n", tag > sysarghdr |
240 | printf "/*\n * System call argument lists.\n *\n" > sysarghdr | | 246 | printf "/*\n * System call argument lists.\n *\n" > sysarghdr |
241 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr | | 247 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysarghdr |
242 | | | 248 | |
243 | printf "/* %s */\n\n", tag > sysautoload | | 249 | printf "/* %s */\n\n", tag > sysautoload |
244 | printf "/*\n * System call autoload table.\n *\n" > sysautoload | | 250 | printf "/*\n * System call autoload table.\n *\n" > sysautoload |
245 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysautoload | | 251 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysautoload |
246 | | | 252 | |
247 | printf "/* %s */\n\n", tag > rumpcalls | | 253 | printf "/* %s */\n\n", tag > rumpcalls |
248 | printf "/*\n * System call vector and marshalling for rump.\n *\n" > rumpcalls | | 254 | printf "/*\n * System call vector and marshalling for rump.\n *\n" > rumpcalls |
249 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls | | 255 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcalls |
250 | | | 256 | |
251 | printf "/* %s */\n\n", tag > rumpcallshdr | | 257 | printf "/* %s */\n\n", tag > rumpcallshdr |
252 | printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr | | 258 | printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr |
253 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr | | 259 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr |
254 | | | 260 | |
255 | printf "/* %s */\n\n", tag > systrace | | 261 | printf "/* %s */\n\n", tag > systrace |
256 | printf "/*\n * System call argument to DTrace register array converstion.\n *\n" > systrace | | 262 | printf "/*\n * System call argument to DTrace register array converstion.\n *\n" > systrace |
257 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > systrace | | 263 | printf " * DO NOT EDIT-- this file is automatically generated.\n" > systrace |
258 | } | | 264 | } |
259 | NR == 1 { | | 265 | NR == 1 { |
260 | sub(/ $/, "") | | 266 | sub(/ $/, "") |
261 | printf " * created from%s\n */\n\n", $0 > sysdcl | | 267 | printf " * created from%s\n */\n\n", $0 > sysdcl |
262 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysdcl | | 268 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysdcl |
263 | | | 269 | |
264 | printf " * created from%s\n */\n\n", $0 > sysnames | | 270 | printf " * created from%s\n */\n\n", $0 > sysnames |
265 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames | | 271 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysnames |
266 | | | 272 | |
267 | printf " * created from%s\n */\n\n", $0 > sysautoload | | 273 | printf " * created from%s\n */\n\n", $0 > sysautoload |
268 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload | | 274 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload |
269 | printf("#include <sys/proc.h>\n") > sysautoload | | 275 | printf("#include <sys/proc.h>\n") > sysautoload |
270 | printf("static struct sc_autoload " emulname \ | | 276 | printf("static struct sc_autoload " emulname \ |
271 | "_syscalls_autoload[] = {\n") > sysautoload | | 277 | "_syscalls_autoload[] = {\n") > sysautoload |
272 | | | 278 | |
273 | printf " * created from%s\n */\n\n", $0 > rumpcalls | | 279 | printf " * created from%s\n */\n\n", $0 > rumpcalls |
274 | printf "#ifdef RUMP_CLIENT\n" > rumpcalls | | 280 | printf "#ifdef RUMP_CLIENT\n" > rumpcalls |
275 | printf "#include <rump/rumpuser_port.h>\n" > rumpcalls | | 281 | printf "#include <rump/rumpuser_port.h>\n" > rumpcalls |
276 | printf "#endif /* RUMP_CLIENT */\n\n" > rumpcalls | | 282 | printf "#endif /* RUMP_CLIENT */\n\n" > rumpcalls |
277 | printf "#include <sys/param.h>\n\n" > rumpcalls | | 283 | printf "#include <sys/param.h>\n\n" > rumpcalls |
278 | printf "#ifdef __NetBSD__\n" > rumpcalls | | 284 | printf "#ifdef __NetBSD__\n" > rumpcalls |
279 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > rumpcalls | | 285 | printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > rumpcalls |
280 | | | 286 | |
281 | printf "#include <sys/fstypes.h>\n" > rumpcalls | | 287 | printf "#include <sys/fstypes.h>\n" > rumpcalls |
282 | printf "#include <sys/proc.h>\n" > rumpcalls | | 288 | printf "#include <sys/proc.h>\n" > rumpcalls |
283 | printf "#endif /* __NetBSD__ */\n\n" > rumpcalls | | 289 | printf "#endif /* __NetBSD__ */\n\n" > rumpcalls |
284 | printf "#ifdef RUMP_CLIENT\n" > rumpcalls | | 290 | printf "#ifdef RUMP_CLIENT\n" > rumpcalls |
285 | printf "#include <errno.h>\n" > rumpcalls | | 291 | printf "#include <errno.h>\n" > rumpcalls |
286 | printf "#include <stdint.h>\n" > rumpcalls | | 292 | printf "#include <stdint.h>\n" > rumpcalls |
287 | printf "#include <stdlib.h>\n" > rumpcalls | | 293 | printf "#include <stdlib.h>\n" > rumpcalls |
288 | printf "#include <string.h>\n\n" > rumpcalls | | 294 | printf "#include <string.h>\n\n" > rumpcalls |
289 | printf "#include <srcsys/syscall.h>\n" > rumpcalls | | 295 | printf "#include <srcsys/syscall.h>\n" > rumpcalls |
290 | printf "#include <srcsys/syscallargs.h>\n\n" > rumpcalls | | 296 | printf "#include <srcsys/syscallargs.h>\n\n" > rumpcalls |
291 | printf "#include <rump/rumpclient.h>\n\n" > rumpcalls | | 297 | printf "#include <rump/rumpclient.h>\n\n" > rumpcalls |
292 | printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls | | 298 | printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls |
293 | printf " rumpclient_syscall(num, data, dlen, retval)\n" > rumpcalls | | 299 | printf " rumpclient_syscall(num, data, dlen, retval)\n" > rumpcalls |
294 | printf "#define rsys_seterrno(error) errno = error\n" > rumpcalls | | 300 | printf "#define rsys_seterrno(error) errno = error\n" > rumpcalls |
295 | printf "#else\n" > rumpcalls | | 301 | printf "#else\n" > rumpcalls |
296 | printf "#include <sys/syscall.h>\n" > rumpcalls | | 302 | printf "#include <sys/syscall.h>\n" > rumpcalls |
297 | printf "#include <sys/syscallargs.h>\n\n" > rumpcalls | | 303 | printf "#include <sys/syscallargs.h>\n\n" > rumpcalls |
298 | printf "#include <sys/syscallvar.h>\n\n" > rumpcalls | | 304 | printf "#include <sys/syscallvar.h>\n\n" > rumpcalls |
299 | printf "#include <rump-sys/kern.h>\n\n" > rumpcalls | | 305 | printf "#include <rump-sys/kern.h>\n\n" > rumpcalls |
300 | printf "#include <rump/rumpuser.h>\n" > rumpcalls | | 306 | printf "#include <rump/rumpuser.h>\n" > rumpcalls |
301 | printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls | | 307 | printf "#define rsys_syscall(num, data, dlen, retval)\t\\\n" > rumpcalls |
302 | printf " rump_syscall(num, data, dlen, retval)\n\n" > rumpcalls | | 308 | printf " rump_syscall(num, data, dlen, retval)\n\n" > rumpcalls |
303 | printf "#define rsys_seterrno(error) rumpuser_seterrno(error)\n" \ | | 309 | printf "#define rsys_seterrno(error) rumpuser_seterrno(error)\n" \ |
304 | > rumpcalls | | 310 | > rumpcalls |
305 | printf "#endif\n\n" > rumpcalls | | 311 | printf "#endif\n\n" > rumpcalls |
306 | | | 312 | |
307 | printf "#ifndef RUMP_KERNEL_IS_LIBC\n" > rumpcalls | | 313 | printf "#ifndef RUMP_KERNEL_IS_LIBC\n" > rumpcalls |
308 | printf "#define RUMP_SYS_COMPAT\n" > rumpcalls | | 314 | printf "#define RUMP_SYS_COMPAT\n" > rumpcalls |
309 | printf "#endif\n\n" > rumpcalls | | 315 | printf "#endif\n\n" > rumpcalls |
310 | | | 316 | |
311 | printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls | | 317 | printf "#if\tBYTE_ORDER == BIG_ENDIAN\n" > rumpcalls |
312 | printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls | | 318 | printf "#define SPARG(p,k)\t((p)->k.be.datum)\n" > rumpcalls |
313 | printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls | | 319 | printf "#else /* LITTLE_ENDIAN, I hope dearly */\n" > rumpcalls |
314 | printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls | | 320 | printf "#define SPARG(p,k)\t((p)->k.le.datum)\n" > rumpcalls |
315 | printf "#endif\n\n" > rumpcalls | | 321 | printf "#endif\n\n" > rumpcalls |
316 | printf "\nvoid rumpns_sys_nomodule(void);\n" > rumpcalls | | 322 | printf "\nvoid rumpns_sys_nomodule(void);\n" > rumpcalls |
317 | | | 323 | |
318 | printf "\n#ifndef RUMP_CLIENT\n" > rumpsysent | | 324 | printf "\n#ifndef RUMP_CLIENT\n" > rumpsysent |
319 | printf "int rumpns_enosys(void);\n" > rumpsysent | | 325 | printf "int rumpns_enosys(void);\n" > rumpsysent |
320 | printf "#define\ts(type)\tsizeof(type)\n" > rumpsysent | | 326 | printf "#define\ts(type)\tsizeof(type)\n" > rumpsysent |
321 | printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > rumpsysent | | 327 | printf "#define\tn(type)\t(sizeof(type)/sizeof (%s))\n", registertype > rumpsysent |
322 | printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > rumpsysent | | 328 | printf "#define\tns(type)\tn(type), s(type)\n\n", registertype > rumpsysent |
323 | printf "struct sysent rump_sysent[] = {\n" > rumpsysent | | 329 | printf "struct sysent rump_sysent[] = {\n" > rumpsysent |
324 | | | 330 | |
325 | # System call names are included by userland (kdump(1)), so | | 331 | # System call names are included by userland (kdump(1)), so |
326 | # hide the include files from it. | | 332 | # hide the include files from it. |
327 | printf "#if defined(_KERNEL_OPT)\n" > sysnames | | 333 | printf "#if defined(_KERNEL_OPT)\n" > sysnames |
328 | | | 334 | |
329 | printf "#else /* _KERNEL_OPT */\n" > sysnamesbottom | | 335 | printf "#else /* _KERNEL_OPT */\n" > sysnamesbottom |
330 | printf "#include <sys/null.h>\n" > sysnamesbottom | | 336 | printf "#include <sys/null.h>\n" > sysnamesbottom |
331 | printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom | | 337 | printf "#endif /* _KERNEL_OPT */\n\n" > sysnamesbottom |
332 | printf "const char *const %s[] = {\n",namesname > sysnamesbottom | | 338 | printf "const char *const %s[] = {\n",namesname > sysnamesbottom |
333 | printf "\n\n/* libc style syscall names */\n" > sysnamesfriendly | | 339 | printf "\n\n/* libc style syscall names */\n" > sysnamesfriendly |
334 | printf "const char *const alt%s[] = {\n", namesname > sysnamesfriendly | | 340 | printf "const char *const alt%s[] = {\n", namesname > sysnamesfriendly |
335 | | | 341 | |
336 | printf " * created from%s\n */\n\n", $0 > sysnumhdr | | 342 | printf " * created from%s\n */\n\n", $0 > sysnumhdr |
337 | printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr | | 343 | printf "#ifndef _" constprefix "SYSCALL_H_\n" > sysnumhdr |
338 | printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr | | 344 | printf "#define _" constprefix "SYSCALL_H_\n\n" > sysnumhdr |
339 | | | 345 | |
340 | printf " * created from%s\n */\n\n", $0 > sysarghdr | | 346 | printf " * created from%s\n */\n\n", $0 > sysarghdr |
341 | printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr | | 347 | printf "#ifndef _" constprefix "SYSCALLARGS_H_\n" > sysarghdr |
342 | printf "#define _" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr | | 348 | printf "#define _" constprefix "SYSCALLARGS_H_\n\n" > sysarghdr |
343 | | | 349 | |
344 | printf " * created from%s\n */\n\n", $0 > rumpcallshdr | | 350 | printf " * created from%s\n */\n\n", $0 > rumpcallshdr |
345 | printf "#ifndef _RUMP_RUMP_SYSCALLS_H_\n" > rumpcallshdr | | 351 | printf "#ifndef _RUMP_RUMP_SYSCALLS_H_\n" > rumpcallshdr |
346 | printf "#define _RUMP_RUMP_SYSCALLS_H_\n\n" > rumpcallshdr | | 352 | printf "#define _RUMP_RUMP_SYSCALLS_H_\n\n" > rumpcallshdr |
347 | printf "#ifdef _KERNEL\n" > rumpcallshdr | | 353 | printf "#ifdef _KERNEL\n" > rumpcallshdr |
348 | printf "#error Interface not supported inside kernel\n" > rumpcallshdr | | 354 | printf "#error Interface not supported inside kernel\n" > rumpcallshdr |
349 | printf "#endif /* _KERNEL */\n\n" > rumpcallshdr | | 355 | printf "#endif /* _KERNEL */\n\n" > rumpcallshdr |
350 | printf "#include <rump/rump_syscalls_compat.h>\n\n" > rumpcallshdr | | 356 | printf "#include <rump/rump_syscalls_compat.h>\n\n" > rumpcallshdr |
351 | | | 357 | |
352 | printf "%s", sysarghdrextra > sysarghdr | | 358 | printf "%s", sysarghdrextra > sysarghdr |
353 | printf "/* Forward declaration */\n" > sysarghdr | | 359 | printf "/* Forward declaration */\n" > sysarghdr |
354 | printf "struct lwp;\n" > sysarghdr | | 360 | printf "struct lwp;\n" > sysarghdr |
355 | printf "\n" > sysarghdr | | 361 | printf "\n" > sysarghdr |
356 | | | 362 | |
357 | # Write max number of system call arguments to both headers | | 363 | # Write max number of system call arguments to both headers |
358 | printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \ | | 364 | printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \ |
359 | > sysnumhdr | | 365 | > sysnumhdr |
360 | printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \ | | 366 | printf("#define\t%sMAXSYSARGS\t%d\n\n", constprefix, maxsysargs) \ |
361 | > sysarghdr | | 367 | > sysarghdr |
362 | printf "#undef\tsyscallarg\n" > sysarghdr | | 368 | printf "#undef\tsyscallarg\n" > sysarghdr |
363 | printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr | | 369 | printf "#define\tsyscallarg(x)\t\t\t\t\t\t\t\\\n" > sysarghdr |
364 | printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr | | 370 | printf "\tunion {\t\t\t\t\t\t\t\t\\\n" > sysarghdr |
365 | printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr | | 371 | printf "\t\t%s pad;\t\t\t\t\t\t\\\n", registertype > sysarghdr |
366 | printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr | | 372 | printf "\t\tstruct { x datum; } le;\t\t\t\t\t\\\n" > sysarghdr |
367 | printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \ | | 373 | printf "\t\tstruct { /* LINTED zero array dimension */\t\t\\\n" \ |
368 | > sysarghdr | | 374 | > sysarghdr |
369 | printf "\t\t\tint8_t pad[ /* CONSTCOND */\t\t\t\\\n" > sysarghdr | | 375 | printf "\t\t\tint8_t pad[ /* CONSTCOND */\t\t\t\\\n" > sysarghdr |
370 | printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \ | | 376 | printf "\t\t\t\t(sizeof (%s) < sizeof (x))\t\\\n", \ |
371 | registertype > sysarghdr | | 377 | registertype > sysarghdr |
372 | printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr | | 378 | printf "\t\t\t\t? 0\t\t\t\t\t\\\n" > sysarghdr |
373 | printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \ | | 379 | printf "\t\t\t\t: sizeof (%s) - sizeof (x)];\t\\\n", \ |
374 | registertype > sysarghdr | | 380 | registertype > sysarghdr |
375 | printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr | | 381 | printf "\t\t\tx datum;\t\t\t\t\t\\\n" > sysarghdr |
376 | printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr | | 382 | printf "\t\t} be;\t\t\t\t\t\t\t\\\n" > sysarghdr |
377 | printf "\t}\n" > sysarghdr | | 383 | printf "\t}\n" > sysarghdr |
378 | printf("\n#undef check_syscall_args\n") >sysarghdr | | 384 | printf("\n#undef check_syscall_args\n") >sysarghdr |
379 | printf("#define check_syscall_args(call) /*LINTED*/ \\\n" \ | | 385 | printf("#define check_syscall_args(call) /*LINTED*/ \\\n" \ |
380 | "\ttypedef char call##_check_args" \ | | 386 | "\ttypedef char call##_check_args" \ |
381 | "[sizeof (struct call##_args) \\\n" \ | | 387 | "[sizeof (struct call##_args) \\\n" \ |
382 | "\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \ | | 388 | "\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \ |
383 | constprefix, registertype) >sysarghdr | | 389 | constprefix, registertype) >sysarghdr |
384 | | | 390 | |
385 | printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace | | 391 | printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace |
386 | printf "static void\nsystrace_args(register_t sysnum, const void *params, uintptr_t *uarg, size_t *n_args)\n{\n" > systrace | | 392 | printf "static void\nsystrace_args(register_t sysnum, const void *params, uintptr_t *uarg, size_t *n_args)\n{\n" > systrace |
387 | printf "\tintptr_t *iarg = (intptr_t *)uarg;\n" > systrace | | 393 | printf "\tintptr_t *iarg = (intptr_t *)uarg;\n" > systrace |
388 | printf "\tswitch (sysnum) {\n" > systrace | | 394 | printf "\tswitch (sysnum) {\n" > systrace |
389 | | | 395 | |
390 | printf "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp | | 396 | printf "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp |
391 | printf "\tswitch (sysnum) {\n" > systracetmp | | 397 | printf "\tswitch (sysnum) {\n" > systracetmp |
392 | | | 398 | |
393 | printf "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceret | | 399 | printf "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceret |
394 | printf "\tswitch (sysnum) {\n" > systraceret | | 400 | printf "\tswitch (sysnum) {\n" > systraceret |
395 | | | 401 | |
396 | # compat types from syscalls.master. this is slightly ugly, | | 402 | # compat types from syscalls.master. this is slightly ugly, |
397 | # but given that we have so few compats from over 17 years, | | 403 | # but given that we have so few compats from over 17 years, |
398 | # a more complicated solution is not currently warranted. | | 404 | # a more complicated solution is not currently warranted. |
399 | uncompattypes["struct timeval50"] = "struct timeval"; | | 405 | uncompattypes["struct timeval50"] = "struct timeval"; |
400 | uncompattypes["struct timespec50"] = "struct timespec"; | | 406 | uncompattypes["struct timespec50"] = "struct timespec"; |
401 | uncompattypes["struct stat30"] = "struct stat"; | | 407 | uncompattypes["struct stat30"] = "struct stat"; |
402 | | | 408 | |
403 | next | | 409 | next |
404 | } | | 410 | } |
405 | NF == 0 || $1 ~ /^;/ { | | 411 | NF == 0 || $1 ~ /^;/ { |
406 | next | | 412 | next |
407 | } | | 413 | } |
408 | $0 ~ /^%%$/ { | | 414 | $0 ~ /^%%$/ { |
409 | intable = 1 | | 415 | intable = 1 |
410 | next | | 416 | next |
411 | } | | 417 | } |
412 | $1 ~ /^#[ ]*include/ { | | 418 | $1 ~ /^#[ ]*include/ { |
413 | print > sysdcl | | 419 | print > sysdcl |
414 | print > sysnames | | 420 | print > sysnames |
415 | next | | 421 | next |
416 | } | | 422 | } |
417 | $1 ~ /^#/ && !intable { | | 423 | $1 ~ /^#/ && !intable { |
418 | print > sysdcl | | 424 | print > sysdcl |
419 | print > sysnames | | 425 | print > sysnames |
420 | next | | 426 | next |
421 | } | | 427 | } |
422 | $1 ~ /^#/ && intable { | | 428 | $1 ~ /^#/ && intable { |
423 | if ($1 ~ /^#[ ]*if/) { | | 429 | if ($1 ~ /^#[ ]*if/) { |
424 | savedepth++ | | 430 | savedepth++ |
425 | savesyscall[savedepth] = syscall | | 431 | savesyscall[savedepth] = syscall |
426 | skip_auto[savedepth] = auto_skip | | 432 | skip_auto[savedepth] = auto_skip |
427 | auto_skip = 0 | | 433 | auto_skip = 0 |
428 | | | 434 | |
429 | # Special handling for sysautoload conditionals | | 435 | # Special handling for sysautoload conditionals |
430 | # | | 436 | # |
431 | # We ignore all conditions other than those for | | 437 | # We ignore all conditions other than those for |
432 | # !defined(_LP64) which are used for SYSV* syscalls | | 438 | # !defined(_LP64) which are used for SYSV* syscalls |
433 | # only | | 439 | # only |
434 | | | 440 | |
435 | if ($0 ~ /!defined\(_LP64\)/) { | | 441 | if ($0 ~ /!defined\(_LP64\)/) { |
436 | printf("#if !defined(_LP64)\n") > sysautoload | | 442 | printf("#if !defined(_LP64)\n") > sysautoload |
437 | auto_skip = savedepth | | 443 | auto_skip = savedepth |
438 | } | | 444 | } |
439 | } | | 445 | } |
440 | if ($1 ~ /^#[ ]*else/) { | | 446 | if ($1 ~ /^#[ ]*else/) { |
441 | if (savedepth <= 0) { | | 447 | if (savedepth <= 0) { |
442 | printf("%s: line %d: unbalanced #else\n", \ | | 448 | printf("%s: line %d: unbalanced #else\n", \ |
443 | infile, NR) | | 449 | infile, NR) |
444 | exit 1 | | 450 | exit 1 |
445 | } | | 451 | } |
446 | if (auto_skip == savedepth) { | | 452 | if (auto_skip == savedepth) { |
447 | print > sysautoload | | 453 | print > sysautoload |
448 | } | | 454 | } |
449 | syscall = savesyscall[savedepth] | | 455 | syscall = savesyscall[savedepth] |
450 | } | | 456 | } |
451 | if ($1 ~ /^#[ ]*endif/) { | | 457 | if ($1 ~ /^#[ ]*endif/) { |
452 | if (savedepth <= 0) { | | 458 | if (savedepth <= 0) { |
453 | printf("%s: line %d: unbalanced #endif\n", \ | | 459 | printf("%s: line %d: unbalanced #endif\n", \ |
454 | infile, NR) | | 460 | infile, NR) |
455 | exit 1 | | 461 | exit 1 |
456 | } | | 462 | } |
457 | if (auto_skip == savedepth) { | | 463 | if (auto_skip == savedepth) { |
458 | print > sysautoload | | 464 | print > sysautoload |
459 | } | | 465 | } |
460 | auto_skip = skip_auto[savedepth]; | | 466 | auto_skip = skip_auto[savedepth]; |
461 | savedepth-- | | 467 | savedepth-- |
462 | } | | 468 | } |
463 | print > sysent | | 469 | print > sysent |
464 | print > sysarghdr | | 470 | print > sysarghdr |
465 | print > sysnumhdr | | 471 | print > sysnumhdr |
466 | print > sysprotos | | 472 | print > sysprotos |
467 | print > sysnamesbottom | | 473 | print > sysnamesbottom |
468 | print > sysnamesfriendly | | 474 | print > sysnamesfriendly |
469 | print > systrace | | 475 | print > systrace |
470 | print > systracetmp | | 476 | print > systracetmp |
471 | print > systraceret | | 477 | print > systraceret |
472 | | | 478 | |
473 | # XXX: technically we do not want to have conditionals in rump, | | 479 | # XXX: technically we do not want to have conditionals in rump, |
474 | # but it is easier to just let the cpp handle them than try to | | 480 | # but it is easier to just let the cpp handle them than try to |
475 | # figure out what we want here in this script | | 481 | # figure out what we want here in this script |
476 | print > rumpsysent | | 482 | print > rumpsysent |
477 | next | | 483 | next |
478 | } | | 484 | } |
479 | syscall != $1 { | | 485 | syscall != $1 { |
480 | printf "%s: line %d: syscall number out of sync at %d\n", \ | | 486 | printf "%s: line %d: syscall number out of sync at %d\n", \ |
481 | infile, NR, syscall | | 487 | infile, NR, syscall |
482 | printf "line is:\n" | | 488 | printf "line is:\n" |
483 | print | | 489 | print |
484 | exit 1 | | 490 | exit 1 |
485 | } | | 491 | } |
486 | function isarg64(type) { | | 492 | function isarg64(type) { |
487 | gsub("netbsd32_", "", type); | | 493 | gsub("netbsd32_", "", type); |
488 | return type == "quad_t" || type == "off_t" \ | | 494 | return type == "quad_t" || type == "off_t" \ |
489 | || type == "dev_t" || type == "time_t"; | | 495 | || type == "dev_t" || type == "time_t"; |
490 | } | | 496 | } |
491 | function parserr(was, wanted) { | | 497 | function parserr(was, wanted) { |
492 | printf "%s: line %d: unexpected %s (expected <%s>)\n", \ | | 498 | printf "%s: line %d: unexpected %s (expected <%s>)\n", \ |
493 | infile, NR, was, wanted | | 499 | infile, NR, was, wanted |
494 | printf "line is:\n" | | 500 | printf "line is:\n" |
495 | print | | 501 | print |
496 | exit 1 | | 502 | exit 1 |
497 | } | | 503 | } |
498 | function fillerpsysent(syscall, flags, name, comment) { | | 504 | function fillerpsysent(syscall, flags, name, comment) { |
499 | return sprintf("\t{%s\n\t\t.sy_call = %s,\n\t},\t\t/* %d = filler */",\ | | 505 | return sprintf("\t{%s\n\t\t.sy_call = %s,\n\t},\t\t/* %d = filler */",\ |
500 | flags, name, syscall, comment); | | 506 | flags, name, syscall, comment); |
501 | } | | 507 | } |
502 | function parseline() { | | 508 | function parseline() { |
503 | f=3 # toss number and type | | 509 | f=3 # toss number and type |
504 | if ($2 == "INDIR") | | 510 | if ($2 == "INDIR") |
505 | sycall_flags="SYCALL_INDIRECT" | | 511 | sycall_flags="SYCALL_INDIRECT" |
506 | else | | 512 | else |
507 | sycall_flags="0" | | 513 | sycall_flags="0" |
508 | if ($NF != "}") { | | 514 | if ($NF != "}") { |
509 | funcalias=$NF | | 515 | funcalias=$NF |
510 | end=NF-1 | | 516 | end=NF-1 |
511 | } else { | | 517 | } else { |
512 | funcalias="" | | 518 | funcalias="" |
513 | end=NF | | 519 | end=NF |
514 | } | | 520 | } |
515 | if ($f == "INDIR") { # allow for "NOARG INDIR" | | 521 | if ($f == "INDIR") { # allow for "NOARG INDIR" |
516 | sycall_flags = "SYCALL_INDIRECT | " sycall_flags | | 522 | sycall_flags = "SYCALL_INDIRECT | " sycall_flags |
517 | f++ | | 523 | f++ |
518 | } | | 524 | } |
519 | if ($f == "MODULAR") { # registered at runtime | | 525 | if ($f == "MODULAR") { # registered at runtime |
520 | modular = 1 | | 526 | modular = 1 |
521 | f++ | | 527 | f++ |
522 | modname = $f | | 528 | modname = $f |
523 | f++ | | 529 | f++ |
524 | } else { | | 530 | } else { |
525 | modular = 0; | | 531 | modular = 0; |
526 | } | | 532 | } |
527 | if ($f == "RUMP") { | | 533 | if ($f == "RUMP") { |
528 | rumpable = 1 | | 534 | rumpable = 1 |
529 | f++ | | 535 | f++ |
530 | } else { | | 536 | } else { |
531 | rumpable = 0 | | 537 | rumpable = 0 |
532 | } | | 538 | } |
533 | if ($f ~ /^[a-z0-9_]*$/) { # allow syscall alias | | 539 | if ($f ~ /^[a-z0-9_]*$/) { # allow syscall alias |
534 | funcalias=$f | | 540 | funcalias=$f |
535 | f++ | | 541 | f++ |
536 | } | | 542 | } |
537 | if ($f != "{") | | 543 | if ($f != "{") |
538 | parserr($f, "{") | | 544 | parserr($f, "{") |
539 | f++ | | 545 | f++ |
540 | if ($end != "}") | | 546 | if ($end != "}") |
541 | parserr($end, "}") | | 547 | parserr($end, "}") |
542 | end-- | | 548 | end-- |
543 | if ($end != ";") | | 549 | if ($end != ";") |
544 | parserr($end, ";") | | 550 | parserr($end, ";") |
545 | end-- | | 551 | end-- |
546 | if ($end != ")") | | 552 | if ($end != ")") |
547 | parserr($end, ")") | | 553 | parserr($end, ")") |
548 | end-- | | 554 | end-- |
549 | | | 555 | |
550 | returntype = oldf = ""; | | 556 | returntype = oldf = ""; |
551 | do { | | 557 | do { |
552 | if (returntype != "" && oldf != "*") | | 558 | if (returntype != "" && oldf != "*") |
553 | returntype = returntype" "; | | 559 | returntype = returntype" "; |
554 | returntype = returntype$f; | | 560 | returntype = returntype$f; |
555 | oldf = $f; | | 561 | oldf = $f; |
556 | f++ | | 562 | f++ |
557 | } while ($f != "|" && f < (end-1)) | | 563 | } while ($f != "|" && f < (end-1)) |
558 | if (f == (end - 1)) { | | 564 | if (f == (end - 1)) { |
559 | parserr($f, "function argument definition (maybe \"|\"?)"); | | 565 | parserr($f, "function argument definition (maybe \"|\"?)"); |
560 | } | | 566 | } |
561 | f++ | | 567 | f++ |
562 | | | 568 | |
563 | fprefix=$f | | 569 | fprefix=$f |
564 | f++ | | 570 | f++ |
565 | if ($f != "|") { | | 571 | if ($f != "|") { |
566 | parserr($f, "function compat delimiter (maybe \"|\"?)"); | | 572 | parserr($f, "function compat delimiter (maybe \"|\"?)"); |
567 | } | | 573 | } |
568 | f++ | | 574 | f++ |
569 | | | 575 | |
570 | fcompat="" | | 576 | fcompat="" |
571 | if ($f != "|") { | | 577 | if ($f != "|") { |
572 | fcompat=$f | | 578 | fcompat=$f |
573 | f++ | | 579 | f++ |
574 | } | | 580 | } |
575 | | | 581 | |
576 | if ($f != "|") { | | 582 | if ($f != "|") { |
577 | parserr($f, "function name delimiter (maybe \"|\"?)"); | | 583 | parserr($f, "function name delimiter (maybe \"|\"?)"); |
578 | } | | 584 | } |
579 | f++ | | 585 | f++ |
580 | fbase=$f | | 586 | fbase=$f |
581 | | | 587 | |
582 | # pipe is special in how to returns its values. | | 588 | # pipe is special in how to returns its values. |
583 | # So just generate it manually if present. | | 589 | # So just generate it manually if present. |
584 | if (rumpable == 1 && fbase == "pipe") { | | 590 | if (rumpable == 1 && fbase == "pipe") { |
585 | rumpable = 0; | | 591 | rumpable = 0; |
586 | rumphaspipe = 1; | | 592 | rumphaspipe = 1; |
587 | } | | 593 | } |
588 | | | 594 | |
589 | if (fcompat != "") { | | 595 | if (fcompat != "") { |
590 | funcname=fprefix "___" fbase "" fcompat | | 596 | funcname=fprefix "___" fbase "" fcompat |
591 | } else { | | 597 | } else { |
592 | funcname=fprefix "_" fbase | | 598 | funcname=fprefix "_" fbase |
593 | } | | 599 | } |
594 | if (isarg64(returntype)) { | | 600 | if (isarg64(returntype)) { |
595 | if (sycall_flags == "0") | | 601 | if (sycall_flags == "0") |
596 | sycall_flags = "SYCALL_RET_64"; | | 602 | sycall_flags = "SYCALL_RET_64"; |
597 | else | | 603 | else |
598 | sycall_flags = "SYCALL_RET_64 | " sycall_flags; | | 604 | sycall_flags = "SYCALL_RET_64 | " sycall_flags; |
599 | } | | 605 | } |
600 | | | 606 | |
601 | if (funcalias == "") { | | 607 | if (funcalias == "") { |
602 | funcalias=funcname | | 608 | funcalias=funcname |
603 | sub(/^([^_]+_)*sys_/, "", funcalias) | | 609 | sub(/^([^_]+_)*sys_/, "", funcalias) |
604 | realname=fbase | | 610 | realname=fbase |
605 | } else { | | 611 | } else { |
606 | realname=funcalias | | 612 | realname=funcalias |
607 | } | | 613 | } |
608 | rumpfname=realname "" fcompat | | 614 | rumpfname=realname "" fcompat |
609 | f++ | | 615 | f++ |
610 | | | 616 | |
611 | if ($f != "(") | | 617 | if ($f != "(") |
612 | parserr($f, "(") | | 618 | parserr($f, "(") |
613 | f++ | | 619 | f++ |
614 | | | 620 | |
615 | argc=0; | | 621 | argc=0; |
616 | argalign=0; | | 622 | argalign=0; |
617 | if (f == end) { | | 623 | if (f == end) { |
618 | if ($f != "void") | | 624 | if ($f != "void") |
619 | parserr($f, "argument definition") | | 625 | parserr($f, "argument definition") |
620 | isvarargs = 0; | | 626 | isvarargs = 0; |
621 | varargc = 0; | | 627 | varargc = 0; |
622 | argtype[0]="void"; | | 628 | argtype[0]="void"; |
623 | return | | 629 | return |
624 | } | | 630 | } |
625 | | | 631 | |
626 | # some system calls (open() and fcntl()) can accept a variable | | 632 | # some system calls (open() and fcntl()) can accept a variable |
627 | # number of arguments. If syscalls accept a variable number of | | 633 | # number of arguments. If syscalls accept a variable number of |
628 | # arguments, they must still have arguments specified for | | 634 | # arguments, they must still have arguments specified for |
629 | # the remaining argument "positions," because of the way the | | 635 | # the remaining argument "positions," because of the way the |
630 | # kernel system call argument handling works. | | 636 | # kernel system call argument handling works. |
631 | # | | 637 | # |
632 | # Indirect system calls, e.g. syscall(), are exceptions to this | | 638 | # Indirect system calls, e.g. syscall(), are exceptions to this |
633 | # rule, since they are handled entirely by machine-dependent code | | 639 | # rule, since they are handled entirely by machine-dependent code |
634 | # and do not need argument structures built. | | 640 | # and do not need argument structures built. |
635 | | | 641 | |
636 | isvarargs = 0; | | 642 | isvarargs = 0; |
637 | args64 = 0; | | 643 | args64 = 0; |
638 | ptr = 0; | | 644 | ptr = 0; |
639 | while (f <= end) { | | 645 | while (f <= end) { |
640 | if ($f == "...") { | | 646 | if ($f == "...") { |
641 | f++; | | 647 | f++; |
642 | isvarargs = 1; | | 648 | isvarargs = 1; |
643 | varargc = argc; | | 649 | varargc = argc; |
644 | continue; | | 650 | continue; |
645 | } | | 651 | } |
646 | argc++ | | 652 | argc++ |
647 | argtype[argc]="" | | 653 | argtype[argc]="" |
648 | oldf="" | | 654 | oldf="" |
649 | while (f < end && $(f+1) != ",") { | | 655 | while (f < end && $(f+1) != ",") { |
650 | if (argtype[argc] != "" && oldf != "*") | | 656 | if (argtype[argc] != "" && oldf != "*") |
651 | argtype[argc] = argtype[argc]" "; | | 657 | argtype[argc] = argtype[argc]" "; |
652 | argtype[argc] = argtype[argc]$f; | | 658 | argtype[argc] = argtype[argc]$f; |
653 | oldf = $f; | | 659 | oldf = $f; |
654 | f++ | | 660 | f++ |
655 | } | | 661 | } |
656 | if (argtype[argc] == "") | | 662 | if (argtype[argc] == "") |
657 | parserr($f, "argument definition") | | 663 | parserr($f, "argument definition") |
658 | if (argtype[argc] == "off_t" \ | | 664 | if (argtype[argc] == "off_t" \ |
659 | || argtype[argc] == "dev_t" \ | | 665 | || argtype[argc] == "dev_t" \ |
660 | || argtype[argc] == "time_t") { | | 666 | || argtype[argc] == "time_t") { |
661 | if ((argalign % 2) != 0 && sysalign && | | 667 | if ((argalign % 2) != 0 && sysalign && |
662 | funcname != "sys_posix_fadvise") # XXX for now | | 668 | funcname != "sys_posix_fadvise") # XXX for now |
663 | parserr($f, "a padding argument") | | 669 | parserr($f, "a padding argument") |
664 | } else { | | 670 | } else { |
665 | argalign++; | | 671 | argalign++; |
666 | } | | 672 | } |
667 | if (isarg64(argtype[argc])) { | | 673 | if (isarg64(argtype[argc])) { |
668 | if (sycall_flags == "0") | | 674 | if (sycall_flags == "0") |
669 | sycall_flags = "SYCALL_ARG"argc-1"_64"; | | 675 | sycall_flags = "SYCALL_ARG"argc-1"_64"; |
670 | else | | 676 | else |
671 | sycall_flags = "SYCALL_ARG"argc-1"_64 | " sycall_flags; | | 677 | sycall_flags = "SYCALL_ARG"argc-1"_64 | " sycall_flags; |
672 | args64++; | | 678 | args64++; |
673 | } | | 679 | } |
674 | if (index(argtype[argc], "*") != 0 && ptr == 0) { | | 680 | if (index(argtype[argc], "*") != 0 && ptr == 0) { |
675 | if (sycall_flags == "0") | | 681 | if (sycall_flags == "0") |
676 | sycall_flags = "SYCALL_ARG_PTR"; | | 682 | sycall_flags = "SYCALL_ARG_PTR"; |
677 | else | | 683 | else |
678 | sycall_flags = "SYCALL_ARG_PTR | " sycall_flags; | | 684 | sycall_flags = "SYCALL_ARG_PTR | " sycall_flags; |
679 | ptr = 1; | | 685 | ptr = 1; |
680 | } | | 686 | } |
681 | argname[argc]=$f; | | 687 | argname[argc]=$f; |
682 | f += 2; # skip name, and any comma | | 688 | f += 2; # skip name, and any comma |
683 | } | | 689 | } |
684 | if (args64 > 0) | | 690 | if (args64 > 0) |
685 | sycall_flags = "SYCALL_NARGS64_VAL("args64") | " sycall_flags; | | 691 | sycall_flags = "SYCALL_NARGS64_VAL("args64") | " sycall_flags; |
686 | # must see another argument after varargs notice. | | 692 | # must see another argument after varargs notice. |
687 | if (isvarargs) { | | 693 | if (isvarargs) { |
688 | if (argc == varargc) | | 694 | if (argc == varargc) |
689 | parserr($f, "argument definition") | | 695 | parserr($f, "argument definition") |
690 | } else | | 696 | } else |
691 | varargc = argc; | | 697 | varargc = argc; |
692 | } | | 698 | } |
693 | | | 699 | |
694 | function printproto(wrap) { | | 700 | function printproto(wrap) { |
695 | printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias, | | 701 | printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias, |
696 | returntype) > sysnumhdr | | 702 | returntype) > sysnumhdr |
697 | for (i = 1; i <= varargc; i++) | | 703 | for (i = 1; i <= varargc; i++) |
698 | printf(" \"%s\"", argtype[i]) > sysnumhdr | | 704 | printf(" \"%s\"", argtype[i]) > sysnumhdr |
699 | if (isvarargs) | | 705 | if (isvarargs) |
700 | printf(" \"...\"") > sysnumhdr | | 706 | printf(" \"...\"") > sysnumhdr |
701 | printf(" */\n") > sysnumhdr | | 707 | printf(" */\n") > sysnumhdr |
702 | printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias, | | 708 | printf("#define\t%s%s%s\t%d\n\n", constprefix, wrap, funcalias, |
703 | syscall) > sysnumhdr | | 709 | syscall) > sysnumhdr |
704 | | | 710 | |
705 | # output entry for syscall autoload table, if modular | | 711 | # output entry for syscall autoload table, if modular |
706 | if (modular ) { | | 712 | if (modular ) { |
707 | printf("\t { %s%s%s, \"%s\" },\n", constprefix, wrap, | | 713 | printf("\t { %s%s%s, \"%s\" },\n", constprefix, wrap, |
708 | funcalias, modname) > sysautoload | | 714 | funcalias, modname) > sysautoload |
709 | } | | 715 | } |
710 | | | 716 | |
711 | | | 717 | |
712 | # rumpalooza | | 718 | # rumpalooza |
713 | if (!rumpable) | | 719 | if (!rumpable) |
714 | return | | 720 | return |
715 | | | 721 | |
716 | # accumulate fbases we have seen. we want the last | | 722 | # accumulate fbases we have seen. we want the last |
717 | # occurence for the default __RENAME() | | 723 | # occurence for the default __RENAME() |
718 | seen = funcseen[fbase] | | 724 | seen = funcseen[fbase] |
719 | funcseen[fbase] = rumpfname | | 725 | funcseen[fbase] = rumpfname |
720 | # special case for mknod as type of last argument changed from | | 726 | # special case for mknod as type of last argument changed from |
721 | # uint32_t to dev_t | | 727 | # uint32_t to dev_t |
722 | if ((seen && fbase != "mknod") || (!seen && fbase == "mknod")) | | 728 | if ((seen && fbase != "mknod") || (!seen && fbase == "mknod")) |
723 | return | | 729 | return |
724 | | | 730 | |
725 | printf("%s rump_sys_%s(", returntype, realname) > rumpprotos | | 731 | printf("%s rump_sys_%s(", returntype, realname) > rumpprotos |
726 | | | 732 | |
727 | for (i = 1; i < varargc; i++) | | 733 | for (i = 1; i < varargc; i++) |
728 | if (argname[i] != "PAD") | | 734 | if (argname[i] != "PAD") |
729 | printf("%s, ", uncompattype(argtype[i])) > rumpprotos | | 735 | printf("%s, ", uncompattype(argtype[i])) > rumpprotos |
730 | | | 736 | |
731 | if (isvarargs) | | 737 | if (isvarargs) |
732 | printf("%s, ...)", uncompattype(argtype[varargc]))>rumpprotos | | 738 | printf("%s, ...)", uncompattype(argtype[varargc]))>rumpprotos |
733 | else | | 739 | else |
734 | printf("%s)", uncompattype(argtype[argc])) > rumpprotos | | 740 | printf("%s)", uncompattype(argtype[argc])) > rumpprotos |
735 | | | 741 | |
736 | printf(" __RENAME(RUMP_SYS_RENAME_%s)", toupper(fbase))> rumpprotos | | 742 | printf(" __RENAME(RUMP_SYS_RENAME_%s)", toupper(fbase))> rumpprotos |
737 | printf(";\n") > rumpprotos | | 743 | printf(";\n") > rumpprotos |
738 | | | 744 | |
739 | # generate forward-declares for types, apart from the | | 745 | # generate forward-declares for types, apart from the |
740 | # braindead typedef jungle we cannot easily handle here | | 746 | # braindead typedef jungle we cannot easily handle here |
741 | for (i = 1; i <= varargc; i++) { | | 747 | for (i = 1; i <= varargc; i++) { |
742 | type=uncompattype(argtype[i]) | | 748 | type=uncompattype(argtype[i]) |
743 | sub("const ", "", type) | | 749 | sub("const ", "", type) |
744 | ntype=type | | 750 | ntype=type |
745 | sub(" *\\*.*", "", ntype); | | 751 | sub(" *\\*.*", "", ntype); |
746 | if (!typeseen[ntype] && \ | | 752 | if (!typeseen[ntype] && \ |
747 | match(type, "struct") && match(type, "\\*")) { | | 753 | match(type, "struct") && match(type, "\\*")) { |
748 | typeseen[ntype] = 1 | | 754 | typeseen[ntype] = 1 |
749 | printf("%s;\n", ntype) > rumptypes | | 755 | printf("%s;\n", ntype) > rumptypes |
750 | } | | 756 | } |
751 | } | | 757 | } |
752 | } | | 758 | } |
753 | | | 759 | |
754 | function printrumpsysent(insysent, compatwrap) { | | 760 | function printrumpsysent(insysent, compatwrap) { |
755 | if (modular) { | | 761 | if (modular) { |
756 | fn = rumpnomodule | | 762 | fn = rumpnomodule |
757 | flags = rumpnoflags | | 763 | flags = rumpnoflags |
758 | } else { | | 764 | } else { |
759 | fn = rumpnosys | | 765 | fn = rumpnosys |
760 | flags = "" | | 766 | flags = "" |
761 | } | | 767 | } |
762 | if (!insysent) { | | 768 | if (!insysent) { |
763 | printf("\t{%s\n\t\t.sy_call = %s,\n},\t\t/* %d = %s */\n", \ | | 769 | printf("\t{%s\n\t\t.sy_call = %s,\n},\t\t/* %d = %s */\n", \ |
764 | flags, fn, syscall, funcalias) > rumpsysent | | 770 | flags, fn, syscall, funcalias) > rumpsysent |
765 | return | | 771 | return |
766 | } | | 772 | } |
767 | | | 773 | |
768 | printf("\t{") > rumpsysent | | 774 | printf("\t{") > rumpsysent |
769 | if (argc != 0) { | | 775 | if (argc != 0) { |
770 | printf("\n\t\tns(struct %ssys_%s_args),", compatwrap_, funcalias) > rumpsysent | | 776 | printf("\n\t\tns(struct %ssys_%s_args),", compatwrap_, funcalias) > rumpsysent |
771 | } | | 777 | } |
772 | | | 778 | |
773 | printf("\n\t\t.sy_call = %s,\n\t},", fn) > rumpsysent | | 779 | printf("\n\t\t.sy_call = %s,\n\t},", fn) > rumpsysent |
774 | printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > rumpsysent | | 780 | printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > rumpsysent |
775 | } | | 781 | } |
776 | | | 782 | |
777 | function iscompattype(type) { | | 783 | function iscompattype(type) { |
778 | for (var in uncompattypes) { | | 784 | for (var in uncompattypes) { |
779 | if (match(type, var)) { | | 785 | if (match(type, var)) { |
780 | return 1 | | 786 | return 1 |
781 | } | | 787 | } |
782 | } | | 788 | } |
783 | | | 789 | |
784 | return 0 | | 790 | return 0 |
785 | } | | 791 | } |
786 | | | 792 | |
787 | function uncompattype(type) { | | 793 | function uncompattype(type) { |
788 | for (var in uncompattypes) { | | 794 | for (var in uncompattypes) { |
789 | if (match(type, var)) { | | 795 | if (match(type, var)) { |
790 | sub(var, uncompattypes[var], type) | | 796 | sub(var, uncompattypes[var], type) |
791 | return type | | 797 | return type |
792 | } | | 798 | } |
793 | } | | 799 | } |
794 | | | 800 | |
795 | return type | | 801 | return type |
796 | } | | 802 | } |
797 | | | 803 | |
798 | function printrumpsysmap(syscall, wfn, funcalias, rumpentry) { | | 804 | function printrumpsysmap(syscall, wfn, funcalias, rumpentry) { |
799 | printf("%-4d %-22s %-18s %s\n", | | 805 | printf("%-4d %-22s %-18s %s\n", |
800 | syscall, wfn, funcalias, rumpentry) > rumpsysmap | | 806 | syscall, wfn, funcalias, rumpentry) > rumpsysmap |
801 | } | | 807 | } |
802 | | | 808 | |
803 | function putsystrace(type, compatwrap_) { | | 809 | function putsystrace(type, compatwrap_) { |
804 | printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace | | 810 | printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace |
805 | printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp | | 811 | printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp |
806 | printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systraceret | | 812 | printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systraceret |
807 | if (argc > 0) { | | 813 | if (argc > 0) { |
808 | printf("\t\tswitch(ndx) {\n") > systracetmp | | 814 | printf("\t\tswitch(ndx) {\n") > systracetmp |
809 | printf("\t\tconst struct %s%s_args *p = params;\n", compatwrap_, funcname) > systrace | | 815 | printf("\t\tconst struct %s%s_args *p = params;\n", compatwrap_, funcname) > systrace |
810 | for (i = 1; i <= argc; i++) { | | 816 | for (i = 1; i <= argc; i++) { |
811 | arg = argtype[i] | | 817 | arg = argtype[i] |
812 | sub("__restrict$", "", arg) | | 818 | sub("__restrict$", "", arg) |
813 | printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp | | 819 | printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp |
814 | if (arg ~ /.*p_t$/ || arg ~ /.*p$/ || arg ~ /.*_t_p$/ || | | 820 | if (arg ~ /.*p_t$/ || arg ~ /.*p$/ || arg ~ /.*_t_p$/ || |
815 | arg ~ /.*_pointer_t$/) | | 821 | arg ~ /.*_pointer_t$/) |
816 | printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s).i32; /* %s */\n", \ | | 822 | printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s).i32; /* %s */\n", \ |
817 | i - 1, \ | | 823 | i - 1, \ |
818 | argname[i], arg) > systrace | | 824 | argname[i], arg) > systrace |
819 | else if (index(arg, "*") > 0 || arg == "caddr_t" || | | 825 | else if (index(arg, "*") > 0 || arg == "caddr_t" || |
820 | arg ~ /.*_handler_t$/) | | 826 | arg ~ /.*_handler_t$/) |
821 | printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s); /* %s */\n", \ | | 827 | printf("\t\tuarg[%d] = (intptr_t) SCARG(p, %s); /* %s */\n", \ |
822 | i - 1, \ | | 828 | i - 1, \ |
823 | argname[i], arg) > systrace | | 829 | argname[i], arg) > systrace |
824 | else if (substr(arg, 1, 1) == "u" || arg == "size_t") | | 830 | else if (substr(arg, 1, 1) == "u" || arg == "size_t") |
825 | printf("\t\tuarg[%d] = SCARG(p, %s); /* %s */\n", \ | | 831 | printf("\t\tuarg[%d] = SCARG(p, %s); /* %s */\n", \ |
826 | i - 1, \ | | 832 | i - 1, \ |
827 | argname[i], arg) > systrace | | 833 | argname[i], arg) > systrace |
828 | else | | 834 | else |
829 | printf("\t\tiarg[%d] = SCARG(p, %s); /* %s */\n", \ | | 835 | printf("\t\tiarg[%d] = SCARG(p, %s); /* %s */\n", \ |
830 | i - 1, \ | | 836 | i - 1, \ |
831 | argname[i], arg) > systrace | | 837 | argname[i], arg) > systrace |
832 | } | | 838 | } |
833 | printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp | | 839 | printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp |
834 | | | 840 | |
835 | printf("\t\tif (ndx == 0 || ndx == 1)\n") > systraceret | | 841 | printf("\t\tif (ndx == 0 || ndx == 1)\n") > systraceret |
836 | printf("\t\t\tp = \"%s\";\n", returntype) > systraceret | | 842 | printf("\t\t\tp = \"%s\";\n", returntype) > systraceret |
837 | printf("\t\tbreak;\n") > systraceret | | 843 | printf("\t\tbreak;\n") > systraceret |
838 | } | | 844 | } |
839 | printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace | | 845 | printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace |
840 | printf("\t\tbreak;\n") > systracetmp | | 846 | printf("\t\tbreak;\n") > systracetmp |
841 | } | | 847 | } |
842 | | | 848 | |
843 | function putent(type, compatwrap) { | | 849 | function putent(type, compatwrap) { |
844 | # output syscall declaration for switch table. | | 850 | # output syscall declaration for switch table. |
845 | if (compatwrap == "") | | 851 | if (compatwrap == "") |
846 | compatwrap_ = "" | | 852 | compatwrap_ = "" |
847 | else | | 853 | else |
848 | compatwrap_ = compatwrap "_" | | 854 | compatwrap_ = compatwrap "_" |
849 | if (argc == 0) | | 855 | if (argc == 0) |
850 | arg_type = "void"; | | 856 | arg_type = "void"; |
851 | else { | | 857 | else { |
852 | arg_type = "struct " compatwrap_ funcname "_args"; | | 858 | arg_type = "struct " compatwrap_ funcname "_args"; |
853 | } | | 859 | } |
854 | putsystrace(type, compatwrap_) | | 860 | putsystrace(type, compatwrap_) |
855 | proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \ | | 861 | proto = "int\t" compatwrap_ funcname "(struct lwp *, const " \ |
856 | arg_type " *, register_t *);\n" | | 862 | arg_type " *, register_t *);\n" |
857 | if (sysmap[proto] != 1) { | | 863 | if (sysmap[proto] != 1) { |
858 | sysmap[proto] = 1; | | 864 | sysmap[proto] = 1; |
859 | print proto > sysprotos; | | 865 | print proto > sysprotos; |
860 | } | | 866 | } |
861 | | | 867 | |
862 | # output syscall switch entry | | 868 | # output syscall switch entry |
863 | printf("\t{") > sysent | | 869 | printf("\t{") > sysent |
864 | if (argc != 0) { | | 870 | if (argc != 0) { |
865 | printf("\n\t\tns(struct %s%s_args),", compatwrap_, funcname) > sysent | | 871 | printf("\n\t\tns(struct %s%s_args),", compatwrap_, funcname) > sysent |
866 | } | | 872 | } |
867 | if (modular) { | | 873 | if (modular) { |
868 | wfn = "sys_nomodule"; | | 874 | wfn = "sys_nomodule"; |
869 | idx = int(syscall / 32); | | 875 | idx = int(syscall / 32); |
870 | bit = 2 ^ (syscall % 32); | | 876 | bit = 2 ^ (syscall % 32); |
871 | nomodbits[ idx ] += bit; | | 877 | nomodbits[ idx ] += bit; |
872 | } else if (compatwrap == "") | | 878 | } else if (compatwrap == "") |
873 | wfn = funcname; | | 879 | wfn = funcname; |
874 | else | | 880 | else |
875 | wfn = compatwrap "(" funcname ")"; | | 881 | wfn = compatwrap "(" funcname ")"; |
876 | wfn_cast="(sy_call_t *)" wfn | | 882 | wfn_cast="(sy_call_t *)" wfn |
877 | if (sycall_flags != "0") | | 883 | if (sycall_flags != "0") |
878 | flags = "\n\t\t.sy_flags = " sycall_flags "," | | 884 | flags = "\n\t\t.sy_flags = " sycall_flags "," |
879 | else | | 885 | else |
880 | flags = "" | | 886 | flags = "" |
881 | printf("%s\n\t\t.sy_call = %s\n\t},", flags, wfn_cast) > sysent | | 887 | printf("%s\n\t\t.sy_call = %s\n\t},", flags, wfn_cast) > sysent |
882 | printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent | | 888 | printf("\t\t/* %d = %s%s */\n", syscall, compatwrap_, funcalias) > sysent |
883 | | | 889 | |
884 | # output syscall name for names table | | 890 | # output syscall name for names table |
885 | printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \ | | 891 | printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, funcalias) \ |
886 | > sysnamesbottom | | 892 | > sysnamesbottom |
887 | if (compatwrap_ != "" || fbase == funcalias) | | 893 | if (compatwrap_ != "" || fbase == funcalias) |
888 | printf("\t/* %3d */\tNULL, /* %s%s */\n", syscall, \ | | 894 | printf("\t/* %3d */\tNULL, /* %s%s */\n", syscall, \ |
889 | compatwrap_, funcalias) > sysnamesfriendly | | 895 | compatwrap_, funcalias) > sysnamesfriendly |
890 | else | | 896 | else |
891 | printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, \ | | 897 | printf("\t/* %3d */\t\"%s%s\",\n", syscall, compatwrap_, \ |
892 | fbase) > sysnamesfriendly | | 898 | fbase) > sysnamesfriendly |
893 | | | 899 | |
894 | # output syscall number of header, if appropriate | | 900 | # output syscall number of header, if appropriate |
895 | if (type == "STD" || type == "NOARGS" || type == "INDIR" || \ | | 901 | if (type == "STD" || type == "NOARGS" || type == "INDIR" || \ |
896 | type == "NOERR") { | | 902 | type == "NOERR") { |
897 | # output a prototype, to be used to generate lint stubs in | | 903 | # output a prototype, to be used to generate lint stubs in |
898 | # libc. | | 904 | # libc. |
899 | printproto("") | | 905 | printproto("") |
900 | } else if (type == "COMPAT" || type == "EXTERN") { | | 906 | } else if (type == "COMPAT" || type == "EXTERN") { |
901 | # Just define the syscall number with a comment. These | | 907 | # Just define the syscall number with a comment. These |
902 | # may be used by compatibility stubs in libc. | | 908 | # may be used by compatibility stubs in libc. |
903 | printproto(compatwrap_) | | 909 | printproto(compatwrap_) |
904 | } | | 910 | } |
905 | | | 911 | |
906 | # output syscall argument structure, if it has arguments | | 912 | # output syscall argument structure, if it has arguments |
907 | if (argc != 0) { | | 913 | if (argc != 0) { |
908 | printf("\n") > sysarghdr | | 914 | printf("\n") > sysarghdr |
909 | if (haverumpcalls && !rumpable) | | 915 | if (haverumpcalls && !rumpable) |
910 | printf("#ifndef RUMP_CLIENT\n") > sysarghdr | | 916 | printf("#ifndef RUMP_CLIENT\n") > sysarghdr |
911 | printf("struct %s%s_args", compatwrap_, funcname) > sysarghdr | | 917 | printf("struct %s%s_args", compatwrap_, funcname) > sysarghdr |
912 | if (type != "NOARGS") { | | 918 | if (type != "NOARGS") { |
913 | print " {" >sysarghdr; | | 919 | print " {" >sysarghdr; |
914 | for (i = 1; i <= argc; i++) | | 920 | for (i = 1; i <= argc; i++) |
915 | printf("\tsyscallarg(%s) %s;\n", argtype[i], | | 921 | printf("\tsyscallarg(%s) %s;\n", argtype[i], |
916 | argname[i]) > sysarghdr | | 922 | argname[i]) > sysarghdr |
917 | printf "}" >sysarghdr; | | 923 | printf "}" >sysarghdr; |
918 | } | | 924 | } |
919 | printf(";\n") > sysarghdr | | 925 | printf(";\n") > sysarghdr |
920 | if (type != "NOARGS" && type != "INDIR") { | | 926 | if (type != "NOARGS" && type != "INDIR") { |
921 | printf("check_syscall_args(%s%s)\n", compatwrap_, | | 927 | printf("check_syscall_args(%s%s)\n", compatwrap_, |
922 | funcname) >sysarghdr | | 928 | funcname) >sysarghdr |
923 | } | | 929 | } |
924 | if (haverumpcalls && !rumpable) | | 930 | if (haverumpcalls && !rumpable) |
925 | printf("#endif /* !RUMP_CLIENT */\n") > sysarghdr | | 931 | printf("#endif /* !RUMP_CLIENT */\n") > sysarghdr |
926 | } | | 932 | } |
927 | | | 933 | |
928 | if (!rumpable) { | | 934 | if (!rumpable) { |
929 | if (funcname == "sys_pipe" && rumphaspipe == 1) { | | 935 | if (funcname == "sys_pipe" && rumphaspipe == 1) { |
930 | insysent = 1 | | 936 | insysent = 1 |
931 | printrumpsysmap(syscall, | | 937 | printrumpsysmap(syscall, |
932 | funcname, funcalias, "rump_sys_pipe") | | 938 | funcname, funcalias, "rump_sys_pipe") |
933 | } else { | | 939 | } else { |
934 | insysent = 0 | | 940 | insysent = 0 |
935 | } | | 941 | } |
936 | } else { | | 942 | } else { |
937 | insysent = 1 | | 943 | insysent = 1 |
938 | } | | 944 | } |
939 | printrumpsysent(insysent, compatwrap) | | 945 | printrumpsysent(insysent, compatwrap) |
940 | | | 946 | |
941 | # output rump marshalling code if necessary | | 947 | # output rump marshalling code if necessary |
942 | if (!rumpable) { | | 948 | if (!rumpable) { |
943 | return | | 949 | return |
944 | } | | 950 | } |
945 | | | 951 | |
946 | printrumpsysmap(syscall, wfn, funcalias, "rump___sysimpl_" rumpfname) | | 952 | printrumpsysmap(syscall, wfn, funcalias, "rump___sysimpl_" rumpfname) |
947 | | | 953 | |
948 | printf("\n") > rumpcalls | | 954 | printf("\n") > rumpcalls |
949 | | | 955 | |
950 | if (compatwrap) | | 956 | if (compatwrap) |
951 | printf("#ifdef RUMP_SYS_COMPAT\n") > rumpcalls | | 957 | printf("#ifdef RUMP_SYS_COMPAT\n") > rumpcalls |
952 | | | 958 | |
953 | # need a local prototype, we export the re-re-named one in .h | | 959 | # need a local prototype, we export the re-re-named one in .h |
954 | printf("%s rump___sysimpl_%s(", returntype, rumpfname) \ | | 960 | printf("%s rump___sysimpl_%s(", returntype, rumpfname) \ |
955 | > rumpcalls | | 961 | > rumpcalls |
956 | for (i = 1; i < argc; i++) { | | 962 | for (i = 1; i < argc; i++) { |
957 | if (argname[i] != "PAD") | | 963 | if (argname[i] != "PAD") |
958 | printf("%s, ", uncompattype(argtype[i])) > rumpcalls | | 964 | printf("%s, ", uncompattype(argtype[i])) > rumpcalls |
959 | } | | 965 | } |
960 | printf("%s);", uncompattype(argtype[argc])) > rumpcalls | | 966 | printf("%s);", uncompattype(argtype[argc])) > rumpcalls |
961 | | | 967 | |
962 | printf("\n%s\nrump___sysimpl_%s(", returntype, rumpfname) > rumpcalls | | 968 | printf("\n%s\nrump___sysimpl_%s(", returntype, rumpfname) > rumpcalls |
963 | for (i = 1; i < argc; i++) { | | 969 | for (i = 1; i < argc; i++) { |
964 | if (argname[i] != "PAD") | | 970 | if (argname[i] != "PAD") |
965 | printf("%s %s, ", uncompattype(argtype[i]), \ | | 971 | printf("%s %s, ", uncompattype(argtype[i]), \ |
966 | argname[i]) > rumpcalls | | 972 | argname[i]) > rumpcalls |
967 | } | | 973 | } |
968 | printf("%s %s)\n", uncompattype(argtype[argc]), argname[argc]) \ | | 974 | printf("%s %s)\n", uncompattype(argtype[argc]), argname[argc]) \ |
969 | > rumpcalls | | 975 | > rumpcalls |
970 | printf("{\n\tregister_t retval[2];\n") > rumpcalls | | 976 | printf("{\n\tregister_t retval[2];\n") > rumpcalls |
971 | if (returntype != "void") { | | 977 | if (returntype != "void") { |
972 | if (type != "NOERR") { | | 978 | if (type != "NOERR") { |
973 | printf("\tint error = 0;\n") > rumpcalls | | 979 | printf("\tint error = 0;\n") > rumpcalls |
974 | } | | 980 | } |
975 | # assume rumpcalls return only integral types | | 981 | # assume rumpcalls return only integral types |
976 | printf("\t%s rv = -1;\n", returntype) > rumpcalls | | 982 | printf("\t%s rv = -1;\n", returntype) > rumpcalls |
977 | } | | 983 | } |
978 | | | 984 | |
979 | argarg = "NULL" | | 985 | argarg = "NULL" |
980 | argsize = 0; | | 986 | argsize = 0; |
981 | if (argc) { | | 987 | if (argc) { |
982 | argarg = "&callarg" | | 988 | argarg = "&callarg" |
983 | argsize = "sizeof(callarg)" | | 989 | argsize = "sizeof(callarg)" |
984 | printf("\tstruct %s%s_args callarg;\n\n",compatwrap_,funcname) \ | | 990 | printf("\tstruct %s%s_args callarg;\n\n",compatwrap_,funcname) \ |
985 | > rumpcalls | | 991 | > rumpcalls |
986 | printf "\tmemset(&callarg, 0, sizeof(callarg));\n" > rumpcalls | | 992 | printf "\tmemset(&callarg, 0, sizeof(callarg));\n" > rumpcalls |
987 | for (i = 1; i <= argc; i++) { | | 993 | for (i = 1; i <= argc; i++) { |
988 | if (argname[i] == "PAD") { | | 994 | if (argname[i] == "PAD") { |
989 | printf("\tSPARG(&callarg, %s) = 0;\n", \ | | 995 | printf("\tSPARG(&callarg, %s) = 0;\n", \ |
990 | argname[i]) > rumpcalls | | 996 | argname[i]) > rumpcalls |
991 | } else { | | 997 | } else { |
992 | if (iscompattype(argtype[i])) { | | 998 | if (iscompattype(argtype[i])) { |
993 | printf("\tSPARG(&callarg, %s) = " \ | | 999 | printf("\tSPARG(&callarg, %s) = " \ |
994 | "(%s)%s;\n", argname[i], argtype[i], \ | | 1000 | "(%s)%s;\n", argname[i], argtype[i], \ |
995 | argname[i]) > rumpcalls | | 1001 | argname[i]) > rumpcalls |
996 | } else { | | 1002 | } else { |
997 | printf("\tSPARG(&callarg, %s) = %s;\n",\ | | 1003 | printf("\tSPARG(&callarg, %s) = %s;\n",\ |
998 | argname[i], argname[i]) > rumpcalls | | 1004 | argname[i], argname[i]) > rumpcalls |
999 | } | | 1005 | } |
1000 | } | | 1006 | } |
1001 | } | | 1007 | } |
1002 | printf("\n") > rumpcalls | | 1008 | printf("\n") > rumpcalls |
1003 | } else { | | 1009 | } else { |
1004 | printf("\n") > rumpcalls | | 1010 | printf("\n") > rumpcalls |
1005 | } | | 1011 | } |
1006 | printf("\t") > rumpcalls | | 1012 | printf("\t") > rumpcalls |
1007 | if (returntype != "void" && type != "NOERR") | | 1013 | if (returntype != "void" && type != "NOERR") |
1008 | printf("error = ") > rumpcalls | | 1014 | printf("error = ") > rumpcalls |
1009 | else if (returntype != "void") | | 1015 | else if (returntype != "void") |
1010 | printf("(void)") > rumpcalls | | 1016 | printf("(void)") > rumpcalls |
1011 | printf("rsys_syscall(%s%s%s, " \ | | 1017 | printf("rsys_syscall(%s%s%s, " \ |
1012 | "%s, %s, retval);\n", constprefix, compatwrap_, funcalias, \ | | 1018 | "%s, %s, retval);\n", constprefix, compatwrap_, funcalias, \ |
1013 | argarg, argsize) > rumpcalls | | 1019 | argarg, argsize) > rumpcalls |
1014 | if (type != "NOERR") { | | 1020 | if (type != "NOERR") { |
1015 | printf("\trsys_seterrno(error);\n") > rumpcalls | | 1021 | printf("\trsys_seterrno(error);\n") > rumpcalls |
1016 | printf("\tif (error == 0) {\n") > rumpcalls | | 1022 | printf("\tif (error == 0) {\n") > rumpcalls |
1017 | indent="\t\t" | | 1023 | indent="\t\t" |
1018 | ending="\t}\n" | | 1024 | ending="\t}\n" |
1019 | } else { | | 1025 | } else { |
1020 | indent="\t" | | 1026 | indent="\t" |
1021 | ending="" | | 1027 | ending="" |
1022 | } | | 1028 | } |
1023 | if (returntype != "void") { | | 1029 | if (returntype != "void") { |
1024 | printf("%sif (sizeof(%s) > sizeof(register_t))\n", \ | | 1030 | printf("%sif (sizeof(%s) > sizeof(register_t))\n", \ |
1025 | indent, returntype) > rumpcalls | | 1031 | indent, returntype) > rumpcalls |
1026 | printf("%s\trv = *(%s *)retval;\n", \ | | 1032 | printf("%s\trv = *(%s *)retval;\n", \ |
1027 | indent, returntype) > rumpcalls | | 1033 | indent, returntype) > rumpcalls |
1028 | printf("%selse\n", indent, indent) > rumpcalls | | 1034 | printf("%selse\n", indent, indent) > rumpcalls |
1029 | printf("%s\trv = *retval;\n", indent, returntype) > rumpcalls | | 1035 | printf("%s\trv = *retval;\n", indent, returntype) > rumpcalls |
1030 | printf("%s", ending) > rumpcalls | | 1036 | printf("%s", ending) > rumpcalls |
1031 | printf("\treturn rv;\n") > rumpcalls | | 1037 | printf("\treturn rv;\n") > rumpcalls |
1032 | } | | 1038 | } |
1033 | printf("}\n") > rumpcalls | | 1039 | printf("}\n") > rumpcalls |
1034 | | | 1040 | |
1035 | printf("#ifdef RUMP_KERNEL_IS_LIBC\n") > rumpcalls | | 1041 | printf("#ifdef RUMP_KERNEL_IS_LIBC\n") > rumpcalls |
1036 | | | 1042 | |
1037 | # create the bog-standard, non-renamed public name. | | 1043 | # create the bog-standard, non-renamed public name. |
1038 | # this way we get e.g. select instead of just __select50 | | 1044 | # this way we get e.g. select instead of just __select50 |
1039 | if (fcompat) | | 1045 | if (fcompat) |
1040 | printf("__weak_alias(%s,rump___sysimpl_%s);\n", \ | | 1046 | printf("__weak_alias(%s,rump___sysimpl_%s);\n", \ |
1041 | fbase, rumpfname) > rumpcalls | | 1047 | fbase, rumpfname) > rumpcalls |
1042 | | | 1048 | |
1043 | printf("__weak_alias(%s,rump___sysimpl_%s);\n", \ | | 1049 | printf("__weak_alias(%s,rump___sysimpl_%s);\n", \ |
1044 | funcalias, rumpfname) > rumpcalls | | 1050 | funcalias, rumpfname) > rumpcalls |
1045 | printf("__weak_alias(_%s,rump___sysimpl_%s);\n", \ | | 1051 | printf("__weak_alias(_%s,rump___sysimpl_%s);\n", \ |
1046 | funcalias, rumpfname) > rumpcalls | | 1052 | funcalias, rumpfname) > rumpcalls |
1047 | printf("__strong_alias(_sys_%s,rump___sysimpl_%s);\n", \ | | 1053 | printf("__strong_alias(_sys_%s,rump___sysimpl_%s);\n", \ |
1048 | funcalias, rumpfname) >rumpcalls | | 1054 | funcalias, rumpfname) >rumpcalls |
1049 | | | 1055 | |
1050 | printf("#endif /* RUMP_KERNEL_IS_LIBC */\n") > rumpcalls | | 1056 | printf("#endif /* RUMP_KERNEL_IS_LIBC */\n") > rumpcalls |
1051 | | | 1057 | |
1052 | if (compatwrap) | | 1058 | if (compatwrap) |
1053 | printf("#endif /* RUMP_SYS_COMPAT */\n") > rumpcalls | | 1059 | printf("#endif /* RUMP_SYS_COMPAT */\n") > rumpcalls |
1054 | | | 1060 | |
1055 | } | | 1061 | } |
1056 | $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" \ | | 1062 | $2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" \ |
1057 | || $2 == "NOERR" { | | 1063 | || $2 == "NOERR" { |
1058 | parseline() | | 1064 | parseline() |
1059 | putent($2, "") | | 1065 | putent($2, "") |
1060 | syscall++ | | 1066 | syscall++ |
1061 | next | | 1067 | next |
1062 | } | | 1068 | } |
1063 | $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" { | | 1069 | $2 == "OBSOL" || $2 == "UNIMPL" || $2 == "EXCL" || $2 == "IGNORED" { |
1064 | if ($2 == "OBSOL") | | 1070 | if ($2 == "OBSOL") |
1065 | comment="obsolete" | | 1071 | comment="obsolete" |
1066 | else if ($2 == "EXCL") | | 1072 | else if ($2 == "EXCL") |
1067 | comment="excluded" | | 1073 | comment="excluded" |
1068 | else if ($2 == "IGNORED") | | 1074 | else if ($2 == "IGNORED") |
1069 | comment="ignored" | | 1075 | comment="ignored" |
1070 | else | | 1076 | else |
1071 | comment="unimplemented" | | 1077 | comment="unimplemented" |
1072 | for (i = 3; i <= NF; i++) | | 1078 | for (i = 3; i <= NF; i++) |
1073 | comment=comment " " $i | | 1079 | comment=comment " " $i |
1074 | | | 1080 | |
1075 | if ($2 == "IGNORED") | | 1081 | if ($2 == "IGNORED") |
1076 | sys_stub = "(sy_call_t *)nullop"; | | 1082 | sys_stub = "(sy_call_t *)nullop"; |
1077 | else | | 1083 | else |
1078 | sys_stub = sys_nosys; | | 1084 | sys_stub = sys_nosys; |
1079 | | | 1085 | |
1080 | print fillerpsysent(syscall, "", sys_stub, comment) > sysent | | 1086 | print fillerpsysent(syscall, "", sys_stub, comment) > sysent |
1081 | print fillerpsysent(syscall, rumpnoflags, rumpnosys, comment) > rumpsysent | | 1087 | print fillerpsysent(syscall, rumpnoflags, rumpnosys, comment) > rumpsysent |
1082 | printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \ | | 1088 | printf("\t/* %3d */\t\"#%d (%s)\",\n", syscall, syscall, comment) \ |
1083 | > sysnamesbottom | | 1089 | > sysnamesbottom |
1084 | printf("\t/* %3d */\tNULL, /* %s */\n", syscall, comment) \ | | 1090 | printf("\t/* %3d */\tNULL, /* %s */\n", syscall, comment) \ |
1085 | > sysnamesfriendly | | 1091 | > sysnamesfriendly |