re PR fortran/88048 (ICE in check_data_variable, at fortran/resolve.c:15491)
[official-gcc.git] / libgo / mksysinfo.sh
blob02f0b5b82fe08d04a2e268312360decb2e56646e
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 from gen-sysinfo.go and errno.i.
9 # This shell script creates the sysinfo.go file which holds types and
10 # constants extracted from the system header files. This reads the
11 # raw data from gen-sysinfo.go which is generated using the
12 # -fdump-go-spec option.
14 # This currently exposes some names that ideally should not be
15 # exposed, as they match grep patterns. E.g., WCHAR_MIN gets exposed
16 # because it starts with W, like the wait flags.
18 OUT=tmp-sysinfo.go
20 set -e
22 echo 'package syscall' > ${OUT}
23 echo 'import "unsafe"' >> ${OUT}
24 echo 'type _ unsafe.Pointer' >> ${OUT}
26 # Get all the consts and types, skipping ones which could not be
27 # represented in Go and ones which we need to rewrite. We also skip
28 # function declarations, as we don't need them here. All the symbols
29 # will all have a leading underscore.
30 grep -v '^// ' gen-sysinfo.go | \
31 grep -v '^func' | \
32 grep -v '^var' | \
33 grep -v '^type _timeval ' | \
34 grep -v '^type _timespec_t ' | \
35 grep -v '^type _timespec ' | \
36 grep -v '^type _timestruc_t ' | \
37 grep -v '^type _epoll_' | \
38 grep -v '^type _*locale[_ ]' | \
39 grep -v 'in6_addr' | \
40 grep -v 'sockaddr_in6' | \
41 sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
42 -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
43 -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
44 -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
45 >> ${OUT}
47 # On AIX, the _arpcom struct, is filtered by the above grep sequence, as it as
48 # a field of type _in6_addr, but other types depend on _arpcom, so we need to
49 # put it back.
50 grep '^type _arpcom ' gen-sysinfo.go | \
51 sed -e 's/_in6_addr/[16]byte/' >> ${OUT}
53 # Same on Solaris for _mld_hdr_t.
54 grep '^type _mld_hdr_t ' gen-sysinfo.go | \
55 sed -e 's/_in6_addr/[16]byte/' >> ${OUT}
57 # The errno constants. These get type Errno.
58 egrep '#define E[A-Z0-9_]+ ' errno.i | \
59 sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
61 # The O_xxx flags.
62 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
63 sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
64 if ! grep '^const O_ASYNC' ${OUT} >/dev/null 2>&1; then
65 echo "const O_ASYNC = 0" >> ${OUT}
67 if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
68 echo "const O_CLOEXEC = 0" >> ${OUT}
71 # The os package requires F_DUPFD_CLOEXEC to be defined.
72 if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then
73 echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
76 # The internal/poll package requires F_GETPIPE_SZ to be defined.
77 if ! grep '^const F_GETPIPE_SZ' ${OUT} >/dev/null 2>&1; then
78 echo "const F_GETPIPE_SZ = 0" >> ${OUT}
81 # AIX 7.1 is a 64 bits value for _FCLOEXEC (referenced by O_CLOEXEC)
82 # which leads to a constant overflow when using O_CLOEXEC in some
83 # go code. Issue wan not present in 6.1 (no O_CLOEXEC) and is no
84 # more present in 7.2 (_FCLOEXEC is a 32 bit value).
85 if test "${GOOS}" = "aix" && `oslevel | grep -q "^7.1"`; then
86 sed -e 's/const __FCLOEXEC = .*/const __FCLOEXEC = 0/' ${OUT} > ${OUT}-2
87 mv ${OUT}-2 ${OUT}
90 # These flags can be lost on i386 GNU/Linux when using
91 # -D_FILE_OFFSET_BITS=64, because we see "#define F_SETLK F_SETLK64"
92 # before we see the definition of F_SETLK64.
93 for flag in F_GETLK F_SETLK F_SETLKW; do
94 if ! grep "^const ${flag} " ${OUT} >/dev/null 2>&1 \
95 && grep "^const ${flag}64 " ${OUT} >/dev/null 2>&1; then
96 echo "const ${flag} = ${flag}64" >> ${OUT}
98 done
100 # The Flock_t struct for fcntl.
101 grep '^type _flock ' gen-sysinfo.go | \
102 sed -e 's/type _flock/type Flock_t/' \
103 -e 's/l_type/Type/' \
104 -e 's/l_whence/Whence/' \
105 -e 's/l_start/Start/' \
106 -e 's/l_len/Len/' \
107 -e 's/l_pid/Pid/' \
108 >> ${OUT}
110 # The signal numbers.
111 grep '^const _SIG[^_]' gen-sysinfo.go | \
112 grep -v '^const _SIGEV_' | \
113 sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = Signal(_\2)/' >> ${OUT}
114 if ! grep '^const SIGPOLL ' ${OUT} >/dev/null 2>&1; then
115 if grep '^const SIGIO ' ${OUT} > /dev/null 2>&1; then
116 echo "const SIGPOLL = SIGIO" >> ${OUT}
119 if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then
120 if grep '^const SIGCHLD ' ${OUT} >/dev/null 2>&1; then
121 echo "const SIGCLD = SIGCHLD" >> ${OUT}
125 # The syscall numbers. We force the names to upper case.
126 grep '^const _SYS_' gen-sysinfo.go | \
127 sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
128 while read sys; do
129 sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
130 echo "const $sup = _$sys" >> ${OUT}
131 done
133 # The GNU/Linux support wants to use SYS_GETDENTS64 if available.
134 if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
135 echo "const SYS_GETDENTS = 0" >> ${OUT}
137 if ! grep '^const SYS_GETDENTS64 ' ${OUT} >/dev/null 2>&1; then
138 echo "const SYS_GETDENTS64 = 0" >> ${OUT}
141 # The syscall package wants the geteuid system call number. It isn't
142 # defined on Alpha, which only provides the getresuid system call.
143 if ! grep '^const SYS_GETEUID ' ${OUT} >/dev/null 2>&1; then
144 echo "const SYS_GETEUID = 0" >> ${OUT}
147 # Stat constants.
148 grep '^const _S_' gen-sysinfo.go | \
149 sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
151 # Mmap constants.
152 grep '^const _PROT_' gen-sysinfo.go | \
153 sed -e 's/^\(const \)_\(PROT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
154 grep '^const _MAP_' gen-sysinfo.go | \
155 sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
156 grep '^const _MADV_' gen-sysinfo.go | \
157 sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
158 grep '^const _MCL_' gen-sysinfo.go | \
159 sed -e 's/^\(const \)_\(MCL_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
161 # Process status constants.
162 grep '^const _W' gen-sysinfo.go |
163 sed -e 's/^\(const \)_\(W[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
164 # WSTOPPED was introduced in glibc 2.3.4.
165 if ! grep '^const _WSTOPPED = ' gen-sysinfo.go >/dev/null 2>&1; then
166 if grep '^const _WUNTRACED = ' gen-sysinfo.go > /dev/null 2>&1; then
167 echo 'const WSTOPPED = _WUNTRACED' >> ${OUT}
168 else
169 echo 'const WSTOPPED = 2' >> ${OUT}
172 if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
173 && ! grep '^const _WALL = ' gen-sysinfo.go >/dev/null 2>&1; then
174 echo 'const WALL = ___WALL' >> ${OUT}
176 # On GNU/Linux the os package requires WEXITED and WNOWAIT.
177 if test "${GOOS}" = "linux"; then
178 if ! grep '^const WEXITED = ' ${OUT} >/dev/null 2>&1; then
179 echo 'const WEXITED = 4' >> ${OUT}
181 if ! grep '^const WNOWAIT = ' ${OUT} >/dev/null 2>&1; then
182 echo 'const WNOWAIT = 0x01000000' >> ${OUT}
186 # Networking constants.
187 egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
188 sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
189 grep '^const _SOMAXCONN' gen-sysinfo.go |
190 sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
191 >> ${OUT}
192 grep '^const _SHUT_' gen-sysinfo.go |
193 sed -e 's/^\(const \)_\(SHUT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
195 # The net package requires some const definitions.
196 for m in IP_PKTINFO IPV6_V6ONLY IPPROTO_IPV6 IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_TCLASS SO_REUSEPORT; do
197 if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
198 echo "const $m = 0" >> ${OUT}
200 done
201 for m in SOCK_CLOEXEC SOCK_NONBLOCK; do
202 if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
203 echo "const $m = -1" >> ${OUT}
205 done
207 # The syscall package requires AF_LOCAL.
208 if ! grep '^const AF_LOCAL ' ${OUT} >/dev/null 2>&1; then
209 if grep '^const AF_UNIX ' ${OUT} >/dev/null 2>&1; then
210 echo "const AF_LOCAL = AF_UNIX" >> ${OUT}
214 # The syscall package requires _AT_FDCWD, but doesn't export it.
215 if ! grep '^const _AT_FDCWD = ' ${OUT} >/dev/null 2>&1; then
216 echo "const _AT_FDCWD = -100" >> ${OUT}
219 # sysconf constants.
220 grep '^const __SC' gen-sysinfo.go |
221 sed -e 's/^\(const \)__\(SC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
223 # pathconf constants.
224 grep '^const __PC' gen-sysinfo.go |
225 sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
227 # The PATH_MAX constant.
228 if grep '^const _PATH_MAX ' gen-sysinfo.go >/dev/null 2>&1; then
229 echo 'const PathMax = _PATH_MAX' >> ${OUT}
232 # epoll constants.
233 grep '^const _EPOLL' gen-sysinfo.go |
234 grep -v EPOLLET |
235 sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
236 # Make sure EPOLLET is positive.
237 if grep '^const _EPOLLET = [0-9]' gen-sysinfo.go >/dev/null 2>&1; then
238 grep '^const _EPOLLET ' gen-sysinfo.go |
239 sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
240 else
241 echo "const EPOLLET = 0x80000000" >> ${OUT}
243 # Make sure EPOLLRDHUP and EPOLL_CLOEXEC are defined.
244 if ! grep '^const EPOLLRDHUP' ${OUT} >/dev/null 2>&1; then
245 echo "const EPOLLRDHUP = 0x2000" >> ${OUT}
247 if ! grep '^const EPOLL_CLOEXEC' ${OUT} >/dev/null 2>&1; then
248 echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
251 # Prctl constants.
252 grep '^const _PR_' gen-sysinfo.go |
253 sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
255 # Ptrace constants.
256 grep '^const _PTRACE' gen-sysinfo.go |
257 sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
258 # We need some ptrace options that are not defined in older versions
259 # of glibc.
260 if ! grep '^const PTRACE_SETOPTIONS' ${OUT} > /dev/null 2>&1; then
261 echo "const PTRACE_SETOPTIONS = 0x4200" >> ${OUT}
263 if ! grep '^const PTRACE_O_TRACESYSGOOD' ${OUT} > /dev/null 2>&1; then
264 echo "const PTRACE_O_TRACESYSGOOD = 0x1" >> ${OUT}
266 if ! grep '^const PTRACE_O_TRACEFORK' ${OUT} > /dev/null 2>&1; then
267 echo "const PTRACE_O_TRACEFORK = 0x2" >> ${OUT}
269 if ! grep '^const PTRACE_O_TRACEVFORK' ${OUT} > /dev/null 2>&1; then
270 echo "const PTRACE_O_TRACEVFORK = 0x4" >> ${OUT}
272 if ! grep '^const PTRACE_O_TRACECLONE' ${OUT} > /dev/null 2>&1; then
273 echo "const PTRACE_O_TRACECLONE = 0x8" >> ${OUT}
275 if ! grep '^const PTRACE_O_TRACEEXEC' ${OUT} > /dev/null 2>&1; then
276 echo "const PTRACE_O_TRACEEXEC = 0x10" >> ${OUT}
278 if ! grep '^const PTRACE_O_TRACEVFORKDONE' ${OUT} > /dev/null 2>&1; then
279 echo "const PTRACE_O_TRACEVFORKDONE = 0x20" >> ${OUT}
281 if ! grep '^const PTRACE_O_TRACEEXIT' ${OUT} > /dev/null 2>&1; then
282 echo "const PTRACE_O_TRACEEXIT = 0x40" >> ${OUT}
284 if ! grep '^const PTRACE_O_MASK' ${OUT} > /dev/null 2>&1; then
285 echo "const PTRACE_O_MASK = 0x7f" >> ${OUT}
287 if ! grep '^const _PTRACE_GETEVENTMSG' ${OUT} > /dev/null 2>&1; then
288 echo "const PTRACE_GETEVENTMSG = 0x4201" >> ${OUT}
290 if ! grep '^const PTRACE_EVENT_FORK' ${OUT} > /dev/null 2>&1; then
291 echo "const PTRACE_EVENT_FORK = 1" >> ${OUT}
293 if ! grep '^const PTRACE_EVENT_VFORK' ${OUT} > /dev/null 2>&1; then
294 echo "const PTRACE_EVENT_VFORK = 2" >> ${OUT}
296 if ! grep '^const PTRACE_EVENT_CLONE' ${OUT} > /dev/null 2>&1; then
297 echo "const PTRACE_EVENT_CLONE = 3" >> ${OUT}
299 if ! grep '^const PTRACE_EVENT_EXEC' ${OUT} > /dev/null 2>&1; then
300 echo "const PTRACE_EVENT_EXEC = 4" >> ${OUT}
302 if ! grep '^const PTRACE_EVENT_VFORK_DONE' ${OUT} > /dev/null 2>&1; then
303 echo "const PTRACE_EVENT_VFORK_DONE = 5" >> ${OUT}
305 if ! grep '^const PTRACE_EVENT_EXIT' ${OUT} > /dev/null 2>&1; then
306 echo "const PTRACE_EVENT_EXIT = 6" >> ${OUT}
308 if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then
309 echo "const _PTRACE_TRACEME = 0" >> ${OUT}
312 # A helper function that prints a structure from gen-sysinfo.go with the first
313 # letter of the field names in upper case. $1 is the name of structure. If $2
314 # is not empty, the structure or type is renamed to $2.
315 upcase_fields () {
316 name="$1"
317 def=`grep "^type $name " gen-sysinfo.go`
318 fields=`echo $def | sed -e 's/^[^{]*{\(.*\)}$/\1/'`
319 prefix=`echo $def | sed -e 's/{.*//'`
320 if test "$2" != ""; then
321 prefix=`echo $prefix | sed -e "s/$1/$2/"`
323 if test "$fields" != ""; then
324 nfields=
325 while test -n "$fields"; do
326 field=`echo $fields | sed -e 's/^\([^;]*\);.*$/\1/'`
327 fields=`echo $fields | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
328 # capitalize the next character.
329 f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
330 r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
331 f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
332 field="$f$r"
333 nfields="$nfields $field;"
334 done
335 echo "${prefix} {$nfields }"
339 # The registers returned by PTRACE_GETREGS. This is probably
340 # GNU/Linux specific; it should do no harm if there is no
341 # _user_regs_struct.
342 regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
343 if test "$regs" = ""; then
344 # mips*
345 regs=`grep '^type _pt_regs struct' gen-sysinfo.go || true`
347 if test "$regs" != ""; then
348 regs=`echo $regs | sed -e 's/type _pt_regs struct//'`
349 regs=`echo $regs |
350 sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'`
351 regs=`echo $regs | sed -e s'/^ *//'`
352 nregs=
353 while test -n "$regs"; do
354 field=`echo $regs | sed -e 's/^\([^;]*\);.*$/\1/'`
355 regs=`echo $regs | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
356 # Capitalize the first character of the field.
357 f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
358 r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
359 f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
360 field="$f$r"
361 field=`echo "$field" | sed \
362 -e 's/__user_psw_struct/PtracePsw/' \
363 -e 's/__user_fpregs_struct/PtraceFpregs/' \
364 -e 's/__user_per_struct/PtracePer/'`
365 nregs="$nregs $field;"
366 done
367 echo "type PtraceRegs struct {$nregs }" >> ${OUT}
370 # Some basic types.
371 echo 'type Size_t _size_t' >> ${OUT}
372 echo "type Ssize_t _ssize_t" >> ${OUT}
373 if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
374 echo "type Offset_t _off64_t" >> ${OUT}
375 else
376 echo "type Offset_t _off_t" >> ${OUT}
378 echo "type Mode_t _mode_t" >> ${OUT}
379 echo "type Pid_t _pid_t" >> ${OUT}
380 echo "type Uid_t _uid_t" >> ${OUT}
381 echo "type Gid_t _gid_t" >> ${OUT}
382 echo "type Socklen_t _socklen_t" >> ${OUT}
384 # The C int type.
385 sizeof_int=`grep '^const ___SIZEOF_INT__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
386 if test "$sizeof_int" = "4"; then
387 echo "type _C_int int32" >> ${OUT}
388 echo "type _C_uint uint32" >> ${OUT}
389 elif test "$sizeof_int" = "8"; then
390 echo "type _C_int int64" >> ${OUT}
391 echo "type _C_uint uint64" >> ${OUT}
392 else
393 echo 1>&2 "mksysinfo.sh: could not determine size of int (got $sizeof_int)"
394 exit 1
397 # The C long type, needed because that is the type that ptrace returns.
398 sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
399 if test "$sizeof_long" = "4"; then
400 echo "type _C_long int32" >> ${OUT}
401 echo "type _C_ulong uint32" >> ${OUT}
402 elif test "$sizeof_long" = "8"; then
403 echo "type _C_long int64" >> ${OUT}
404 echo "type _C_ulong uint64" >> ${OUT}
405 else
406 echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
407 exit 1
410 # Solaris 2 needs _u?pad128_t, but its default definition in terms of long
411 # double is commented by -fdump-go-spec.
412 if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then
413 echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT}
415 if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then
416 echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT}
419 # The time_t type.
420 if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then
421 echo 'type Time_t _time_t' >> ${OUT}
424 # The time structures need special handling: we need to name the
425 # types, so that we can cast integers to the right types when
426 # assigning to the structures.
427 timeval=`grep '^type _timeval ' gen-sysinfo.go`
428 timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
429 timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'`
430 echo "type Timeval_sec_t $timeval_sec" >> ${OUT}
431 echo "type Timeval_usec_t $timeval_usec" >> ${OUT}
432 echo $timeval | \
433 sed -e 's/type _timeval /type Timeval /' \
434 -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \
435 -e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT}
436 timespec=`grep '^type _timespec ' gen-sysinfo.go || true`
437 if test "$timespec" = ""; then
438 # IRIX 6.5 has __timespec instead.
439 timespec=`grep '^type ___timespec ' gen-sysinfo.go || true`
441 timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
442 timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
443 echo "type Timespec_sec_t $timespec_sec" >> ${OUT}
444 echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT}
445 echo $timespec | \
446 sed -e 's/^type ___timespec /type Timespec /' \
447 -e 's/^type _timespec /type Timespec /' \
448 -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
449 -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
451 timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true`
452 if test "$timestruc" != ""; then
453 timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
454 timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
455 echo "type Timestruc_sec_t $timestruc_sec" >> ${OUT}
456 echo "type Timestruc_nsec_t $timestruc_nsec" >> ${OUT}
457 echo $timestruc | \
458 sed -e 's/^type _timestruc_t /type Timestruc /' \
459 -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timestruc_sec_t/' \
460 -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
463 # The tms struct.
464 grep '^type _tms ' gen-sysinfo.go | \
465 sed -e 's/type _tms/type Tms/' \
466 -e 's/tms_utime/Utime/' \
467 -e 's/tms_stime/Stime/' \
468 -e 's/tms_cutime/Cutime/' \
469 -e 's/tms_cstime/Cstime/' \
470 >> ${OUT}
472 # AIX uses st_timespec struct for stat.
473 grep '^type _st_timespec ' gen-sysinfo.go | \
474 sed -e 's/type _st_timespec /type StTimespec /' \
475 -e 's/tv_sec/Sec/' \
476 -e 's/tv_nsec/Nsec/' >> ${OUT}
478 # The stat type.
479 # Prefer largefile variant if available.
480 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
481 if test "$stat" != ""; then
482 grep '^type _stat64 ' gen-sysinfo.go
483 else
484 grep '^type _stat ' gen-sysinfo.go
485 fi | sed -e 's/type _stat64/type Stat_t/' \
486 -e 's/type _stat/type Stat_t/' \
487 -e 's/st_dev/Dev/' \
488 -e 's/st_ino/Ino/g' \
489 -e 's/st_nlink/Nlink/' \
490 -e 's/st_mode/Mode/' \
491 -e 's/st_uid/Uid/' \
492 -e 's/st_gid/Gid/' \
493 -e 's/st_rdev/Rdev/' \
494 -e 's/st_size/Size/' \
495 -e 's/st_blksize/Blksize/' \
496 -e 's/st_blocks/Blocks/' \
497 -e 's/st_atim/Atim/' \
498 -e 's/st_mtim/Mtim/' \
499 -e 's/st_ctim/Ctim/' \
500 -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
501 -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
502 -e 's/\([^a-zA-Z0-9_]\)_st_timespec_t\([^a-zA-Z0-9_]\)/\1StTimespec\2/g' \
503 -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
504 -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
505 -e 's/Godump_[0-9] struct { \([^;]*;\) };/\1/g' \
506 >> ${OUT}
508 # The directory searching types.
509 # Prefer largefile variant if available.
510 dirent=`grep '^type _dirent64 ' gen-sysinfo.go || true`
511 if test "$dirent" != ""; then
512 grep '^type _dirent64 ' gen-sysinfo.go
513 else
514 grep '^type _dirent ' gen-sysinfo.go
515 fi | sed -e 's/type _dirent64/type Dirent/' \
516 -e 's/type _dirent/type Dirent/' \
517 -e 's/d_name \[0+1\]/d_name [0+256]/' \
518 -e 's/d_name/Name/' \
519 -e 's/]int8/]byte/' \
520 -e 's/d_ino/Ino/' \
521 -e 's/d_namlen/Namlen/' \
522 -e 's/d_off/Off/' \
523 -e 's/d_reclen/Reclen/' \
524 -e 's/d_type/Type/' \
525 >> ${OUT}
526 echo "type DIR _DIR" >> ${OUT}
528 # Values for d_type field in dirent.
529 grep '^const _DT_' gen-sysinfo.go |
530 sed -e 's/^\(const \)_\(DT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
532 # The rusage struct.
533 rusage=`grep '^type _rusage struct' gen-sysinfo.go`
534 if test "$rusage" != ""; then
535 # Remove anonymous unions from GNU/Linux <bits/resource.h>.
536 rusage=`echo $rusage | sed -e 's/Godump_[0-9][0-9]* struct {\([^}]*\)};/\1/g'`
537 rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
538 rusage=`echo $rusage | sed -e 's/^ *//'`
539 nrusage=
540 while test -n "$rusage"; do
541 field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
542 rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
543 # Drop the leading ru_, capitalize the next character.
544 field=`echo $field | sed -e 's/^ru_//'`
545 f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
546 r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
547 f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
548 # Fix _timeval _timespec, and _timestruc_t.
549 r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
550 r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
551 r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
552 field="$f$r"
553 nrusage="$nrusage $field;"
554 done
555 echo "type Rusage struct {$nrusage }" >> ${OUT}
556 else
557 echo "type Rusage struct {}" >> ${OUT}
560 # The RUSAGE constants.
561 grep '^const _RUSAGE_' gen-sysinfo.go | \
562 sed -e 's/^\(const \)_\(RUSAGE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
564 # The utsname struct.
565 grep '^type _utsname ' gen-sysinfo.go | \
566 sed -e 's/_utsname/Utsname/' \
567 -e 's/sysname/Sysname/' \
568 -e 's/nodename/Nodename/' \
569 -e 's/release/Release/' \
570 -e 's/version/Version/' \
571 -e 's/machine/Machine/' \
572 -e 's/domainname/Domainname/' \
573 >> ${OUT}
575 # The iovec struct.
576 iovec=`grep '^type _iovec ' gen-sysinfo.go`
577 iovec_len=`echo $iovec | sed -n -e 's/^.*iov_len \([^ ]*\);.*$/\1/p'`
578 echo "type Iovec_len_t $iovec_len" >> ${OUT}
579 echo $iovec | \
580 sed -e 's/_iovec/Iovec/' \
581 -e 's/iov_base/Base/' \
582 -e 's/iov_len *[a-zA-Z0-9_]*/Len Iovec_len_t/' \
583 >> ${OUT}
585 # The msghdr struct.
586 msghdr=`grep '^type _msghdr ' gen-sysinfo.go`
587 msghdr_controllen=`echo $msghdr | sed -n -e 's/^.*msg_controllen \([^ ]*\);.*$/\1/p'`
588 echo "type Msghdr_controllen_t $msghdr_controllen" >> ${OUT}
589 echo $msghdr | \
590 sed -e 's/_msghdr/Msghdr/' \
591 -e 's/msg_name/Name/' \
592 -e 's/msg_namelen/Namelen/' \
593 -e 's/msg_iov/Iov/' \
594 -e 's/msg_iovlen/Iovlen/' \
595 -e 's/_iovec/Iovec/' \
596 -e 's/msg_control/Control/' \
597 -e 's/msg_controllen *[a-zA-Z0-9_]*/Controllen Msghdr_controllen_t/' \
598 -e 's/msg_flags/Flags/' \
599 >> ${OUT}
601 # The MSG_ flags for Msghdr.
602 grep '^const _MSG_' gen-sysinfo.go | \
603 sed -e 's/^\(const \)_\(MSG_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
605 # The cmsghdr struct.
606 cmsghdr=`grep '^type _cmsghdr ' gen-sysinfo.go`
607 if test -n "$cmsghdr"; then
608 cmsghdr_len=`echo $cmsghdr | sed -n -e 's/^.*cmsg_len \([^ ]*\);.*$/\1/p'`
609 echo "type Cmsghdr_len_t $cmsghdr_len" >> ${OUT}
610 echo "$cmsghdr" | \
611 sed -e 's/_cmsghdr/Cmsghdr/' \
612 -e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
613 -e 's/cmsg_level/Level/' \
614 -e 's/cmsg_type/Type/' \
615 -e 's/\[\]/[0]/' \
616 >> ${OUT}
619 # The SCM_ flags for Cmsghdr.
620 grep '^const _SCM_' gen-sysinfo.go | \
621 sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
623 # The ucred struct.
624 upcase_fields "_ucred" "Ucred" >> ${OUT} || true
626 # The ip_mreq struct.
627 grep '^type _ip_mreq ' gen-sysinfo.go | \
628 sed -e 's/_ip_mreq/IPMreq/' \
629 -e 's/imr_multiaddr/Multiaddr/' \
630 -e 's/imr_interface/Interface/' \
631 -e 's/_in_addr/[4]byte/g' \
632 >> ${OUT}
634 # We need IPMreq to compile the net package.
635 if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then
636 echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT}
639 # The ipv6_mreq struct.
640 grep '^type _ipv6_mreq ' gen-sysinfo.go | \
641 sed -e 's/_ipv6_mreq/IPv6Mreq/' \
642 -e 's/ipv6mr_multiaddr/Multiaddr/' \
643 -e 's/ipv6mr_interface/Interface/' \
644 -e 's/_in6_addr/[16]byte/' \
645 >> ${OUT}
647 # We need IPv6Mreq to compile the net package.
648 if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then
649 echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
652 # The ip_mreqn struct.
653 grep '^type _ip_mreqn ' gen-sysinfo.go | \
654 sed -e 's/_ip_mreqn/IPMreqn/' \
655 -e 's/imr_multiaddr/Multiaddr/' \
656 -e 's/imr_address/Address/' \
657 -e 's/imr_ifindex/Ifindex/' \
658 -e 's/_in_addr/[4]byte/g' \
659 >> ${OUT}
661 # We need IPMreq to compile the net package.
662 if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then
663 echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT}
666 # The icmp6_filter struct.
667 grep '^type _icmp6_filter ' gen-sysinfo.go | \
668 sed -e 's/_icmp6_filter/ICMPv6Filter/' \
669 -e 's/data/Data/' \
670 -e 's/filt/Filt/' \
671 >> ${OUT}
673 # We need ICMPv6Filter to compile the syscall package.
674 if ! grep 'type ICMPv6Filter ' ${OUT} > /dev/null 2>&1; then
675 echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT}
678 # The ip6_mtuinfo struct.
679 grep '^type _ip6_mtuinfo ' gen-sysinfo.go | \
680 sed -e 's/_ip6_mtuinfo/IPv6MTUInfo/' \
681 -e 's/ip6m_addr/Addr/' \
682 -e 's/_sockaddr_in6/RawSockaddrInet6/' \
683 -e 's/ip6m_mtu/Mtu/' \
684 >> ${OUT}
686 # We need IPv6MTUInfo to compile the syscall package.
687 if ! grep 'type IPv6MTUInfo ' ${OUT} >/dev/null 2>&1; then
688 echo 'type IPv6MTUInfo struct { Addr RawSockaddrInet6; Mtu uint32; }' >> ${OUT}
690 if ! grep 'const _sizeof_ip6_mtuinfo = ' ${OUT} >/dev/null 2>&1; then
691 echo 'const SizeofIPv6MTUInfo = 32' >> ${OUT}
694 # Try to guess the type to use for fd_set.
695 fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
696 fds_bits_type="_C_long"
697 if test "$fd_set" != ""; then
698 fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'`
700 echo "type fds_bits_type $fds_bits_type" >> ${OUT}
702 # The addrinfo struct.
703 grep '^type _addrinfo ' gen-sysinfo.go | \
704 sed -e 's/_addrinfo/Addrinfo/g' \
705 -e 's/ ai_/ Ai_/g' \
706 >> ${OUT}
708 # The addrinfo and nameinfo flags and errors.
709 grep '^const _AI_' gen-sysinfo.go | \
710 sed -e 's/^\(const \)_\(AI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
711 grep '^const _EAI_' gen-sysinfo.go | \
712 sed -e 's/^\(const \)_\(EAI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
713 grep '^const _NI_' gen-sysinfo.go | \
714 sed -e 's/^\(const \)_\(NI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
716 # If nothing else defined EAI_OVERFLOW, make sure it has a value.
717 if ! grep "const EAI_OVERFLOW " ${OUT} >/dev/null 2>&1; then
718 echo "const EAI_OVERFLOW = 0" >> ${OUT}
721 # The passwd struct.
722 # Force uid and gid from int32 to uint32 for consistency; they are
723 # int32 on Solaris 10 but uint32 everywhere else including Solaris 11.
724 grep '^type _passwd ' gen-sysinfo.go | \
725 sed -e 's/_passwd/Passwd/' \
726 -e 's/ pw_/ Pw_/g' \
727 -e 's/ Pw_uid int32/ Pw_uid uint32/' \
728 -e 's/ Pw_gid int32/ Pw_gid uint32/' \
729 >> ${OUT}
731 # The group struct.
732 grep '^type _group ' gen-sysinfo.go | \
733 sed -e 's/_group/Group/' \
734 -e 's/ gr_/ Gr_/g' \
735 >> ${OUT}
737 # The ioctl flags for the controlling TTY.
738 grep '^const _TIOC' gen-sysinfo.go | \
739 grep -v '_val =' | \
740 sed -e 's/^\(const \)_\(TIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
741 grep '^const _TUNSET' gen-sysinfo.go | \
742 grep -v '_val =' | \
743 sed -e 's/^\(const \)_\(TUNSET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
744 # We need TIOCGWINSZ.
745 if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then
746 if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then
747 echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT}
750 if ! grep '^const TIOCSWINSZ' ${OUT} >/dev/null 2>&1; then
751 if grep '^const _TIOCSWINSZ_val' ${OUT} >/dev/null 2>&1; then
752 echo 'const TIOCSWINSZ = _TIOCSWINSZ_val' >> ${OUT}
755 if ! grep '^const TIOCNOTTY' ${OUT} >/dev/null 2>&1; then
756 if grep '^const _TIOCNOTTY_val' ${OUT} >/dev/null 2>&1; then
757 echo 'const TIOCNOTTY = _TIOCNOTTY_val' >> ${OUT}
760 if ! grep '^const TIOCSCTTY' ${OUT} >/dev/null 2>&1; then
761 if grep '^const _TIOCSCTTY_val' ${OUT} >/dev/null 2>&1; then
762 echo 'const TIOCSCTTY = _TIOCSCTTY_val' >> ${OUT}
765 if ! grep '^const TIOCGPGRP' ${OUT} >/dev/null 2>&1; then
766 if grep '^const _TIOCGPGRP_val' ${OUT} >/dev/null 2>&1; then
767 echo 'const TIOCGPGRP = _TIOCGPGRP_val' >> ${OUT}
770 if ! grep '^const TIOCSPGRP' ${OUT} >/dev/null 2>&1; then
771 if grep '^const _TIOCSPGRP_val' ${OUT} >/dev/null 2>&1; then
772 echo 'const TIOCSPGRP = _TIOCSPGRP_val' >> ${OUT}
775 if ! grep '^const TIOCGPTN' ${OUT} >/dev/null 2>&1; then
776 if grep '^const _TIOCGPTN_val' ${OUT} >/dev/null 2>&1; then
777 echo 'const TIOCGPTN = _TIOCGPTN_val' >> ${OUT}
780 if ! grep '^const TIOCSPTLCK' ${OUT} >/dev/null 2>&1; then
781 if grep '^const _TIOCSPTLCK_val' ${OUT} >/dev/null 2>&1; then
782 echo 'const TIOCSPTLCK = _TIOCSPTLCK_val' >> ${OUT}
785 if ! grep '^const TIOCGDEV' ${OUT} >/dev/null 2>&1; then
786 if grep '^const _TIOCGDEV_val' ${OUT} >/dev/null 2>&1; then
787 echo 'const TIOCGDEV = _TIOCGDEV_val' >> ${OUT}
790 if ! grep '^const TIOCSIG' ${OUT} >/dev/null 2>&1; then
791 if grep '^const _TIOCSIG_val' ${OUT} >/dev/null 2>&1; then
792 echo 'const TIOCSIG = _TIOCSIG_val' >> ${OUT}
796 if ! grep '^const TUNSETNOCSUM' ${OUT} >/dev/null 2>&1; then
797 if grep '^const _TUNSETNOCSUM_val' ${OUT} >/dev/null 2>&1; then
798 echo 'const TUNSETNOCSUM = _TUNSETNOCSUM_val' >> ${OUT}
802 if ! grep '^const TUNSETDEBUG' ${OUT} >/dev/null 2>&1; then
803 if grep '^const _TUNSETDEBUG_val' ${OUT} >/dev/null 2>&1; then
804 echo 'const TUNSETDEBUG = _TUNSETDEBUG_val' >> ${OUT}
808 if ! grep '^const TUNSETIFF' ${OUT} >/dev/null 2>&1; then
809 if grep '^const _TUNSETIFF_val' ${OUT} >/dev/null 2>&1; then
810 echo 'const TUNSETIFF = _TUNSETIFF_val' >> ${OUT}
814 if ! grep '^const TUNSETPERSIST' ${OUT} >/dev/null 2>&1; then
815 if grep '^const _TUNSETPERSIST_val' ${OUT} >/dev/null 2>&1; then
816 echo 'const TUNSETPERSIST = _TUNSETPERSIST_val' >> ${OUT}
820 if ! grep '^const TUNSETOWNER' ${OUT} >/dev/null 2>&1; then
821 if grep '^const _TUNSETOWNER_val' ${OUT} >/dev/null 2>&1; then
822 echo 'const TUNSETOWNER = _TUNSETOWNER_val' >> ${OUT}
826 if ! grep '^const TUNSETLINK' ${OUT} >/dev/null 2>&1; then
827 if grep '^const _TUNSETLINK_val' ${OUT} >/dev/null 2>&1; then
828 echo 'const TUNSETLINK = _TUNSETLINK_val' >> ${OUT}
832 if ! grep '^const TUNSETGROUP' ${OUT} >/dev/null 2>&1; then
833 if grep '^const _TUNSETGROUP_val' ${OUT} >/dev/null 2>&1; then
834 echo 'const TUNSETGROUP = _TUNSETGROUP_val' >> ${OUT}
838 if ! grep '^const TUNGETFEATURES' ${OUT} >/dev/null 2>&1; then
839 if grep '^const _TUNGETFEATURES_val' ${OUT} >/dev/null 2>&1; then
840 echo 'const TUNGETFEATURES = _TUNGETFEATURES_val' >> ${OUT}
844 if ! grep '^const TUNSETOFFLOAD' ${OUT} >/dev/null 2>&1; then
845 if grep '^const _TUNSETOFFLOAD_val' ${OUT} >/dev/null 2>&1; then
846 echo 'const TUNSETOFFLOAD = _TUNSETOFFLOAD_val' >> ${OUT}
850 if ! grep '^const TUNSETTXFILTER' ${OUT} >/dev/null 2>&1; then
851 if grep '^const _TUNSETTXFILTER_val' ${OUT} >/dev/null 2>&1; then
852 echo 'const TUNSETTXFILTER = _TUNSETTXFILTER_val' >> ${OUT}
856 if ! grep '^const TUNGETIFF' ${OUT} >/dev/null 2>&1; then
857 if grep '^const _TUNGETIFF_val' ${OUT} >/dev/null 2>&1; then
858 echo 'const TUNGETIFF = _TUNGETIFF_val' >> ${OUT}
862 if ! grep '^const TUNGETSNDBUF' ${OUT} >/dev/null 2>&1; then
863 if grep '^const _TUNGETSNDBUF_val' ${OUT} >/dev/null 2>&1; then
864 echo 'const TUNGETSNDBUF = _TUNGETSNDBUF_val' >> ${OUT}
868 if ! grep '^const TUNSETSNDBUF' ${OUT} >/dev/null 2>&1; then
869 if grep '^const _TUNSETSNDBUF_val' ${OUT} >/dev/null 2>&1; then
870 echo 'const TUNSETSNDBUF = _TUNSETSNDBUF_val' >> ${OUT}
874 if ! grep '^const TUNATTACHFILTER' ${OUT} >/dev/null 2>&1; then
875 if grep '^const _TUNATTACHFILTER_val' ${OUT} >/dev/null 2>&1; then
876 echo 'const TUNATTACHFILTER = _TUNATTACHFILTER_val' >> ${OUT}
880 if ! grep '^const TUNDETACHFILTER' ${OUT} >/dev/null 2>&1; then
881 if grep '^const _TUNDETACHFILTER_val' ${OUT} >/dev/null 2>&1; then
882 echo 'const TUNDETACHFILTER = _TUNDETACHFILTER_val' >> ${OUT}
886 if ! grep '^const TUNGETVNETHDRSZ' ${OUT} >/dev/null 2>&1; then
887 if grep '^const _TUNGETVNETHDRSZ_val' ${OUT} >/dev/null 2>&1; then
888 echo 'const TUNGETVNETHDRSZ = _TUNGETVNETHDRSZ_val' >> ${OUT}
892 if ! grep '^const TUNSETVNETHDRSZ' ${OUT} >/dev/null 2>&1; then
893 if grep '^const _TUNSETVNETHDRSZ_val' ${OUT} >/dev/null 2>&1; then
894 echo 'const TUNSETVNETHDRSZ = _TUNSETVNETHDRSZ_val' >> ${OUT}
898 if ! grep '^const TUNSETQUEUE' ${OUT} >/dev/null 2>&1; then
899 if grep '^const _TUNSETQUEUE_val' ${OUT} >/dev/null 2>&1; then
900 echo 'const TUNSETQUEUE = _TUNSETQUEUE_val' >> ${OUT}
905 if ! grep '^const TUNSETIFINDEX' ${OUT} >/dev/null 2>&1; then
906 if grep '^const _TUNSETIFINDEX_val' ${OUT} >/dev/null 2>&1; then
907 echo 'const TUNSETIFINDEX = _TUNSETIFINDEX_val' >> ${OUT}
911 if ! grep '^const TUNGETFILTER' ${OUT} >/dev/null 2>&1; then
912 if grep '^const _TUNGETFILTER_val' ${OUT} >/dev/null 2>&1; then
913 echo 'const TUNGETFILTER = _TUNGETFILTER_val' >> ${OUT}
917 # The ioctl flags for terminal control
918 grep '^const _TC[GS]ET' gen-sysinfo.go | grep -v _val | \
919 sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
920 if ! grep '^const TCGETS' ${OUT} >/dev/null 2>&1; then
921 if grep '^const _TCGETS_val' ${OUT} >/dev/null 2>&1; then
922 echo 'const TCGETS = _TCGETS_val' >> ${OUT}
925 if ! grep '^const TCSETS' ${OUT} >/dev/null 2>&1; then
926 if grep '^const _TCSETS_val' ${OUT} >/dev/null 2>&1; then
927 echo 'const TCSETS = _TCSETS_val' >> ${OUT}
931 # ioctl constants. Might fall back to 0 if TIOCNXCL is missing, too, but
932 # needs handling in syscalls.exec.go.
933 if ! grep '^const _TIOCSCTTY ' gen-sysinfo.go >/dev/null 2>&1; then
934 if grep '^const _TIOCNXCL ' gen-sysinfo.go >/dev/null 2>&1; then
935 echo "const TIOCSCTTY = TIOCNXCL" >> ${OUT}
939 # If nothing else defined TIOCSCTTY, make sure it has a value.
940 if ! grep "const TIOCSCTTY " ${OUT} >/dev/null 2>&1; then
941 echo "const TIOCSCTTY = 0" >> ${OUT}
944 # The nlmsghdr struct.
945 grep '^type _nlmsghdr ' gen-sysinfo.go | \
946 sed -e 's/_nlmsghdr/NlMsghdr/' \
947 -e 's/nlmsg_len/Len/' \
948 -e 's/nlmsg_type/Type/' \
949 -e 's/nlmsg_flags/Flags/' \
950 -e 's/nlmsg_seq/Seq/' \
951 -e 's/nlmsg_pid/Pid/' \
952 >> ${OUT}
954 # The nlmsg flags and operators.
955 grep '^const _NLM' gen-sysinfo.go | \
956 sed -e 's/^\(const \)_\(NLM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
958 # NLMSG_HDRLEN is defined as an expression using sizeof.
959 if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then
960 if grep '^const _sizeof_nlmsghdr ' ${OUT} > /dev/null 2>&1; then
961 echo 'const NLMSG_HDRLEN = (_sizeof_nlmsghdr + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1)' >> ${OUT}
965 # The rtmsg struct.
966 grep '^type _rtmsg ' gen-sysinfo.go | \
967 sed -e 's/_rtmsg/RtMsg/' \
968 -e 's/rtm_family/Family/' \
969 -e 's/rtm_dst_len/Dst_len/' \
970 -e 's/rtm_src_len/Src_len/' \
971 -e 's/rtm_tos/Tos/' \
972 -e 's/rtm_table/Table/' \
973 -e 's/rtm_protocol/Protocol/' \
974 -e 's/rtm_scope/Scope/' \
975 -e 's/rtm_type/Type/' \
976 -e 's/rtm_flags/Flags/' \
977 >> ${OUT}
979 # The rtgenmsg struct.
980 grep '^type _rtgenmsg ' gen-sysinfo.go | \
981 sed -e 's/_rtgenmsg/RtGenmsg/' \
982 -e 's/rtgen_family/Family/' \
983 >> ${OUT}
985 # The routing message flags.
986 grep '^const _RT_' gen-sysinfo.go | \
987 sed -e 's/^\(const \)_\(RT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
988 grep '^const _RTA' gen-sysinfo.go | \
989 sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
990 grep '^const _RTF' gen-sysinfo.go | \
991 sed -e 's/^\(const \)_\(RTF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
992 grep '^const _RTCF' gen-sysinfo.go | \
993 sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
994 grep '^const _RTM' gen-sysinfo.go | \
995 sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
996 grep '^const _RTN' gen-sysinfo.go | \
997 sed -e 's/^\(const \)_\(RTN[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
998 grep '^const _RTPROT' gen-sysinfo.go | \
999 sed -e 's/^\(const \)_\(RTPROT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1001 # The ifinfomsg struct.
1002 grep '^type _ifinfomsg ' gen-sysinfo.go | \
1003 sed -e 's/_ifinfomsg/IfInfomsg/' \
1004 -e 's/ifi_family/Family/' \
1005 -e 's/ifi_type/Type/' \
1006 -e 's/ifi_index/Index/' \
1007 -e 's/ifi_flags/Flags/' \
1008 -e 's/ifi_change/Change/' \
1009 >> ${OUT}
1011 # The interface information types and flags.
1012 grep '^const _IFA' gen-sysinfo.go | \
1013 sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1014 grep '^const _IFLA' gen-sysinfo.go | \
1015 sed -e 's/^\(const \)_\(IFLA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1016 grep '^const _IFF' gen-sysinfo.go | \
1017 sed -e 's/^\(const \)_\(IFF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1018 grep '^const _IFNAMSIZ' gen-sysinfo.go | \
1019 sed -e 's/^\(const \)_\(IFNAMSIZ[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1020 grep '^const _SIOC' gen-sysinfo.go |
1021 sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1023 # The ifaddrmsg struct.
1024 grep '^type _ifaddrmsg ' gen-sysinfo.go | \
1025 sed -e 's/_ifaddrmsg/IfAddrmsg/' \
1026 -e 's/ifa_family/Family/' \
1027 -e 's/ifa_prefixlen/Prefixlen/' \
1028 -e 's/ifa_flags/Flags/' \
1029 -e 's/ifa_scope/Scope/' \
1030 -e 's/ifa_index/Index/' \
1031 >> ${OUT}
1033 # The rtattr struct.
1034 grep '^type _rtattr ' gen-sysinfo.go | \
1035 sed -e 's/_rtattr/RtAttr/' \
1036 -e 's/rta_len/Len/' \
1037 -e 's/rta_type/Type/' \
1038 >> ${OUT}
1040 # The in_pktinfo struct.
1041 grep '^type _in_pktinfo ' gen-sysinfo.go | \
1042 sed -e 's/_in_pktinfo/Inet4Pktinfo/' \
1043 -e 's/ipi_ifindex/Ifindex/' \
1044 -e 's/ipi_spec_dst/Spec_dst/' \
1045 -e 's/ipi_addr/Addr/' \
1046 -e 's/_in_addr/[4]byte/g' \
1047 >> ${OUT}
1049 # The in6_pktinfo struct.
1050 grep '^type _in6_pktinfo ' gen-sysinfo.go | \
1051 sed -e 's/_in6_pktinfo/Inet6Pktinfo/' \
1052 -e 's/ipi6_addr/Addr/' \
1053 -e 's/ipi6_ifindex/Ifindex/' \
1054 -e 's/_in6_addr/[16]byte/' \
1055 >> ${OUT}
1057 # The termios struct.
1058 grep '^type _termios ' gen-sysinfo.go | \
1059 sed -e 's/_termios/Termios/' \
1060 -e 's/c_iflag/Iflag/' \
1061 -e 's/c_oflag/Oflag/' \
1062 -e 's/c_cflag/Cflag/' \
1063 -e 's/c_lflag/Lflag/' \
1064 -e 's/c_line/Line/' \
1065 -e 's/c_cc/Cc/' \
1066 -e 's/c_ispeed/Ispeed/' \
1067 -e 's/c_ospeed/Ospeed/' \
1068 >> ${OUT}
1070 # The termios constants.
1071 for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
1072 IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
1073 OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 CS5 CS6 CS7 CS8 TABDLY \
1074 BSDLY VTDLY FFDLY CBAUD CBAUDEX CSIZE CSTOPB CREAD PARENB PARODD HUPCL \
1075 CLOCAL LOBLK CIBAUD CMSPAR CRTSCTS ISIG ICANON XCASE ECHO ECHOE ECHOK \
1076 ECHONL ECHOCTL ECHOPRT ECHOKE DEFECHO FLUSHO NOFLSH TOSTOP PENDIN IEXTEN \
1077 VINTR VQUIT VERASE VKILL VEOF VMIN VEOL VTIME VEOL2 VSWTCH VSTART VSTOP \
1078 VSUSP VDSUSP VLNEXT VWERASE VREPRINT VDISCARD VSTATUS TCSANOW TCSADRAIN \
1079 TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \
1080 B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \
1081 B38400 B57600 B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \
1082 B1152000 B1500000 B2000000 B2500000 B3000000 B3500000 B4000000; do
1084 grep "^const _$n " gen-sysinfo.go | \
1085 sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1086 done
1088 # The mount flags
1089 grep '^const _MNT_' gen-sysinfo.go |
1090 sed -e 's/^\(const \)_\(MNT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1091 grep '^const _MS_' gen-sysinfo.go |
1092 sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1094 # The fallocate flags.
1095 grep '^const _FALLOC_' gen-sysinfo.go |
1096 sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1098 # The statfs struct.
1099 # Prefer largefile variant if available.
1100 statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
1101 if test "$statfs" != ""; then
1102 grep '^type _statfs64 ' gen-sysinfo.go
1103 else
1104 grep '^type _statfs ' gen-sysinfo.go
1105 fi | sed -e 's/type _statfs64/type Statfs_t/' \
1106 -e 's/type _statfs/type Statfs_t/' \
1107 -e 's/f_type/Type/' \
1108 -e 's/f_bsize/Bsize/' \
1109 -e 's/f_blocks/Blocks/' \
1110 -e 's/f_bfree/Bfree/' \
1111 -e 's/f_bavail/Bavail/' \
1112 -e 's/f_files/Files/' \
1113 -e 's/f_ffree/Ffree/' \
1114 -e 's/f_fsid/Fsid/' \
1115 -e 's/f_namelen/Namelen/' \
1116 -e 's/f_frsize/Frsize/' \
1117 -e 's/f_flags/Flags/' \
1118 -e 's/f_spare/Spare/' \
1119 >> ${OUT}
1121 # The timex struct.
1122 timex=`grep '^type _timex ' gen-sysinfo.go || true`
1123 if test "$timex" = ""; then
1124 timex=`grep '^// type _timex ' gen-sysinfo.go || true`
1125 if test "$timex" != ""; then
1126 timex=`echo $timex | sed -e 's|// ||' -e 's/INVALID-bit-field/int32/g'`
1129 if test "$timex" != ""; then
1130 echo "$timex" | \
1131 sed -e 's/_timex/Timex/' \
1132 -e 's/modes/Modes/' \
1133 -e 's/offset/Offset/' \
1134 -e 's/freq/Freq/' \
1135 -e 's/maxerror/Maxerror/' \
1136 -e 's/esterror/Esterror/' \
1137 -e 's/status/Status/' \
1138 -e 's/constant/Constant/' \
1139 -e 's/precision/Precision/' \
1140 -e 's/tolerance/Tolerance/' \
1141 -e 's/ time / Time /' \
1142 -e 's/tick/Tick/' \
1143 -e 's/ppsfreq/Ppsfreq/' \
1144 -e 's/jitter/Jitter/' \
1145 -e 's/shift/Shift/' \
1146 -e 's/stabil/Stabil/' \
1147 -e 's/jitcnt/Jitcnt/' \
1148 -e 's/calcnt/Calcnt/' \
1149 -e 's/errcnt/Errcnt/' \
1150 -e 's/stbcnt/Stbcnt/' \
1151 -e 's/tai/Tai/' \
1152 -e 's/_timeval/Timeval/' \
1153 >> ${OUT}
1156 # The rlimit struct.
1157 # On systems that use syscall/libcall_posix_largefile.go, use rlimit64
1158 # if it exists.
1159 rlimit="_rlimit"
1160 if test "${GOOS}" = "aix" || test "${GOOS}" = "linux" || (test "${GOOS}" = "solaris" && (test "${GOARCH}" = "386" || test "${GOARCH}" = "sparc")); then
1161 if grep '^type _rlimit64 ' gen-sysinfo.go > /dev/null 2>&1; then
1162 rlimit="_rlimit64"
1165 grep "^type ${rlimit} " gen-sysinfo.go | \
1166 sed -e "s/${rlimit}/Rlimit/" \
1167 -e 's/rlim_cur/Cur/' \
1168 -e 's/rlim_max/Max/' \
1169 >> ${OUT}
1171 # The RLIMIT constants.
1172 grep '^const _RLIMIT_' gen-sysinfo.go |
1173 sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1174 grep '^const _RLIM_' gen-sysinfo.go |
1175 grep -v '^const _RLIM_INFINITY ' |
1176 sed -e 's/^\(const \)_\(RLIM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1177 rliminf=""
1178 if test "${rlimit}" = "_rlimit64" && grep '^const _RLIM64_INFINITY ' gen-sysinfo.go > /dev/null 2>&1; then
1179 rliminf=`grep '^const _RLIM64_INFINITY ' gen-sysinfo.go | sed -e 's/.* //'`
1180 else
1181 rliminf=`grep '^const _RLIM_INFINITY ' gen-sysinfo.go | sed -e 's/.* //'`
1183 # For compatibility with the gc syscall package, treat 0xffffffffffffffff as -1.
1184 if test "$rliminf" = "0xffffffffffffffff"; then
1185 echo "const RLIM_INFINITY = -1" >> ${OUT}
1186 elif test -n "$rliminf"; then
1187 echo "const RLIM_INFINITY = $rliminf" >> ${OUT}
1190 # The sysinfo struct.
1191 grep '^type _sysinfo ' gen-sysinfo.go | \
1192 sed -e 's/_sysinfo/Sysinfo_t/' \
1193 -e 's/uptime/Uptime/' \
1194 -e 's/loads/Loads/' \
1195 -e 's/totalram/Totalram/' \
1196 -e 's/freeram/Freeram/' \
1197 -e 's/sharedram/Sharedram/' \
1198 -e 's/bufferram/Bufferram/' \
1199 -e 's/totalswap/Totalswap/' \
1200 -e 's/freeswap/Freeswap/' \
1201 -e 's/procs/Procs/' \
1202 -e 's/totalhigh/Totalhigh/' \
1203 -e 's/freehigh/Freehigh/' \
1204 -e 's/mem_unit/Unit/' \
1205 >> ${OUT}
1207 # The utimbuf struct.
1208 grep '^type _utimbuf ' gen-sysinfo.go | \
1209 sed -e 's/_utimbuf/Utimbuf/' \
1210 -e 's/actime/Actime/' \
1211 -e 's/modtime/Modtime/' \
1212 >> ${OUT}
1214 # The LOCK flags for flock.
1215 grep '^const _LOCK_' gen-sysinfo.go |
1216 sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1218 # The PRIO constants.
1219 grep '^const _PRIO_' gen-sysinfo.go | \
1220 sed -e 's/^\(const \)_\(PRIO_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1222 # The GNU/Linux LINUX_REBOOT flags.
1223 grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
1224 sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1226 # The GNU/Linux sock_filter struct.
1227 grep '^type _sock_filter ' gen-sysinfo.go | \
1228 sed -e 's/_sock_filter/SockFilter/' \
1229 -e 's/code/Code/' \
1230 -e 's/jt/Jt/' \
1231 -e 's/jf/Jf/' \
1232 -e 's/k /K /' \
1233 >> ${OUT}
1235 # The GNU/Linux sock_fprog struct.
1236 grep '^type _sock_fprog ' gen-sysinfo.go | \
1237 sed -e 's/_sock_fprog/SockFprog/' \
1238 -e 's/len/Len/' \
1239 -e 's/filter/Filter/' \
1240 -e 's/_sock_filter/SockFilter/' \
1241 >> ${OUT}
1243 # The GNU/Linux filter flags.
1244 grep '^const _BPF_' gen-sysinfo.go | \
1245 sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1247 # The GNU/Linux nlattr struct.
1248 grep '^type _nlattr ' gen-sysinfo.go | \
1249 sed -e 's/_nlattr/NlAttr/' \
1250 -e 's/nla_len/Len/' \
1251 -e 's/nla_type/Type/' \
1252 >> ${OUT}
1254 # The GNU/Linux nlmsgerr struct.
1255 grep '^type _nlmsgerr ' gen-sysinfo.go | \
1256 sed -e 's/_nlmsgerr/NlMsgerr/' \
1257 -e 's/error/Error/' \
1258 -e 's/msg/Msg/' \
1259 -e 's/_nlmsghdr/NlMsghdr/' \
1260 >> ${OUT}
1262 # The GNU/Linux rtnexthop struct.
1263 grep '^type _rtnexthop ' gen-sysinfo.go | \
1264 sed -e 's/_rtnexthop/RtNexthop/' \
1265 -e 's/rtnh_len/Len/' \
1266 -e 's/rtnh_flags/Flags/' \
1267 -e 's/rtnh_hops/Hops/' \
1268 -e 's/rtnh_ifindex/Ifindex/' \
1269 >> ${OUT}
1271 # The GNU/Linux netlink flags.
1272 grep '^const _NETLINK_' gen-sysinfo.go | \
1273 sed -e 's/^\(const \)_\(NETLINK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1274 grep '^const _NLA_' gen-sysinfo.go | grep -v '_val =' | \
1275 sed -e 's/^\(const \)_\(NLA_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1277 if ! grep '^const NLA_HDRLEN' ${OUT} >/dev/null 2>&1; then
1278 if grep '^const _NLA_HDRLEN_val' ${OUT} >/dev/null 2>&1; then
1279 echo 'const NLA_HDRLEN = _NLA_HDRLEN_val' >> ${OUT}
1283 # The GNU/Linux packet socket flags.
1284 grep '^const _PACKET_' gen-sysinfo.go | \
1285 sed -e 's/^\(const \)_\(PACKET_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1287 # The GNU/Linux inotify_event struct.
1288 grep '^type _inotify_event ' gen-sysinfo.go | \
1289 sed -e 's/_inotify_event/InotifyEvent/' \
1290 -e 's/wd/Wd/' \
1291 -e 's/mask/Mask/' \
1292 -e 's/cookie/Cookie/' \
1293 -e 's/len/Len/' \
1294 -e 's/name/Name/' \
1295 -e 's/\[\]/[0]/' \
1296 -e 's/\[0\]byte/[0]int8/' \
1297 >> ${OUT}
1299 # The GNU/Linux CLONE flags.
1300 grep '^const _CLONE_' gen-sysinfo.go | \
1301 sed -e 's/^\(const \)_\(CLONE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
1302 # We need some CLONE constants that are not defined in older versions
1303 # of glibc.
1304 if ! grep '^const CLONE_NEWUSER ' ${OUT} > /dev/null 2>&1; then
1305 echo "const CLONE_NEWUSER = 0x10000000" >> ${OUT}
1307 if ! grep '^const CLONE_NEWNET ' ${OUT} > /dev/null 2>&1; then
1308 echo "const CLONE_NEWNET = 0x40000000" >> ${OUT}
1311 # Struct sizes.
1312 set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \
1313 ifaddrmsg IfAddrmsg ifinfomsg IfInfomsg in_pktinfo Inet4Pktinfo \
1314 in6_pktinfo Inet6Pktinfo inotify_event InotifyEvent linger Linger \
1315 msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \
1316 rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \
1317 sock_filter SockFilter sock_fprog SockFprog ucred Ucred \
1318 icmp6_filter ICMPv6Filter ip6_mtuinfo IPv6MTUInfo
1319 while test $# != 0; do
1320 nc=$1
1321 ngo=$2
1322 shift
1323 shift
1324 if grep "^const _sizeof_$nc =" gen-sysinfo.go >/dev/null 2>&1; then
1325 echo "const Sizeof$ngo = _sizeof_$nc" >> ${OUT}
1327 done
1329 # In order to compile the net package, we need some sizes to exist
1330 # even if the types do not.
1331 if ! grep 'const SizeofIPMreq ' ${OUT} >/dev/null 2>&1; then
1332 echo 'const SizeofIPMreq = 8' >> ${OUT}
1334 if ! grep 'const SizeofIPv6Mreq ' ${OUT} >/dev/null 2>&1; then
1335 echo 'const SizeofIPv6Mreq = 20' >> ${OUT}
1337 if ! grep 'const SizeofIPMreqn ' ${OUT} >/dev/null 2>&1; then
1338 echo 'const SizeofIPMreqn = 12' >> ${OUT}
1340 if ! grep 'const SizeofICMPv6Filter ' ${OUT} >/dev/null 2>&1; then
1341 echo 'const SizeofICMPv6Filter = 32' >> ${OUT}
1344 # The Solaris 11 Update 1 _zone_net_addr_t struct.
1345 grep '^type _zone_net_addr_t ' gen-sysinfo.go | \
1346 sed -e 's/_in6_addr/[16]byte/' \
1347 >> ${OUT}
1349 # The Solaris 11.4 _flow_arp_desc_t struct.
1350 grep '^type _flow_arp_desc_t ' gen-sysinfo.go | \
1351 sed -e 's/_in6_addr_t/[16]byte/g' \
1352 >> ${OUT}
1354 # The Solaris 11.4 _flow_l3_desc_t struct.
1355 grep '^type _flow_l3_desc_t ' gen-sysinfo.go | \
1356 sed -e 's/_in6_addr_t/[16]byte/g' \
1357 >> ${OUT}
1359 # The Solaris 11.3 _mac_ipaddr_t struct.
1360 grep '^type _mac_ipaddr_t ' gen-sysinfo.go | \
1361 sed -e 's/_in6_addr_t/[16]byte/g' \
1362 >> ${OUT}
1364 # The Solaris 11.3 _mactun_info_t struct.
1365 grep '^type _mactun_info_t ' gen-sysinfo.go | \
1366 sed -e 's/_in6_addr_t/[16]byte/g' \
1367 >> ${OUT}
1369 exit $?