2010-12-03 05:34:57 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# Create sysinfo.go.
|
|
|
|
|
|
|
|
# This shell script creates the sysinfo.go file which holds types and
|
|
|
|
# constants extracted from the system header files. This relies on a
|
2011-01-13 06:42:40 +01:00
|
|
|
# hook in gcc: the -fdump-go-spec option will generate debugging
|
|
|
|
# information in Go syntax.
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
# We currently #include all the files at once, which works, but leads
|
|
|
|
# to exposing some names which ideally should not be exposed, as they
|
|
|
|
# match grep patterns. E.g., WCHAR_MIN gets exposed because it starts
|
|
|
|
# with W, like the wait flags.
|
|
|
|
|
|
|
|
CC=${CC:-gcc}
|
|
|
|
OUT=tmp-sysinfo.go
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
rm -f sysinfo.c
|
|
|
|
cat > sysinfo.c <<EOF
|
|
|
|
#include "config.h"
|
2011-01-28 01:11:23 +01:00
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <netinet/in.h>
|
2011-04-01 01:55:21 +02:00
|
|
|
/* <netinet/tcp.h> needs u_char/u_short, but <sys/bsd_types> is only
|
|
|
|
included by <netinet/in.h> if _SGIAPI (i.e. _SGI_SOURCE
|
2011-09-28 15:14:11 +02:00
|
|
|
&& !_XOPEN_SOURCE.
|
|
|
|
<sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
|
|
|
|
<sys/ttold.h> does so unconditionally. */
|
2011-04-01 01:55:21 +02:00
|
|
|
#ifdef __sgi__
|
|
|
|
#include <sys/bsd_types.h>
|
2011-09-28 15:14:11 +02:00
|
|
|
#include <sys/ttold.h>
|
2011-04-01 01:55:21 +02:00
|
|
|
#endif
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <netinet/tcp.h>
|
2012-04-21 20:49:58 +02:00
|
|
|
#if defined(HAVE_NETINET_IN_SYSTM_H)
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_NETINET_IP_H)
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_NETINET_IP_MROUTE_H)
|
|
|
|
#include <netinet/ip_mroute.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_NETINET_IF_ETHER_H)
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
#endif
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <signal.h>
|
2011-09-16 17:47:21 +02:00
|
|
|
#include <sys/ioctl.h>
|
2011-09-23 17:29:17 +02:00
|
|
|
#include <termios.h>
|
2010-12-03 05:34:57 +01:00
|
|
|
#if defined(HAVE_SYSCALL_H)
|
|
|
|
#include <syscall.h>
|
|
|
|
#endif
|
2011-02-21 05:17:20 +01:00
|
|
|
#if defined(HAVE_SYS_SYSCALL_H)
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#endif
|
2010-12-03 05:34:57 +01:00
|
|
|
#if defined(HAVE_SYS_EPOLL_H)
|
|
|
|
#include <sys/epoll.h>
|
|
|
|
#endif
|
2012-04-21 20:49:58 +02:00
|
|
|
#if defined(HAVE_SYS_FILE_H)
|
|
|
|
#include <sys/file.h>
|
|
|
|
#endif
|
2011-04-07 19:09:10 +02:00
|
|
|
#if defined(HAVE_SYS_MMAN_H)
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
2012-01-25 21:56:26 +01:00
|
|
|
#if defined(HAVE_SYS_PRCTL_H)
|
|
|
|
#include <sys/prctl.h>
|
|
|
|
#endif
|
2010-12-03 05:34:57 +01:00
|
|
|
#if defined(HAVE_SYS_PTRACE_H)
|
|
|
|
#include <sys/ptrace.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/resource.h>
|
2011-01-27 01:03:51 +01:00
|
|
|
#include <sys/uio.h>
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
2012-02-02 07:40:11 +01:00
|
|
|
#include <sys/times.h>
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#if defined(HAVE_SYS_USER_H)
|
|
|
|
#include <sys/user.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_SYS_UTSNAME_H)
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#endif
|
2011-04-02 00:53:54 +02:00
|
|
|
#if defined(HAVE_SYS_SELECT_H)
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
2012-02-29 21:02:31 +01:00
|
|
|
#include <time.h>
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <unistd.h>
|
2011-05-20 02:18:15 +02:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <pwd.h>
|
2011-09-16 17:47:21 +02:00
|
|
|
#if defined(HAVE_LINUX_FILTER_H)
|
|
|
|
#include <linux/filter.h>
|
|
|
|
#endif
|
2012-04-21 20:49:58 +02:00
|
|
|
#if defined(HAVE_LINUX_IF_ADDR_H)
|
|
|
|
#include <linux/if_addr.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_LINUX_IF_ETHER_H)
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_LINUX_IF_TUN_H)
|
|
|
|
#include <linux/if_tun.h>
|
|
|
|
#endif
|
2011-09-16 17:47:21 +02:00
|
|
|
#if defined(HAVE_LINUX_NETLINK_H)
|
|
|
|
#include <linux/netlink.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_LINUX_RTNETLINK_H)
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_NET_IF_H)
|
|
|
|
#include <net/if.h>
|
|
|
|
#endif
|
2012-04-03 21:42:24 +02:00
|
|
|
#if defined(HAVE_NET_IF_ARP_H)
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
#endif
|
2012-04-21 20:49:58 +02:00
|
|
|
#if defined(HAVE_NET_ROUTE_H)
|
|
|
|
#include <net/route.h>
|
|
|
|
#endif
|
|
|
|
#if defined (HAVE_NETPACKET_PACKET_H)
|
|
|
|
#include <netpacket/packet.h>
|
|
|
|
#endif
|
2012-02-18 02:22:02 +01:00
|
|
|
#if defined(HAVE_SYS_MOUNT_H)
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_SYS_VFS_H)
|
|
|
|
#include <sys/vfs.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_STATFS_H)
|
|
|
|
#include <sys/statfs.h>
|
|
|
|
#endif
|
2012-02-29 21:02:31 +01:00
|
|
|
#if defined(HAVE_SYS_TIMEX_H)
|
|
|
|
#include <sys/timex.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_SYS_SYSINFO_H)
|
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_USTAT_H)
|
|
|
|
#include <ustat.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_UTIME_H)
|
|
|
|
#include <utime.h>
|
|
|
|
#endif
|
2012-04-04 20:50:09 +02:00
|
|
|
#if defined(HAVE_LINUX_ETHER_H)
|
|
|
|
#include <linux/ether.h>
|
|
|
|
#endif
|
2012-04-22 22:07:23 +02:00
|
|
|
#if defined(HAVE_LINUX_FS_H)
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#endif
|
2012-02-29 21:02:31 +01:00
|
|
|
#if defined(HAVE_LINUX_REBOOT_H)
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#endif
|
2012-04-21 20:49:58 +02:00
|
|
|
#if defined(HAVE_SYS_INOTIFY_H)
|
|
|
|
#include <sys/inotify.h>
|
|
|
|
#endif
|
2013-11-06 20:49:01 +01:00
|
|
|
#if defined(HAVE_NETINET_ICMP6_H)
|
|
|
|
#include <netinet/icmp6.h>
|
|
|
|
#endif
|
2014-05-07 23:48:29 +02:00
|
|
|
#if defined(HAVE_SCHED_H)
|
|
|
|
#include <sched.h>
|
|
|
|
#endif
|
2012-01-14 00:17:20 +01:00
|
|
|
|
|
|
|
/* Constants that may only be defined as expressions on some systems,
|
|
|
|
expressions too complex for -fdump-go-spec to handle. These are
|
|
|
|
handled specially below. */
|
|
|
|
enum {
|
|
|
|
#ifdef TIOCGWINSZ
|
|
|
|
TIOCGWINSZ_val = TIOCGWINSZ,
|
|
|
|
#endif
|
2014-10-28 19:18:39 +01:00
|
|
|
#ifdef TIOCSWINSZ
|
|
|
|
TIOCSWINSZ_val = TIOCSWINSZ,
|
|
|
|
#endif
|
2012-12-04 07:23:37 +01:00
|
|
|
#ifdef TIOCNOTTY
|
|
|
|
TIOCNOTTY_val = TIOCNOTTY,
|
|
|
|
#endif
|
|
|
|
#ifdef TIOCSCTTY
|
|
|
|
TIOCSCTTY_val = TIOCSCTTY,
|
|
|
|
#endif
|
2015-11-02 21:23:09 +01:00
|
|
|
#ifdef TIOCGPGRP
|
|
|
|
TIOCGPGRP_val = TIOCGPGRP,
|
|
|
|
#endif
|
2015-11-01 21:51:23 +01:00
|
|
|
#ifdef TIOCSPGRP
|
|
|
|
TIOCSPGRP_val = TIOCSPGRP,
|
|
|
|
#endif
|
2014-05-08 00:22:29 +02:00
|
|
|
#ifdef TIOCGPTN
|
|
|
|
TIOCGPTN_val = TIOCGPTN,
|
|
|
|
#endif
|
|
|
|
#ifdef TIOCSPTLCK
|
|
|
|
TIOCSPTLCK_val = TIOCSPTLCK,
|
|
|
|
#endif
|
|
|
|
#ifdef TIOCGDEV
|
|
|
|
TIOCGDEV_val = TIOCGDEV,
|
|
|
|
#endif
|
|
|
|
#ifdef TIOCSIG
|
|
|
|
TIOCSIG_val = TIOCSIG,
|
|
|
|
#endif
|
2014-10-28 19:18:39 +01:00
|
|
|
#ifdef TCGETS
|
|
|
|
TCGETS_val = TCGETS,
|
|
|
|
#endif
|
|
|
|
#ifdef TCSETS
|
|
|
|
TCSETS_val = TCSETS,
|
|
|
|
#endif
|
2015-07-25 02:01:04 +02:00
|
|
|
#ifdef TUNSETIFF
|
|
|
|
TUNSETIFF_val = TUNSETIFF,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETNOCSUM
|
|
|
|
TUNSETNOCSUM_val = TUNSETNOCSUM,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETDEBUG
|
|
|
|
TUNSETDEBUG_val = TUNSETDEBUG,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETPERSIST
|
|
|
|
TUNSETPERSIST_val = TUNSETPERSIST,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETOWNER
|
|
|
|
TUNSETOWNER_val = TUNSETOWNER,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETLINK
|
|
|
|
TUNSETLINK_val = TUNSETLINK,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETGROUP
|
|
|
|
TUNSETGROUP_val = TUNSETGROUP,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNGETFEATURES
|
|
|
|
TUNGETFEATURES_val = TUNGETFEATURES,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETOFFLOAD
|
|
|
|
TUNSETOFFLOAD_val = TUNSETOFFLOAD,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETTXFILTER
|
|
|
|
TUNSETTXFILTER_val = TUNSETTXFILTER,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNGETIFF
|
|
|
|
TUNGETIFF_val = TUNGETIFF,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNGETSNDBUF
|
|
|
|
TUNGETSNDBUF_val = TUNGETSNDBUF,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETSNDBUF
|
|
|
|
TUNSETSNDBUF_val = TUNSETSNDBUF,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNATTACHFILTER
|
|
|
|
TUNATTACHFILTER_val = TUNATTACHFILTER,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNDETACHFILTER
|
|
|
|
TUNDETACHFILTER_val = TUNDETACHFILTER,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNGETVNETHDRSZ
|
|
|
|
TUNGETVNETHDRSZ_val = TUNGETVNETHDRSZ,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETVNETHDRSZ
|
|
|
|
TUNSETVNETHDRSZ_val = TUNSETVNETHDRSZ,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETQUEUE
|
|
|
|
TUNSETQUEUE_val = TUNSETQUEUE,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNSETIFINDEX
|
|
|
|
TUNSETIFINDEX_val = TUNSETIFINDEX,
|
|
|
|
#endif
|
|
|
|
#ifdef TUNGETFILTER
|
|
|
|
TUNGETFILTER_val = TUNGETFILTER,
|
|
|
|
#endif
|
2015-12-18 02:15:37 +01:00
|
|
|
#ifdef NLA_HDRLEN
|
|
|
|
NLA_HDRLEN_val = NLA_HDRLEN,
|
|
|
|
#endif
|
2015-07-25 02:01:04 +02:00
|
|
|
|
2012-01-14 00:17:20 +01:00
|
|
|
};
|
2010-12-03 05:34:57 +01:00
|
|
|
EOF
|
|
|
|
|
2011-01-29 00:54:56 +01:00
|
|
|
${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
echo 'package syscall' > ${OUT}
|
2011-09-16 17:47:21 +02:00
|
|
|
echo 'import "unsafe"' >> ${OUT}
|
2011-09-26 23:49:08 +02:00
|
|
|
echo 'type _ unsafe.Pointer' >> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
# Get all the consts and types, skipping ones which could not be
|
|
|
|
# represented in Go and ones which we need to rewrite. We also skip
|
|
|
|
# function declarations, as we don't need them here. All the symbols
|
|
|
|
# will all have a leading underscore.
|
|
|
|
grep -v '^// ' gen-sysinfo.go | \
|
|
|
|
grep -v '^func' | \
|
|
|
|
grep -v '^type _timeval ' | \
|
2011-04-25 21:36:12 +02:00
|
|
|
grep -v '^type _timespec_t ' | \
|
|
|
|
grep -v '^type _timespec ' | \
|
2011-01-13 06:42:40 +01:00
|
|
|
grep -v '^type _timestruc_t ' | \
|
2010-12-03 05:34:57 +01:00
|
|
|
grep -v '^type _epoll_' | \
|
|
|
|
grep -v 'in6_addr' | \
|
|
|
|
grep -v 'sockaddr_in6' | \
|
|
|
|
sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
|
2011-04-25 21:36:12 +02:00
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
|
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
|
2011-01-13 06:42:40 +01:00
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
|
2010-12-03 05:34:57 +01:00
|
|
|
>> ${OUT}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
# The errno constants. These get type Errno.
|
|
|
|
echo '#include <errno.h>' | ${CC} -x c - -E -dM | \
|
|
|
|
egrep '#define E[A-Z0-9_]+ ' | \
|
|
|
|
sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
# The O_xxx flags.
|
2011-04-01 07:11:23 +02:00
|
|
|
egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
|
2010-12-03 05:34:57 +01:00
|
|
|
sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-01-13 06:42:40 +01:00
|
|
|
if ! grep '^const O_ASYNC' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const O_ASYNC = 0" >> ${OUT}
|
|
|
|
fi
|
2010-12-03 05:34:57 +01:00
|
|
|
if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const O_CLOEXEC = 0" >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2013-11-11 22:21:50 +01:00
|
|
|
# The os package requires F_DUPFD_CLOEXEC to be defined.
|
|
|
|
if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2012-08-21 07:29:30 +02:00
|
|
|
# These flags can be lost on i386 GNU/Linux when using
|
|
|
|
# -D_FILE_OFFSET_BITS=64, because we see "#define F_SETLK F_SETLK64"
|
|
|
|
# before we see the definition of F_SETLK64.
|
|
|
|
for flag in F_GETLK F_SETLK F_SETLKW; do
|
|
|
|
if ! grep "^const ${flag} " ${OUT} >/dev/null 2>&1 \
|
|
|
|
&& grep "^const ${flag}64 " ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const ${flag} = ${flag}64" >> ${OUT}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-06-07 00:37:27 +02:00
|
|
|
# The Flock_t struct for fcntl.
|
|
|
|
grep '^type _flock ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/type _flock/type Flock_t/' \
|
|
|
|
-e 's/l_type/Type/' \
|
|
|
|
-e 's/l_whence/Whence/' \
|
|
|
|
-e 's/l_start/Start/' \
|
|
|
|
-e 's/l_len/Len/' \
|
|
|
|
-e 's/l_pid/Pid/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# The signal numbers.
|
|
|
|
grep '^const _SIG[^_]' gen-sysinfo.go | \
|
|
|
|
grep -v '^const _SIGEV_' | \
|
2012-03-02 17:38:43 +01:00
|
|
|
sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = Signal(_\2)/' >> ${OUT}
|
2012-10-24 21:00:44 +02:00
|
|
|
if ! grep '^const SIGPOLL ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const SIGIO ' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const SIGPOLL = SIGIO" >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const SIGCHLD ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const SIGCLD = SIGCHLD" >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
# The syscall numbers. We force the names to upper case.
|
|
|
|
grep '^const _SYS_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
|
|
|
|
while read sys; do
|
|
|
|
sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
|
|
|
|
echo "const $sup = _$sys" >> ${OUT}
|
|
|
|
done
|
|
|
|
|
2012-04-30 18:04:17 +02:00
|
|
|
# The GNU/Linux support wants to use SYS_GETDENTS64 if available.
|
|
|
|
if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const SYS_GETDENTS = 0" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const SYS_GETDENTS64 ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const SYS_GETDENTS64 = 0" >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# Stat constants.
|
|
|
|
grep '^const _S_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-04-07 19:09:10 +02:00
|
|
|
|
|
|
|
# Mmap constants.
|
|
|
|
grep '^const _PROT_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(PROT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _MAP_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-03-01 18:22:29 +01:00
|
|
|
grep '^const _MADV_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-04-21 20:49:58 +02:00
|
|
|
grep '^const _MCL_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(MCL_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
# Process status constants.
|
|
|
|
grep '^const _W' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(W[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
# WSTOPPED was introduced in glibc 2.3.4.
|
|
|
|
if ! grep '^const _WSTOPPED = ' gen-sysinfo.go >/dev/null 2>&1; then
|
|
|
|
if grep '^const _WUNTRACED = ' gen-sysinfo.go > /dev/null 2>&1; then
|
|
|
|
echo 'const WSTOPPED = _WUNTRACED' >> ${OUT}
|
|
|
|
else
|
|
|
|
echo 'const WSTOPPED = 2' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
|
|
|
|
&& ! grep '^const _WALL = ' gen-sysinfo.go >/dev/null 2>&1; then
|
|
|
|
echo 'const WALL = ___WALL' >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Networking constants.
|
2012-04-04 20:50:09 +02:00
|
|
|
egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
|
2010-12-03 05:34:57 +01:00
|
|
|
sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _SOMAXCONN' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
|
|
|
|
>> ${OUT}
|
|
|
|
grep '^const _SHUT_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(SHUT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2011-12-13 23:25:30 +01:00
|
|
|
# The net package requires some const definitions.
|
2012-04-26 06:25:56 +02:00
|
|
|
for m in IP_PKTINFO IPV6_V6ONLY IPPROTO_IPV6 IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_TCLASS SO_REUSEPORT; do
|
2011-12-13 23:25:30 +01:00
|
|
|
if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const $m = 0" >> ${OUT}
|
|
|
|
fi
|
|
|
|
done
|
2013-01-29 21:52:43 +01:00
|
|
|
for m in SOCK_CLOEXEC SOCK_NONBLOCK; do
|
|
|
|
if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const $m = -1" >> ${OUT}
|
|
|
|
fi
|
|
|
|
done
|
2011-01-28 00:28:09 +01:00
|
|
|
|
2013-02-11 20:03:04 +01:00
|
|
|
# The syscall package requires AF_LOCAL.
|
|
|
|
if ! grep '^const AF_LOCAL ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const AF_UNIX ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const AF_LOCAL = AF_UNIX" >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# pathconf constants.
|
|
|
|
grep '^const __PC' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
|
|
|
|
|
2012-04-22 22:07:23 +02:00
|
|
|
# The PATH_MAX constant.
|
2012-04-24 21:12:26 +02:00
|
|
|
if grep '^const _PATH_MAX ' gen-sysinfo.go >/dev/null 2>&1; then
|
2012-04-22 22:07:23 +02:00
|
|
|
echo 'const PathMax = _PATH_MAX' >> ${OUT}
|
2012-04-24 21:12:26 +02:00
|
|
|
fi
|
2012-04-22 22:07:23 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
# epoll constants.
|
|
|
|
grep '^const _EPOLL' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-01-14 00:03:02 +01:00
|
|
|
# Make sure EPOLLRDHUP and EPOLL_CLOEXEC are defined.
|
2010-12-03 05:34:57 +01:00
|
|
|
if ! grep '^const EPOLLRDHUP' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const EPOLLRDHUP = 0x2000" >> ${OUT}
|
|
|
|
fi
|
2012-01-14 00:03:02 +01:00
|
|
|
if ! grep '^const EPOLL_CLOEXEC' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
|
|
|
|
fi
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2012-01-25 21:56:26 +01:00
|
|
|
# Prctl constants.
|
|
|
|
grep '^const _PR_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2011-10-23 21:04:37 +02:00
|
|
|
# Ptrace constants.
|
|
|
|
grep '^const _PTRACE' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
# We need some ptrace options that are not defined in older versions
|
|
|
|
# of glibc.
|
|
|
|
if ! grep '^const PTRACE_SETOPTIONS' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_SETOPTIONS = 0x4200" >> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACESYSGOOD' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACESYSGOOD = 0x1" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACEFORK' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACEFORK = 0x2" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACEVFORK' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACEVFORK = 0x4" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACECLONE' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACECLONE = 0x8" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACEEXEC' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACEEXEC = 0x10" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACEVFORKDONE' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACEVFORKDONE = 0x20" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_TRACEEXIT' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_TRACEEXIT = 0x40" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_O_MASK' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_O_MASK = 0x7f" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const _PTRACE_GETEVENTMSG' ${OUT} > /dev/null 2>&1; then
|
2012-01-26 02:08:20 +01:00
|
|
|
echo "const PTRACE_GETEVENTMSG = 0x4201" >> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_EVENT_FORK' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_EVENT_FORK = 1" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_EVENT_VFORK' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_EVENT_VFORK = 2" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_EVENT_CLONE' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_EVENT_CLONE = 3" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_EVENT_EXEC' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_EVENT_EXEC = 4" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_EVENT_VFORK_DONE' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_EVENT_VFORK_DONE = 5" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep '^const PTRACE_EVENT_EXIT' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const PTRACE_EVENT_EXIT = 6" >> ${OUT}
|
|
|
|
fi
|
2011-01-13 06:42:40 +01:00
|
|
|
if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then
|
2011-10-25 19:45:55 +02:00
|
|
|
echo "const _PTRACE_TRACEME = 0" >> ${OUT}
|
2011-01-13 06:42:40 +01:00
|
|
|
fi
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2014-11-04 23:39:30 +01:00
|
|
|
# A helper function that prints a structure from gen-sysinfo.go with the first
|
|
|
|
# letter of the field names in upper case. $1 is the name of structure. If $2
|
|
|
|
# is not empty, the structure or type is renamed to $2.
|
|
|
|
upcase_fields () {
|
|
|
|
name="$1"
|
|
|
|
def=`grep "^type $name" gen-sysinfo.go`
|
|
|
|
fields=`echo $def | sed -e 's/^[^{]*{\(.*\)}$/\1/'`
|
|
|
|
prefix=`echo $def | sed -e 's/{.*//'`
|
|
|
|
if test "$2" != ""; then
|
|
|
|
prefix=`echo $prefix | sed -e "s/$1/$2/"`
|
|
|
|
fi
|
|
|
|
if test "$fields" != ""; then
|
|
|
|
nfields=
|
|
|
|
while test -n "$fields"; do
|
|
|
|
field=`echo $fields | sed -e 's/^\([^;]*\);.*$/\1/'`
|
|
|
|
fields=`echo $fields | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
|
|
|
|
# capitalize the next character.
|
|
|
|
f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
|
|
|
|
r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
|
|
|
|
f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
|
|
|
|
field="$f$r"
|
|
|
|
nfields="$nfields $field;"
|
|
|
|
done
|
|
|
|
echo "${prefix} {$nfields }"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# The registers returned by PTRACE_GETREGS. This is probably
|
2011-01-13 06:42:40 +01:00
|
|
|
# GNU/Linux specific; it should do no harm if there is no
|
|
|
|
# _user_regs_struct.
|
2011-01-13 21:23:19 +01:00
|
|
|
regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
|
2015-09-23 22:43:46 +02:00
|
|
|
if test "$regs" = ""; then
|
2014-11-04 23:39:30 +01:00
|
|
|
# s390
|
|
|
|
regs=`grep '^type __user_regs_struct struct' gen-sysinfo.go || true`
|
|
|
|
if test "$regs" != ""; then
|
|
|
|
# Substructures of __user_regs_struct on s390
|
2014-11-06 17:44:32 +01:00
|
|
|
upcase_fields "__user_psw_struct" "PtracePsw" >> ${OUT} || true
|
|
|
|
upcase_fields "__user_fpregs_struct" "PtraceFpregs" >> ${OUT} || true
|
|
|
|
upcase_fields "__user_per_struct" "PtracePer" >> ${OUT} || true
|
2014-11-04 23:39:30 +01:00
|
|
|
fi
|
|
|
|
fi
|
2010-12-03 05:34:57 +01:00
|
|
|
if test "$regs" != ""; then
|
2014-11-04 23:39:30 +01:00
|
|
|
regs=`echo $regs |
|
|
|
|
sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'`
|
2010-12-03 05:34:57 +01:00
|
|
|
regs=`echo $regs | sed -e s'/^ *//'`
|
|
|
|
nregs=
|
|
|
|
while test -n "$regs"; do
|
|
|
|
field=`echo $regs | sed -e 's/^\([^;]*\);.*$/\1/'`
|
|
|
|
regs=`echo $regs | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
|
|
|
|
# Capitalize the first character of the field.
|
|
|
|
f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
|
|
|
|
r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
|
|
|
|
f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
|
|
|
|
field="$f$r"
|
2014-11-04 23:39:30 +01:00
|
|
|
field=`echo "$field" | sed \
|
|
|
|
-e 's/__user_psw_struct/PtracePsw/' \
|
|
|
|
-e 's/__user_fpregs_struct/PtraceFpregs/' \
|
|
|
|
-e 's/__user_per_struct/PtracePer/'`
|
2010-12-03 05:34:57 +01:00
|
|
|
nregs="$nregs $field;"
|
|
|
|
done
|
|
|
|
echo "type PtraceRegs struct {$nregs }" >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Some basic types.
|
|
|
|
echo 'type Size_t _size_t' >> ${OUT}
|
|
|
|
echo "type Ssize_t _ssize_t" >> ${OUT}
|
|
|
|
if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
|
|
|
|
echo "type Offset_t _off64_t" >> ${OUT}
|
|
|
|
else
|
|
|
|
echo "type Offset_t _off_t" >> ${OUT}
|
|
|
|
fi
|
|
|
|
echo "type Mode_t _mode_t" >> ${OUT}
|
|
|
|
echo "type Pid_t _pid_t" >> ${OUT}
|
|
|
|
echo "type Uid_t _uid_t" >> ${OUT}
|
|
|
|
echo "type Gid_t _gid_t" >> ${OUT}
|
|
|
|
echo "type Socklen_t _socklen_t" >> ${OUT}
|
|
|
|
|
2012-11-03 00:39:36 +01:00
|
|
|
# The C int type.
|
|
|
|
sizeof_int=`grep '^const ___SIZEOF_INT__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
|
|
|
|
if test "$sizeof_int" = "4"; then
|
|
|
|
echo "type _C_int int32" >> ${OUT}
|
2013-02-08 20:24:26 +01:00
|
|
|
echo "type _C_uint uint32" >> ${OUT}
|
2012-11-03 00:39:36 +01:00
|
|
|
elif test "$sizeof_int" = "8"; then
|
|
|
|
echo "type _C_int int64" >> ${OUT}
|
2013-02-08 20:24:26 +01:00
|
|
|
echo "type _C_uint uint64" >> ${OUT}
|
2012-11-03 00:39:36 +01:00
|
|
|
else
|
|
|
|
echo 1>&2 "mksysinfo.sh: could not determine size of int (got $sizeof_int)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# The C long type, needed because that is the type that ptrace returns.
|
2010-12-03 05:34:57 +01:00
|
|
|
sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
|
|
|
|
if test "$sizeof_long" = "4"; then
|
|
|
|
echo "type _C_long int32" >> ${OUT}
|
|
|
|
elif test "$sizeof_long" = "8"; then
|
|
|
|
echo "type _C_long int64" >> ${OUT}
|
|
|
|
else
|
|
|
|
echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-01-14 19:41:31 +01:00
|
|
|
# Solaris 2 needs _u?pad128_t, but its default definition in terms of long
|
|
|
|
# double is commented by -fdump-go-spec.
|
|
|
|
if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then
|
|
|
|
echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT}
|
|
|
|
fi
|
|
|
|
if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then
|
|
|
|
echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
# The time_t type.
|
|
|
|
if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then
|
|
|
|
echo 'type Time_t _time_t' >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# The time structures need special handling: we need to name the
|
|
|
|
# types, so that we can cast integers to the right types when
|
|
|
|
# assigning to the structures.
|
|
|
|
timeval=`grep '^type _timeval ' gen-sysinfo.go`
|
|
|
|
timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
|
|
|
|
timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'`
|
|
|
|
echo "type Timeval_sec_t $timeval_sec" >> ${OUT}
|
|
|
|
echo "type Timeval_usec_t $timeval_usec" >> ${OUT}
|
|
|
|
echo $timeval | \
|
|
|
|
sed -e 's/type _timeval /type Timeval /' \
|
|
|
|
-e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \
|
|
|
|
-e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT}
|
2011-04-01 01:55:21 +02:00
|
|
|
timespec=`grep '^type _timespec ' gen-sysinfo.go || true`
|
|
|
|
if test "$timespec" = ""; then
|
|
|
|
# IRIX 6.5 has __timespec instead.
|
|
|
|
timespec=`grep '^type ___timespec ' gen-sysinfo.go || true`
|
|
|
|
fi
|
2010-12-03 05:34:57 +01:00
|
|
|
timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
|
|
|
|
timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
|
|
|
|
echo "type Timespec_sec_t $timespec_sec" >> ${OUT}
|
|
|
|
echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT}
|
|
|
|
echo $timespec | \
|
2011-04-25 21:36:12 +02:00
|
|
|
sed -e 's/^type ___timespec /type Timespec /' \
|
|
|
|
-e 's/^type _timespec /type Timespec /' \
|
2010-12-03 05:34:57 +01:00
|
|
|
-e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
|
|
|
|
-e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
|
|
|
|
|
2011-01-13 06:42:40 +01:00
|
|
|
timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true`
|
|
|
|
if test "$timestruc" != ""; then
|
|
|
|
timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
|
|
|
|
timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
|
|
|
|
echo "type Timestruc_sec_t $timestruc_sec" >> ${OUT}
|
|
|
|
echo "type Timestruc_nsec_t $timestruc_nsec" >> ${OUT}
|
|
|
|
echo $timestruc | \
|
|
|
|
sed -e 's/^type _timestruc_t /type Timestruc /' \
|
|
|
|
-e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timestruc_sec_t/' \
|
|
|
|
-e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2012-02-02 07:40:11 +01:00
|
|
|
# The tms struct.
|
|
|
|
grep '^type _tms ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/type _tms/type Tms/' \
|
|
|
|
-e 's/tms_utime/Utime/' \
|
|
|
|
-e 's/tms_stime/Stime/' \
|
|
|
|
-e 's/tms_cutime/Cutime/' \
|
|
|
|
-e 's/tms_cstime/Cstime/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# The stat type.
|
2011-02-21 05:17:20 +01:00
|
|
|
# Prefer largefile variant if available.
|
|
|
|
stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
|
|
|
|
if test "$stat" != ""; then
|
|
|
|
grep '^type _stat64 ' gen-sysinfo.go
|
|
|
|
else
|
|
|
|
grep '^type _stat ' gen-sysinfo.go
|
2011-04-01 07:11:23 +02:00
|
|
|
fi | sed -e 's/type _stat64/type Stat_t/' \
|
|
|
|
-e 's/type _stat/type Stat_t/' \
|
2011-02-21 05:17:20 +01:00
|
|
|
-e 's/st_dev/Dev/' \
|
|
|
|
-e 's/st_ino/Ino/g' \
|
|
|
|
-e 's/st_nlink/Nlink/' \
|
|
|
|
-e 's/st_mode/Mode/' \
|
|
|
|
-e 's/st_uid/Uid/' \
|
|
|
|
-e 's/st_gid/Gid/' \
|
|
|
|
-e 's/st_rdev/Rdev/' \
|
|
|
|
-e 's/st_size/Size/' \
|
|
|
|
-e 's/st_blksize/Blksize/' \
|
|
|
|
-e 's/st_blocks/Blocks/' \
|
2012-04-22 22:07:23 +02:00
|
|
|
-e 's/st_atim/Atim/' \
|
|
|
|
-e 's/st_mtim/Mtim/' \
|
|
|
|
-e 's/st_ctim/Ctim/' \
|
2011-02-21 05:17:20 +01:00
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
|
2011-04-25 21:36:12 +02:00
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
|
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
|
2011-02-21 05:17:20 +01:00
|
|
|
-e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
|
2011-05-31 20:06:47 +02:00
|
|
|
-e 's/Godump_[0-9] struct { \([^;]*;\) };/\1/g' \
|
2011-02-21 05:17:20 +01:00
|
|
|
>> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
# The directory searching types.
|
2011-02-21 05:17:20 +01:00
|
|
|
# Prefer largefile variant if available.
|
|
|
|
dirent=`grep '^type _dirent64 ' gen-sysinfo.go || true`
|
|
|
|
if test "$dirent" != ""; then
|
|
|
|
grep '^type _dirent64 ' gen-sysinfo.go
|
|
|
|
else
|
|
|
|
grep '^type _dirent ' gen-sysinfo.go
|
2011-04-01 07:11:23 +02:00
|
|
|
fi | sed -e 's/type _dirent64/type Dirent/' \
|
|
|
|
-e 's/type _dirent/type Dirent/' \
|
2011-02-21 05:17:20 +01:00
|
|
|
-e 's/d_name \[0+1\]/d_name [0+256]/' \
|
|
|
|
-e 's/d_name/Name/' \
|
|
|
|
-e 's/]int8/]byte/' \
|
|
|
|
-e 's/d_ino/Ino/' \
|
|
|
|
-e 's/d_off/Off/' \
|
|
|
|
-e 's/d_reclen/Reclen/' \
|
|
|
|
-e 's/d_type/Type/' \
|
|
|
|
>> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
echo "type DIR _DIR" >> ${OUT}
|
|
|
|
|
2012-04-04 20:50:09 +02:00
|
|
|
# Values for d_type field in dirent.
|
|
|
|
grep '^const _DT_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(DT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# The rusage struct.
|
|
|
|
rusage=`grep '^type _rusage struct' gen-sysinfo.go`
|
|
|
|
if test "$rusage" != ""; then
|
2012-06-05 07:32:54 +02:00
|
|
|
# Remove anonymous unions from GNU/Linux <bits/resource.h>.
|
2014-11-04 23:39:30 +01:00
|
|
|
rusage=`echo $rusage | sed -e 's/Godump_[0-9][0-9]* struct {\([^}]*\)};/\1/g'`
|
2012-07-09 13:13:49 +02:00
|
|
|
rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
|
|
|
|
rusage=`echo $rusage | sed -e 's/^ *//'`
|
2010-12-03 05:34:57 +01:00
|
|
|
nrusage=
|
|
|
|
while test -n "$rusage"; do
|
|
|
|
field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
|
|
|
|
rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
|
|
|
|
# Drop the leading ru_, capitalize the next character.
|
|
|
|
field=`echo $field | sed -e 's/^ru_//'`
|
|
|
|
f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
|
|
|
|
r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
|
|
|
|
f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
|
2011-01-13 06:42:40 +01:00
|
|
|
# Fix _timeval _timespec, and _timestruc_t.
|
2010-12-03 05:34:57 +01:00
|
|
|
r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
|
|
|
|
r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
|
2011-01-13 06:42:40 +01:00
|
|
|
r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
|
2010-12-03 05:34:57 +01:00
|
|
|
field="$f$r"
|
|
|
|
nrusage="$nrusage $field;"
|
|
|
|
done
|
|
|
|
echo "type Rusage struct {$nrusage }" >> ${OUT}
|
2011-03-31 01:05:04 +02:00
|
|
|
else
|
|
|
|
echo "type Rusage struct {}" >> ${OUT}
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
|
2011-05-20 02:18:15 +02:00
|
|
|
# The RUSAGE constants.
|
|
|
|
grep '^const _RUSAGE_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RUSAGE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
# The utsname struct.
|
|
|
|
grep '^type _utsname ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_utsname/Utsname/' \
|
|
|
|
-e 's/sysname/Sysname/' \
|
|
|
|
-e 's/nodename/Nodename/' \
|
|
|
|
-e 's/release/Release/' \
|
|
|
|
-e 's/version/Version/' \
|
|
|
|
-e 's/machine/Machine/' \
|
|
|
|
-e 's/domainname/Domainname/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-01-21 19:19:03 +01:00
|
|
|
# The iovec struct.
|
|
|
|
iovec=`grep '^type _iovec ' gen-sysinfo.go`
|
|
|
|
iovec_len=`echo $iovec | sed -n -e 's/^.*iov_len \([^ ]*\);.*$/\1/p'`
|
|
|
|
echo "type Iovec_len_t $iovec_len" >> ${OUT}
|
|
|
|
echo $iovec | \
|
|
|
|
sed -e 's/_iovec/Iovec/' \
|
|
|
|
-e 's/iov_base/Base/' \
|
|
|
|
-e 's/iov_len *[a-zA-Z0-9_]*/Len Iovec_len_t/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The msghdr struct.
|
|
|
|
msghdr=`grep '^type _msghdr ' gen-sysinfo.go`
|
|
|
|
msghdr_controllen=`echo $msghdr | sed -n -e 's/^.*msg_controllen \([^ ]*\);.*$/\1/p'`
|
|
|
|
echo "type Msghdr_controllen_t $msghdr_controllen" >> ${OUT}
|
|
|
|
echo $msghdr | \
|
|
|
|
sed -e 's/_msghdr/Msghdr/' \
|
|
|
|
-e 's/msg_name/Name/' \
|
|
|
|
-e 's/msg_namelen/Namelen/' \
|
|
|
|
-e 's/msg_iov/Iov/' \
|
|
|
|
-e 's/msg_iovlen/Iovlen/' \
|
|
|
|
-e 's/_iovec/Iovec/' \
|
|
|
|
-e 's/msg_control/Control/' \
|
|
|
|
-e 's/msg_controllen *[a-zA-Z0-9_]*/Controllen Msghdr_controllen_t/' \
|
|
|
|
-e 's/msg_flags/Flags/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2012-01-31 00:57:42 +01:00
|
|
|
# The MSG_ flags for Msghdr.
|
|
|
|
grep '^const _MSG_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(MSG_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
|
|
|
# The cmsghdr struct.
|
|
|
|
cmsghdr=`grep '^type _cmsghdr ' gen-sysinfo.go`
|
|
|
|
if test -n "$cmsghdr"; then
|
|
|
|
cmsghdr_len=`echo $cmsghdr | sed -n -e 's/^.*cmsg_len \([^ ]*\);.*$/\1/p'`
|
|
|
|
echo "type Cmsghdr_len_t $cmsghdr_len" >> ${OUT}
|
|
|
|
echo "$cmsghdr" | \
|
|
|
|
sed -e 's/_cmsghdr/Cmsghdr/' \
|
|
|
|
-e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
|
|
|
|
-e 's/cmsg_level/Level/' \
|
|
|
|
-e 's/cmsg_type/Type/' \
|
2012-02-03 02:06:19 +01:00
|
|
|
-e 's/\[\]/[0]/' \
|
2012-01-31 00:57:42 +01:00
|
|
|
>> ${OUT}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# The SCM_ flags for Cmsghdr.
|
|
|
|
grep '^const _SCM_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
|
|
|
# The ucred struct.
|
2014-11-06 17:44:32 +01:00
|
|
|
upcase_fields "_ucred" "Ucred" >> ${OUT} || true
|
2012-01-31 00:57:42 +01:00
|
|
|
|
2011-10-27 01:57:58 +02:00
|
|
|
# The ip_mreq struct.
|
2011-03-17 00:05:44 +01:00
|
|
|
grep '^type _ip_mreq ' gen-sysinfo.go | \
|
2011-09-16 17:47:21 +02:00
|
|
|
sed -e 's/_ip_mreq/IPMreq/' \
|
2011-03-17 00:05:44 +01:00
|
|
|
-e 's/imr_multiaddr/Multiaddr/' \
|
|
|
|
-e 's/imr_interface/Interface/' \
|
|
|
|
-e 's/_in_addr/[4]byte/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-12-13 23:25:30 +01:00
|
|
|
# We need IPMreq to compile the net package.
|
|
|
|
if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT}
|
2011-10-23 21:04:37 +02:00
|
|
|
fi
|
|
|
|
|
2011-10-27 01:57:58 +02:00
|
|
|
# The ipv6_mreq struct.
|
|
|
|
grep '^type _ipv6_mreq ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_ipv6_mreq/IPv6Mreq/' \
|
|
|
|
-e 's/ipv6mr_multiaddr/Multiaddr/' \
|
|
|
|
-e 's/ipv6mr_interface/Interface/' \
|
|
|
|
-e 's/_in6_addr/[16]byte/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-12-13 23:25:30 +01:00
|
|
|
# We need IPv6Mreq to compile the net package.
|
|
|
|
if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2012-01-25 21:56:26 +01:00
|
|
|
# The ip_mreqn struct.
|
|
|
|
grep '^type _ip_mreqn ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_ip_mreqn/IPMreqn/' \
|
|
|
|
-e 's/imr_multiaddr/Multiaddr/' \
|
|
|
|
-e 's/imr_address/Address/' \
|
|
|
|
-e 's/imr_ifindex/Ifindex/' \
|
|
|
|
-e 's/_in_addr/[4]byte/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# We need IPMreq to compile the net package.
|
|
|
|
if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2013-11-06 20:49:01 +01:00
|
|
|
# The icmp6_filter struct.
|
|
|
|
grep '^type _icmp6_filter ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_icmp6_filter/ICMPv6Filter/' \
|
|
|
|
-e 's/data/Data/' \
|
|
|
|
-e 's/filt/Filt/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# We need ICMPv6Filter to compile the syscall package.
|
|
|
|
if ! grep 'type ICMPv6Filter ' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT}
|
|
|
|
fi
|
|
|
|
|
2016-02-26 18:36:00 +01:00
|
|
|
# The ip6_mtuinfo struct.
|
|
|
|
grep '^type _ip6_mtuinfo ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_ip6_mtuinfo/IPv6MTUInfo/' \
|
|
|
|
-e 's/ip6m_addr/Addr/' \
|
|
|
|
-e 's/_sockaddr_in6/RawSockaddrInet6/' \
|
|
|
|
-e 's/ip6m_mtu/Mtu/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-04-02 00:53:54 +02:00
|
|
|
# Try to guess the type to use for fd_set.
|
|
|
|
fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
|
|
|
|
fds_bits_type="_C_long"
|
|
|
|
if test "$fd_set" != ""; then
|
|
|
|
fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'`
|
|
|
|
fi
|
|
|
|
echo "type fds_bits_type $fds_bits_type" >> ${OUT}
|
|
|
|
|
2011-05-20 02:18:15 +02:00
|
|
|
# The addrinfo struct.
|
|
|
|
grep '^type _addrinfo ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_addrinfo/Addrinfo/g' \
|
|
|
|
-e 's/ ai_/ Ai_/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2015-10-31 01:59:47 +01:00
|
|
|
# The addrinfo and nameinfo flags and errors.
|
2011-05-20 02:18:15 +02:00
|
|
|
grep '^const _AI_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(AI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-12-13 00:40:51 +01:00
|
|
|
grep '^const _EAI_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(EAI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2015-10-31 01:59:47 +01:00
|
|
|
grep '^const _NI_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(NI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-05-20 02:18:15 +02:00
|
|
|
|
|
|
|
# The passwd struct.
|
|
|
|
grep '^type _passwd ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_passwd/Passwd/' \
|
|
|
|
-e 's/ pw_/ Pw_/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-09-16 17:47:21 +02:00
|
|
|
# The ioctl flags for the controlling TTY.
|
|
|
|
grep '^const _TIOC' gen-sysinfo.go | \
|
2012-01-14 00:17:20 +01:00
|
|
|
grep -v '_val =' | \
|
2011-09-16 17:47:21 +02:00
|
|
|
sed -e 's/^\(const \)_\(TIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2015-07-25 02:01:04 +02:00
|
|
|
grep '^const _TUNSET' gen-sysinfo.go | \
|
|
|
|
grep -v '_val =' | \
|
|
|
|
sed -e 's/^\(const \)_\(TUNSET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-01-14 00:17:20 +01:00
|
|
|
# We need TIOCGWINSZ.
|
|
|
|
if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then
|
2012-01-17 15:13:33 +01:00
|
|
|
echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT}
|
2012-01-14 00:17:20 +01:00
|
|
|
fi
|
|
|
|
fi
|
2014-10-28 19:18:39 +01:00
|
|
|
if ! grep '^const TIOCSWINSZ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCSWINSZ_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCSWINSZ = _TIOCSWINSZ_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2012-12-04 07:23:37 +01:00
|
|
|
if ! grep '^const TIOCNOTTY' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCNOTTY_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCNOTTY = _TIOCNOTTY_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! grep '^const TIOCSCTTY' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCSCTTY_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCSCTTY = _TIOCSCTTY_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2015-11-02 21:23:09 +01:00
|
|
|
if ! grep '^const TIOCGPGRP' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCGPGRP_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCGPGRP = _TIOCGPGRP_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2015-11-01 21:51:23 +01:00
|
|
|
if ! grep '^const TIOCSPGRP' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCSPGRP_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCSPGRP = _TIOCSPGRP_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2014-05-08 00:22:29 +02:00
|
|
|
if ! grep '^const TIOCGPTN' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCGPTN_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCGPTN = _TIOCGPTN_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! grep '^const TIOCSPTLCK' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCSPTLCK_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCSPTLCK = _TIOCSPTLCK_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! grep '^const TIOCGDEV' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCGDEV_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCGDEV = _TIOCGDEV_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! grep '^const TIOCSIG' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCSIG_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TIOCSIG = _TIOCSIG_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-16 17:47:21 +02:00
|
|
|
|
2015-07-25 02:01:04 +02:00
|
|
|
if ! grep '^const TUNSETNOCSUM' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETNOCSUM_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETNOCSUM = _TUNSETNOCSUM_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETDEBUG' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETDEBUG_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETDEBUG = _TUNSETDEBUG_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETIFF' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETIFF_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETIFF = _TUNSETIFF_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETPERSIST' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETPERSIST_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETPERSIST = _TUNSETPERSIST_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETOWNER' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETOWNER_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETOWNER = _TUNSETOWNER_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETLINK' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETLINK_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETLINK = _TUNSETLINK_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETGROUP' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETGROUP_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETGROUP = _TUNSETGROUP_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNGETFEATURES' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNGETFEATURES_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNGETFEATURES = _TUNGETFEATURES_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETOFFLOAD' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETOFFLOAD_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETOFFLOAD = _TUNSETOFFLOAD_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETTXFILTER' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETTXFILTER_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETTXFILTER = _TUNSETTXFILTER_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNGETIFF' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNGETIFF_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNGETIFF = _TUNGETIFF_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNGETSNDBUF' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNGETSNDBUF_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNGETSNDBUF = _TUNGETSNDBUF_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETSNDBUF' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETSNDBUF_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETSNDBUF = _TUNSETSNDBUF_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNATTACHFILTER' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNATTACHFILTER_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNATTACHFILTER = _TUNATTACHFILTER_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNDETACHFILTER' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNDETACHFILTER_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNDETACHFILTER = _TUNDETACHFILTER_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-07-29 23:42:30 +02:00
|
|
|
if ! grep '^const TUNGETVNETHDRSZ' ${OUT} >/dev/null 2>&1; then
|
2015-07-25 02:01:04 +02:00
|
|
|
if grep '^const _TUNGETVNETHDRSZ_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNGETVNETHDRSZ = _TUNGETVNETHDRSZ_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-07-29 23:42:30 +02:00
|
|
|
if ! grep '^const TUNSETVNETHDRSZ' ${OUT} >/dev/null 2>&1; then
|
2015-07-25 02:01:04 +02:00
|
|
|
if grep '^const _TUNSETVNETHDRSZ_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETVNETHDRSZ = _TUNSETVNETHDRSZ_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-07-29 23:42:30 +02:00
|
|
|
if ! grep '^const TUNSETQUEUE' ${OUT} >/dev/null 2>&1; then
|
2015-07-25 02:01:04 +02:00
|
|
|
if grep '^const _TUNSETQUEUE_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETQUEUE = _TUNSETQUEUE_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! grep '^const TUNSETIFINDEX' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNSETIFINDEX_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNSETIFINDEX = _TUNSETIFINDEX_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep '^const TUNGETFILTER' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TUNGETFILTER_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TUNGETFILTER = _TUNGETFILTER_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-10-27 01:57:58 +02:00
|
|
|
# The ioctl flags for terminal control
|
2014-10-28 19:18:39 +01:00
|
|
|
grep '^const _TC[GS]ET' gen-sysinfo.go | grep -v _val | \
|
2011-10-27 01:57:58 +02:00
|
|
|
sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2014-10-28 19:18:39 +01:00
|
|
|
if ! grep '^const TCGETS' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TCGETS_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TCGETS = _TCGETS_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if ! grep '^const TCSETS' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TCSETS_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const TCSETS = _TCSETS_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
2011-10-27 01:57:58 +02:00
|
|
|
|
2011-09-27 15:16:22 +02:00
|
|
|
# ioctl constants. Might fall back to 0 if TIOCNXCL is missing, too, but
|
|
|
|
# needs handling in syscalls.exec.go.
|
|
|
|
if ! grep '^const _TIOCSCTTY ' gen-sysinfo.go >/dev/null 2>&1; then
|
|
|
|
if grep '^const _TIOCNXCL ' gen-sysinfo.go >/dev/null 2>&1; then
|
|
|
|
echo "const TIOCSCTTY = TIOCNXCL" >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-09-16 17:47:21 +02:00
|
|
|
# The nlmsghdr struct.
|
|
|
|
grep '^type _nlmsghdr ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_nlmsghdr/NlMsghdr/' \
|
|
|
|
-e 's/nlmsg_len/Len/' \
|
|
|
|
-e 's/nlmsg_type/Type/' \
|
|
|
|
-e 's/nlmsg_flags/Flags/' \
|
|
|
|
-e 's/nlmsg_seq/Seq/' \
|
|
|
|
-e 's/nlmsg_pid/Pid/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The nlmsg flags and operators.
|
|
|
|
grep '^const _NLM' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(NLM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
|
|
|
# NLMSG_HDRLEN is defined as an expression using sizeof.
|
|
|
|
if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then
|
2012-04-22 20:51:44 +02:00
|
|
|
if grep '^const _sizeof_nlmsghdr ' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo 'const NLMSG_HDRLEN = (_sizeof_nlmsghdr + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1)' >> ${OUT}
|
2011-09-16 17:47:21 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-10-23 21:04:37 +02:00
|
|
|
# The rtmsg struct.
|
|
|
|
grep '^type _rtmsg ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_rtmsg/RtMsg/' \
|
|
|
|
-e 's/rtm_family/Family/' \
|
|
|
|
-e 's/rtm_dst_len/Dst_len/' \
|
|
|
|
-e 's/rtm_src_len/Src_len/' \
|
|
|
|
-e 's/rtm_tos/Tos/' \
|
|
|
|
-e 's/rtm_table/Table/' \
|
2012-04-21 20:49:58 +02:00
|
|
|
-e 's/rtm_protocol/Protocol/' \
|
2011-10-23 21:04:37 +02:00
|
|
|
-e 's/rtm_scope/Scope/' \
|
|
|
|
-e 's/rtm_type/Type/' \
|
|
|
|
-e 's/rtm_flags/Flags/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-09-16 17:47:21 +02:00
|
|
|
# The rtgenmsg struct.
|
|
|
|
grep '^type _rtgenmsg ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_rtgenmsg/RtGenmsg/' \
|
|
|
|
-e 's/rtgen_family/Family/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The routing message flags.
|
2012-04-21 20:49:58 +02:00
|
|
|
grep '^const _RT_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-09-16 17:47:21 +02:00
|
|
|
grep '^const _RTA' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-04-03 21:42:24 +02:00
|
|
|
grep '^const _RTF' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RTF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _RTCF' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-09-16 17:47:21 +02:00
|
|
|
grep '^const _RTM' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-04-21 20:49:58 +02:00
|
|
|
grep '^const _RTN' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RTN[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _RTPROT' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(RTPROT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-09-16 17:47:21 +02:00
|
|
|
|
|
|
|
# The ifinfomsg struct.
|
|
|
|
grep '^type _ifinfomsg ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_ifinfomsg/IfInfomsg/' \
|
|
|
|
-e 's/ifi_family/Family/' \
|
|
|
|
-e 's/ifi_type/Type/' \
|
|
|
|
-e 's/ifi_index/Index/' \
|
|
|
|
-e 's/ifi_flags/Flags/' \
|
|
|
|
-e 's/ifi_change/Change/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The interface information types and flags.
|
|
|
|
grep '^const _IFA' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _IFLA' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(IFLA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _IFF' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(IFF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-02-29 21:02:31 +01:00
|
|
|
grep '^const _IFNAMSIZ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(IFNAMSIZ[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
grep '^const _SIOC' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2011-09-16 17:47:21 +02:00
|
|
|
|
|
|
|
# The ifaddrmsg struct.
|
|
|
|
grep '^type _ifaddrmsg ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_ifaddrmsg/IfAddrmsg/' \
|
|
|
|
-e 's/ifa_family/Family/' \
|
|
|
|
-e 's/ifa_prefixlen/Prefixlen/' \
|
|
|
|
-e 's/ifa_flags/Flags/' \
|
|
|
|
-e 's/ifa_scope/Scope/' \
|
|
|
|
-e 's/ifa_index/Index/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The rtattr struct.
|
|
|
|
grep '^type _rtattr ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_rtattr/RtAttr/' \
|
|
|
|
-e 's/rta_len/Len/' \
|
|
|
|
-e 's/rta_type/Type/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2012-04-22 21:26:01 +02:00
|
|
|
# The in_pktinfo struct.
|
|
|
|
grep '^type _in_pktinfo ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in_pktinfo/Inet4Pktinfo/' \
|
|
|
|
-e 's/ipi_ifindex/Ifindex/' \
|
|
|
|
-e 's/ipi_spec_dst/Spec_dst/' \
|
|
|
|
-e 's/ipi_addr/Addr/' \
|
2012-04-22 22:07:23 +02:00
|
|
|
-e 's/_in_addr/[4]byte/g' \
|
2012-04-22 21:26:01 +02:00
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The in6_pktinfo struct.
|
|
|
|
grep '^type _in6_pktinfo ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in6_pktinfo/Inet6Pktinfo/' \
|
|
|
|
-e 's/ipi6_addr/Addr/' \
|
|
|
|
-e 's/ipi6_ifindex/Ifindex/' \
|
|
|
|
-e 's/_in6_addr/[16]byte/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-10-27 01:57:58 +02:00
|
|
|
# The termios struct.
|
|
|
|
grep '^type _termios ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_termios/Termios/' \
|
|
|
|
-e 's/c_iflag/Iflag/' \
|
|
|
|
-e 's/c_oflag/Oflag/' \
|
|
|
|
-e 's/c_cflag/Cflag/' \
|
|
|
|
-e 's/c_lflag/Lflag/' \
|
|
|
|
-e 's/c_line/Line/' \
|
|
|
|
-e 's/c_cc/Cc/' \
|
|
|
|
-e 's/c_ispeed/Ispeed/' \
|
|
|
|
-e 's/c_ospeed/Ospeed/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
# The termios constants.
|
2011-10-27 01:57:58 +02:00
|
|
|
for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
|
|
|
|
IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
|
2012-04-04 20:50:09 +02:00
|
|
|
OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 CS5 CS6 CS7 CS8 TABDLY \
|
|
|
|
BSDLY VTDLY FFDLY CBAUD CBAUDEX CSIZE CSTOPB CREAD PARENB PARODD HUPCL \
|
|
|
|
CLOCAL LOBLK CIBAUD CMSPAR CRTSCTS ISIG ICANON XCASE ECHO ECHOE ECHOK \
|
|
|
|
ECHONL ECHOCTL ECHOPRT ECHOKE DEFECHO FLUSHO NOFLSH TOSTOP PENDIN IEXTEN \
|
|
|
|
VINTR VQUIT VERASE VKILL VEOF VMIN VEOL VTIME VEOL2 VSWTCH VSTART VSTOP \
|
|
|
|
VSUSP VDSUSP VLNEXT VWERASE VREPRINT VDISCARD VSTATUS TCSANOW TCSADRAIN \
|
2011-12-13 00:40:51 +01:00
|
|
|
TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \
|
|
|
|
B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \
|
2012-04-04 20:50:09 +02:00
|
|
|
B38400 B57600 B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \
|
2012-04-22 22:07:23 +02:00
|
|
|
B1152000 B1500000 B2000000 B2500000 B3000000 B3500000 B4000000; do
|
2011-10-27 01:57:58 +02:00
|
|
|
|
|
|
|
grep "^const _$n " gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
done
|
|
|
|
|
2012-02-18 02:22:02 +01:00
|
|
|
# The mount flags
|
2012-04-21 20:49:58 +02:00
|
|
|
grep '^const _MNT_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(MNT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-02-18 02:22:02 +01:00
|
|
|
grep '^const _MS_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
|
|
|
# The fallocate flags.
|
|
|
|
grep '^const _FALLOC_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
|
|
|
# The statfs struct.
|
|
|
|
# Prefer largefile variant if available.
|
|
|
|
statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
|
|
|
|
if test "$statfs" != ""; then
|
|
|
|
grep '^type _statfs64 ' gen-sysinfo.go
|
|
|
|
else
|
|
|
|
grep '^type _statfs ' gen-sysinfo.go
|
|
|
|
fi | sed -e 's/type _statfs64/type Statfs_t/' \
|
|
|
|
-e 's/type _statfs/type Statfs_t/' \
|
|
|
|
-e 's/f_type/Type/' \
|
|
|
|
-e 's/f_bsize/Bsize/' \
|
|
|
|
-e 's/f_blocks/Blocks/' \
|
|
|
|
-e 's/f_bfree/Bfree/' \
|
|
|
|
-e 's/f_bavail/Bavail/' \
|
|
|
|
-e 's/f_files/Files/' \
|
|
|
|
-e 's/f_ffree/Ffree/' \
|
|
|
|
-e 's/f_fsid/Fsid/' \
|
|
|
|
-e 's/f_namelen/Namelen/' \
|
|
|
|
-e 's/f_frsize/Frsize/' \
|
|
|
|
-e 's/f_flags/Flags/' \
|
|
|
|
-e 's/f_spare/Spare/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
# The timex struct.
|
2012-03-13 21:56:23 +01:00
|
|
|
timex=`grep '^type _timex ' gen-sysinfo.go || true`
|
|
|
|
if test "$timex" = ""; then
|
|
|
|
timex=`grep '^// type _timex ' gen-sysinfo.go || true`
|
|
|
|
if test "$timex" != ""; then
|
|
|
|
timex=`echo $timex | sed -e 's|// ||' -e 's/INVALID-bit-field/int32/g'`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if test "$timex" != ""; then
|
|
|
|
echo "$timex" | \
|
2012-02-29 21:02:31 +01:00
|
|
|
sed -e 's/_timex/Timex/' \
|
|
|
|
-e 's/modes/Modes/' \
|
|
|
|
-e 's/offset/Offset/' \
|
|
|
|
-e 's/freq/Freq/' \
|
|
|
|
-e 's/maxerror/Maxerror/' \
|
|
|
|
-e 's/esterror/Esterror/' \
|
|
|
|
-e 's/status/Status/' \
|
|
|
|
-e 's/constant/Constant/' \
|
|
|
|
-e 's/precision/Precision/' \
|
|
|
|
-e 's/tolerance/Tolerance/' \
|
|
|
|
-e 's/ time / Time /' \
|
|
|
|
-e 's/tick/Tick/' \
|
|
|
|
-e 's/ppsfreq/Ppsfreq/' \
|
|
|
|
-e 's/jitter/Jitter/' \
|
|
|
|
-e 's/shift/Shift/' \
|
|
|
|
-e 's/stabil/Stabil/' \
|
|
|
|
-e 's/jitcnt/Jitcnt/' \
|
|
|
|
-e 's/calcnt/Calcnt/' \
|
|
|
|
-e 's/errcnt/Errcnt/' \
|
|
|
|
-e 's/stbcnt/Stbcnt/' \
|
|
|
|
-e 's/tai/Tai/' \
|
|
|
|
-e 's/_timeval/Timeval/' \
|
|
|
|
>> ${OUT}
|
2012-03-13 21:56:23 +01:00
|
|
|
fi
|
2012-02-29 21:02:31 +01:00
|
|
|
|
|
|
|
# The rlimit struct.
|
|
|
|
grep '^type _rlimit ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_rlimit/Rlimit/' \
|
|
|
|
-e 's/rlim_cur/Cur/' \
|
|
|
|
-e 's/rlim_max/Max/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The RLIMIT constants.
|
|
|
|
grep '^const _RLIMIT_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-04-22 22:07:23 +02:00
|
|
|
grep '^const _RLIM_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(RLIM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-02-29 21:02:31 +01:00
|
|
|
|
|
|
|
# The sysinfo struct.
|
|
|
|
grep '^type _sysinfo ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_sysinfo/Sysinfo_t/' \
|
|
|
|
-e 's/uptime/Uptime/' \
|
|
|
|
-e 's/loads/Loads/' \
|
|
|
|
-e 's/totalram/Totalram/' \
|
|
|
|
-e 's/freeram/Freeram/' \
|
|
|
|
-e 's/sharedram/Sharedram/' \
|
|
|
|
-e 's/bufferram/Bufferram/' \
|
|
|
|
-e 's/totalswap/Totalswap/' \
|
|
|
|
-e 's/freeswap/Freeswap/' \
|
|
|
|
-e 's/procs/Procs/' \
|
|
|
|
-e 's/totalhigh/Totalhigh/' \
|
|
|
|
-e 's/freehigh/Freehigh/' \
|
|
|
|
-e 's/mem_unit/Unit/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The ustat struct.
|
|
|
|
grep '^type _ustat ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_ustat/Ustat_t/' \
|
|
|
|
-e 's/f_tfree/Tfree/' \
|
|
|
|
-e 's/f_tinode/Tinoe/' \
|
|
|
|
-e 's/f_fname/Fname/' \
|
|
|
|
-e 's/f_fpack/Fpack/' \
|
|
|
|
>> ${OUT}
|
2012-03-02 22:07:52 +01:00
|
|
|
# Force it to be defined, as on some older GNU/Linux systems the
|
|
|
|
# header file fails when using with <linux/filter.h>.
|
|
|
|
if ! grep 'type _ustat ' gen-sysinfo.go >/dev/null 2>&1; then
|
|
|
|
echo 'type Ustat_t struct { Tfree int32; Tinoe uint64; Fname [5+1]int8; Fpack [5+1]int8; }' >> ${OUT}
|
|
|
|
fi
|
2012-02-29 21:02:31 +01:00
|
|
|
|
|
|
|
# The utimbuf struct.
|
|
|
|
grep '^type _utimbuf ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_utimbuf/Utimbuf/' \
|
|
|
|
-e 's/actime/Actime/' \
|
|
|
|
-e 's/modtime/Modtime/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2012-04-21 20:49:58 +02:00
|
|
|
# The LOCK flags for flock.
|
|
|
|
grep '^const _LOCK_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2013-10-17 20:41:12 +02:00
|
|
|
# The PRIO constants.
|
|
|
|
grep '^const _PRIO_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(PRIO_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
# The GNU/Linux LINUX_REBOOT flags.
|
|
|
|
grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
|
|
|
|
sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
|
|
|
# The GNU/Linux sock_filter struct.
|
|
|
|
grep '^type _sock_filter ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_sock_filter/SockFilter/' \
|
|
|
|
-e 's/code/Code/' \
|
|
|
|
-e 's/jt/Jt/' \
|
|
|
|
-e 's/jf/Jf/' \
|
|
|
|
-e 's/k /K /' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The GNU/Linux sock_fprog struct.
|
|
|
|
grep '^type _sock_fprog ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_sock_fprog/SockFprog/' \
|
|
|
|
-e 's/len/Len/' \
|
|
|
|
-e 's/filter/Filter/' \
|
|
|
|
-e 's/_sock_filter/SockFilter/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2012-04-03 21:42:24 +02:00
|
|
|
# The GNU/Linux filter flags.
|
|
|
|
grep '^const _BPF_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2012-04-22 21:26:01 +02:00
|
|
|
# The GNU/Linux nlattr struct.
|
|
|
|
grep '^type _nlattr ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_nlattr/NlAttr/' \
|
|
|
|
-e 's/nla_len/Len/' \
|
|
|
|
-e 's/nla_type/Type/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The GNU/Linux nlmsgerr struct.
|
|
|
|
grep '^type _nlmsgerr ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_nlmsgerr/NlMsgerr/' \
|
|
|
|
-e 's/error/Error/' \
|
|
|
|
-e 's/msg/Msg/' \
|
2012-04-22 22:07:23 +02:00
|
|
|
-e 's/_nlmsghdr/NlMsghdr/' \
|
2012-04-22 21:26:01 +02:00
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The GNU/Linux rtnexthop struct.
|
|
|
|
grep '^type _rtnexthop ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_rtnexthop/RtNexthop/' \
|
|
|
|
-e 's/rtnh_len/Len/' \
|
|
|
|
-e 's/rtnh_flags/Flags/' \
|
|
|
|
-e 's/rtnh_hops/Hops/' \
|
|
|
|
-e 's/rtnh_ifindex/Ifindex/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2012-04-21 20:49:58 +02:00
|
|
|
# The GNU/Linux netlink flags.
|
|
|
|
grep '^const _NETLINK_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(NETLINK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2015-12-18 02:15:37 +01:00
|
|
|
grep '^const _NLA_' gen-sysinfo.go | grep -v '_val =' | \
|
2012-04-22 22:07:23 +02:00
|
|
|
sed -e 's/^\(const \)_\(NLA_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2012-04-21 20:49:58 +02:00
|
|
|
|
2015-12-18 02:15:37 +01:00
|
|
|
if ! grep '^const NLA_HDRLEN' ${OUT} >/dev/null 2>&1; then
|
|
|
|
if grep '^const _NLA_HDRLEN_val' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const NLA_HDRLEN = _NLA_HDRLEN_val' >> ${OUT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-04-21 20:49:58 +02:00
|
|
|
# The GNU/Linux packet socket flags.
|
|
|
|
grep '^const _PACKET_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(PACKET_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
|
|
|
|
2012-04-22 21:26:01 +02:00
|
|
|
# The GNU/Linux inotify_event struct.
|
|
|
|
grep '^type _inotify_event ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_inotify_event/InotifyEvent/' \
|
|
|
|
-e 's/wd/Wd/' \
|
|
|
|
-e 's/mask/Mask/' \
|
|
|
|
-e 's/cookie/Cookie/' \
|
|
|
|
-e 's/len/Len/' \
|
|
|
|
-e 's/name/Name/' \
|
|
|
|
-e 's/\[\]/[0]/' \
|
2012-04-22 22:07:23 +02:00
|
|
|
-e 's/\[0\]byte/[0]int8/' \
|
2012-04-22 21:26:01 +02:00
|
|
|
>> ${OUT}
|
|
|
|
|
2014-05-07 23:48:29 +02:00
|
|
|
# The GNU/Linux CLONE flags.
|
|
|
|
grep '^const _CLONE_' gen-sysinfo.go | \
|
|
|
|
sed -e 's/^\(const \)_\(CLONE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
|
2015-11-03 16:07:47 +01:00
|
|
|
# We need some CLONE constants that are not defined in older versions
|
|
|
|
# of glibc.
|
|
|
|
if ! grep '^const CLONE_NEWUSER ' ${OUT} > /dev/null 2>&1; then
|
|
|
|
echo "const CLONE_NEWUSER = 0x10000000" >> ${OUT}
|
|
|
|
fi
|
2014-05-07 23:48:29 +02:00
|
|
|
|
2012-04-22 20:51:44 +02:00
|
|
|
# Struct sizes.
|
|
|
|
set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \
|
|
|
|
ifaddrmsg IfAddrmsg ifinfomsg IfInfomsg in_pktinfo Inet4Pktinfo \
|
2012-04-22 22:07:23 +02:00
|
|
|
in6_pktinfo Inet6Pktinfo inotify_event InotifyEvent linger Linger \
|
2012-04-22 20:51:44 +02:00
|
|
|
msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \
|
|
|
|
rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \
|
2013-11-06 20:49:01 +01:00
|
|
|
sock_filter SockFilter sock_fprog SockFprog ucred Ucred \
|
2016-02-26 18:36:00 +01:00
|
|
|
icmp6_filter ICMPv6Filter ip6_mtuinfo IPv6MTUInfo
|
2012-04-22 20:51:44 +02:00
|
|
|
while test $# != 0; do
|
|
|
|
nc=$1
|
|
|
|
ngo=$2
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
if grep "^const _sizeof_$nc =" gen-sysinfo.go >/dev/null 2>&1; then
|
|
|
|
echo "const Sizeof$ngo = _sizeof_$nc" >> ${OUT}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# In order to compile the net package, we need some sizes to exist
|
|
|
|
# even if the types do not.
|
|
|
|
if ! grep 'const SizeofIPMreq ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const SizeofIPMreq = 8' >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep 'const SizeofIPv6Mreq ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const SizeofIPv6Mreq = 20' >> ${OUT}
|
|
|
|
fi
|
|
|
|
if ! grep 'const SizeofIPMreqn ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const SizeofIPMreqn = 12' >> ${OUT}
|
|
|
|
fi
|
2013-11-06 20:49:01 +01:00
|
|
|
if ! grep 'const SizeofICMPv6Filter ' ${OUT} >/dev/null 2>&1; then
|
|
|
|
echo 'const SizeofICMPv6Filter = 32' >> ${OUT}
|
|
|
|
fi
|
2012-04-22 20:51:44 +02:00
|
|
|
|
2015-04-08 16:17:13 +02:00
|
|
|
# The Solaris 11 Update 1 _zone_net_addr_t struct.
|
|
|
|
grep '^type _zone_net_addr_t ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in6_addr/[16]byte/' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2015-11-10 22:38:30 +01:00
|
|
|
# The Solaris 12 _flow_arp_desc_t struct.
|
|
|
|
grep '^type _flow_arp_desc_t ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in6_addr_t/[16]byte/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The Solaris 12 _flow_l3_desc_t struct.
|
|
|
|
grep '^type _flow_l3_desc_t ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in6_addr_t/[16]byte/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The Solaris 12 _mac_ipaddr_t struct.
|
|
|
|
grep '^type _mac_ipaddr_t ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in6_addr_t/[16]byte/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
|
|
|
# The Solaris 12 _mactun_info_t struct.
|
|
|
|
grep '^type _mactun_info_t ' gen-sysinfo.go | \
|
|
|
|
sed -e 's/_in6_addr_t/[16]byte/g' \
|
|
|
|
>> ${OUT}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
exit $?
|