| @@ -1,24 +1,24 @@ | | | @@ -1,24 +1,24 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | | | 2 | |
3 | # Generates various defines needed for using rump on non-NetBSD systems. | | 3 | # Generates various defines needed for using rump on non-NetBSD systems. |
4 | # Run this occasionally (yes, it's a slightly suboptimal kludge, but | | 4 | # Run this occasionally (yes, it's a slightly suboptimal kludge, but |
5 | # better than nothing). | | 5 | # better than nothing). |
6 | | | 6 | |
7 | echo Generating rumpdefs.h | | 7 | echo Generating rumpdefs.h |
8 | rm -f rumpdefs.h | | 8 | rm -f rumpdefs.h |
9 | exec 3>&1 > rumpdefs.h | | 9 | exec 3>&1 > rumpdefs.h |
10 | | | 10 | |
11 | printf '/* $NetBSD: makerumpdefs.sh,v 1.29 2016/02/02 01:15:24 pooka Exp $ */\n\n' | | 11 | printf '/* $NetBSD: makerumpdefs.sh,v 1.30 2018/08/21 08:22:33 msaitoh Exp $ */\n\n' |
12 | printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n\n' | | 12 | printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n\n' |
13 | printf '#ifndef _RUMP_RUMPDEFS_H_\n' | | 13 | printf '#ifndef _RUMP_RUMPDEFS_H_\n' |
14 | printf '#define _RUMP_RUMPDEFS_H_\n\n' | | 14 | printf '#define _RUMP_RUMPDEFS_H_\n\n' |
15 | printf '#include <rump/rump_namei.h>\n' | | 15 | printf '#include <rump/rump_namei.h>\n' |
16 | | | 16 | |
17 | fromvers () { | | 17 | fromvers () { |
18 | echo | | 18 | echo |
19 | sed -n '1{s/\$//gp;q;}' $1 | | 19 | sed -n '1{s/\$//gp;q;}' $1 |
20 | } | | 20 | } |
21 | | | 21 | |
22 | # not perfect, but works well enough for the cases so far | | 22 | # not perfect, but works well enough for the cases so far |
23 | # (also has one struct-specific hack for MAXNAMLEN) | | 23 | # (also has one struct-specific hack for MAXNAMLEN) |
24 | getstruct () { | | 24 | getstruct () { |
| @@ -125,32 +125,32 @@ getstruct ../../../ufs/ufs/ufsmount.h uf | | | @@ -125,32 +125,32 @@ getstruct ../../../ufs/ufs/ufsmount.h uf |
125 | fromvers ../../../fs/sysvbfs/sysvbfs_args.h | | 125 | fromvers ../../../fs/sysvbfs/sysvbfs_args.h |
126 | getstruct ../../../fs/sysvbfs/sysvbfs_args.h sysvbfs_args | | 126 | getstruct ../../../fs/sysvbfs/sysvbfs_args.h sysvbfs_args |
127 | | | 127 | |
128 | fromvers ../../../sys/dirent.h | | 128 | fromvers ../../../sys/dirent.h |
129 | getstruct ../../../sys/dirent.h dirent | | 129 | getstruct ../../../sys/dirent.h dirent |
130 | | | 130 | |
131 | printf '\n#endif /* _RUMP_RUMPDEFS_H_ */\n' | | 131 | printf '\n#endif /* _RUMP_RUMPDEFS_H_ */\n' |
132 | | | 132 | |
133 | exec 1>&3 | | 133 | exec 1>&3 |
134 | | | 134 | |
135 | echo Generating rumperr.h | | 135 | echo Generating rumperr.h |
136 | rm -f rumperr.h | | 136 | rm -f rumperr.h |
137 | exec > rumperr.h | | 137 | exec > rumperr.h |
138 | printf '/* $NetBSD: makerumpdefs.sh,v 1.29 2016/02/02 01:15:24 pooka Exp $ */\n\n' | | 138 | printf '/* $NetBSD: makerumpdefs.sh,v 1.30 2018/08/21 08:22:33 msaitoh Exp $ */\n\n' |
139 | printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n' | | 139 | printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n' |
140 | | | 140 | |
141 | fromvers ../../../sys/errno.h | | 141 | fromvers ../../../sys/errno.h |
142 | | | 142 | |
143 | printf "\nstatic inline const char *\nrump_strerror(int error)\n{\n\n" | | 143 | printf "\nstatic __inline const char *\nrump_strerror(int error)\n{\n\n" |
144 | printf "\tswitch (error) {\n\tcase 0:\n" | | 144 | printf "\tswitch (error) {\n\tcase 0:\n" |
145 | printf "\t\t return \"No error: zero, zip, zilch, none!\";\n" | | 145 | printf "\t\t return \"No error: zero, zip, zilch, none!\";\n" |
146 | awk '/^#define[ ]*E.*[0-9]/{ | | 146 | awk '/^#define[ ]*E.*[0-9]/{ |
147 | ename = $2 | | 147 | ename = $2 |
148 | evalue = $3 | | 148 | evalue = $3 |
149 | error = 1 | | 149 | error = 1 |
150 | if (ename == "ELAST") { | | 150 | if (ename == "ELAST") { |
151 | printf "\tdefault:\n" | | 151 | printf "\tdefault:\n" |
152 | printf "\t\treturn \"Invalid error!\";\n\t}\n}\n" | | 152 | printf "\t\treturn \"Invalid error!\";\n\t}\n}\n" |
153 | error = 0 | | 153 | error = 0 |
154 | exit 0 | | 154 | exit 0 |
155 | } | | 155 | } |
156 | if (preverror + 1 != evalue) | | 156 | if (preverror + 1 != evalue) |
| @@ -166,33 +166,33 @@ awk '/^#define[ ]*E.*[0-9]/{ | | | @@ -166,33 +166,33 @@ awk '/^#define[ ]*E.*[0-9]/{ |
166 | } | | 166 | } |
167 | END { | | 167 | END { |
168 | exit error | | 168 | exit error |
169 | }' < ../../../sys/errno.h | | 169 | }' < ../../../sys/errno.h |
170 | if [ $? -ne 0 ]; then | | 170 | if [ $? -ne 0 ]; then |
171 | echo 'Parsing errno.h failed!' 1>&3 | | 171 | echo 'Parsing errno.h failed!' 1>&3 |
172 | rm -f rumpdefs.h rumperr.h | | 172 | rm -f rumpdefs.h rumperr.h |
173 | exit 1 | | 173 | exit 1 |
174 | fi | | 174 | fi |
175 | | | 175 | |
176 | echo Generating rumperrno2host.h 1>&3 | | 176 | echo Generating rumperrno2host.h 1>&3 |
177 | rm -f rumperrno2host.h | | 177 | rm -f rumperrno2host.h |
178 | exec > rumperrno2host.h | | 178 | exec > rumperrno2host.h |
179 | printf '/* $NetBSD: makerumpdefs.sh,v 1.29 2016/02/02 01:15:24 pooka Exp $ */\n\n' | | 179 | printf '/* $NetBSD: makerumpdefs.sh,v 1.30 2018/08/21 08:22:33 msaitoh Exp $ */\n\n' |
180 | printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n' | | 180 | printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n' |
181 | | | 181 | |
182 | fromvers ../../../sys/errno.h | | 182 | fromvers ../../../sys/errno.h |
183 | | | 183 | |
184 | printf "\n#ifndef ERANGE\n#error include ISO C style errno.h first\n#endif\n" | | 184 | printf "\n#ifndef ERANGE\n#error include ISO C style errno.h first\n#endif\n" |
185 | printf "\nstatic inline int \nrump_errno2host(int rumperrno)\n{\n\n" | | 185 | printf "\nstatic __inline int \nrump_errno2host(int rumperrno)\n{\n\n" |
186 | printf "\tswitch (rumperrno) {\n\tcase 0:\n" | | 186 | printf "\tswitch (rumperrno) {\n\tcase 0:\n" |
187 | printf "\t\t return 0;\n" | | 187 | printf "\t\t return 0;\n" |
188 | awk '/^#define[ ]*E.*[0-9]/{ | | 188 | awk '/^#define[ ]*E.*[0-9]/{ |
189 | ename = $2 | | 189 | ename = $2 |
190 | evalue = $3 | | 190 | evalue = $3 |
191 | error = 1 | | 191 | error = 1 |
192 | if (ename == "ELAST") { | | 192 | if (ename == "ELAST") { |
193 | printf "\tdefault:\n" | | 193 | printf "\tdefault:\n" |
194 | printf "#ifdef EINVAL\n\t\treturn EINVAL;\n" | | 194 | printf "#ifdef EINVAL\n\t\treturn EINVAL;\n" |
195 | printf "#else\n\t\treturn ERANGE;\n#endif\n" | | 195 | printf "#else\n\t\treturn ERANGE;\n#endif\n" |
196 | printf "\t}\n}\n" | | 196 | printf "\t}\n}\n" |
197 | error = 0 | | 197 | error = 0 |
198 | exit 0 | | 198 | exit 0 |