diff options
Diffstat (limited to 'vendor/golang.org/x/sys/unix/mkerrors.sh')
-rw-r--r-- | vendor/golang.org/x/sys/unix/mkerrors.sh | 784 |
1 files changed, 784 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh new file mode 100644 index 0000000..6202638 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh | |||
@@ -0,0 +1,784 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | # Copyright 2009 The Go Authors. All rights reserved. | ||
3 | # Use of this source code is governed by a BSD-style | ||
4 | # license that can be found in the LICENSE file. | ||
5 | |||
6 | # Generate Go code listing errors and other #defined constant | ||
7 | # values (ENAMETOOLONG etc.), by asking the preprocessor | ||
8 | # about the definitions. | ||
9 | |||
10 | unset LANG | ||
11 | export LC_ALL=C | ||
12 | export LC_CTYPE=C | ||
13 | |||
14 | if test -z "$GOARCH" -o -z "$GOOS"; then | ||
15 | echo 1>&2 "GOARCH or GOOS not defined in environment" | ||
16 | exit 1 | ||
17 | fi | ||
18 | |||
19 | # Check that we are using the new build system if we should | ||
20 | if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then | ||
21 | echo 1>&2 "In the Docker based build system, mkerrors should not be called directly." | ||
22 | echo 1>&2 "See README.md" | ||
23 | exit 1 | ||
24 | fi | ||
25 | |||
26 | if [[ "$GOOS" = "aix" ]]; then | ||
27 | CC=${CC:-gcc} | ||
28 | else | ||
29 | CC=${CC:-cc} | ||
30 | fi | ||
31 | |||
32 | if [[ "$GOOS" = "solaris" ]]; then | ||
33 | # Assumes GNU versions of utilities in PATH. | ||
34 | export PATH=/usr/gnu/bin:$PATH | ||
35 | fi | ||
36 | |||
37 | uname=$(uname) | ||
38 | |||
39 | includes_AIX=' | ||
40 | #include <net/if.h> | ||
41 | #include <net/netopt.h> | ||
42 | #include <netinet/ip_mroute.h> | ||
43 | #include <sys/protosw.h> | ||
44 | #include <sys/stropts.h> | ||
45 | #include <sys/mman.h> | ||
46 | #include <sys/poll.h> | ||
47 | #include <sys/select.h> | ||
48 | #include <sys/termio.h> | ||
49 | #include <termios.h> | ||
50 | #include <fcntl.h> | ||
51 | |||
52 | #define AF_LOCAL AF_UNIX | ||
53 | ' | ||
54 | |||
55 | includes_Darwin=' | ||
56 | #define _DARWIN_C_SOURCE | ||
57 | #define KERNEL 1 | ||
58 | #define _DARWIN_USE_64_BIT_INODE | ||
59 | #define __APPLE_USE_RFC_3542 | ||
60 | #include <stdint.h> | ||
61 | #include <sys/attr.h> | ||
62 | #include <sys/clonefile.h> | ||
63 | #include <sys/kern_control.h> | ||
64 | #include <sys/types.h> | ||
65 | #include <sys/event.h> | ||
66 | #include <sys/ptrace.h> | ||
67 | #include <sys/select.h> | ||
68 | #include <sys/socket.h> | ||
69 | #include <sys/stat.h> | ||
70 | #include <sys/un.h> | ||
71 | #include <sys/sockio.h> | ||
72 | #include <sys/sys_domain.h> | ||
73 | #include <sys/sysctl.h> | ||
74 | #include <sys/mman.h> | ||
75 | #include <sys/mount.h> | ||
76 | #include <sys/utsname.h> | ||
77 | #include <sys/wait.h> | ||
78 | #include <sys/xattr.h> | ||
79 | #include <sys/vsock.h> | ||
80 | #include <net/bpf.h> | ||
81 | #include <net/if.h> | ||
82 | #include <net/if_types.h> | ||
83 | #include <net/route.h> | ||
84 | #include <netinet/in.h> | ||
85 | #include <netinet/ip.h> | ||
86 | #include <termios.h> | ||
87 | |||
88 | // for backwards compatibility because moved TIOCREMOTE to Kernel.framework after MacOSX12.0.sdk. | ||
89 | #define TIOCREMOTE 0x80047469 | ||
90 | ' | ||
91 | |||
92 | includes_DragonFly=' | ||
93 | #include <sys/types.h> | ||
94 | #include <sys/event.h> | ||
95 | #include <sys/select.h> | ||
96 | #include <sys/socket.h> | ||
97 | #include <sys/sockio.h> | ||
98 | #include <sys/stat.h> | ||
99 | #include <sys/sysctl.h> | ||
100 | #include <sys/mman.h> | ||
101 | #include <sys/mount.h> | ||
102 | #include <sys/wait.h> | ||
103 | #include <sys/ioctl.h> | ||
104 | #include <net/bpf.h> | ||
105 | #include <net/if.h> | ||
106 | #include <net/if_clone.h> | ||
107 | #include <net/if_types.h> | ||
108 | #include <net/route.h> | ||
109 | #include <netinet/in.h> | ||
110 | #include <termios.h> | ||
111 | #include <netinet/ip.h> | ||
112 | #include <net/ip_mroute/ip_mroute.h> | ||
113 | ' | ||
114 | |||
115 | includes_FreeBSD=' | ||
116 | #include <sys/capsicum.h> | ||
117 | #include <sys/param.h> | ||
118 | #include <sys/types.h> | ||
119 | #include <sys/disk.h> | ||
120 | #include <sys/event.h> | ||
121 | #include <sys/sched.h> | ||
122 | #include <sys/select.h> | ||
123 | #include <sys/socket.h> | ||
124 | #include <sys/un.h> | ||
125 | #include <sys/sockio.h> | ||
126 | #include <sys/stat.h> | ||
127 | #include <sys/sysctl.h> | ||
128 | #include <sys/mman.h> | ||
129 | #include <sys/mount.h> | ||
130 | #include <sys/wait.h> | ||
131 | #include <sys/ioctl.h> | ||
132 | #include <sys/ptrace.h> | ||
133 | #include <net/bpf.h> | ||
134 | #include <net/if.h> | ||
135 | #include <net/if_types.h> | ||
136 | #include <net/route.h> | ||
137 | #include <netinet/in.h> | ||
138 | #include <termios.h> | ||
139 | #include <netinet/ip.h> | ||
140 | #include <netinet/ip_mroute.h> | ||
141 | #include <sys/extattr.h> | ||
142 | |||
143 | #if __FreeBSD__ >= 10 | ||
144 | #define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10 | ||
145 | #undef SIOCAIFADDR | ||
146 | #define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data | ||
147 | #undef SIOCSIFPHYADDR | ||
148 | #define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data | ||
149 | #endif | ||
150 | ' | ||
151 | |||
152 | includes_Linux=' | ||
153 | #define _LARGEFILE_SOURCE | ||
154 | #define _LARGEFILE64_SOURCE | ||
155 | #ifndef __LP64__ | ||
156 | #define _FILE_OFFSET_BITS 64 | ||
157 | #endif | ||
158 | #define _GNU_SOURCE | ||
159 | |||
160 | // <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of | ||
161 | // these structures. We just include them copied from <bits/termios.h>. | ||
162 | #if defined(__powerpc__) | ||
163 | struct sgttyb { | ||
164 | char sg_ispeed; | ||
165 | char sg_ospeed; | ||
166 | char sg_erase; | ||
167 | char sg_kill; | ||
168 | short sg_flags; | ||
169 | }; | ||
170 | |||
171 | struct tchars { | ||
172 | char t_intrc; | ||
173 | char t_quitc; | ||
174 | char t_startc; | ||
175 | char t_stopc; | ||
176 | char t_eofc; | ||
177 | char t_brkc; | ||
178 | }; | ||
179 | |||
180 | struct ltchars { | ||
181 | char t_suspc; | ||
182 | char t_dsuspc; | ||
183 | char t_rprntc; | ||
184 | char t_flushc; | ||
185 | char t_werasc; | ||
186 | char t_lnextc; | ||
187 | }; | ||
188 | #endif | ||
189 | |||
190 | #include <bits/sockaddr.h> | ||
191 | #include <sys/epoll.h> | ||
192 | #include <sys/eventfd.h> | ||
193 | #include <sys/inotify.h> | ||
194 | #include <sys/ioctl.h> | ||
195 | #include <sys/mman.h> | ||
196 | #include <sys/mount.h> | ||
197 | #include <sys/prctl.h> | ||
198 | #include <sys/stat.h> | ||
199 | #include <sys/types.h> | ||
200 | #include <sys/time.h> | ||
201 | #include <sys/select.h> | ||
202 | #include <sys/signalfd.h> | ||
203 | #include <sys/socket.h> | ||
204 | #include <sys/timerfd.h> | ||
205 | #include <sys/uio.h> | ||
206 | #include <sys/xattr.h> | ||
207 | #include <netinet/udp.h> | ||
208 | #include <linux/audit.h> | ||
209 | #include <linux/bpf.h> | ||
210 | #include <linux/can.h> | ||
211 | #include <linux/can/error.h> | ||
212 | #include <linux/can/netlink.h> | ||
213 | #include <linux/can/raw.h> | ||
214 | #include <linux/capability.h> | ||
215 | #include <linux/cryptouser.h> | ||
216 | #include <linux/devlink.h> | ||
217 | #include <linux/dm-ioctl.h> | ||
218 | #include <linux/errqueue.h> | ||
219 | #include <linux/ethtool_netlink.h> | ||
220 | #include <linux/falloc.h> | ||
221 | #include <linux/fanotify.h> | ||
222 | #include <linux/fib_rules.h> | ||
223 | #include <linux/filter.h> | ||
224 | #include <linux/fs.h> | ||
225 | #include <linux/fscrypt.h> | ||
226 | #include <linux/fsverity.h> | ||
227 | #include <linux/genetlink.h> | ||
228 | #include <linux/hdreg.h> | ||
229 | #include <linux/hidraw.h> | ||
230 | #include <linux/if.h> | ||
231 | #include <linux/if_addr.h> | ||
232 | #include <linux/if_alg.h> | ||
233 | #include <linux/if_arp.h> | ||
234 | #include <linux/if_ether.h> | ||
235 | #include <linux/if_ppp.h> | ||
236 | #include <linux/if_tun.h> | ||
237 | #include <linux/if_packet.h> | ||
238 | #include <linux/if_xdp.h> | ||
239 | #include <linux/input.h> | ||
240 | #include <linux/kcm.h> | ||
241 | #include <linux/kexec.h> | ||
242 | #include <linux/keyctl.h> | ||
243 | #include <linux/landlock.h> | ||
244 | #include <linux/loop.h> | ||
245 | #include <linux/lwtunnel.h> | ||
246 | #include <linux/magic.h> | ||
247 | #include <linux/memfd.h> | ||
248 | #include <linux/module.h> | ||
249 | #include <linux/mount.h> | ||
250 | #include <linux/netfilter/nfnetlink.h> | ||
251 | #include <linux/netlink.h> | ||
252 | #include <linux/net_namespace.h> | ||
253 | #include <linux/nfc.h> | ||
254 | #include <linux/nsfs.h> | ||
255 | #include <linux/perf_event.h> | ||
256 | #include <linux/pps.h> | ||
257 | #include <linux/ptrace.h> | ||
258 | #include <linux/random.h> | ||
259 | #include <linux/reboot.h> | ||
260 | #include <linux/rtc.h> | ||
261 | #include <linux/rtnetlink.h> | ||
262 | #include <linux/sched.h> | ||
263 | #include <linux/seccomp.h> | ||
264 | #include <linux/serial.h> | ||
265 | #include <linux/sockios.h> | ||
266 | #include <linux/taskstats.h> | ||
267 | #include <linux/tipc.h> | ||
268 | #include <linux/vm_sockets.h> | ||
269 | #include <linux/wait.h> | ||
270 | #include <linux/watchdog.h> | ||
271 | #include <linux/wireguard.h> | ||
272 | |||
273 | #include <mtd/ubi-user.h> | ||
274 | #include <mtd/mtd-user.h> | ||
275 | #include <net/route.h> | ||
276 | |||
277 | #if defined(__sparc__) | ||
278 | // On sparc{,64}, the kernel defines struct termios2 itself which clashes with the | ||
279 | // definition in glibc. As only the error constants are needed here, include the | ||
280 | // generic termibits.h (which is included by termbits.h on sparc). | ||
281 | #include <asm-generic/termbits.h> | ||
282 | #else | ||
283 | #include <asm/termbits.h> | ||
284 | #endif | ||
285 | |||
286 | #ifndef MSG_FASTOPEN | ||
287 | #define MSG_FASTOPEN 0x20000000 | ||
288 | #endif | ||
289 | |||
290 | #ifndef PTRACE_GETREGS | ||
291 | #define PTRACE_GETREGS 0xc | ||
292 | #endif | ||
293 | |||
294 | #ifndef PTRACE_SETREGS | ||
295 | #define PTRACE_SETREGS 0xd | ||
296 | #endif | ||
297 | |||
298 | #ifndef SOL_NETLINK | ||
299 | #define SOL_NETLINK 270 | ||
300 | #endif | ||
301 | |||
302 | #ifndef SOL_SMC | ||
303 | #define SOL_SMC 286 | ||
304 | #endif | ||
305 | |||
306 | #ifdef SOL_BLUETOOTH | ||
307 | // SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h | ||
308 | // but it is already in bluetooth_linux.go | ||
309 | #undef SOL_BLUETOOTH | ||
310 | #endif | ||
311 | |||
312 | // Certain constants are missing from the fs/crypto UAPI | ||
313 | #define FS_KEY_DESC_PREFIX "fscrypt:" | ||
314 | #define FS_KEY_DESC_PREFIX_SIZE 8 | ||
315 | #define FS_MAX_KEY_SIZE 64 | ||
316 | |||
317 | // The code generator produces -0x1 for (~0), but an unsigned value is necessary | ||
318 | // for the tipc_subscr timeout __u32 field. | ||
319 | #undef TIPC_WAIT_FOREVER | ||
320 | #define TIPC_WAIT_FOREVER 0xffffffff | ||
321 | |||
322 | // Copied from linux/l2tp.h | ||
323 | // Including linux/l2tp.h here causes conflicts between linux/in.h | ||
324 | // and netinet/in.h included via net/route.h above. | ||
325 | #define IPPROTO_L2TP 115 | ||
326 | |||
327 | // Copied from linux/hid.h. | ||
328 | // Keep in sync with the size of the referenced fields. | ||
329 | #define _HIDIOCGRAWNAME_LEN 128 // sizeof_field(struct hid_device, name) | ||
330 | #define _HIDIOCGRAWPHYS_LEN 64 // sizeof_field(struct hid_device, phys) | ||
331 | #define _HIDIOCGRAWUNIQ_LEN 64 // sizeof_field(struct hid_device, uniq) | ||
332 | |||
333 | #define _HIDIOCGRAWNAME HIDIOCGRAWNAME(_HIDIOCGRAWNAME_LEN) | ||
334 | #define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN) | ||
335 | #define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN) | ||
336 | |||
337 | ' | ||
338 | |||
339 | includes_NetBSD=' | ||
340 | #include <sys/types.h> | ||
341 | #include <sys/param.h> | ||
342 | #include <sys/event.h> | ||
343 | #include <sys/extattr.h> | ||
344 | #include <sys/mman.h> | ||
345 | #include <sys/mount.h> | ||
346 | #include <sys/sched.h> | ||
347 | #include <sys/select.h> | ||
348 | #include <sys/socket.h> | ||
349 | #include <sys/sockio.h> | ||
350 | #include <sys/sysctl.h> | ||
351 | #include <sys/termios.h> | ||
352 | #include <sys/ttycom.h> | ||
353 | #include <sys/wait.h> | ||
354 | #include <net/bpf.h> | ||
355 | #include <net/if.h> | ||
356 | #include <net/if_types.h> | ||
357 | #include <net/route.h> | ||
358 | #include <netinet/in.h> | ||
359 | #include <netinet/in_systm.h> | ||
360 | #include <netinet/ip.h> | ||
361 | #include <netinet/ip_mroute.h> | ||
362 | #include <netinet/if_ether.h> | ||
363 | |||
364 | // Needed since <sys/param.h> refers to it... | ||
365 | #define schedppq 1 | ||
366 | ' | ||
367 | |||
368 | includes_OpenBSD=' | ||
369 | #include <sys/types.h> | ||
370 | #include <sys/param.h> | ||
371 | #include <sys/event.h> | ||
372 | #include <sys/mman.h> | ||
373 | #include <sys/mount.h> | ||
374 | #include <sys/select.h> | ||
375 | #include <sys/sched.h> | ||
376 | #include <sys/socket.h> | ||
377 | #include <sys/sockio.h> | ||
378 | #include <sys/stat.h> | ||
379 | #include <sys/sysctl.h> | ||
380 | #include <sys/termios.h> | ||
381 | #include <sys/ttycom.h> | ||
382 | #include <sys/unistd.h> | ||
383 | #include <sys/wait.h> | ||
384 | #include <net/bpf.h> | ||
385 | #include <net/if.h> | ||
386 | #include <net/if_types.h> | ||
387 | #include <net/if_var.h> | ||
388 | #include <net/route.h> | ||
389 | #include <netinet/in.h> | ||
390 | #include <netinet/in_systm.h> | ||
391 | #include <netinet/ip.h> | ||
392 | #include <netinet/ip_mroute.h> | ||
393 | #include <netinet/if_ether.h> | ||
394 | #include <net/if_bridge.h> | ||
395 | |||
396 | // We keep some constants not supported in OpenBSD 5.5 and beyond for | ||
397 | // the promise of compatibility. | ||
398 | #define EMUL_ENABLED 0x1 | ||
399 | #define EMUL_NATIVE 0x2 | ||
400 | #define IPV6_FAITH 0x1d | ||
401 | #define IPV6_OPTIONS 0x1 | ||
402 | #define IPV6_RTHDR_STRICT 0x1 | ||
403 | #define IPV6_SOCKOPT_RESERVED1 0x3 | ||
404 | #define SIOCGIFGENERIC 0xc020693a | ||
405 | #define SIOCSIFGENERIC 0x80206939 | ||
406 | #define WALTSIG 0x4 | ||
407 | ' | ||
408 | |||
409 | includes_SunOS=' | ||
410 | #include <limits.h> | ||
411 | #include <sys/types.h> | ||
412 | #include <sys/select.h> | ||
413 | #include <sys/socket.h> | ||
414 | #include <sys/sockio.h> | ||
415 | #include <sys/stat.h> | ||
416 | #include <sys/stream.h> | ||
417 | #include <sys/mman.h> | ||
418 | #include <sys/wait.h> | ||
419 | #include <sys/ioctl.h> | ||
420 | #include <sys/mkdev.h> | ||
421 | #include <net/bpf.h> | ||
422 | #include <net/if.h> | ||
423 | #include <net/if_arp.h> | ||
424 | #include <net/if_types.h> | ||
425 | #include <net/route.h> | ||
426 | #include <netinet/icmp6.h> | ||
427 | #include <netinet/in.h> | ||
428 | #include <netinet/ip.h> | ||
429 | #include <netinet/ip_mroute.h> | ||
430 | #include <termios.h> | ||
431 | ' | ||
432 | |||
433 | |||
434 | includes=' | ||
435 | #include <sys/types.h> | ||
436 | #include <sys/file.h> | ||
437 | #include <fcntl.h> | ||
438 | #include <dirent.h> | ||
439 | #include <sys/socket.h> | ||
440 | #include <netinet/in.h> | ||
441 | #include <netinet/ip.h> | ||
442 | #include <netinet/ip6.h> | ||
443 | #include <netinet/tcp.h> | ||
444 | #include <errno.h> | ||
445 | #include <sys/signal.h> | ||
446 | #include <signal.h> | ||
447 | #include <sys/resource.h> | ||
448 | #include <time.h> | ||
449 | ' | ||
450 | ccflags="$@" | ||
451 | |||
452 | # Write go tool cgo -godefs input. | ||
453 | ( | ||
454 | echo package unix | ||
455 | echo | ||
456 | echo '/*' | ||
457 | indirect="includes_$(uname)" | ||
458 | echo "${!indirect} $includes" | ||
459 | echo '*/' | ||
460 | echo 'import "C"' | ||
461 | echo 'import "syscall"' | ||
462 | echo | ||
463 | echo 'const (' | ||
464 | |||
465 | # The gcc command line prints all the #defines | ||
466 | # it encounters while processing the input | ||
467 | echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags | | ||
468 | awk ' | ||
469 | $1 != "#define" || $2 ~ /\(/ || $3 == "" {next} | ||
470 | |||
471 | $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers | ||
472 | $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next} | ||
473 | $2 ~ /^(SCM_SRCRT)$/ {next} | ||
474 | $2 ~ /^(MAP_FAILED)$/ {next} | ||
475 | $2 ~ /^ELF_.*$/ {next}# <asm/elf.h> contains ELF_ARCH, etc. | ||
476 | |||
477 | $2 ~ /^EXTATTR_NAMESPACE_NAMES/ || | ||
478 | $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next} | ||
479 | |||
480 | $2 !~ /^ECCAPBITS/ && | ||
481 | $2 !~ /^ETH_/ && | ||
482 | $2 !~ /^EPROC_/ && | ||
483 | $2 !~ /^EQUIV_/ && | ||
484 | $2 !~ /^EXPR_/ && | ||
485 | $2 !~ /^EVIOC/ && | ||
486 | $2 ~ /^E[A-Z0-9_]+$/ || | ||
487 | $2 ~ /^B[0-9_]+$/ || | ||
488 | $2 ~ /^(OLD|NEW)DEV$/ || | ||
489 | $2 == "BOTHER" || | ||
490 | $2 ~ /^CI?BAUD(EX)?$/ || | ||
491 | $2 == "IBSHIFT" || | ||
492 | $2 ~ /^V[A-Z0-9]+$/ || | ||
493 | $2 ~ /^CS[A-Z0-9]/ || | ||
494 | $2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ || | ||
495 | $2 ~ /^IGN/ || | ||
496 | $2 ~ /^IX(ON|ANY|OFF)$/ || | ||
497 | $2 ~ /^IN(LCR|PCK)$/ || | ||
498 | $2 !~ "X86_CR3_PCID_NOFLUSH" && | ||
499 | $2 ~ /(^FLU?SH)|(FLU?SH$)/ || | ||
500 | $2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ || | ||
501 | $2 == "BRKINT" || | ||
502 | $2 == "HUPCL" || | ||
503 | $2 == "PENDIN" || | ||
504 | $2 == "TOSTOP" || | ||
505 | $2 == "XCASE" || | ||
506 | $2 == "ALTWERASE" || | ||
507 | $2 == "NOKERNINFO" || | ||
508 | $2 == "NFDBITS" || | ||
509 | $2 ~ /^PAR/ || | ||
510 | $2 ~ /^SIG[^_]/ || | ||
511 | $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ || | ||
512 | $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ || | ||
513 | $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ || | ||
514 | $2 ~ /^O?XTABS$/ || | ||
515 | $2 ~ /^TC[IO](ON|OFF)$/ || | ||
516 | $2 ~ /^IN_/ || | ||
517 | $2 ~ /^KCM/ || | ||
518 | $2 ~ /^LANDLOCK_/ || | ||
519 | $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || | ||
520 | $2 ~ /^LO_(KEY|NAME)_SIZE$/ || | ||
521 | $2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || | ||
522 | $2 == "LOOP_CONFIGURE" || | ||
523 | $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || | ||
524 | $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || | ||
525 | $2 ~ /^NFC_.*_(MAX)?SIZE$/ || | ||
526 | $2 ~ /^RAW_PAYLOAD_/ || | ||
527 | $2 ~ /^[US]F_/ || | ||
528 | $2 ~ /^TP_STATUS_/ || | ||
529 | $2 ~ /^FALLOC_/ || | ||
530 | $2 ~ /^ICMPV?6?_(FILTER|SEC)/ || | ||
531 | $2 == "SOMAXCONN" || | ||
532 | $2 == "NAME_MAX" || | ||
533 | $2 == "IFNAMSIZ" || | ||
534 | $2 ~ /^CTL_(HW|KERN|MAXNAME|NET|QUERY)$/ || | ||
535 | $2 ~ /^KERN_(HOSTNAME|OS(RELEASE|TYPE)|VERSION)$/ || | ||
536 | $2 ~ /^HW_MACHINE$/ || | ||
537 | $2 ~ /^SYSCTL_VERS/ || | ||
538 | $2 !~ "MNT_BITS" && | ||
539 | $2 ~ /^(MS|MNT|MOUNT|UMOUNT)_/ || | ||
540 | $2 ~ /^NS_GET_/ || | ||
541 | $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || | ||
542 | $2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|PIOD|TFD)_/ || | ||
543 | $2 ~ /^KEXEC_/ || | ||
544 | $2 ~ /^LINUX_REBOOT_CMD_/ || | ||
545 | $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || | ||
546 | $2 ~ /^MODULE_INIT_/ || | ||
547 | $2 !~ "NLA_TYPE_MASK" && | ||
548 | $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && | ||
549 | $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || | ||
550 | $2 ~ /^FIORDCHK$/ || | ||
551 | $2 ~ /^SIOC/ || | ||
552 | $2 ~ /^TIOC/ || | ||
553 | $2 ~ /^TCGET/ || | ||
554 | $2 ~ /^TCSET/ || | ||
555 | $2 ~ /^TC(FLSH|SBRKP?|XONC)$/ || | ||
556 | $2 !~ "RTF_BITS" && | ||
557 | $2 ~ /^(IFF|IFT|NET_RT|RTM(GRP)?|RTF|RTV|RTA|RTAX)_/ || | ||
558 | $2 ~ /^BIOC/ || | ||
559 | $2 ~ /^DIOC/ || | ||
560 | $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ || | ||
561 | $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ || | ||
562 | $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ || | ||
563 | $2 ~ /^CLONE_[A-Z_]+/ || | ||
564 | $2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+|BPF_F_LINK)$/ && | ||
565 | $2 ~ /^(BPF|DLT)_/ || | ||
566 | $2 ~ /^AUDIT_/ || | ||
567 | $2 ~ /^(CLOCK|TIMER)_/ || | ||
568 | $2 ~ /^CAN_/ || | ||
569 | $2 ~ /^CAP_/ || | ||
570 | $2 ~ /^CP_/ || | ||
571 | $2 ~ /^CPUSTATES$/ || | ||
572 | $2 ~ /^CTLIOCGINFO$/ || | ||
573 | $2 ~ /^ALG_/ || | ||
574 | $2 ~ /^FI(CLONE|DEDUPERANGE)/ || | ||
575 | $2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ || | ||
576 | $2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ || | ||
577 | $2 ~ /^FS_VERITY_/ || | ||
578 | $2 ~ /^FSCRYPT_/ || | ||
579 | $2 ~ /^DM_/ || | ||
580 | $2 ~ /^GRND_/ || | ||
581 | $2 ~ /^RND/ || | ||
582 | $2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ || | ||
583 | $2 ~ /^KEYCTL_/ || | ||
584 | $2 ~ /^PERF_/ || | ||
585 | $2 ~ /^SECCOMP_MODE_/ || | ||
586 | $2 ~ /^SEEK_/ || | ||
587 | $2 ~ /^SCHED_/ || | ||
588 | $2 ~ /^SPLICE_/ || | ||
589 | $2 ~ /^SYNC_FILE_RANGE_/ || | ||
590 | $2 !~ /IOC_MAGIC/ && | ||
591 | $2 ~ /^[A-Z][A-Z0-9_]+_MAGIC2?$/ || | ||
592 | $2 ~ /^(VM|VMADDR)_/ || | ||
593 | $2 ~ /^IOCTL_VM_SOCKETS_/ || | ||
594 | $2 ~ /^(TASKSTATS|TS)_/ || | ||
595 | $2 ~ /^CGROUPSTATS_/ || | ||
596 | $2 ~ /^GENL_/ || | ||
597 | $2 ~ /^STATX_/ || | ||
598 | $2 ~ /^RENAME/ || | ||
599 | $2 ~ /^UBI_IOC[A-Z]/ || | ||
600 | $2 ~ /^UTIME_/ || | ||
601 | $2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ || | ||
602 | $2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ || | ||
603 | $2 ~ /^FSOPT_/ || | ||
604 | $2 ~ /^WDIO[CFS]_/ || | ||
605 | $2 ~ /^NFN/ || | ||
606 | $2 ~ /^XDP_/ || | ||
607 | $2 ~ /^RWF_/ || | ||
608 | $2 ~ /^(HDIO|WIN|SMART)_/ || | ||
609 | $2 ~ /^CRYPTO_/ || | ||
610 | $2 ~ /^TIPC_/ || | ||
611 | $2 !~ "DEVLINK_RELOAD_LIMITS_VALID_MASK" && | ||
612 | $2 ~ /^DEVLINK_/ || | ||
613 | $2 ~ /^ETHTOOL_/ || | ||
614 | $2 ~ /^LWTUNNEL_IP/ || | ||
615 | $2 ~ /^ITIMER_/ || | ||
616 | $2 !~ "WMESGLEN" && | ||
617 | $2 ~ /^W[A-Z0-9]+$/ || | ||
618 | $2 ~ /^P_/ || | ||
619 | $2 ~/^PPPIOC/ || | ||
620 | $2 ~ /^FAN_|FANOTIFY_/ || | ||
621 | $2 == "HID_MAX_DESCRIPTOR_SIZE" || | ||
622 | $2 ~ /^_?HIDIOC/ || | ||
623 | $2 ~ /^BUS_(USB|HIL|BLUETOOTH|VIRTUAL)$/ || | ||
624 | $2 ~ /^MTD/ || | ||
625 | $2 ~ /^OTP/ || | ||
626 | $2 ~ /^MEM/ || | ||
627 | $2 ~ /^WG/ || | ||
628 | $2 ~ /^FIB_RULE_/ || | ||
629 | $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE|IOMIN$|IOOPT$|ALIGNOFF$|DISCARD|ROTATIONAL$|ZEROOUT$|GETDISKSEQ$)/ {printf("\t%s = C.%s\n", $2, $2)} | ||
630 | $2 ~ /^__WCOREFLAG$/ {next} | ||
631 | $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} | ||
632 | |||
633 | {next} | ||
634 | ' | sort | ||
635 | |||
636 | echo ')' | ||
637 | ) >_const.go | ||
638 | |||
639 | # Pull out the error names for later. | ||
640 | errors=$( | ||
641 | echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags | | ||
642 | awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' | | ||
643 | sort | ||
644 | ) | ||
645 | |||
646 | # Pull out the signal names for later. | ||
647 | signals=$( | ||
648 | echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags | | ||
649 | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | | ||
650 | grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | | ||
651 | sort | ||
652 | ) | ||
653 | |||
654 | # Again, writing regexps to a file. | ||
655 | echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags | | ||
656 | awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' | | ||
657 | sort >_error.grep | ||
658 | echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags | | ||
659 | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | | ||
660 | grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | | ||
661 | sort >_signal.grep | ||
662 | |||
663 | echo '// mkerrors.sh' "$@" | ||
664 | echo '// Code generated by the command above; see README.md. DO NOT EDIT.' | ||
665 | echo | ||
666 | echo "//go:build ${GOARCH} && ${GOOS}" | ||
667 | echo | ||
668 | go tool cgo -godefs -- "$@" _const.go >_error.out | ||
669 | cat _error.out | grep -vf _error.grep | grep -vf _signal.grep | ||
670 | echo | ||
671 | echo '// Errors' | ||
672 | echo 'const (' | ||
673 | cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/' | ||
674 | echo ')' | ||
675 | |||
676 | echo | ||
677 | echo '// Signals' | ||
678 | echo 'const (' | ||
679 | cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/' | ||
680 | echo ')' | ||
681 | |||
682 | # Run C program to print error and syscall strings. | ||
683 | ( | ||
684 | echo -E " | ||
685 | #include <stdio.h> | ||
686 | #include <stdlib.h> | ||
687 | #include <errno.h> | ||
688 | #include <ctype.h> | ||
689 | #include <string.h> | ||
690 | #include <signal.h> | ||
691 | |||
692 | #define nelem(x) (sizeof(x)/sizeof((x)[0])) | ||
693 | |||
694 | enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below | ||
695 | |||
696 | struct tuple { | ||
697 | int num; | ||
698 | const char *name; | ||
699 | }; | ||
700 | |||
701 | struct tuple errors[] = { | ||
702 | " | ||
703 | for i in $errors | ||
704 | do | ||
705 | echo -E ' {'$i', "'$i'" },' | ||
706 | done | ||
707 | |||
708 | echo -E " | ||
709 | }; | ||
710 | |||
711 | struct tuple signals[] = { | ||
712 | " | ||
713 | for i in $signals | ||
714 | do | ||
715 | echo -E ' {'$i', "'$i'" },' | ||
716 | done | ||
717 | |||
718 | # Use -E because on some systems bash builtin interprets \n itself. | ||
719 | echo -E ' | ||
720 | }; | ||
721 | |||
722 | static int | ||
723 | tuplecmp(const void *a, const void *b) | ||
724 | { | ||
725 | return ((struct tuple *)a)->num - ((struct tuple *)b)->num; | ||
726 | } | ||
727 | |||
728 | int | ||
729 | main(void) | ||
730 | { | ||
731 | int i, e; | ||
732 | char buf[1024], *p; | ||
733 | |||
734 | printf("\n\n// Error table\n"); | ||
735 | printf("var errorList = [...]struct {\n"); | ||
736 | printf("\tnum syscall.Errno\n"); | ||
737 | printf("\tname string\n"); | ||
738 | printf("\tdesc string\n"); | ||
739 | printf("} {\n"); | ||
740 | qsort(errors, nelem(errors), sizeof errors[0], tuplecmp); | ||
741 | for(i=0; i<nelem(errors); i++) { | ||
742 | e = errors[i].num; | ||
743 | if(i > 0 && errors[i-1].num == e) | ||
744 | continue; | ||
745 | strncpy(buf, strerror(e), sizeof(buf) - 1); | ||
746 | buf[sizeof(buf) - 1] = '\0'; | ||
747 | // lowercase first letter: Bad -> bad, but STREAM -> STREAM. | ||
748 | if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) | ||
749 | buf[0] += a - A; | ||
750 | printf("\t{ %d, \"%s\", \"%s\" },\n", e, errors[i].name, buf); | ||
751 | } | ||
752 | printf("}\n\n"); | ||
753 | |||
754 | printf("\n\n// Signal table\n"); | ||
755 | printf("var signalList = [...]struct {\n"); | ||
756 | printf("\tnum syscall.Signal\n"); | ||
757 | printf("\tname string\n"); | ||
758 | printf("\tdesc string\n"); | ||
759 | printf("} {\n"); | ||
760 | qsort(signals, nelem(signals), sizeof signals[0], tuplecmp); | ||
761 | for(i=0; i<nelem(signals); i++) { | ||
762 | e = signals[i].num; | ||
763 | if(i > 0 && signals[i-1].num == e) | ||
764 | continue; | ||
765 | strncpy(buf, strsignal(e), sizeof(buf) - 1); | ||
766 | buf[sizeof(buf) - 1] = '\0'; | ||
767 | // lowercase first letter: Bad -> bad, but STREAM -> STREAM. | ||
768 | if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) | ||
769 | buf[0] += a - A; | ||
770 | // cut trailing : number. | ||
771 | p = strrchr(buf, ":"[0]); | ||
772 | if(p) | ||
773 | *p = '\0'; | ||
774 | printf("\t{ %d, \"%s\", \"%s\" },\n", e, signals[i].name, buf); | ||
775 | } | ||
776 | printf("}\n\n"); | ||
777 | |||
778 | return 0; | ||
779 | } | ||
780 | |||
781 | ' | ||
782 | ) >_errors.c | ||
783 | |||
784 | $CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out | ||