runtime: copy mstats code from Go 1.7 runtime
[official-gcc.git] / libgo / sysinfo.c
blob09c0f496a6e635439be5a3931ede4189f21287a5
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 <sys/types.h>
13 #include <dirent.h>
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <ucontext.h>
17 #include <netinet/in.h>
18 /* <netinet/tcp.h> needs u_char/u_short, but <sys/bsd_types> is only
19 included by <netinet/in.h> if _SGIAPI (i.e. _SGI_SOURCE
20 && !_XOPEN_SOURCE.
21 <sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
22 <sys/ttold.h> does so unconditionally. */
23 #ifdef __sgi__
24 #include <sys/bsd_types.h>
25 #include <sys/ttold.h>
26 #endif
27 #include <netinet/tcp.h>
28 #if defined(HAVE_NETINET_IN_SYSTM_H)
29 #include <netinet/in_systm.h>
30 #endif
31 #if defined(HAVE_NETINET_IP_H)
32 #include <netinet/ip.h>
33 #endif
34 #if defined(HAVE_NETINET_IP_MROUTE_H)
35 #include <netinet/ip_mroute.h>
36 #endif
37 #if defined(HAVE_NETINET_IF_ETHER_H)
38 #include <netinet/if_ether.h>
39 #endif
40 #include <signal.h>
41 #include <sys/ioctl.h>
42 #include <termios.h>
43 #if defined(HAVE_SYSCALL_H)
44 #include <syscall.h>
45 #endif
46 #if defined(HAVE_SYS_SYSCALL_H)
47 #include <sys/syscall.h>
48 #endif
49 #if defined(HAVE_SYS_EPOLL_H)
50 #include <sys/epoll.h>
51 #endif
52 #if defined(HAVE_SYS_FILE_H)
53 #include <sys/file.h>
54 #endif
55 #if defined(HAVE_SYS_MMAN_H)
56 #include <sys/mman.h>
57 #endif
58 #if defined(HAVE_SYS_PRCTL_H)
59 #include <sys/prctl.h>
60 #endif
61 #if defined(HAVE_SYS_PTRACE_H)
62 #include <sys/ptrace.h>
63 #endif
64 #include <sys/resource.h>
65 #include <sys/uio.h>
66 #include <sys/socket.h>
67 #include <sys/stat.h>
68 #include <sys/time.h>
69 #include <sys/times.h>
70 #include <sys/wait.h>
71 #include <sys/un.h>
72 #if defined(HAVE_SYS_USER_H)
73 #include <sys/user.h>
74 #endif
75 #if defined(HAVE_SYS_UTSNAME_H)
76 #include <sys/utsname.h>
77 #endif
78 #if defined(HAVE_SYS_SELECT_H)
79 #include <sys/select.h>
80 #endif
81 #include <time.h>
82 #include <unistd.h>
83 #include <netdb.h>
84 #include <pwd.h>
85 #include <grp.h>
86 #if defined(HAVE_LINUX_FILTER_H)
87 #include <linux/filter.h>
88 #endif
89 #if defined(HAVE_LINUX_IF_ADDR_H)
90 #include <linux/if_addr.h>
91 #endif
92 #if defined(HAVE_LINUX_IF_ETHER_H)
93 #include <linux/if_ether.h>
94 #endif
95 #if defined(HAVE_LINUX_IF_TUN_H)
96 #include <linux/if_tun.h>
97 #endif
98 #if defined(HAVE_LINUX_NETLINK_H)
99 #include <linux/netlink.h>
100 #endif
101 #if defined(HAVE_LINUX_RTNETLINK_H)
102 #include <linux/rtnetlink.h>
103 #endif
104 #if defined(HAVE_NET_IF_H)
105 #include <net/if.h>
106 #endif
107 #if defined(HAVE_NET_IF_ARP_H)
108 #include <net/if_arp.h>
109 #endif
110 #if defined(HAVE_NET_ROUTE_H)
111 #include <net/route.h>
112 #endif
113 #if defined (HAVE_NETPACKET_PACKET_H)
114 #include <netpacket/packet.h>
115 #endif
116 #if defined(HAVE_SYS_MOUNT_H)
117 #include <sys/mount.h>
118 #endif
119 #if defined(HAVE_SYS_VFS_H)
120 #include <sys/vfs.h>
121 #endif
122 #if defined(HAVE_STATFS_H)
123 #include <sys/statfs.h>
124 #endif
125 #if defined(HAVE_SYS_TIMEX_H)
126 #include <sys/timex.h>
127 #endif
128 #if defined(HAVE_SYS_SYSINFO_H)
129 #include <sys/sysinfo.h>
130 #endif
131 #if defined(HAVE_USTAT_H)
132 #include <ustat.h>
133 #endif
134 #if defined(HAVE_UTIME_H)
135 #include <utime.h>
136 #endif
137 #if defined(HAVE_LINUX_ETHER_H)
138 #include <linux/ether.h>
139 #endif
140 #if defined(HAVE_LINUX_FS_H)
141 #include <linux/fs.h>
142 #endif
143 #if defined(HAVE_LINUX_REBOOT_H)
144 #include <linux/reboot.h>
145 #endif
146 #if defined(HAVE_SYS_INOTIFY_H)
147 #include <sys/inotify.h>
148 #endif
149 #if defined(HAVE_NETINET_ICMP6_H)
150 #include <netinet/icmp6.h>
151 #endif
152 #if defined(HAVE_SCHED_H)
153 #include <sched.h>
154 #endif
155 #if defined(HAVE_SEMAPHORE_H)
156 #include <semaphore.h>
157 #endif
159 /* Constants that may only be defined as expressions on some systems,
160 expressions too complex for -fdump-go-spec to handle. These are
161 handled specially below. */
162 enum {
163 #ifdef TIOCGWINSZ
164 TIOCGWINSZ_val = TIOCGWINSZ,
165 #endif
166 #ifdef TIOCSWINSZ
167 TIOCSWINSZ_val = TIOCSWINSZ,
168 #endif
169 #ifdef TIOCNOTTY
170 TIOCNOTTY_val = TIOCNOTTY,
171 #endif
172 #ifdef TIOCSCTTY
173 TIOCSCTTY_val = TIOCSCTTY,
174 #endif
175 #ifdef TIOCGPGRP
176 TIOCGPGRP_val = TIOCGPGRP,
177 #endif
178 #ifdef TIOCSPGRP
179 TIOCSPGRP_val = TIOCSPGRP,
180 #endif
181 #ifdef TIOCGPTN
182 TIOCGPTN_val = TIOCGPTN,
183 #endif
184 #ifdef TIOCSPTLCK
185 TIOCSPTLCK_val = TIOCSPTLCK,
186 #endif
187 #ifdef TIOCGDEV
188 TIOCGDEV_val = TIOCGDEV,
189 #endif
190 #ifdef TIOCSIG
191 TIOCSIG_val = TIOCSIG,
192 #endif
193 #ifdef TCGETS
194 TCGETS_val = TCGETS,
195 #endif
196 #ifdef TCSETS
197 TCSETS_val = TCSETS,
198 #endif
199 #ifdef TUNSETIFF
200 TUNSETIFF_val = TUNSETIFF,
201 #endif
202 #ifdef TUNSETNOCSUM
203 TUNSETNOCSUM_val = TUNSETNOCSUM,
204 #endif
205 #ifdef TUNSETDEBUG
206 TUNSETDEBUG_val = TUNSETDEBUG,
207 #endif
208 #ifdef TUNSETPERSIST
209 TUNSETPERSIST_val = TUNSETPERSIST,
210 #endif
211 #ifdef TUNSETOWNER
212 TUNSETOWNER_val = TUNSETOWNER,
213 #endif
214 #ifdef TUNSETLINK
215 TUNSETLINK_val = TUNSETLINK,
216 #endif
217 #ifdef TUNSETGROUP
218 TUNSETGROUP_val = TUNSETGROUP,
219 #endif
220 #ifdef TUNGETFEATURES
221 TUNGETFEATURES_val = TUNGETFEATURES,
222 #endif
223 #ifdef TUNSETOFFLOAD
224 TUNSETOFFLOAD_val = TUNSETOFFLOAD,
225 #endif
226 #ifdef TUNSETTXFILTER
227 TUNSETTXFILTER_val = TUNSETTXFILTER,
228 #endif
229 #ifdef TUNGETIFF
230 TUNGETIFF_val = TUNGETIFF,
231 #endif
232 #ifdef TUNGETSNDBUF
233 TUNGETSNDBUF_val = TUNGETSNDBUF,
234 #endif
235 #ifdef TUNSETSNDBUF
236 TUNSETSNDBUF_val = TUNSETSNDBUF,
237 #endif
238 #ifdef TUNATTACHFILTER
239 TUNATTACHFILTER_val = TUNATTACHFILTER,
240 #endif
241 #ifdef TUNDETACHFILTER
242 TUNDETACHFILTER_val = TUNDETACHFILTER,
243 #endif
244 #ifdef TUNGETVNETHDRSZ
245 TUNGETVNETHDRSZ_val = TUNGETVNETHDRSZ,
246 #endif
247 #ifdef TUNSETVNETHDRSZ
248 TUNSETVNETHDRSZ_val = TUNSETVNETHDRSZ,
249 #endif
250 #ifdef TUNSETQUEUE
251 TUNSETQUEUE_val = TUNSETQUEUE,
252 #endif
253 #ifdef TUNSETIFINDEX
254 TUNSETIFINDEX_val = TUNSETIFINDEX,
255 #endif
256 #ifdef TUNGETFILTER
257 TUNGETFILTER_val = TUNGETFILTER,
258 #endif
259 #ifdef NLA_HDRLEN
260 NLA_HDRLEN_val = NLA_HDRLEN,
261 #endif