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