annotate libgo/mksysinfo.sh @ 138:fc828634a951

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