OSDN Git Service

syscall: Add more constants.
[pf3gnuchains/gcc-fork.git] / libgo / mksysinfo.sh
index bca814c..291fbb5 100755 (executable)
@@ -78,6 +78,7 @@ cat > sysinfo.c <<EOF
 #if defined(HAVE_SYS_SELECT_H)
 #include <sys/select.h>
 #endif
+#include <time.h>
 #include <unistd.h>
 #include <netdb.h>
 #include <pwd.h>
@@ -93,6 +94,36 @@ cat > sysinfo.c <<EOF
 #if defined(HAVE_NET_IF_H)
 #include <net/if.h>
 #endif
+#if defined(HAVE_NET_IF_ARP_H)
+#include <net/if_arp.h>
+#endif
+#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
+#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
+#if defined(HAVE_LINUX_ETHER_H)
+#include <linux/ether.h>
+#endif
+#if defined(HAVE_LINUX_REBOOT_H)
+#include <linux/reboot.h>
+#endif
 
 /* Constants that may only be defined as expressions on some systems,
    expressions too complex for -fdump-go-spec to handle.  These are
@@ -147,7 +178,7 @@ fi
 # The signal numbers.
 grep '^const _SIG[^_]' gen-sysinfo.go | \
   grep -v '^const _SIGEV_' | \
-  sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+  sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = Signal(_\2)/' >> ${OUT}
 
 # The syscall numbers.  We force the names to upper case.
 grep '^const _SYS_' gen-sysinfo.go | \
@@ -166,6 +197,8 @@ 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}
+grep '^const _MADV_' gen-sysinfo.go | \
+  sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 
 # Process status constants.
 grep '^const _W' gen-sysinfo.go |
@@ -184,7 +217,7 @@ if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
 fi
 
 # Networking constants.
-egrep '^const _(AF|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
+egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _SOMAXCONN' gen-sysinfo.go |
   sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
@@ -330,6 +363,11 @@ if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then
   echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT}
 fi
 
+# 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
+
 # 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.
@@ -426,6 +464,10 @@ fi | sed -e 's/type _dirent64/type Dirent/' \
       >> ${OUT}
 echo "type DIR _DIR" >> ${OUT}
 
+# Values for d_type field in dirent.
+grep '^const _DT_' gen-sysinfo.go |
+  sed -e 's/^\(const \)_\(DT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
 # The rusage struct.
 rusage=`grep '^type _rusage struct' gen-sysinfo.go`
 if test "$rusage" != ""; then
@@ -507,6 +549,7 @@ if test -n "$cmsghdr"; then
         -e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
         -e 's/cmsg_level/Level/' \
         -e 's/cmsg_type/Type/' \
+        -e 's/\[\]/[0]/' \
       >> ${OUT}
 
   # The size of the cmsghdr struct.
@@ -677,6 +720,10 @@ grep '^type _rtgenmsg ' gen-sysinfo.go | \
 # The routing message flags.
 grep '^const _RTA' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+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}
 grep '^const _RTM' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 
@@ -702,6 +749,10 @@ 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}
+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}
 
 # The size of the ifinfomsg struct.
 if grep 'type IfInfomsg ' ${OUT} > /dev/null 2>&1; then
@@ -751,18 +802,164 @@ grep '^type _termios ' gen-sysinfo.go | \
 # The termios constants.
 for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
     IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
-    OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 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 \
+    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 \
     TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \
     B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \
-    B38400 B57600 B115200 B230400; do
+    B38400 B57600 B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \
+    B1152000 B1500000 B2000000 B2500000 B3000000 B4000000; do
 
     grep "^const _$n " gen-sysinfo.go | \
        sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 done
 
+# The mount flags
+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}
+
+# The timex struct.
+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" | \
+    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}
+fi
+
+# 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}
+
+# 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}
+# 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
+
+# The utimbuf struct.
+grep '^type _utimbuf ' gen-sysinfo.go | \
+    sed -e 's/_utimbuf/Utimbuf/' \
+      -e 's/actime/Actime/' \
+      -e 's/modtime/Modtime/' \
+    >> ${OUT}
+
+# 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}
+
+# The GNU/Linux filter flags.
+grep '^const _BPF_' gen-sysinfo.go | \
+  sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
+# 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}
+
 exit $?