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. */
13 #include <sys/types.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
22 <sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
23 <sys/ttold.h> does so unconditionally. */
25 #include <sys/bsd_types.h>
26 #include <sys/ttold.h>
28 #include <netinet/tcp.h>
29 #if defined(HAVE_NETINET_IN_SYSTM_H)
30 #include <netinet/in_systm.h>
32 #if defined(HAVE_NETINET_IP_H)
33 #include <netinet/ip.h>
35 #if defined(HAVE_NETINET_IP_MROUTE_H)
36 #include <netinet/ip_mroute.h>
38 #if defined(HAVE_NETINET_IF_ETHER_H)
39 #include <netinet/if_ether.h>
42 #include <sys/ioctl.h>
44 #if defined(HAVE_SYSCALL_H)
47 #if defined(HAVE_SYS_SYSCALL_H)
48 #include <sys/syscall.h>
50 #if defined(HAVE_SYS_EPOLL_H)
51 #include <sys/epoll.h>
53 #if defined(HAVE_SYS_EVENT_H)
54 #include <sys/event.h>
56 #if defined(HAVE_SYS_FILE_H)
59 #if defined(HAVE_SYS_MMAN_H)
62 #if defined(HAVE_SYS_PRCTL_H)
63 #include <sys/prctl.h>
65 #if defined(HAVE_SYS_PTRACE_H)
66 #include <sys/ptrace.h>
68 #include <sys/resource.h>
70 #include <sys/socket.h>
73 #include <sys/times.h>
76 #if defined(HAVE_SYS_USER_H)
79 #if defined(HAVE_SYS_UTSNAME_H)
80 #include <sys/utsname.h>
82 #if defined(HAVE_SYS_SELECT_H)
83 #include <sys/select.h>
90 #if defined(HAVE_LINUX_FILTER_H)
91 #include <linux/filter.h>
93 #if defined(HAVE_LINUX_IF_ADDR_H)
94 #include <linux/if_addr.h>
96 #if defined(HAVE_LINUX_IF_ETHER_H)
97 #include <linux/if_ether.h>
99 #if defined(HAVE_LINUX_IF_TUN_H)
100 #include <linux/if_tun.h>
102 #if defined(HAVE_LINUX_NETLINK_H)
103 #include <linux/netlink.h>
105 #if defined(HAVE_LINUX_PTRACE_H)
106 /* Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762 . */
107 #define ia64_fpreg pt_ia64_fpreg
108 #define pt_all_user_regs pt_ia64_all_user_regs
109 #include <linux/ptrace.h>
111 #undef pt_all_user_regs
113 #if defined(HAVE_LINUX_RTNETLINK_H)
114 #include <linux/rtnetlink.h>
116 #if defined(HAVE_NET_IF_H)
119 #if defined(HAVE_NET_IF_ARP_H)
120 #include <net/if_arp.h>
122 #if defined(HAVE_NET_ROUTE_H)
123 #include <net/route.h>
125 #if defined (HAVE_NETPACKET_PACKET_H)
126 #include <netpacket/packet.h>
128 #if defined(HAVE_SYS_MOUNT_H)
129 #include <sys/mount.h>
131 #if defined(HAVE_SYS_VFS_H)
134 #if defined(HAVE_STATFS_H)
135 #include <sys/statfs.h>
137 #if defined(HAVE_SYS_TIMEX_H)
138 #include <sys/timex.h>
140 #if defined(HAVE_SYS_SYSINFO_H)
141 #include <sys/sysinfo.h>
143 #if defined(HAVE_USTAT_H)
146 #if defined(HAVE_UTIME_H)
149 #if defined(HAVE_LINUX_ETHER_H)
150 #include <linux/ether.h>
152 #if defined(HAVE_LINUX_FS_H)
153 #include <linux/fs.h>
155 #if defined(HAVE_LINUX_REBOOT_H)
156 #include <linux/reboot.h>
158 #if defined(HAVE_SYS_INOTIFY_H)
159 #include <sys/inotify.h>
161 #if defined(HAVE_NETINET_ICMP6_H)
162 #include <netinet/icmp6.h>
164 #if defined(HAVE_SCHED_H)
167 #if defined(HAVE_SEMAPHORE_H)
168 #include <semaphore.h>
170 #if defined(HAVE_PORT_H)
178 /* Constants that may only be defined as expressions on some systems,
179 expressions too complex for -fdump-go-spec to handle. These are
180 handled specially below. */
183 TIOCGWINSZ_val
= TIOCGWINSZ
,
186 TIOCSWINSZ_val
= TIOCSWINSZ
,
189 TIOCNOTTY_val
= TIOCNOTTY
,
192 TIOCSCTTY_val
= TIOCSCTTY
,
195 TIOCGPGRP_val
= TIOCGPGRP
,
198 TIOCSPGRP_val
= TIOCSPGRP
,
201 TIOCGPTN_val
= TIOCGPTN
,
204 TIOCSPTLCK_val
= TIOCSPTLCK
,
207 TIOCGDEV_val
= TIOCGDEV
,
210 TIOCSIG_val
= TIOCSIG
,
219 TUNSETIFF_val
= TUNSETIFF
,
222 TUNSETNOCSUM_val
= TUNSETNOCSUM
,
225 TUNSETDEBUG_val
= TUNSETDEBUG
,
228 TUNSETPERSIST_val
= TUNSETPERSIST
,
231 TUNSETOWNER_val
= TUNSETOWNER
,
234 TUNSETLINK_val
= TUNSETLINK
,
237 TUNSETGROUP_val
= TUNSETGROUP
,
239 #ifdef TUNGETFEATURES
240 TUNGETFEATURES_val
= TUNGETFEATURES
,
243 TUNSETOFFLOAD_val
= TUNSETOFFLOAD
,
245 #ifdef TUNSETTXFILTER
246 TUNSETTXFILTER_val
= TUNSETTXFILTER
,
249 TUNGETIFF_val
= TUNGETIFF
,
252 TUNGETSNDBUF_val
= TUNGETSNDBUF
,
255 TUNSETSNDBUF_val
= TUNSETSNDBUF
,
257 #ifdef TUNATTACHFILTER
258 TUNATTACHFILTER_val
= TUNATTACHFILTER
,
260 #ifdef TUNDETACHFILTER
261 TUNDETACHFILTER_val
= TUNDETACHFILTER
,
263 #ifdef TUNGETVNETHDRSZ
264 TUNGETVNETHDRSZ_val
= TUNGETVNETHDRSZ
,
266 #ifdef TUNSETVNETHDRSZ
267 TUNSETVNETHDRSZ_val
= TUNSETVNETHDRSZ
,
270 TUNSETQUEUE_val
= TUNSETQUEUE
,
273 TUNSETIFINDEX_val
= TUNSETIFINDEX
,
276 TUNGETFILTER_val
= TUNGETFILTER
,
279 NLA_HDRLEN_val
= NLA_HDRLEN
,
283 #if defined(HAVE_SYS_EPOLL_H)
285 epoll_data_offset
= offsetof(struct epoll_event
, data
)