Patchwork libgo patch committed: More syscall package improvements

login
register
mail settings
Submitter Ian Taylor
Date April 21, 2012, 6:50 p.m.
Message ID <mcry5po5389.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/154229/
State New
Headers show

Comments

Ian Taylor - April 21, 2012, 6:50 p.m.
This patch to libgo brings the syscall package closer to the one
provided on GNU/Linux systems by the master Go library.  This is mostly
additional constants, but also corrects the Tgkill and Mount functions.
This an incremental step; there is more work to do.  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and
4.7 branch.

Ian

Patch

diff -r a776919b56e7 libgo/configure.ac
--- a/libgo/configure.ac	Fri Apr 20 14:20:14 2012 -0700
+++ b/libgo/configure.ac	Sat Apr 21 11:47:01 2012 -0700
@@ -453,9 +453,9 @@ 
   ;;
 esac
 
-AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/reboot.h)
+AC_CHECK_HEADERS(sys/file.h sys/mman.h syscall.h sys/epoll.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h)
 
-AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [],
+AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
diff -r a776919b56e7 libgo/go/syscall/libcall_linux.go
--- a/libgo/go/syscall/libcall_linux.go	Fri Apr 20 14:20:14 2012 -0700
+++ b/libgo/go/syscall/libcall_linux.go	Sat Apr 21 11:47:01 2012 -0700
@@ -335,7 +335,7 @@ 
 //sys	Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
 //tee(rfd int, wfd int, len Size_t, flags uint) Ssize_t
 
-func Tgkill(tgid, tid, sig Signal) error {
+func Tgkill(tgid, tid int, sig Signal) error {
 	r1, _, errno := Syscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
 	if r1 < 0 {
 		return errno
diff -r a776919b56e7 libgo/go/syscall/libcall_posix.go
--- a/libgo/go/syscall/libcall_posix.go	Fri Apr 20 14:20:14 2012 -0700
+++ b/libgo/go/syscall/libcall_posix.go	Sat Apr 21 11:47:01 2012 -0700
@@ -268,7 +268,7 @@ 
 //sys	Mknod(path string, mode uint32, dev int) (err error)
 //mknod(path *byte, mode Mode_t, dev _dev_t) int
 
-//sys	Mount(source string, target string, fstype string, flags int, data string) (err error)
+//sys	Mount(source string, target string, fstype string, flags uintptr, data string) (err error)
 //mount(source *byte, target *byte, fstype *byte, flags _C_long, data *byte) int
 
 //sys	Nanosleep(time *Timespec, leftover *Timespec) (err error)
diff -r a776919b56e7 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Fri Apr 20 14:20:14 2012 -0700
+++ b/libgo/mksysinfo.sh	Sat Apr 21 11:47:01 2012 -0700
@@ -40,6 +40,18 @@ 
 #include <sys/ttold.h>
 #endif
 #include <netinet/tcp.h>
+#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
 #include <signal.h>
 #include <sys/ioctl.h>
 #include <termios.h>
@@ -52,6 +64,9 @@ 
 #if defined(HAVE_SYS_EPOLL_H)
 #include <sys/epoll.h>
 #endif
+#if defined(HAVE_SYS_FILE_H)
+#include <sys/file.h>
+#endif
 #if defined(HAVE_SYS_MMAN_H)
 #include <sys/mman.h>
 #endif
@@ -85,6 +100,15 @@ 
 #if defined(HAVE_LINUX_FILTER_H)
 #include <linux/filter.h>
 #endif
+#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
 #if defined(HAVE_LINUX_NETLINK_H)
 #include <linux/netlink.h>
 #endif
@@ -97,6 +121,12 @@ 
 #if defined(HAVE_NET_IF_ARP_H)
 #include <net/if_arp.h>
 #endif
+#if defined(HAVE_NET_ROUTE_H)
+#include <net/route.h>
+#endif
+#if defined (HAVE_NETPACKET_PACKET_H)
+#include <netpacket/packet.h>
+#endif
 #if defined(HAVE_SYS_MOUNT_H)
 #include <sys/mount.h>
 #endif
@@ -124,6 +154,9 @@ 
 #if defined(HAVE_LINUX_REBOOT_H)
 #include <linux/reboot.h>
 #endif
+#if defined(HAVE_SYS_INOTIFY_H)
+#include <sys/inotify.h>
+#endif
 
 /* Constants that may only be defined as expressions on some systems,
    expressions too complex for -fdump-go-spec to handle.  These are
@@ -199,6 +232,8 @@ 
   sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _MADV_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+grep '^const _MCL_' gen-sysinfo.go | \
+  sed -e 's/^\(const \)_\(MCL_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 
 # Process status constants.
 grep '^const _W' gen-sysinfo.go |
@@ -700,7 +735,7 @@ 
       -e 's/rtm_src_len/Src_len/' \
       -e 's/rtm_tos/Tos/' \
       -e 's/rtm_table/Table/' \
-      -e 's/rtm_protocol/Procotol/' \
+      -e 's/rtm_protocol/Protocol/' \
       -e 's/rtm_scope/Scope/' \
       -e 's/rtm_type/Type/' \
       -e 's/rtm_flags/Flags/' \
@@ -718,6 +753,8 @@ 
     >> ${OUT}
 
 # The routing message flags.
+grep '^const _RT_' gen-sysinfo.go | \
+    sed -e 's/^\(const \)_\(RT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _RTA' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _RTF' gen-sysinfo.go | \
@@ -726,6 +763,10 @@ 
     sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _RTM' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+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}
 
 # The size of the rtgenmsg struct.
 if grep 'type RtGenmsg ' ${OUT} > /dev/null 2>&1; then
@@ -818,6 +859,8 @@ 
 done
 
 # The mount flags
+grep '^const _MNT_' gen-sysinfo.go |
+    sed -e 's/^\(const \)_\(MNT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _MS_' gen-sysinfo.go |
     sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 
@@ -932,6 +975,10 @@ 
       -e 's/modtime/Modtime/' \
     >> ${OUT}
 
+# The LOCK flags for flock.
+grep '^const _LOCK_' gen-sysinfo.go |
+    sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
 # The GNU/Linux LINUX_REBOOT flags.
 grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
     sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
@@ -957,6 +1004,14 @@ 
 grep '^const _BPF_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 
+# The GNU/Linux netlink flags.
+grep '^const _NETLINK_' gen-sysinfo.go | \
+  sed -e 's/^\(const \)_\(NETLINK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
+# The GNU/Linux packet socket flags.
+grep '^const _PACKET_' gen-sysinfo.go | \
+  sed -e 's/^\(const \)_\(PACKET_[^= ]*\)\(.*\)$/\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/' \