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