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