Revert "Properly handle system call numbers in lingo"
[official-gcc.git] / libgo / mksysinfo.sh
blob291fbb52cc007e9622572fb50ef16c6d951773bd
1 #!/bin/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 # Create sysinfo.go.
9 # This shell script creates the sysinfo.go file which holds types and
10 # constants extracted from the system header files. This relies on a
11 # hook in gcc: the -fdump-go-spec option will generate debugging
12 # information in Go syntax.
14 # We currently #include all the files at once, which works, but leads
15 # to exposing some names which ideally should not be exposed, as they
16 # match grep patterns. E.g., WCHAR_MIN gets exposed because it starts
17 # with W, like the wait flags.
19 CC=${CC:-gcc}
20 OUT=tmp-sysinfo.go
22 set -e
24 rm -f sysinfo.c
25 cat > sysinfo.c <<EOF
26 #include "config.h"
28 #include <sys/types.h>
29 #include <dirent.h>
30 #include <errno.h>
31 #include <fcntl.h>
32 #include <netinet/in.h>
33 /* <netinet/tcp.h> needs u_char/u_short, but <sys/bsd_types> is only
34 included by <netinet/in.h> if _SGIAPI (i.e. _SGI_SOURCE
35 && !_XOPEN_SOURCE.
36 <sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
37 <sys/ttold.h> does so unconditionally. */
38 #ifdef __sgi__
39 #include <sys/bsd_types.h>
40 #include <sys/ttold.h>
41 #endif
42 #include <netinet/tcp.h>
43 #include <signal.h>
44 #include <sys/ioctl.h>
45 #include <termios.h>
46 #if defined(HAVE_SYSCALL_H)
47 #include <syscall.h>
48 #endif
49 #if defined(HAVE_SYS_SYSCALL_H)
50 #include <sys/syscall.h>
51 #endif
52 #if defined(HAVE_SYS_EPOLL_H)
53 #include <sys/epoll.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 #if defined(HAVE_LINUX_FILTER_H)
86 #include <linux/filter.h>
87 #endif
88 #if defined(HAVE_LINUX_NETLINK_H)
89 #include <linux/netlink.h>
90 #endif
91 #if defined(HAVE_LINUX_RTNETLINK_H)
92 #include <linux/rtnetlink.h>
93 #endif
94 #if defined(HAVE_NET_IF_H)
95 #include <net/if.h>
96 #endif
97 #if defined(HAVE_NET_IF_ARP_H)
98 #include <net/if_arp.h>
99 #endif
100 #if defined(HAVE_SYS_MOUNT_H)
101 #include <sys/mount.h>
102 #endif
103 #if defined(HAVE_SYS_VFS_H)
104 #include <sys/vfs.h>
105 #endif
106 #if defined(HAVE_STATFS_H)
107 #include <sys/statfs.h>
108 #endif
109 #if defined(HAVE_SYS_TIMEX_H)
110 #include <sys/timex.h>
111 #endif
112 #if defined(HAVE_SYS_SYSINFO_H)
113 #include <sys/sysinfo.h>
114 #endif
115 #if defined(HAVE_USTAT_H)
116 #include <ustat.h>
117 #endif
118 #if defined(HAVE_UTIME_H)
119 #include <utime.h>
120 #endif
121 #if defined(HAVE_LINUX_ETHER_H)
122 #include <linux/ether.h>
123 #endif
124 #if defined(HAVE_LINUX_REBOOT_H)
125 #include <linux/reboot.h>
126 #endif
128 /* Constants that may only be defined as expressions on some systems,
129 expressions too complex for -fdump-go-spec to handle. These are
130 handled specially below. */
131 enum {
132 #ifdef TIOCGWINSZ
133 TIOCGWINSZ_val = TIOCGWINSZ,
134 #endif
138 ${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c
140 echo 'package syscall' > ${OUT}
141 echo 'import "unsafe"' >> ${OUT}
142 echo 'type _ unsafe.Pointer' >> ${OUT}
144 # Get all the consts and types, skipping ones which could not be
145 # represented in Go and ones which we need to rewrite. We also skip
146 # function declarations, as we don't need them here. All the symbols
147 # will all have a leading underscore.
148 grep -v '^// ' gen-sysinfo.go | \
149 grep -v '^func' | \
150 grep -v '^type _timeval ' | \
151 grep -v '^type _timespec_t ' | \
152 grep -v '^type _timespec ' | \
153 grep -v '^type _timestruc_t ' | \
154 grep -v '^type _epoll_' | \
155 grep -v 'in6_addr' | \
156 grep -v 'sockaddr_in6' | \
157 sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
158 -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
159 -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
160 -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
161 >> ${OUT}
163 # The errno constants. These get type Errno.
164 echo '#include <errno.h>' | ${CC} -x c - -E -dM | \
165 egrep '#define E[A-Z0-9_]+ ' | \
166 sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
168 # The O_xxx flags.
169 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
170 sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
171 if ! grep '^const O_ASYNC' ${OUT} >/dev/null 2>&1; then
172 echo "const O_ASYNC = 0" >> ${OUT}
174 if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
175 echo "const O_CLOEXEC = 0" >> ${OUT}
178 # The signal numbers.
179 grep '^const _SIG[^_]' gen-sysinfo.go | \
180 grep -v '^const _SIGEV_' | \
181 sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = Signal(_\2)/' >> ${OUT}
183 # The syscall numbers. We force the names to upper case.
184 grep '^const _SYS_' gen-sysinfo.go | \
185 sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
186 while read sys; do
187 sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
188 echo "const $sup = _$sys" >> ${OUT}
189 done
191 # Stat constants.
192 grep '^const _S_' gen-sysinfo.go | \
193 sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
195 # Mmap constants.
196 grep '^const _PROT_' gen-sysinfo.go | \
197 sed -e 's/^\(const \)_\(PROT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
198 grep '^const _MAP_' gen-sysinfo.go | \
199 sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
200 grep '^const _MADV_' gen-sysinfo.go | \
201 sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
203 # Process status constants.
204 grep '^const _W' gen-sysinfo.go |
205 sed -e 's/^\(const \)_\(W[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
206 # WSTOPPED was introduced in glibc 2.3.4.
207 if ! grep '^const _WSTOPPED = ' gen-sysinfo.go >/dev/null 2>&1; then
208 if grep '^const _WUNTRACED = ' gen-sysinfo.go > /dev/null 2>&1; then
209 echo 'const WSTOPPED = _WUNTRACED' >> ${OUT}
210 else
211 echo 'const WSTOPPED = 2' >> ${OUT}
214 if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
215 && ! grep '^const _WALL = ' gen-sysinfo.go >/dev/null 2>&1; then
216 echo 'const WALL = ___WALL' >> ${OUT}
219 # Networking constants.
220 egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
221 sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
222 grep '^const _SOMAXCONN' gen-sysinfo.go |
223 sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
224 >> ${OUT}
225 grep '^const _SHUT_' gen-sysinfo.go |
226 sed -e 's/^\(const \)_\(SHUT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
228 # The net package requires some const definitions.
229 for m in IP_PKTINFO IPV6_V6ONLY IPPROTO_IPV6 IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_TCLASS; do
230 if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
231 echo "const $m = 0" >> ${OUT}
233 done
235 # pathconf constants.
236 grep '^const __PC' gen-sysinfo.go |
237 sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
239 # epoll constants.
240 grep '^const _EPOLL' gen-sysinfo.go |
241 sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
242 # Make sure EPOLLRDHUP and EPOLL_CLOEXEC are defined.
243 if ! grep '^const EPOLLRDHUP' ${OUT} >/dev/null 2>&1; then
244 echo "const EPOLLRDHUP = 0x2000" >> ${OUT}
246 if ! grep '^const EPOLL_CLOEXEC' ${OUT} >/dev/null 2>&1; then
247 echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
250 # Prctl constants.
251 grep '^const _PR_' gen-sysinfo.go |
252 sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
254 # Ptrace constants.
255 grep '^const _PTRACE' gen-sysinfo.go |
256 sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
257 # We need some ptrace options that are not defined in older versions
258 # of glibc.
259 if ! grep '^const PTRACE_SETOPTIONS' ${OUT} > /dev/null 2>&1; then
260 echo "const PTRACE_SETOPTIONS = 0x4200" >> ${OUT}
262 if ! grep '^const PTRACE_O_TRACESYSGOOD' ${OUT} > /dev/null 2>&1; then
263 echo "const PTRACE_O_TRACESYSGOOD = 0x1" >> ${OUT}
265 if ! grep '^const PTRACE_O_TRACEFORK' ${OUT} > /dev/null 2>&1; then
266 echo "const PTRACE_O_TRACEFORK = 0x2" >> ${OUT}
268 if ! grep '^const PTRACE_O_TRACEVFORK' ${OUT} > /dev/null 2>&1; then
269 echo "const PTRACE_O_TRACEVFORK = 0x4" >> ${OUT}
271 if ! grep '^const PTRACE_O_TRACECLONE' ${OUT} > /dev/null 2>&1; then
272 echo "const PTRACE_O_TRACECLONE = 0x8" >> ${OUT}
274 if ! grep '^const PTRACE_O_TRACEEXEC' ${OUT} > /dev/null 2>&1; then
275 echo "const PTRACE_O_TRACEEXEC = 0x10" >> ${OUT}
277 if ! grep '^const PTRACE_O_TRACEVFORKDONE' ${OUT} > /dev/null 2>&1; then
278 echo "const PTRACE_O_TRACEVFORKDONE = 0x20" >> ${OUT}
280 if ! grep '^const PTRACE_O_TRACEEXIT' ${OUT} > /dev/null 2>&1; then
281 echo "const PTRACE_O_TRACEEXIT = 0x40" >> ${OUT}
283 if ! grep '^const PTRACE_O_MASK' ${OUT} > /dev/null 2>&1; then
284 echo "const PTRACE_O_MASK = 0x7f" >> ${OUT}
286 if ! grep '^const _PTRACE_GETEVENTMSG' ${OUT} > /dev/null 2>&1; then
287 echo "const PTRACE_GETEVENTMSG = 0x4201" >> ${OUT}
289 if ! grep '^const PTRACE_EVENT_FORK' ${OUT} > /dev/null 2>&1; then
290 echo "const PTRACE_EVENT_FORK = 1" >> ${OUT}
292 if ! grep '^const PTRACE_EVENT_VFORK' ${OUT} > /dev/null 2>&1; then
293 echo "const PTRACE_EVENT_VFORK = 2" >> ${OUT}
295 if ! grep '^const PTRACE_EVENT_CLONE' ${OUT} > /dev/null 2>&1; then
296 echo "const PTRACE_EVENT_CLONE = 3" >> ${OUT}
298 if ! grep '^const PTRACE_EVENT_EXEC' ${OUT} > /dev/null 2>&1; then
299 echo "const PTRACE_EVENT_EXEC = 4" >> ${OUT}
301 if ! grep '^const PTRACE_EVENT_VFORK_DONE' ${OUT} > /dev/null 2>&1; then
302 echo "const PTRACE_EVENT_VFORK_DONE = 5" >> ${OUT}
304 if ! grep '^const PTRACE_EVENT_EXIT' ${OUT} > /dev/null 2>&1; then
305 echo "const PTRACE_EVENT_EXIT = 6" >> ${OUT}
307 if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then
308 echo "const _PTRACE_TRACEME = 0" >> ${OUT}
311 # The registers returned by PTRACE_GETREGS. This is probably
312 # GNU/Linux specific; it should do no harm if there is no
313 # _user_regs_struct.
314 regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
315 if test "$regs" != ""; then
316 regs=`echo $regs | sed -e 's/type _user_regs_struct struct //' -e 's/[{}]//g'`
317 regs=`echo $regs | sed -e s'/^ *//'`
318 nregs=
319 while test -n "$regs"; do
320 field=`echo $regs | sed -e 's/^\([^;]*\);.*$/\1/'`
321 regs=`echo $regs | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
322 # Capitalize the first character of the field.
323 f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
324 r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
325 f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
326 field="$f$r"
327 nregs="$nregs $field;"
328 done
329 echo "type PtraceRegs struct {$nregs }" >> ${OUT}
332 # Some basic types.
333 echo 'type Size_t _size_t' >> ${OUT}
334 echo "type Ssize_t _ssize_t" >> ${OUT}
335 if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
336 echo "type Offset_t _off64_t" >> ${OUT}
337 else
338 echo "type Offset_t _off_t" >> ${OUT}
340 echo "type Mode_t _mode_t" >> ${OUT}
341 echo "type Pid_t _pid_t" >> ${OUT}
342 echo "type Uid_t _uid_t" >> ${OUT}
343 echo "type Gid_t _gid_t" >> ${OUT}
344 echo "type Socklen_t _socklen_t" >> ${OUT}
346 # The long type, needed because that is the type that ptrace returns.
347 sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
348 if test "$sizeof_long" = "4"; then
349 echo "type _C_long int32" >> ${OUT}
350 elif test "$sizeof_long" = "8"; then
351 echo "type _C_long int64" >> ${OUT}
352 else
353 echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
354 exit 1
357 # Solaris 2 needs _u?pad128_t, but its default definition in terms of long
358 # double is commented by -fdump-go-spec.
359 if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then
360 echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT}
362 if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then
363 echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT}
366 # The time_t type.
367 if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then
368 echo 'type Time_t _time_t' >> ${OUT}
371 # The time structures need special handling: we need to name the
372 # types, so that we can cast integers to the right types when
373 # assigning to the structures.
374 timeval=`grep '^type _timeval ' gen-sysinfo.go`
375 timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
376 timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'`
377 echo "type Timeval_sec_t $timeval_sec" >> ${OUT}
378 echo "type Timeval_usec_t $timeval_usec" >> ${OUT}
379 echo $timeval | \
380 sed -e 's/type _timeval /type Timeval /' \
381 -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \
382 -e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT}
383 timespec=`grep '^type _timespec ' gen-sysinfo.go || true`
384 if test "$timespec" = ""; then
385 # IRIX 6.5 has __timespec instead.
386 timespec=`grep '^type ___timespec ' gen-sysinfo.go || true`
388 timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
389 timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
390 echo "type Timespec_sec_t $timespec_sec" >> ${OUT}
391 echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT}
392 echo $timespec | \
393 sed -e 's/^type ___timespec /type Timespec /' \
394 -e 's/^type _timespec /type Timespec /' \
395 -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
396 -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
398 timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true`
399 if test "$timestruc" != ""; then
400 timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
401 timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
402 echo "type Timestruc_sec_t $timestruc_sec" >> ${OUT}
403 echo "type Timestruc_nsec_t $timestruc_nsec" >> ${OUT}
404 echo $timestruc | \
405 sed -e 's/^type _timestruc_t /type Timestruc /' \
406 -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timestruc_sec_t/' \
407 -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
410 # The tms struct.
411 grep '^type _tms ' gen-sysinfo.go | \
412 sed -e 's/type _tms/type Tms/' \
413 -e 's/tms_utime/Utime/' \
414 -e 's/tms_stime/Stime/' \
415 -e 's/tms_cutime/Cutime/' \
416 -e 's/tms_cstime/Cstime/' \
417 >> ${OUT}
419 # The stat type.
420 # Prefer largefile variant if available.
421 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
422 if test "$stat" != ""; then
423 grep '^type _stat64 ' gen-sysinfo.go
424 else
425 grep '^type _stat ' gen-sysinfo.go
426 fi | sed -e 's/type _stat64/type Stat_t/' \
427 -e 's/type _stat/type Stat_t/' \
428 -e 's/st_dev/Dev/' \
429 -e 's/st_ino/Ino/g' \
430 -e 's/st_nlink/Nlink/' \
431 -e 's/st_mode/Mode/' \
432 -e 's/st_uid/Uid/' \
433 -e 's/st_gid/Gid/' \
434 -e 's/st_rdev/Rdev/' \
435 -e 's/st_size/Size/' \
436 -e 's/st_blksize/Blksize/' \
437 -e 's/st_blocks/Blocks/' \
438 -e 's/st_atim/Atime/' \
439 -e 's/st_mtim/Mtime/' \
440 -e 's/st_ctim/Ctime/' \
441 -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
442 -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
443 -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
444 -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
445 -e 's/Godump_[0-9] struct { \([^;]*;\) };/\1/g' \
446 >> ${OUT}
448 # The directory searching types.
449 # Prefer largefile variant if available.
450 dirent=`grep '^type _dirent64 ' gen-sysinfo.go || true`
451 if test "$dirent" != ""; then
452 grep '^type _dirent64 ' gen-sysinfo.go
453 else
454 grep '^type _dirent ' gen-sysinfo.go
455 fi | sed -e 's/type _dirent64/type Dirent/' \
456 -e 's/type _dirent/type Dirent/' \
457 -e 's/d_name \[0+1\]/d_name [0+256]/' \
458 -e 's/d_name/Name/' \
459 -e 's/]int8/]byte/' \
460 -e 's/d_ino/Ino/' \
461 -e 's/d_off/Off/' \
462 -e 's/d_reclen/Reclen/' \
463 -e 's/d_type/Type/' \
464 >> ${OUT}
465 echo "type DIR _DIR" >> ${OUT}
467 # Values for d_type field in dirent.
468 grep '^const _DT_' gen-sysinfo.go |
469 sed -e 's/^\(const \)_\(DT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
471 # The rusage struct.
472 rusage=`grep '^type _rusage struct' gen-sysinfo.go`
473 if test "$rusage" != ""; then
474 rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
475 rusage=`echo $rusage | sed -e 's/^ *//'`
476 nrusage=
477 while test -n "$rusage"; do
478 field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
479 rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
480 # Drop the leading ru_, capitalize the next character.
481 field=`echo $field | sed -e 's/^ru_//'`
482 f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
483 r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
484 f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
485 # Fix _timeval _timespec, and _timestruc_t.
486 r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
487 r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
488 r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
489 field="$f$r"
490 nrusage="$nrusage $field;"
491 done
492 echo "type Rusage struct {$nrusage }" >> ${OUT}
493 else
494 echo "type Rusage struct {}" >> ${OUT}
497 # The RUSAGE constants.
498 grep '^const _RUSAGE_' gen-sysinfo.go | \
499 sed -e 's/^\(const \)_\(RUSAGE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
501 # The utsname struct.
502 grep '^type _utsname ' gen-sysinfo.go | \
503 sed -e 's/_utsname/Utsname/' \
504 -e 's/sysname/Sysname/' \
505 -e 's/nodename/Nodename/' \
506 -e 's/release/Release/' \
507 -e 's/version/Version/' \
508 -e 's/machine/Machine/' \
509 -e 's/domainname/Domainname/' \
510 >> ${OUT}
512 # The iovec struct.
513 iovec=`grep '^type _iovec ' gen-sysinfo.go`
514 iovec_len=`echo $iovec | sed -n -e 's/^.*iov_len \([^ ]*\);.*$/\1/p'`
515 echo "type Iovec_len_t $iovec_len" >> ${OUT}
516 echo $iovec | \
517 sed -e 's/_iovec/Iovec/' \
518 -e 's/iov_base/Base/' \
519 -e 's/iov_len *[a-zA-Z0-9_]*/Len Iovec_len_t/' \
520 >> ${OUT}
522 # The msghdr struct.
523 msghdr=`grep '^type _msghdr ' gen-sysinfo.go`
524 msghdr_controllen=`echo $msghdr | sed -n -e 's/^.*msg_controllen \([^ ]*\);.*$/\1/p'`
525 echo "type Msghdr_controllen_t $msghdr_controllen" >> ${OUT}
526 echo $msghdr | \
527 sed -e 's/_msghdr/Msghdr/' \
528 -e 's/msg_name/Name/' \
529 -e 's/msg_namelen/Namelen/' \
530 -e 's/msg_iov/Iov/' \
531 -e 's/msg_iovlen/Iovlen/' \
532 -e 's/_iovec/Iovec/' \
533 -e 's/msg_control/Control/' \
534 -e 's/msg_controllen *[a-zA-Z0-9_]*/Controllen Msghdr_controllen_t/' \
535 -e 's/msg_flags/Flags/' \
536 >> ${OUT}
538 # The MSG_ flags for Msghdr.
539 grep '^const _MSG_' gen-sysinfo.go | \
540 sed -e 's/^\(const \)_\(MSG_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
542 # The cmsghdr struct.
543 cmsghdr=`grep '^type _cmsghdr ' gen-sysinfo.go`
544 if test -n "$cmsghdr"; then
545 cmsghdr_len=`echo $cmsghdr | sed -n -e 's/^.*cmsg_len \([^ ]*\);.*$/\1/p'`
546 echo "type Cmsghdr_len_t $cmsghdr_len" >> ${OUT}
547 echo "$cmsghdr" | \
548 sed -e 's/_cmsghdr/Cmsghdr/' \
549 -e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
550 -e 's/cmsg_level/Level/' \
551 -e 's/cmsg_type/Type/' \
552 -e 's/\[\]/[0]/' \
553 >> ${OUT}
555 # The size of the cmsghdr struct.
556 echo 'var SizeofCmsghdr = int(unsafe.Sizeof(Cmsghdr{}))' >> ${OUT}
559 # The SCM_ flags for Cmsghdr.
560 grep '^const _SCM_' gen-sysinfo.go | \
561 sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
563 # The ucred struct.
564 grep '^type _ucred ' gen-sysinfo.go | \
565 sed -e 's/_ucred/Ucred/' \
566 -e 's/pid/Pid/' \
567 -e 's/uid/Uid/' \
568 -e 's/gid/Gid/' \
569 >> ${OUT}
571 # The size of the ucred struct.
572 if grep 'type Ucred ' ${OUT} >/dev/null 2>&1; then
573 echo 'var SizeofUcred = int(unsafe.Sizeof(Ucred{}))' >> ${OUT}
576 # The ip_mreq struct.
577 grep '^type _ip_mreq ' gen-sysinfo.go | \
578 sed -e 's/_ip_mreq/IPMreq/' \
579 -e 's/imr_multiaddr/Multiaddr/' \
580 -e 's/imr_interface/Interface/' \
581 -e 's/_in_addr/[4]byte/g' \
582 >> ${OUT}
584 # We need IPMreq to compile the net package.
585 if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then
586 echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT}
589 # The size of the ip_mreq struct.
590 echo 'var SizeofIPMreq = int(unsafe.Sizeof(IPMreq{}))' >> ${OUT}
592 # The ipv6_mreq struct.
593 grep '^type _ipv6_mreq ' gen-sysinfo.go | \
594 sed -e 's/_ipv6_mreq/IPv6Mreq/' \
595 -e 's/ipv6mr_multiaddr/Multiaddr/' \
596 -e 's/ipv6mr_interface/Interface/' \
597 -e 's/_in6_addr/[16]byte/' \
598 >> ${OUT}
600 # We need IPv6Mreq to compile the net package.
601 if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then
602 echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
605 # The size of the ipv6_mreq struct.
606 echo 'var SizeofIPv6Mreq = int(unsafe.Sizeof(IPv6Mreq{}))' >> ${OUT}
608 # The ip_mreqn struct.
609 grep '^type _ip_mreqn ' gen-sysinfo.go | \
610 sed -e 's/_ip_mreqn/IPMreqn/' \
611 -e 's/imr_multiaddr/Multiaddr/' \
612 -e 's/imr_address/Address/' \
613 -e 's/imr_ifindex/Ifindex/' \
614 -e 's/_in_addr/[4]byte/g' \
615 >> ${OUT}
617 # We need IPMreq to compile the net package.
618 if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then
619 echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT}
622 # The size of the ip_mreqn struct.
623 echo 'var SizeofIPMreqn = int(unsafe.Sizeof(IPMreqn{}))' >> ${OUT}
625 # Try to guess the type to use for fd_set.
626 fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
627 fds_bits_type="_C_long"
628 if test "$fd_set" != ""; then
629 fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'`
631 echo "type fds_bits_type $fds_bits_type" >> ${OUT}
633 # The addrinfo struct.
634 grep '^type _addrinfo ' gen-sysinfo.go | \
635 sed -e 's/_addrinfo/Addrinfo/g' \
636 -e 's/ ai_/ Ai_/g' \
637 >> ${OUT}
639 # The addrinfo flags and errors.
640 grep '^const _AI_' gen-sysinfo.go | \
641 sed -e 's/^\(const \)_\(AI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
642 grep '^const _EAI_' gen-sysinfo.go | \
643 sed -e 's/^\(const \)_\(EAI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
645 # The passwd struct.
646 grep '^type _passwd ' gen-sysinfo.go | \
647 sed -e 's/_passwd/Passwd/' \
648 -e 's/ pw_/ Pw_/g' \
649 >> ${OUT}
651 # The ioctl flags for the controlling TTY.
652 grep '^const _TIOC' gen-sysinfo.go | \
653 grep -v '_val =' | \
654 sed -e 's/^\(const \)_\(TIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
655 # We need TIOCGWINSZ.
656 if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then
657 if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then
658 echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT}
662 # The ioctl flags for terminal control
663 grep '^const _TC[GS]ET' gen-sysinfo.go | \
664 sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
666 # ioctl constants. Might fall back to 0 if TIOCNXCL is missing, too, but
667 # needs handling in syscalls.exec.go.
668 if ! grep '^const _TIOCSCTTY ' gen-sysinfo.go >/dev/null 2>&1; then
669 if grep '^const _TIOCNXCL ' gen-sysinfo.go >/dev/null 2>&1; then
670 echo "const TIOCSCTTY = TIOCNXCL" >> ${OUT}
674 # The nlmsghdr struct.
675 grep '^type _nlmsghdr ' gen-sysinfo.go | \
676 sed -e 's/_nlmsghdr/NlMsghdr/' \
677 -e 's/nlmsg_len/Len/' \
678 -e 's/nlmsg_type/Type/' \
679 -e 's/nlmsg_flags/Flags/' \
680 -e 's/nlmsg_seq/Seq/' \
681 -e 's/nlmsg_pid/Pid/' \
682 >> ${OUT}
684 # The nlmsg flags and operators.
685 grep '^const _NLM' gen-sysinfo.go | \
686 sed -e 's/^\(const \)_\(NLM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
688 # NLMSG_HDRLEN is defined as an expression using sizeof.
689 if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then
690 if grep '^type NlMsghdr ' ${OUT} > /dev/null 2>&1; then
691 echo 'var NLMSG_HDRLEN = int((unsafe.Sizeof(NlMsghdr{}) + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1))' >> ${OUT}
695 # The rtmsg struct.
696 grep '^type _rtmsg ' gen-sysinfo.go | \
697 sed -e 's/_rtmsg/RtMsg/' \
698 -e 's/rtm_family/Family/' \
699 -e 's/rtm_dst_len/Dst_len/' \
700 -e 's/rtm_src_len/Src_len/' \
701 -e 's/rtm_tos/Tos/' \
702 -e 's/rtm_table/Table/' \
703 -e 's/rtm_protocol/Procotol/' \
704 -e 's/rtm_scope/Scope/' \
705 -e 's/rtm_type/Type/' \
706 -e 's/rtm_flags/Flags/' \
707 >> ${OUT}
709 # The size of the rtmsg struct.
710 if grep 'type RtMsg ' ${OUT} > /dev/null 2>&1; then
711 echo 'var SizeofRtMsg = int(unsafe.Sizeof(RtMsg{}))' >> ${OUT}
714 # The rtgenmsg struct.
715 grep '^type _rtgenmsg ' gen-sysinfo.go | \
716 sed -e 's/_rtgenmsg/RtGenmsg/' \
717 -e 's/rtgen_family/Family/' \
718 >> ${OUT}
720 # The routing message flags.
721 grep '^const _RTA' gen-sysinfo.go | \
722 sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
723 grep '^const _RTF' gen-sysinfo.go | \
724 sed -e 's/^\(const \)_\(RTF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
725 grep '^const _RTCF' gen-sysinfo.go | \
726 sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
727 grep '^const _RTM' gen-sysinfo.go | \
728 sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
730 # The size of the rtgenmsg struct.
731 if grep 'type RtGenmsg ' ${OUT} > /dev/null 2>&1; then
732 echo 'var SizeofRtGenmsg = int(unsafe.Sizeof(RtGenmsg{}))' >> ${OUT}
735 # The ifinfomsg struct.
736 grep '^type _ifinfomsg ' gen-sysinfo.go | \
737 sed -e 's/_ifinfomsg/IfInfomsg/' \
738 -e 's/ifi_family/Family/' \
739 -e 's/ifi_type/Type/' \
740 -e 's/ifi_index/Index/' \
741 -e 's/ifi_flags/Flags/' \
742 -e 's/ifi_change/Change/' \
743 >> ${OUT}
745 # The interface information types and flags.
746 grep '^const _IFA' gen-sysinfo.go | \
747 sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
748 grep '^const _IFLA' gen-sysinfo.go | \
749 sed -e 's/^\(const \)_\(IFLA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
750 grep '^const _IFF' gen-sysinfo.go | \
751 sed -e 's/^\(const \)_\(IFF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
752 grep '^const _IFNAMSIZ' gen-sysinfo.go | \
753 sed -e 's/^\(const \)_\(IFNAMSIZ[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
754 grep '^const _SIOC' gen-sysinfo.go |
755 sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
757 # The size of the ifinfomsg struct.
758 if grep 'type IfInfomsg ' ${OUT} > /dev/null 2>&1; then
759 echo 'var SizeofIfInfomsg = int(unsafe.Sizeof(IfInfomsg{}))' >> ${OUT}
762 # The ifaddrmsg struct.
763 grep '^type _ifaddrmsg ' gen-sysinfo.go | \
764 sed -e 's/_ifaddrmsg/IfAddrmsg/' \
765 -e 's/ifa_family/Family/' \
766 -e 's/ifa_prefixlen/Prefixlen/' \
767 -e 's/ifa_flags/Flags/' \
768 -e 's/ifa_scope/Scope/' \
769 -e 's/ifa_index/Index/' \
770 >> ${OUT}
772 # The size of the ifaddrmsg struct.
773 if grep 'type IfAddrmsg ' ${OUT} > /dev/null 2>&1; then
774 echo 'var SizeofIfAddrmsg = int(unsafe.Sizeof(IfAddrmsg{}))' >> ${OUT}
777 # The rtattr struct.
778 grep '^type _rtattr ' gen-sysinfo.go | \
779 sed -e 's/_rtattr/RtAttr/' \
780 -e 's/rta_len/Len/' \
781 -e 's/rta_type/Type/' \
782 >> ${OUT}
784 # The size of the rtattr struct.
785 if grep 'type RtAttr ' ${OUT} > /dev/null 2>&1; then
786 echo 'var SizeofRtAttr = int(unsafe.Sizeof(RtAttr{}))' >> ${OUT}
789 # The termios struct.
790 grep '^type _termios ' gen-sysinfo.go | \
791 sed -e 's/_termios/Termios/' \
792 -e 's/c_iflag/Iflag/' \
793 -e 's/c_oflag/Oflag/' \
794 -e 's/c_cflag/Cflag/' \
795 -e 's/c_lflag/Lflag/' \
796 -e 's/c_line/Line/' \
797 -e 's/c_cc/Cc/' \
798 -e 's/c_ispeed/Ispeed/' \
799 -e 's/c_ospeed/Ospeed/' \
800 >> ${OUT}
802 # The termios constants.
803 for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
804 IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
805 OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 CS5 CS6 CS7 CS8 TABDLY \
806 BSDLY VTDLY FFDLY CBAUD CBAUDEX CSIZE CSTOPB CREAD PARENB PARODD HUPCL \
807 CLOCAL LOBLK CIBAUD CMSPAR CRTSCTS ISIG ICANON XCASE ECHO ECHOE ECHOK \
808 ECHONL ECHOCTL ECHOPRT ECHOKE DEFECHO FLUSHO NOFLSH TOSTOP PENDIN IEXTEN \
809 VINTR VQUIT VERASE VKILL VEOF VMIN VEOL VTIME VEOL2 VSWTCH VSTART VSTOP \
810 VSUSP VDSUSP VLNEXT VWERASE VREPRINT VDISCARD VSTATUS TCSANOW TCSADRAIN \
811 TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \
812 B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \
813 B38400 B57600 B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \
814 B1152000 B1500000 B2000000 B2500000 B3000000 B4000000; do
816 grep "^const _$n " gen-sysinfo.go | \
817 sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
818 done
820 # The mount flags
821 grep '^const _MS_' gen-sysinfo.go |
822 sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
824 # The fallocate flags.
825 grep '^const _FALLOC_' gen-sysinfo.go |
826 sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
828 # The statfs struct.
829 # Prefer largefile variant if available.
830 statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
831 if test "$statfs" != ""; then
832 grep '^type _statfs64 ' gen-sysinfo.go
833 else
834 grep '^type _statfs ' gen-sysinfo.go
835 fi | sed -e 's/type _statfs64/type Statfs_t/' \
836 -e 's/type _statfs/type Statfs_t/' \
837 -e 's/f_type/Type/' \
838 -e 's/f_bsize/Bsize/' \
839 -e 's/f_blocks/Blocks/' \
840 -e 's/f_bfree/Bfree/' \
841 -e 's/f_bavail/Bavail/' \
842 -e 's/f_files/Files/' \
843 -e 's/f_ffree/Ffree/' \
844 -e 's/f_fsid/Fsid/' \
845 -e 's/f_namelen/Namelen/' \
846 -e 's/f_frsize/Frsize/' \
847 -e 's/f_flags/Flags/' \
848 -e 's/f_spare/Spare/' \
849 >> ${OUT}
851 # The timex struct.
852 timex=`grep '^type _timex ' gen-sysinfo.go || true`
853 if test "$timex" = ""; then
854 timex=`grep '^// type _timex ' gen-sysinfo.go || true`
855 if test "$timex" != ""; then
856 timex=`echo $timex | sed -e 's|// ||' -e 's/INVALID-bit-field/int32/g'`
859 if test "$timex" != ""; then
860 echo "$timex" | \
861 sed -e 's/_timex/Timex/' \
862 -e 's/modes/Modes/' \
863 -e 's/offset/Offset/' \
864 -e 's/freq/Freq/' \
865 -e 's/maxerror/Maxerror/' \
866 -e 's/esterror/Esterror/' \
867 -e 's/status/Status/' \
868 -e 's/constant/Constant/' \
869 -e 's/precision/Precision/' \
870 -e 's/tolerance/Tolerance/' \
871 -e 's/ time / Time /' \
872 -e 's/tick/Tick/' \
873 -e 's/ppsfreq/Ppsfreq/' \
874 -e 's/jitter/Jitter/' \
875 -e 's/shift/Shift/' \
876 -e 's/stabil/Stabil/' \
877 -e 's/jitcnt/Jitcnt/' \
878 -e 's/calcnt/Calcnt/' \
879 -e 's/errcnt/Errcnt/' \
880 -e 's/stbcnt/Stbcnt/' \
881 -e 's/tai/Tai/' \
882 -e 's/_timeval/Timeval/' \
883 >> ${OUT}
886 # The rlimit struct.
887 grep '^type _rlimit ' gen-sysinfo.go | \
888 sed -e 's/_rlimit/Rlimit/' \
889 -e 's/rlim_cur/Cur/' \
890 -e 's/rlim_max/Max/' \
891 >> ${OUT}
893 # The RLIMIT constants.
894 grep '^const _RLIMIT_' gen-sysinfo.go |
895 sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
897 # The sysinfo struct.
898 grep '^type _sysinfo ' gen-sysinfo.go | \
899 sed -e 's/_sysinfo/Sysinfo_t/' \
900 -e 's/uptime/Uptime/' \
901 -e 's/loads/Loads/' \
902 -e 's/totalram/Totalram/' \
903 -e 's/freeram/Freeram/' \
904 -e 's/sharedram/Sharedram/' \
905 -e 's/bufferram/Bufferram/' \
906 -e 's/totalswap/Totalswap/' \
907 -e 's/freeswap/Freeswap/' \
908 -e 's/procs/Procs/' \
909 -e 's/totalhigh/Totalhigh/' \
910 -e 's/freehigh/Freehigh/' \
911 -e 's/mem_unit/Unit/' \
912 >> ${OUT}
914 # The ustat struct.
915 grep '^type _ustat ' gen-sysinfo.go | \
916 sed -e 's/_ustat/Ustat_t/' \
917 -e 's/f_tfree/Tfree/' \
918 -e 's/f_tinode/Tinoe/' \
919 -e 's/f_fname/Fname/' \
920 -e 's/f_fpack/Fpack/' \
921 >> ${OUT}
922 # Force it to be defined, as on some older GNU/Linux systems the
923 # header file fails when using with <linux/filter.h>.
924 if ! grep 'type _ustat ' gen-sysinfo.go >/dev/null 2>&1; then
925 echo 'type Ustat_t struct { Tfree int32; Tinoe uint64; Fname [5+1]int8; Fpack [5+1]int8; }' >> ${OUT}
928 # The utimbuf struct.
929 grep '^type _utimbuf ' gen-sysinfo.go | \
930 sed -e 's/_utimbuf/Utimbuf/' \
931 -e 's/actime/Actime/' \
932 -e 's/modtime/Modtime/' \
933 >> ${OUT}
935 # The GNU/Linux LINUX_REBOOT flags.
936 grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
937 sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
939 # The GNU/Linux sock_filter struct.
940 grep '^type _sock_filter ' gen-sysinfo.go | \
941 sed -e 's/_sock_filter/SockFilter/' \
942 -e 's/code/Code/' \
943 -e 's/jt/Jt/' \
944 -e 's/jf/Jf/' \
945 -e 's/k /K /' \
946 >> ${OUT}
948 # The GNU/Linux sock_fprog struct.
949 grep '^type _sock_fprog ' gen-sysinfo.go | \
950 sed -e 's/_sock_fprog/SockFprog/' \
951 -e 's/len/Len/' \
952 -e 's/filter/Filter/' \
953 -e 's/_sock_filter/SockFilter/' \
954 >> ${OUT}
956 # The GNU/Linux filter flags.
957 grep '^const _BPF_' gen-sysinfo.go | \
958 sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
960 # The Solaris 11 Update 1 _zone_net_addr_t struct.
961 grep '^type _zone_net_addr_t ' gen-sysinfo.go | \
962 sed -e 's/_in6_addr/[16]byte/' \
963 >> ${OUT}
965 exit $?