[RS6000] Power10 vec-splati-runnable multiple test failures
[official-gcc.git] / libgo / sysinfo.c
blobba84071a7bb2d49a44e71c789657730ce483cc69
1 /* sysinfo.c -- input for mksysinfo.sh
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 /* This file is passed to GCC with the -fdump-go-spec option to
8 generate a Go version of the system information. */
10 #include "config.h"
12 #include <stddef.h>
13 #include <sys/types.h>
14 #include <dirent.h>
15 #include <errno.h>
16 #include <fcntl.h>
17 #include <ucontext.h>
18 #include <netinet/in.h>
19 /* <netinet/tcp.h> needs u_char/u_short, but <sys/bsd_types> is only
20 included by <netinet/in.h> if _SGIAPI (i.e. _SGI_SOURCE
21 && !_XOPEN_SOURCE.
22 <sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
23 <sys/ttold.h> does so unconditionally. */
24 #ifdef __sgi__
25 #include <sys/bsd_types.h>
26 #include <sys/ttold.h>
27 #endif
28 #include <netinet/tcp.h>
29 #if defined(HAVE_NETINET_IN_SYSTM_H)
30 #include <netinet/in_systm.h>
31 #endif
32 #if defined(HAVE_NETINET_IP_H)
33 #include <netinet/ip.h>
34 #endif
35 #if defined(HAVE_NETINET_IP_MROUTE_H)
36 #include <netinet/ip_mroute.h>
37 #endif
38 #if defined(HAVE_NETINET_IF_ETHER_H)
39 #include <netinet/if_ether.h>
40 #endif
41 #include <signal.h>
42 #include <sys/ioctl.h>
43 #include <termios.h>
44 #if defined(HAVE_SYSCALL_H)
45 #include <syscall.h>
46 #endif
47 #if defined(HAVE_SYS_SYSCALL_H)
48 #include <sys/syscall.h>
49 #endif
50 #if defined(HAVE_SYS_SYSCTL_H)
51 #include <sys/sysctl.h>
52 #endif
53 #if defined(HAVE_SYS_EPOLL_H)
54 #include <sys/epoll.h>
55 #endif
56 #if defined(HAVE_SYS_EVENT_H)
57 #include <sys/event.h>
58 #endif
59 #if defined(HAVE_SYS_FILE_H)
60 #include <sys/file.h>
61 #endif
62 #if defined(HAVE_SYS_MMAN_H)
63 #include <sys/mman.h>
64 #endif
65 #if defined(HAVE_SYS_PRCTL_H)
66 #include <sys/prctl.h>
67 #endif
68 #if defined(HAVE_SYS_PTRACE_H)
69 #include <sys/ptrace.h>
70 #endif
71 #include <sys/resource.h>
72 #include <sys/uio.h>
73 #include <sys/socket.h>
74 #include <sys/stat.h>
75 #include <sys/time.h>
76 #include <sys/times.h>
77 #include <sys/wait.h>
78 #include <sys/un.h>
79 #if defined(HAVE_SYS_USER_H)
80 #include <sys/user.h>
81 #endif
82 #if defined(HAVE_SYS_UTSNAME_H)
83 #include <sys/utsname.h>
84 #endif
85 #if defined(HAVE_SYS_SELECT_H)
86 #include <sys/select.h>
87 #endif
88 #include <time.h>
89 #include <unistd.h>
90 #include <netdb.h>
91 #include <pwd.h>
92 #include <grp.h>
93 #if defined(HAVE_LINUX_FILTER_H)
94 #include <linux/filter.h>
95 #endif
96 #if defined(HAVE_LINUX_IF_ADDR_H)
97 #include <linux/if_addr.h>
98 #endif
99 #if defined(HAVE_LINUX_IF_ETHER_H)
100 #include <linux/if_ether.h>
101 #endif
102 #if defined(HAVE_LINUX_IF_TUN_H)
103 #include <linux/if_tun.h>
104 #endif
105 #if defined(HAVE_LINUX_NETLINK_H)
106 #include <linux/netlink.h>
107 #endif
108 #if defined(HAVE_LINUX_PTRACE_H)
109 /* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 . */
110 #define ia64_fpreg pt_ia64_fpreg
111 #define pt_all_user_regs pt_ia64_all_user_regs
112 /* Avoid redefinition of ptrace_peeksiginfo from <sys/ptrace.h>.
113 https://gcc.gnu.org/PR81324 . */
114 #define ptrace_peeksiginfo_args ignore_ptrace_peeksiginfo_args
115 #include <linux/ptrace.h>
116 #undef ia64_fpreg
117 #undef pt_all_user_regs
118 #undef ptrace_peeksiginfo_args
119 #endif
120 #if defined(HAVE_LINUX_RTNETLINK_H)
121 #include <linux/rtnetlink.h>
122 #endif
123 #if defined(HAVE_NET_BPF_H)
124 #include <net/bpf.h>
125 #endif
126 #if defined(HAVE_NET_IF_H)
127 #include <net/if.h>
128 #endif
129 #if defined(HAVE_NET_IF_ARP_H)
130 #include <net/if_arp.h>
131 #endif
132 #if defined(HAVE_NET_ROUTE_H)
133 #include <net/route.h>
134 #endif
135 #if defined (HAVE_NETPACKET_PACKET_H)
136 #include <netpacket/packet.h>
137 #endif
138 #if defined(HAVE_SYS_MOUNT_H)
139 #include <sys/mount.h>
140 #endif
141 #if defined(HAVE_SYS_VFS_H)
142 #include <sys/vfs.h>
143 #endif
144 #if defined(HAVE_STATFS_H)
145 #include <sys/statfs.h>
146 #endif
147 #if defined(HAVE_SYS_TIMEX_H)
148 #include <sys/timex.h>
149 #endif
150 #if defined(HAVE_SYS_SYSINFO_H)
151 #include <sys/sysinfo.h>
152 #endif
153 #if defined(HAVE_UTIME_H)
154 #include <utime.h>
155 #endif
156 #if defined(HAVE_LINUX_ETHER_H)
157 #include <linux/ether.h>
158 #endif
159 #if defined(HAVE_LINUX_FS_H)
160 #include <linux/fs.h>
161 #endif
162 #if defined(HAVE_LINUX_REBOOT_H)
163 #include <linux/reboot.h>
164 #endif
165 #if defined(HAVE_SYS_INOTIFY_H)
166 #include <sys/inotify.h>
167 #endif
168 #if defined(HAVE_NETINET_ICMP6_H)
169 #include <netinet/icmp6.h>
170 #endif
171 #if defined(HAVE_SCHED_H)
172 #include <sched.h>
173 #endif
174 #if defined(HAVE_SEMAPHORE_H)
175 #include <semaphore.h>
176 #endif
177 #if defined(HAVE_PORT_H)
178 #include <port.h>
179 #endif
181 #ifdef USE_LIBFFI
182 #include "ffi.h"
183 #endif
185 /* Constants that may only be defined as expressions on some systems,
186 expressions too complex for -fdump-go-spec to handle. These are
187 handled specially below. */
188 enum {
189 #ifdef TIOCGWINSZ
190 TIOCGWINSZ_val = TIOCGWINSZ,
191 #endif
192 #ifdef TIOCSWINSZ
193 TIOCSWINSZ_val = TIOCSWINSZ,
194 #endif
195 #ifdef TIOCNOTTY
196 TIOCNOTTY_val = TIOCNOTTY,
197 #endif
198 #ifdef TIOCSCTTY
199 TIOCSCTTY_val = TIOCSCTTY,
200 #endif
201 #ifdef TIOCGPGRP
202 TIOCGPGRP_val = TIOCGPGRP,
203 #endif
204 #ifdef TIOCSPGRP
205 TIOCSPGRP_val = TIOCSPGRP,
206 #endif
207 #ifdef TIOCGPTN
208 TIOCGPTN_val = TIOCGPTN,
209 #endif
210 #ifdef TIOCSPTLCK
211 TIOCSPTLCK_val = TIOCSPTLCK,
212 #endif
213 #ifdef TIOCGDEV
214 TIOCGDEV_val = TIOCGDEV,
215 #endif
216 #ifdef TIOCSIG
217 TIOCSIG_val = TIOCSIG,
218 #endif
219 #ifdef TCGETS
220 TCGETS_val = TCGETS,
221 #endif
222 #ifdef TCSETS
223 TCSETS_val = TCSETS,
224 #endif
225 #ifdef TUNSETIFF
226 TUNSETIFF_val = TUNSETIFF,
227 #endif
228 #ifdef TUNSETNOCSUM
229 TUNSETNOCSUM_val = TUNSETNOCSUM,
230 #endif
231 #ifdef TUNSETDEBUG
232 TUNSETDEBUG_val = TUNSETDEBUG,
233 #endif
234 #ifdef TUNSETPERSIST
235 TUNSETPERSIST_val = TUNSETPERSIST,
236 #endif
237 #ifdef TUNSETOWNER
238 TUNSETOWNER_val = TUNSETOWNER,
239 #endif
240 #ifdef TUNSETLINK
241 TUNSETLINK_val = TUNSETLINK,
242 #endif
243 #ifdef TUNSETGROUP
244 TUNSETGROUP_val = TUNSETGROUP,
245 #endif
246 #ifdef TUNGETFEATURES
247 TUNGETFEATURES_val = TUNGETFEATURES,
248 #endif
249 #ifdef TUNSETOFFLOAD
250 TUNSETOFFLOAD_val = TUNSETOFFLOAD,
251 #endif
252 #ifdef TUNSETTXFILTER
253 TUNSETTXFILTER_val = TUNSETTXFILTER,
254 #endif
255 #ifdef TUNGETIFF
256 TUNGETIFF_val = TUNGETIFF,
257 #endif
258 #ifdef TUNGETSNDBUF
259 TUNGETSNDBUF_val = TUNGETSNDBUF,
260 #endif
261 #ifdef TUNSETSNDBUF
262 TUNSETSNDBUF_val = TUNSETSNDBUF,
263 #endif
264 #ifdef TUNATTACHFILTER
265 TUNATTACHFILTER_val = TUNATTACHFILTER,
266 #endif
267 #ifdef TUNDETACHFILTER
268 TUNDETACHFILTER_val = TUNDETACHFILTER,
269 #endif
270 #ifdef TUNGETVNETHDRSZ
271 TUNGETVNETHDRSZ_val = TUNGETVNETHDRSZ,
272 #endif
273 #ifdef TUNSETVNETHDRSZ
274 TUNSETVNETHDRSZ_val = TUNSETVNETHDRSZ,
275 #endif
276 #ifdef TUNSETQUEUE
277 TUNSETQUEUE_val = TUNSETQUEUE,
278 #endif
279 #ifdef TUNSETIFINDEX
280 TUNSETIFINDEX_val = TUNSETIFINDEX,
281 #endif
282 #ifdef TUNGETFILTER
283 TUNGETFILTER_val = TUNGETFILTER,
284 #endif
285 #ifdef NLA_HDRLEN
286 NLA_HDRLEN_val = NLA_HDRLEN,
287 #endif
288 #ifdef BIOCFLUSH
289 BIOCFLUSH_val = BIOCFLUSH,
290 #endif
291 #ifdef BIOCGBLEN
292 BIOCGBLEN_val = BIOCGBLEN,
293 #endif
294 #ifdef BIOCGDLT
295 BIOCGDLT_val = BIOCGDLT,
296 #endif
297 #ifdef BIOCGETIF
298 BIOCGETIF_val = BIOCGETIF,
299 #endif
300 #ifdef BIOCGHDRCMPLT
301 BIOCGHDRCMPLT_val = BIOCGHDRCMPLT,
302 #endif
303 #ifdef BIOCGRTIMEOUT
304 BIOCGRTIMEOUT_val = BIOCGRTIMEOUT,
305 #endif
306 #ifdef BIOCGSTATS
307 BIOCGSTATS_val = BIOCGSTATS,
308 #endif
309 #ifdef BIOCIMMEDIATE
310 BIOCIMMEDIATE_val = BIOCIMMEDIATE,
311 #endif
312 #ifdef BIOCPROMISC
313 BIOCPROMISC_val = BIOCPROMISC,
314 #endif
315 #ifdef BIOCSBLEN
316 BIOCSBLEN_val = BIOCSBLEN,
317 #endif
318 #ifdef BIOCSDLT
319 BIOCSDLT_val = BIOCSDLT,
320 #endif
321 #ifdef BIOCSETF
322 BIOCSETF_val = BIOCSETF,
323 #endif
324 #ifdef BIOCSETIF
325 BIOCSETIF_val = BIOCSETIF,
326 #endif
327 #ifdef BIOCSHDRCMPLT
328 BIOCSHDRCMPLT_val = BIOCSHDRCMPLT,
329 #endif
330 #ifdef BIOCSRTIMEOUT
331 BIOCSRTIMEOUT_val = BIOCSRTIMEOUT,
332 #endif
333 #ifdef BIOCVERSION
334 BIOCVERSION_val = BIOCVERSION,
335 #endif
338 // SIOCGIFMTU can't be added in the above enum as it might
339 // be signed in some OSes.
340 #ifdef SIOCGIFMTU
341 enum {
342 SIOCGIFMTU_val = SIOCGIFMTU,
344 #endif
346 #if defined(HAVE_SYS_EPOLL_H)
347 enum {
348 epoll_data_offset = offsetof(struct epoll_event, data)
350 #endif
352 // The following section introduces explicit references to types and
353 // constants of interest to support bootstrapping libgo using a
354 // compiler that doesn't support -fdump-go-spec (e.g., clang), via
355 // DWARF-based tools. This process is made more difficult due to the
356 // fact that clang tries hard to omit types/constants from DWARF if it
357 // can't find explicit references to them, so here we make sure that
358 // key items are mentioned in ways that will force them into the
359 // generated DWARF.
361 #if defined(__clang__)
363 // Make a reference to a type
364 #define TREF(typ) typ typ ## ref
366 // Make a reference to an opaque type
367 #define OTREF(typ) typ *typ ## ref
369 // Make a reference to a struct tag
370 #define SREF(stag) struct stag stag ## ref
372 // Make a reference to an enum literal
373 #define EREF(elit) unsigned elit ## fn(unsigned x) { return x == elit ? 1 : 0; }
375 //......................................................................
377 // From dirent.h
378 SREF(dirent);
379 SREF(dirent64);
380 OTREF(DIR);
381 EREF(DT_UNKNOWN);
383 // From fcntl.h
384 SREF(flock);
385 SREF(flock64);
387 // From ffi headers
388 SREF(_ffi_type);
389 TREF(ffi_cif);
390 TREF(ffi_abi);
391 TREF(ffi_status);
392 EREF(FFI_OK);
394 // From grp.h
395 SREF(group);
397 #if defined(HAVE_LINUX_FILTER_H)
398 // From linux/filter.h
399 SREF(sock_filter);
400 SREF(sock_fprog);
401 #endif
403 // From linux/if.h
404 EREF(IFF_UP);
406 #if defined(HAVE_LINUX_IF_ADDR_H)
407 // From linux/if_addr.h
408 SREF(ifaddrmsg);
409 EREF(IFA_ADDRESS);
410 #endif
412 #if defined(HAVE_LINUX_RTNETLINK_H)
413 // From linux/if_link.h
414 EREF(IFLA_ADDRESS);
415 #endif
417 // From in.h, in6.h, icmp6.h
418 SREF(ip_mreq);
419 SREF(ip_mreqn);
420 SREF(ipv6_mreq);
421 SREF(ip6_mtuinfo);
422 SREF(icmp6_filter);
423 SREF(in_pktinfo);
424 EREF(IPPROTO_TCP);
426 #if defined(HAVE_LINUX_RTNETLINK_H)
427 // From linux/rtnetlink.h
428 SREF(rtgenmsg);
429 SREF(rtmsg);
430 SREF(ifinfomsg);
431 SREF(rtattr);
432 SREF(rtnexthop);
433 EREF(RTM_BASE);
434 EREF(RTN_UNSPEC);
435 #endif
437 // From netdb.h
438 SREF(addrinfo);
440 // From netlink.h
441 SREF(nlattr);
442 SREF(nlmsgerr);
444 // From pthread.h and related
445 TREF(pthread_attr_t);
446 TREF(pthread_t);
447 TREF(pthread_mutex_t);
448 TREF(pthread_mutexattr_t);
450 // From pwd.h
451 SREF(passwd);
453 // From signal.h and related
454 TREF(sigset_t);
455 TREF(siginfo_t);
456 TREF(stack_t);
457 SREF(sigaction);
458 SREF(sigstack);
459 EREF(SI_USER);
460 EREF(FPE_INTOVF);
461 EREF(BUS_ADRALN);
462 EREF(SS_ONSTACK);
463 EREF(SEGV_MAPERR);
465 // From stat.h
466 SREF(stat64);
468 // From statfs.h
469 SREF(statfs);
470 SREF(statfs64);
472 // From sysinfo.h
473 SREF(sysinfo);
475 // From <sys/epoll.h>
476 #if defined(HAVE_SYS_EPOLL_H)
477 SREF(epoll_event);
478 EREF(EPOLLIN);
479 EREF(epoll_data_offset);
480 #endif
482 #if defined(HAVE_SYS_MOUNT_H)
483 // From sys/mount.h
484 EREF(MS_PRIVATE);
485 EREF(MNT_FORCE);
486 #endif
488 #if defined(HAVE_SYS_PTRACE_H)
489 // From <sys/ptrace.h>
490 #if defined (__aarch64__)
491 SREF(user_pt_regs);
492 #else
493 SREF(pt_regs);
494 #endif
495 EREF(PTRACE_PEEKTEXT);
496 #endif
498 // From sys/resource.h
499 SREF(rusage);
500 SREF(rlimit64);
501 EREF(RLIMIT_NOFILE);
502 EREF(PRIO_USER);
503 EREF(RUSAGE_SELF);
505 // From sys/select.h
506 TREF(fd_set);
508 // From sys/socket.h
509 SREF(msghdr);
510 SREF(cmsghdr);
511 SREF(ucred);
512 EREF(MSG_OOB);
513 EREF(SCM_RIGHTS);
514 EREF(SOCK_RAW);
515 EREF(SHUT_RD);
517 // From sys/time.h and sys/times.h
518 SREF(timespec);
519 SREF(timeval);
520 SREF(itimerval);
521 SREF(tms);
522 EREF(ITIMER_PROF);
524 #if defined(HAVE_SYS_TIMEX_H)
525 // From sys/timex.h
526 SREF(timex);
527 #endif
529 // From sys/types.h
530 TREF(pid_t);
531 TREF(off_t);
532 TREF(loff_t);
533 TREF(size_t);
534 TREF(ssize_t);
535 TREF(mode_t);
536 TREF(dev_t);
537 TREF(time_t);
539 // From sys/ucontext.h
540 TREF(ucontext_t);
542 #if defined(HAVE_SYS_USER_H)
543 // From sys/user.h
544 SREF(user_regs_struct);
545 #endif
547 #if defined(HAVE_SYS_UTSNAME_H)
548 // From sys/utsname.h
549 SREF(utsname);
550 #endif
552 // From termios.h
553 SREF(termios);
555 // From uio.h
556 SREF(iovec);
558 // From utime.h
559 SREF(utimbuf);
561 // From unistd.h
562 EREF(_PC_NAME_MAX);
563 EREF(_SC_GETPW_R_SIZE_MAX);
565 #endif // clang