annotate libgo/mksysinfo.sh @ 158:494b0b89df80 default tip

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