OSDN Git Service

5e3e9bb0897e6bb3b34d128d8b747120afab5a19
[pf3gnuchains/gcc-fork.git] / libgo / mksysinfo.sh
1 #!/bin/sh
2
3 # Copyright 2009 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
6
7 # Create sysinfo.go.
8
9 # This shell script creates the sysinfo.go file which holds types and
10 # constants extracted from the system header files.  This relies on a
11 # hook in gcc: the -fdump-go-spec option will generate debugging
12 # information in Go syntax.
13
14 # We currently #include all the files at once, which works, but leads
15 # to exposing some names which ideally should not be exposed, as they
16 # match grep patterns.  E.g., WCHAR_MIN gets exposed because it starts
17 # with W, like the wait flags.
18
19 CC=${CC:-gcc}
20 OUT=tmp-sysinfo.go
21
22 set -e
23
24 rm -f sysinfo.c
25 cat > sysinfo.c <<EOF
26 #include "config.h"
27
28 #include <sys/types.h>
29 #include <dirent.h>
30 #include <errno.h>
31 #include <fcntl.h>
32 #include <netinet/in.h>
33 /* <netinet/tcp.h> needs u_char/u_short, but <sys/bsd_types> is only
34    included by <netinet/in.h> if _SGIAPI (i.e. _SGI_SOURCE
35    && !_XOPEN_SOURCE.
36    <sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
37    <sys/ttold.h> does so unconditionally.  */
38 #ifdef __sgi__
39 #include <sys/bsd_types.h>
40 #include <sys/ttold.h>
41 #endif
42 #include <netinet/tcp.h>
43 #include <signal.h>
44 #include <sys/ioctl.h>
45 #include <termios.h>
46 #if defined(HAVE_SYSCALL_H)
47 #include <syscall.h>
48 #endif
49 #if defined(HAVE_SYS_SYSCALL_H)
50 #include <sys/syscall.h>
51 #endif
52 #if defined(HAVE_SYS_EPOLL_H)
53 #include <sys/epoll.h>
54 #endif
55 #if defined(HAVE_SYS_MMAN_H)
56 #include <sys/mman.h>
57 #endif
58 #if defined(HAVE_SYS_PRCTL_H)
59 #include <sys/prctl.h>
60 #endif
61 #if defined(HAVE_SYS_PTRACE_H)
62 #include <sys/ptrace.h>
63 #endif
64 #include <sys/resource.h>
65 #include <sys/uio.h>
66 #include <sys/socket.h>
67 #include <sys/stat.h>
68 #include <sys/time.h>
69 #include <sys/times.h>
70 #include <sys/wait.h>
71 #include <sys/un.h>
72 #if defined(HAVE_SYS_USER_H)
73 #include <sys/user.h>
74 #endif
75 #if defined(HAVE_SYS_UTSNAME_H)
76 #include <sys/utsname.h>
77 #endif
78 #if defined(HAVE_SYS_SELECT_H)
79 #include <sys/select.h>
80 #endif
81 #include <time.h>
82 #include <unistd.h>
83 #include <netdb.h>
84 #include <pwd.h>
85 #if defined(HAVE_LINUX_FILTER_H)
86 #include <linux/filter.h>
87 #endif
88 #if defined(HAVE_LINUX_NETLINK_H)
89 #include <linux/netlink.h>
90 #endif
91 #if defined(HAVE_LINUX_RTNETLINK_H)
92 #include <linux/rtnetlink.h>
93 #endif
94 #if defined(HAVE_NET_IF_H)
95 #include <net/if.h>
96 #endif
97 #if defined(HAVE_SYS_MOUNT_H)
98 #include <sys/mount.h>
99 #endif
100 #if defined(HAVE_SYS_VFS_H)
101 #include <sys/vfs.h>
102 #endif
103 #if defined(HAVE_STATFS_H)
104 #include <sys/statfs.h>
105 #endif
106 #if defined(HAVE_SYS_TIMEX_H)
107 #include <sys/timex.h>
108 #endif
109 #if defined(HAVE_SYS_SYSINFO_H)
110 #include <sys/sysinfo.h>
111 #endif
112 #if defined(HAVE_USTAT_H)
113 #include <ustat.h>
114 #endif
115 #if defined(HAVE_UTIME_H)
116 #include <utime.h>
117 #endif
118 #if defined(HAVE_LINUX_REBOOT_H)
119 #include <linux/reboot.h>
120 #endif
121
122 /* Constants that may only be defined as expressions on some systems,
123    expressions too complex for -fdump-go-spec to handle.  These are
124    handled specially below.  */
125 enum {
126 #ifdef TIOCGWINSZ
127   TIOCGWINSZ_val = TIOCGWINSZ,
128 #endif
129 };
130 EOF
131
132 ${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c
133
134 echo 'package syscall' > ${OUT}
135 echo 'import "unsafe"' >> ${OUT}
136 echo 'type _ unsafe.Pointer' >> ${OUT}
137
138 # Get all the consts and types, skipping ones which could not be
139 # represented in Go and ones which we need to rewrite.  We also skip
140 # function declarations, as we don't need them here.  All the symbols
141 # will all have a leading underscore.
142 grep -v '^// ' gen-sysinfo.go | \
143   grep -v '^func' | \
144   grep -v '^type _timeval ' | \
145   grep -v '^type _timespec_t ' | \
146   grep -v '^type _timespec ' | \
147   grep -v '^type _timestruc_t ' | \
148   grep -v '^type _epoll_' | \
149   grep -v 'in6_addr' | \
150   grep -v 'sockaddr_in6' | \
151   sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
152       -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
153       -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
154       -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
155     >> ${OUT}
156
157 # The errno constants.  These get type Errno.
158 echo '#include <errno.h>' | ${CC} -x c - -E -dM | \
159   egrep '#define E[A-Z0-9_]+ ' | \
160   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
161
162 # The O_xxx flags.
163 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
164   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
165 if ! grep '^const O_ASYNC' ${OUT} >/dev/null 2>&1; then
166   echo "const O_ASYNC = 0" >> ${OUT}
167 fi
168 if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
169   echo "const O_CLOEXEC = 0" >> ${OUT}
170 fi
171
172 # The signal numbers.
173 grep '^const _SIG[^_]' gen-sysinfo.go | \
174   grep -v '^const _SIGEV_' | \
175   sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
176
177 # The syscall numbers.  We force the names to upper case.
178 grep '^const _SYS_' gen-sysinfo.go | \
179   sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
180   while read sys; do
181     sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
182     echo "const $sup = _$sys" >> ${OUT}
183   done
184
185 # Stat constants.
186 grep '^const _S_' gen-sysinfo.go | \
187   sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
188
189 # Mmap constants.
190 grep '^const _PROT_' gen-sysinfo.go | \
191   sed -e 's/^\(const \)_\(PROT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
192 grep '^const _MAP_' gen-sysinfo.go | \
193   sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
194
195 # Process status constants.
196 grep '^const _W' gen-sysinfo.go |
197   sed -e 's/^\(const \)_\(W[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
198 # WSTOPPED was introduced in glibc 2.3.4.
199 if ! grep '^const _WSTOPPED = ' gen-sysinfo.go >/dev/null 2>&1; then
200   if grep '^const _WUNTRACED = ' gen-sysinfo.go > /dev/null 2>&1; then
201     echo 'const WSTOPPED = _WUNTRACED' >> ${OUT}
202   else
203     echo 'const WSTOPPED = 2' >> ${OUT}
204   fi
205 fi
206 if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
207    && ! grep '^const _WALL = ' gen-sysinfo.go >/dev/null 2>&1; then
208   echo 'const WALL = ___WALL' >> ${OUT}
209 fi
210
211 # Networking constants.
212 egrep '^const _(AF|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
213   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
214 grep '^const _SOMAXCONN' gen-sysinfo.go |
215   sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
216     >> ${OUT}
217 grep '^const _SHUT_' gen-sysinfo.go |
218   sed -e 's/^\(const \)_\(SHUT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
219
220 # The net package requires some const definitions.
221 for m in IP_PKTINFO IPV6_V6ONLY IPPROTO_IPV6 IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_TCLASS; do
222   if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
223     echo "const $m = 0" >> ${OUT}
224   fi
225 done
226
227 # pathconf constants.
228 grep '^const __PC' gen-sysinfo.go |
229   sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
230
231 # epoll constants.
232 grep '^const _EPOLL' gen-sysinfo.go |
233   sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
234 # Make sure EPOLLRDHUP and EPOLL_CLOEXEC are defined.
235 if ! grep '^const EPOLLRDHUP' ${OUT} >/dev/null 2>&1; then
236   echo "const EPOLLRDHUP = 0x2000" >> ${OUT}
237 fi
238 if ! grep '^const EPOLL_CLOEXEC' ${OUT} >/dev/null 2>&1; then
239   echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
240 fi
241
242 # Prctl constants.
243 grep '^const _PR_' gen-sysinfo.go |
244   sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
245
246 # Ptrace constants.
247 grep '^const _PTRACE' gen-sysinfo.go |
248   sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
249 # We need some ptrace options that are not defined in older versions
250 # of glibc.
251 if ! grep '^const PTRACE_SETOPTIONS' ${OUT} > /dev/null 2>&1; then
252   echo "const PTRACE_SETOPTIONS = 0x4200" >> ${OUT}
253 fi
254 if ! grep '^const PTRACE_O_TRACESYSGOOD' ${OUT} > /dev/null 2>&1; then
255   echo "const PTRACE_O_TRACESYSGOOD = 0x1" >> ${OUT}
256 fi
257 if ! grep '^const PTRACE_O_TRACEFORK' ${OUT} > /dev/null 2>&1; then
258   echo "const PTRACE_O_TRACEFORK = 0x2" >> ${OUT}
259 fi
260 if ! grep '^const PTRACE_O_TRACEVFORK' ${OUT} > /dev/null 2>&1; then
261   echo "const PTRACE_O_TRACEVFORK = 0x4" >> ${OUT}
262 fi
263 if ! grep '^const PTRACE_O_TRACECLONE' ${OUT} > /dev/null 2>&1; then
264   echo "const PTRACE_O_TRACECLONE = 0x8" >> ${OUT}
265 fi
266 if ! grep '^const PTRACE_O_TRACEEXEC' ${OUT} > /dev/null 2>&1; then
267   echo "const PTRACE_O_TRACEEXEC = 0x10" >> ${OUT}
268 fi
269 if ! grep '^const PTRACE_O_TRACEVFORKDONE' ${OUT} > /dev/null 2>&1; then
270   echo "const PTRACE_O_TRACEVFORKDONE = 0x20" >> ${OUT}
271 fi
272 if ! grep '^const PTRACE_O_TRACEEXIT' ${OUT} > /dev/null 2>&1; then
273   echo "const PTRACE_O_TRACEEXIT = 0x40" >> ${OUT}
274 fi
275 if ! grep '^const PTRACE_O_MASK' ${OUT} > /dev/null 2>&1; then
276   echo "const PTRACE_O_MASK = 0x7f" >> ${OUT}
277 fi
278 if ! grep '^const _PTRACE_GETEVENTMSG' ${OUT} > /dev/null 2>&1; then
279   echo "const PTRACE_GETEVENTMSG = 0x4201" >> ${OUT}
280 fi
281 if ! grep '^const PTRACE_EVENT_FORK' ${OUT} > /dev/null 2>&1; then
282   echo "const PTRACE_EVENT_FORK = 1" >> ${OUT}
283 fi
284 if ! grep '^const PTRACE_EVENT_VFORK' ${OUT} > /dev/null 2>&1; then
285   echo "const PTRACE_EVENT_VFORK = 2" >> ${OUT}
286 fi
287 if ! grep '^const PTRACE_EVENT_CLONE' ${OUT} > /dev/null 2>&1; then
288   echo "const PTRACE_EVENT_CLONE = 3" >> ${OUT}
289 fi
290 if ! grep '^const PTRACE_EVENT_EXEC' ${OUT} > /dev/null 2>&1; then
291   echo "const PTRACE_EVENT_EXEC = 4" >> ${OUT}
292 fi
293 if ! grep '^const PTRACE_EVENT_VFORK_DONE' ${OUT} > /dev/null 2>&1; then
294   echo "const PTRACE_EVENT_VFORK_DONE = 5" >> ${OUT}
295 fi
296 if ! grep '^const PTRACE_EVENT_EXIT' ${OUT} > /dev/null 2>&1; then
297   echo "const PTRACE_EVENT_EXIT = 6" >> ${OUT}
298 fi
299 if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then
300   echo "const _PTRACE_TRACEME = 0" >> ${OUT}
301 fi
302
303 # The registers returned by PTRACE_GETREGS.  This is probably
304 # GNU/Linux specific; it should do no harm if there is no
305 # _user_regs_struct.
306 regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
307 if test "$regs" != ""; then
308   regs=`echo $regs | sed -e 's/type _user_regs_struct struct //' -e 's/[{}]//g'`
309   regs=`echo $regs | sed -e s'/^ *//'`
310   nregs=
311   while test -n "$regs"; do
312     field=`echo $regs | sed -e 's/^\([^;]*\);.*$/\1/'`
313     regs=`echo $regs | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
314     # Capitalize the first character of the field.
315     f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
316     r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
317     f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
318     field="$f$r"
319     nregs="$nregs $field;"
320   done
321   echo "type PtraceRegs struct {$nregs }" >> ${OUT}
322 fi
323
324 # Some basic types.
325 echo 'type Size_t _size_t' >> ${OUT}
326 echo "type Ssize_t _ssize_t" >> ${OUT}
327 if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
328   echo "type Offset_t _off64_t" >> ${OUT}
329 else
330   echo "type Offset_t _off_t" >> ${OUT}
331 fi
332 echo "type Mode_t _mode_t" >> ${OUT}
333 echo "type Pid_t _pid_t" >> ${OUT}
334 echo "type Uid_t _uid_t" >> ${OUT}
335 echo "type Gid_t _gid_t" >> ${OUT}
336 echo "type Socklen_t _socklen_t" >> ${OUT}
337
338 # The long type, needed because that is the type that ptrace returns.
339 sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
340 if test "$sizeof_long" = "4"; then
341   echo "type _C_long int32" >> ${OUT}
342 elif test "$sizeof_long" = "8"; then
343   echo "type _C_long int64" >> ${OUT}
344 else
345   echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
346   exit 1
347 fi
348
349 # Solaris 2 needs _u?pad128_t, but its default definition in terms of long
350 # double is commented by -fdump-go-spec.
351 if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then
352   echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT}
353 fi
354 if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then
355   echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT}
356 fi
357
358 # The time_t type.
359 if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then
360   echo 'type Time_t _time_t' >> ${OUT}
361 fi
362
363 # The time structures need special handling: we need to name the
364 # types, so that we can cast integers to the right types when
365 # assigning to the structures.
366 timeval=`grep '^type _timeval ' gen-sysinfo.go`
367 timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
368 timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'`
369 echo "type Timeval_sec_t $timeval_sec" >> ${OUT}
370 echo "type Timeval_usec_t $timeval_usec" >> ${OUT}
371 echo $timeval | \
372   sed -e 's/type _timeval /type Timeval /' \
373       -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \
374       -e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT}
375 timespec=`grep '^type _timespec ' gen-sysinfo.go || true`
376 if test "$timespec" = ""; then
377   # IRIX 6.5 has __timespec instead.
378   timespec=`grep '^type ___timespec ' gen-sysinfo.go || true`
379 fi
380 timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
381 timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
382 echo "type Timespec_sec_t $timespec_sec" >> ${OUT}
383 echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT}
384 echo $timespec | \
385   sed -e 's/^type ___timespec /type Timespec /' \
386       -e 's/^type _timespec /type Timespec /' \
387       -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
388       -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
389
390 timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true`
391 if test "$timestruc" != ""; then
392   timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
393   timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
394   echo "type Timestruc_sec_t $timestruc_sec" >> ${OUT}
395   echo "type Timestruc_nsec_t $timestruc_nsec" >> ${OUT}
396   echo $timestruc | \
397     sed -e 's/^type _timestruc_t /type Timestruc /' \
398         -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timestruc_sec_t/' \
399         -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
400 fi
401
402 # The tms struct.
403 grep '^type _tms ' gen-sysinfo.go | \
404     sed -e 's/type _tms/type Tms/' \
405       -e 's/tms_utime/Utime/' \
406       -e 's/tms_stime/Stime/' \
407       -e 's/tms_cutime/Cutime/' \
408       -e 's/tms_cstime/Cstime/' \
409     >> ${OUT}
410
411 # The stat type.
412 # Prefer largefile variant if available.
413 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
414 if test "$stat" != ""; then
415   grep '^type _stat64 ' gen-sysinfo.go
416 else
417   grep '^type _stat ' gen-sysinfo.go
418 fi | sed -e 's/type _stat64/type Stat_t/' \
419          -e 's/type _stat/type Stat_t/' \
420          -e 's/st_dev/Dev/' \
421          -e 's/st_ino/Ino/g' \
422          -e 's/st_nlink/Nlink/' \
423          -e 's/st_mode/Mode/' \
424          -e 's/st_uid/Uid/' \
425          -e 's/st_gid/Gid/' \
426          -e 's/st_rdev/Rdev/' \
427          -e 's/st_size/Size/' \
428          -e 's/st_blksize/Blksize/' \
429          -e 's/st_blocks/Blocks/' \
430          -e 's/st_atim/Atime/' \
431          -e 's/st_mtim/Mtime/' \
432          -e 's/st_ctim/Ctime/' \
433          -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
434          -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
435          -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
436          -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
437          -e 's/Godump_[0-9] struct { \([^;]*;\) };/\1/g' \
438        >> ${OUT}
439
440 # The directory searching types.
441 # Prefer largefile variant if available.
442 dirent=`grep '^type _dirent64 ' gen-sysinfo.go || true`
443 if test "$dirent" != ""; then
444   grep '^type _dirent64 ' gen-sysinfo.go
445 else
446   grep '^type _dirent ' gen-sysinfo.go
447 fi | sed -e 's/type _dirent64/type Dirent/' \
448          -e 's/type _dirent/type Dirent/' \
449          -e 's/d_name \[0+1\]/d_name [0+256]/' \
450          -e 's/d_name/Name/' \
451          -e 's/]int8/]byte/' \
452          -e 's/d_ino/Ino/' \
453          -e 's/d_off/Off/' \
454          -e 's/d_reclen/Reclen/' \
455          -e 's/d_type/Type/' \
456       >> ${OUT}
457 echo "type DIR _DIR" >> ${OUT}
458
459 # The rusage struct.
460 rusage=`grep '^type _rusage struct' gen-sysinfo.go`
461 if test "$rusage" != ""; then
462   rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
463   rusage=`echo $rusage | sed -e 's/^ *//'`
464   nrusage=
465   while test -n "$rusage"; do
466     field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
467     rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
468     # Drop the leading ru_, capitalize the next character.
469     field=`echo $field | sed -e 's/^ru_//'`
470     f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
471     r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
472     f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
473     # Fix _timeval _timespec, and _timestruc_t.
474     r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
475     r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
476     r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
477     field="$f$r"
478     nrusage="$nrusage $field;"
479   done
480   echo "type Rusage struct {$nrusage }" >> ${OUT}
481 else
482   echo "type Rusage struct {}" >> ${OUT}
483 fi
484
485 # The RUSAGE constants.
486 grep '^const _RUSAGE_' gen-sysinfo.go | \
487   sed -e 's/^\(const \)_\(RUSAGE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
488
489 # The utsname struct.
490 grep '^type _utsname ' gen-sysinfo.go | \
491     sed -e 's/_utsname/Utsname/' \
492       -e 's/sysname/Sysname/' \
493       -e 's/nodename/Nodename/' \
494       -e 's/release/Release/' \
495       -e 's/version/Version/' \
496       -e 's/machine/Machine/' \
497       -e 's/domainname/Domainname/' \
498     >> ${OUT}
499
500 # The iovec struct.
501 iovec=`grep '^type _iovec ' gen-sysinfo.go`
502 iovec_len=`echo $iovec | sed -n -e 's/^.*iov_len \([^ ]*\);.*$/\1/p'`
503 echo "type Iovec_len_t $iovec_len" >> ${OUT}
504 echo $iovec | \
505     sed -e 's/_iovec/Iovec/' \
506       -e 's/iov_base/Base/' \
507       -e 's/iov_len *[a-zA-Z0-9_]*/Len Iovec_len_t/' \
508     >> ${OUT}
509
510 # The msghdr struct.
511 msghdr=`grep '^type _msghdr ' gen-sysinfo.go`
512 msghdr_controllen=`echo $msghdr | sed -n -e 's/^.*msg_controllen \([^ ]*\);.*$/\1/p'`
513 echo "type Msghdr_controllen_t $msghdr_controllen" >> ${OUT}
514 echo $msghdr | \
515     sed -e 's/_msghdr/Msghdr/' \
516       -e 's/msg_name/Name/' \
517       -e 's/msg_namelen/Namelen/' \
518       -e 's/msg_iov/Iov/' \
519       -e 's/msg_iovlen/Iovlen/' \
520       -e 's/_iovec/Iovec/' \
521       -e 's/msg_control/Control/' \
522       -e 's/msg_controllen *[a-zA-Z0-9_]*/Controllen Msghdr_controllen_t/' \
523       -e 's/msg_flags/Flags/' \
524     >> ${OUT}
525
526 # The MSG_ flags for Msghdr.
527 grep '^const _MSG_' gen-sysinfo.go | \
528   sed -e 's/^\(const \)_\(MSG_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
529
530 # The cmsghdr struct.
531 cmsghdr=`grep '^type _cmsghdr ' gen-sysinfo.go`
532 if test -n "$cmsghdr"; then
533   cmsghdr_len=`echo $cmsghdr | sed -n -e 's/^.*cmsg_len \([^ ]*\);.*$/\1/p'`
534   echo "type Cmsghdr_len_t $cmsghdr_len" >> ${OUT}
535   echo "$cmsghdr" | \
536       sed -e 's/_cmsghdr/Cmsghdr/' \
537         -e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
538         -e 's/cmsg_level/Level/' \
539         -e 's/cmsg_type/Type/' \
540         -e 's/\[\]/[0]/' \
541       >> ${OUT}
542
543   # The size of the cmsghdr struct.
544   echo 'var SizeofCmsghdr = int(unsafe.Sizeof(Cmsghdr{}))' >> ${OUT}
545 fi
546
547 # The SCM_ flags for Cmsghdr.
548 grep '^const _SCM_' gen-sysinfo.go | \
549   sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
550
551 # The ucred struct.
552 grep '^type _ucred ' gen-sysinfo.go | \
553     sed -e 's/_ucred/Ucred/' \
554       -e 's/pid/Pid/' \
555       -e 's/uid/Uid/' \
556       -e 's/gid/Gid/' \
557     >> ${OUT}
558
559 # The size of the ucred struct.
560 if grep 'type Ucred ' ${OUT} >/dev/null 2>&1; then
561   echo 'var SizeofUcred = int(unsafe.Sizeof(Ucred{}))' >> ${OUT}
562 fi  
563
564 # The ip_mreq struct.
565 grep '^type _ip_mreq ' gen-sysinfo.go | \
566     sed -e 's/_ip_mreq/IPMreq/' \
567       -e 's/imr_multiaddr/Multiaddr/' \
568       -e 's/imr_interface/Interface/' \
569       -e 's/_in_addr/[4]byte/g' \
570     >> ${OUT}
571
572 # We need IPMreq to compile the net package.
573 if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then
574   echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT}
575 fi
576
577 # The size of the ip_mreq struct.
578 echo 'var SizeofIPMreq = int(unsafe.Sizeof(IPMreq{}))' >> ${OUT}
579
580 # The ipv6_mreq struct.
581 grep '^type _ipv6_mreq ' gen-sysinfo.go | \
582     sed -e 's/_ipv6_mreq/IPv6Mreq/' \
583       -e 's/ipv6mr_multiaddr/Multiaddr/' \
584       -e 's/ipv6mr_interface/Interface/' \
585       -e 's/_in6_addr/[16]byte/' \
586     >> ${OUT}
587
588 # We need IPv6Mreq to compile the net package.
589 if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then
590   echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
591 fi
592
593 # The size of the ipv6_mreq struct.
594 echo 'var SizeofIPv6Mreq = int(unsafe.Sizeof(IPv6Mreq{}))' >> ${OUT}
595
596 # The ip_mreqn struct.
597 grep '^type _ip_mreqn ' gen-sysinfo.go | \
598     sed -e 's/_ip_mreqn/IPMreqn/' \
599       -e 's/imr_multiaddr/Multiaddr/' \
600       -e 's/imr_address/Address/' \
601       -e 's/imr_ifindex/Ifindex/' \
602       -e 's/_in_addr/[4]byte/g' \
603     >> ${OUT}
604
605 # We need IPMreq to compile the net package.
606 if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then
607   echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT}
608 fi
609
610 # The size of the ip_mreqn struct.
611 echo 'var SizeofIPMreqn = int(unsafe.Sizeof(IPMreqn{}))' >> ${OUT}
612
613 # Try to guess the type to use for fd_set.
614 fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
615 fds_bits_type="_C_long"
616 if test "$fd_set" != ""; then
617     fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'`
618 fi
619 echo "type fds_bits_type $fds_bits_type" >> ${OUT}
620
621 # The addrinfo struct.
622 grep '^type _addrinfo ' gen-sysinfo.go | \
623     sed -e 's/_addrinfo/Addrinfo/g' \
624       -e 's/ ai_/ Ai_/g' \
625     >> ${OUT}
626
627 # The addrinfo flags and errors.
628 grep '^const _AI_' gen-sysinfo.go | \
629   sed -e 's/^\(const \)_\(AI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
630 grep '^const _EAI_' gen-sysinfo.go | \
631   sed -e 's/^\(const \)_\(EAI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
632
633 # The passwd struct.
634 grep '^type _passwd ' gen-sysinfo.go | \
635     sed -e 's/_passwd/Passwd/' \
636       -e 's/ pw_/ Pw_/g' \
637     >> ${OUT}
638
639 # The ioctl flags for the controlling TTY.
640 grep '^const _TIOC' gen-sysinfo.go | \
641     grep -v '_val =' | \
642     sed -e 's/^\(const \)_\(TIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
643 # We need TIOCGWINSZ.
644 if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then
645   if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then
646     echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT}
647   fi
648 fi
649
650 # The ioctl flags for terminal control
651 grep '^const _TC[GS]ET' gen-sysinfo.go | \
652     sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
653
654 # ioctl constants.  Might fall back to 0 if TIOCNXCL is missing, too, but
655 # needs handling in syscalls.exec.go.
656 if ! grep '^const _TIOCSCTTY ' gen-sysinfo.go >/dev/null 2>&1; then
657   if grep '^const _TIOCNXCL ' gen-sysinfo.go >/dev/null 2>&1; then
658     echo "const TIOCSCTTY = TIOCNXCL" >> ${OUT}
659   fi
660 fi
661
662 # The nlmsghdr struct.
663 grep '^type _nlmsghdr ' gen-sysinfo.go | \
664     sed -e 's/_nlmsghdr/NlMsghdr/' \
665       -e 's/nlmsg_len/Len/' \
666       -e 's/nlmsg_type/Type/' \
667       -e 's/nlmsg_flags/Flags/' \
668       -e 's/nlmsg_seq/Seq/' \
669       -e 's/nlmsg_pid/Pid/' \
670     >> ${OUT}
671
672 # The nlmsg flags and operators.
673 grep '^const _NLM' gen-sysinfo.go | \
674     sed -e 's/^\(const \)_\(NLM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
675
676 # NLMSG_HDRLEN is defined as an expression using sizeof.
677 if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then
678   if grep '^type NlMsghdr ' ${OUT} > /dev/null 2>&1; then
679     echo 'var NLMSG_HDRLEN = int((unsafe.Sizeof(NlMsghdr{}) + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1))' >> ${OUT}
680   fi
681 fi
682
683 # The rtmsg struct.
684 grep '^type _rtmsg ' gen-sysinfo.go | \
685     sed -e 's/_rtmsg/RtMsg/' \
686       -e 's/rtm_family/Family/' \
687       -e 's/rtm_dst_len/Dst_len/' \
688       -e 's/rtm_src_len/Src_len/' \
689       -e 's/rtm_tos/Tos/' \
690       -e 's/rtm_table/Table/' \
691       -e 's/rtm_protocol/Procotol/' \
692       -e 's/rtm_scope/Scope/' \
693       -e 's/rtm_type/Type/' \
694       -e 's/rtm_flags/Flags/' \
695     >> ${OUT}
696
697 # The size of the rtmsg struct.
698 if grep 'type RtMsg ' ${OUT} > /dev/null 2>&1; then
699   echo 'var SizeofRtMsg = int(unsafe.Sizeof(RtMsg{}))' >> ${OUT}
700 fi
701
702 # The rtgenmsg struct.
703 grep '^type _rtgenmsg ' gen-sysinfo.go | \
704     sed -e 's/_rtgenmsg/RtGenmsg/' \
705       -e 's/rtgen_family/Family/' \
706     >> ${OUT}
707
708 # The routing message flags.
709 grep '^const _RTA' gen-sysinfo.go | \
710     sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
711 grep '^const _RTM' gen-sysinfo.go | \
712     sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
713
714 # The size of the rtgenmsg struct.
715 if grep 'type RtGenmsg ' ${OUT} > /dev/null 2>&1; then
716   echo 'var SizeofRtGenmsg = int(unsafe.Sizeof(RtGenmsg{}))' >> ${OUT}
717 fi
718
719 # The ifinfomsg struct.
720 grep '^type _ifinfomsg ' gen-sysinfo.go | \
721     sed -e 's/_ifinfomsg/IfInfomsg/' \
722       -e 's/ifi_family/Family/' \
723       -e 's/ifi_type/Type/' \
724       -e 's/ifi_index/Index/' \
725       -e 's/ifi_flags/Flags/' \
726       -e 's/ifi_change/Change/' \
727     >> ${OUT}
728
729 # The interface information types and flags.
730 grep '^const _IFA' gen-sysinfo.go | \
731     sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
732 grep '^const _IFLA' gen-sysinfo.go | \
733     sed -e 's/^\(const \)_\(IFLA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
734 grep '^const _IFF' gen-sysinfo.go | \
735     sed -e 's/^\(const \)_\(IFF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
736 grep '^const _IFNAMSIZ' gen-sysinfo.go | \
737     sed -e 's/^\(const \)_\(IFNAMSIZ[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
738 grep '^const _SIOC' gen-sysinfo.go |
739     sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
740
741 # The size of the ifinfomsg struct.
742 if grep 'type IfInfomsg ' ${OUT} > /dev/null 2>&1; then
743   echo 'var SizeofIfInfomsg = int(unsafe.Sizeof(IfInfomsg{}))' >> ${OUT}
744 fi
745
746 # The ifaddrmsg struct.
747 grep '^type _ifaddrmsg ' gen-sysinfo.go | \
748     sed -e 's/_ifaddrmsg/IfAddrmsg/' \
749       -e 's/ifa_family/Family/' \
750       -e 's/ifa_prefixlen/Prefixlen/' \
751       -e 's/ifa_flags/Flags/' \
752       -e 's/ifa_scope/Scope/' \
753       -e 's/ifa_index/Index/' \
754     >> ${OUT}
755
756 # The size of the ifaddrmsg struct.
757 if grep 'type IfAddrmsg ' ${OUT} > /dev/null 2>&1; then
758   echo 'var SizeofIfAddrmsg = int(unsafe.Sizeof(IfAddrmsg{}))' >> ${OUT}
759 fi
760
761 # The rtattr struct.
762 grep '^type _rtattr ' gen-sysinfo.go | \
763     sed -e 's/_rtattr/RtAttr/' \
764       -e 's/rta_len/Len/' \
765       -e 's/rta_type/Type/' \
766     >> ${OUT}
767
768 # The size of the rtattr struct.
769 if grep 'type RtAttr ' ${OUT} > /dev/null 2>&1; then
770   echo 'var SizeofRtAttr = int(unsafe.Sizeof(RtAttr{}))' >> ${OUT}
771 fi
772
773 # The termios struct.
774 grep '^type _termios ' gen-sysinfo.go | \
775     sed -e 's/_termios/Termios/' \
776       -e 's/c_iflag/Iflag/' \
777       -e 's/c_oflag/Oflag/' \
778       -e 's/c_cflag/Cflag/' \
779       -e 's/c_lflag/Lflag/' \
780       -e 's/c_line/Line/' \
781       -e 's/c_cc/Cc/' \
782       -e 's/c_ispeed/Ispeed/' \
783       -e 's/c_ospeed/Ospeed/' \
784     >> ${OUT}
785
786 # The termios constants.
787 for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
788     IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
789     OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 TABDLY BSDLY VTDLY \
790     FFDLY CBAUD CBAUDEX CSIZE CSTOPB CREAD PARENB PARODD HUPCL CLOCAL \
791     LOBLK CIBAUD CMSPAR CRTSCTS ISIG ICANON XCASE ECHO ECHOE ECHOK ECHONL \
792     ECHOCTL ECHOPRT ECHOKE DEFECHO FLUSHO NOFLSH TOSTOP PENDIN IEXTEN VINTR \
793     VQUIT VERASE VKILL VEOF VMIN VEOL VTIME VEOL2 VSWTCH VSTART VSTOP VSUSP \
794     VDSUSP VLNEXT VWERASE VREPRINT VDISCARD VSTATUS TCSANOW TCSADRAIN \
795     TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \
796     B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \
797     B38400 B57600 B115200 B230400; do
798
799     grep "^const _$n " gen-sysinfo.go | \
800         sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
801 done
802
803 # The mount flags
804 grep '^const _MS_' gen-sysinfo.go |
805     sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
806
807 # The fallocate flags.
808 grep '^const _FALLOC_' gen-sysinfo.go |
809     sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
810
811 # The statfs struct.
812 # Prefer largefile variant if available.
813 statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
814 if test "$statfs" != ""; then
815   grep '^type _statfs64 ' gen-sysinfo.go
816 else
817   grep '^type _statfs ' gen-sysinfo.go
818 fi | sed -e 's/type _statfs64/type Statfs_t/' \
819          -e 's/type _statfs/type Statfs_t/' \
820          -e 's/f_type/Type/' \
821          -e 's/f_bsize/Bsize/' \
822          -e 's/f_blocks/Blocks/' \
823          -e 's/f_bfree/Bfree/' \
824          -e 's/f_bavail/Bavail/' \
825          -e 's/f_files/Files/' \
826          -e 's/f_ffree/Ffree/' \
827          -e 's/f_fsid/Fsid/' \
828          -e 's/f_namelen/Namelen/' \
829          -e 's/f_frsize/Frsize/' \
830          -e 's/f_flags/Flags/' \
831          -e 's/f_spare/Spare/' \
832     >> ${OUT}
833
834 # The timex struct.
835 grep '^type _timex ' gen-sysinfo.go | \
836     sed -e 's/_timex/Timex/' \
837       -e 's/modes/Modes/' \
838       -e 's/offset/Offset/' \
839       -e 's/freq/Freq/' \
840       -e 's/maxerror/Maxerror/' \
841       -e 's/esterror/Esterror/' \
842       -e 's/status/Status/' \
843       -e 's/constant/Constant/' \
844       -e 's/precision/Precision/' \
845       -e 's/tolerance/Tolerance/' \
846       -e 's/ time / Time /' \
847       -e 's/tick/Tick/' \
848       -e 's/ppsfreq/Ppsfreq/' \
849       -e 's/jitter/Jitter/' \
850       -e 's/shift/Shift/' \
851       -e 's/stabil/Stabil/' \
852       -e 's/jitcnt/Jitcnt/' \
853       -e 's/calcnt/Calcnt/' \
854       -e 's/errcnt/Errcnt/' \
855       -e 's/stbcnt/Stbcnt/' \
856       -e 's/tai/Tai/' \
857       -e 's/_timeval/Timeval/' \
858     >> ${OUT}
859
860 # The rlimit struct.
861 grep '^type _rlimit ' gen-sysinfo.go | \
862     sed -e 's/_rlimit/Rlimit/' \
863       -e 's/rlim_cur/Cur/' \
864       -e 's/rlim_max/Max/' \
865     >> ${OUT}
866
867 # The RLIMIT constants.
868 grep '^const _RLIMIT_' gen-sysinfo.go |
869     sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
870
871 # The sysinfo struct.
872 grep '^type _sysinfo ' gen-sysinfo.go | \
873     sed -e 's/_sysinfo/Sysinfo_t/' \
874       -e 's/uptime/Uptime/' \
875       -e 's/loads/Loads/' \
876       -e 's/totalram/Totalram/' \
877       -e 's/freeram/Freeram/' \
878       -e 's/sharedram/Sharedram/' \
879       -e 's/bufferram/Bufferram/' \
880       -e 's/totalswap/Totalswap/' \
881       -e 's/freeswap/Freeswap/' \
882       -e 's/procs/Procs/' \
883       -e 's/totalhigh/Totalhigh/' \
884       -e 's/freehigh/Freehigh/' \
885       -e 's/mem_unit/Unit/' \
886     >> ${OUT}
887
888 # The ustat struct.
889 grep '^type _ustat ' gen-sysinfo.go | \
890     sed -e 's/_ustat/Ustat_t/' \
891       -e 's/f_tfree/Tfree/' \
892       -e 's/f_tinode/Tinoe/' \
893       -e 's/f_fname/Fname/' \
894       -e 's/f_fpack/Fpack/' \
895     >> ${OUT}
896
897 # The utimbuf struct.
898 grep '^type _utimbuf ' gen-sysinfo.go | \
899     sed -e 's/_utimbuf/Utimbuf/' \
900       -e 's/actime/Actime/' \
901       -e 's/modtime/Modtime/' \
902     >> ${OUT}
903
904 # The GNU/Linux LINUX_REBOOT flags.
905 grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
906     sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
907
908 # The GNU/Linux sock_filter struct.
909 grep '^type _sock_filter ' gen-sysinfo.go | \
910     sed -e 's/_sock_filter/SockFilter/' \
911       -e 's/code/Code/' \
912       -e 's/jt/Jt/' \
913       -e 's/jf/Jf/' \
914       -e 's/k /K /' \
915     >> ${OUT}
916
917 # The GNU/Linux sock_fprog struct.
918 grep '^type _sock_fprog ' gen-sysinfo.go | \
919     sed -e 's/_sock_fprog/SockFprog/' \
920       -e 's/len/Len/' \
921       -e 's/filter/Filter/' \
922       -e 's/_sock_filter/SockFilter/' \
923     >> ${OUT}
924
925 exit $?