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