Patchwork libgo patch committed: Solaris net fixes

login
register
mail settings
Submitter Ian Taylor
Date Feb. 20, 2013, 8:05 p.m.
Message ID <mcrk3q2oinp.fsf@google.com>
Download mbox | patch
Permalink /patch/222141/
State New
Headers show

Comments

Ian Taylor - Feb. 20, 2013, 8:05 p.m.
This patch, mainly from Rainer Orth, in PR 56171 fixes passing a file
descriptor on Solaris.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 3b1c3cceaf02 libgo/Makefile.am
--- a/libgo/Makefile.am	Wed Feb 20 11:41:05 2013 -0800
+++ b/libgo/Makefile.am	Wed Feb 20 12:01:58 2013 -0800
@@ -1656,6 +1656,13 @@ 
 endif
 endif
 
+# Define socket functions.
+if LIBGO_IS_SOLARIS
+syscall_socket_os_file = go/syscall/socket_xnet.go
+else
+syscall_socket_os_file = go/syscall/socket_posix.go
+endif
+
 # Support for uname.
 if LIBGO_IS_SOLARIS
 if LIBGO_IS_386
@@ -1722,6 +1729,7 @@ 
 	$(syscall_errstr_file) \
 	$(syscall_size_file) \
 	$(syscall_socket_file) \
+	$(syscall_socket_os_file) \
 	$(syscall_uname_file) \
 	$(syscall_netlink_file) \
 	$(syscall_lsf_file) \
@@ -1746,13 +1754,20 @@ 
 	go/syscall/passfd_test.go
 
 libcalls.go: s-libcalls; @true
-s-libcalls: Makefile go/syscall/mksyscall.awk $(go_base_syscall_files)
+s-libcalls: libcalls-list go/syscall/mksyscall.awk $(go_base_syscall_files)
 	rm -f libcalls.go.tmp
-	files=`echo $^ | sed -e 's/Makefile//' -e 's|[^ ]*go/syscall/mksyscall.awk||'`; \
+	files=`echo $^ | sed -e 's/libcalls-list//' -e 's|[^ ]*go/syscall/mksyscall.awk||'`; \
 	$(AWK) -f $(srcdir)/go/syscall/mksyscall.awk $${files} > libcalls.go.tmp
 	$(SHELL) $(srcdir)/../move-if-change libcalls.go.tmp libcalls.go
 	$(STAMP) $@
 
+libcalls-list: s-libcalls-list; @true
+s-libcalls-list: Makefile
+	rm -f libcalls-list.tmp
+	echo $(go_base_syscall_files) > libcalls-list.tmp
+	$(SHELL) $(srcdir)/../move-if-change libcalls-list.tmp libcalls-list
+	$(STAMP) $@
+
 syscall_arch.go: s-syscall_arch; @true
 s-syscall_arch: Makefile
 	rm -f syscall_arch.go.tmp
diff -r 3b1c3cceaf02 libgo/go/syscall/sockcmsg_unix.go
--- a/libgo/go/syscall/sockcmsg_unix.go	Wed Feb 20 11:41:05 2013 -0800
+++ b/libgo/go/syscall/sockcmsg_unix.go	Wed Feb 20 12:01:58 2013 -0800
@@ -8,7 +8,10 @@ 
 
 package syscall
 
-import "unsafe"
+import (
+	"runtime"
+	"unsafe"
+)
 
 // Round the length of a raw sockaddr up to align it propery.
 func cmsgAlignOf(salen int) int {
@@ -18,6 +21,11 @@ 
 	if darwinAMD64 {
 		salign = 4
 	}
+	// NOTE: Solaris always uses 32-bit alignment,
+	// cf. _CMSG_DATA_ALIGNMENT in <sys/socket.h>.
+	if runtime.GOOS == "solaris" {
+		salign = 4
+	}
 	if salen == 0 {
 		return salign
 	}
diff -r 3b1c3cceaf02 libgo/go/syscall/socket.go
--- a/libgo/go/syscall/socket.go	Wed Feb 20 11:41:05 2013 -0800
+++ b/libgo/go/syscall/socket.go	Wed Feb 20 12:01:58 2013 -0800
@@ -177,9 +177,6 @@ 
 	return anyToSockaddr(&rsa)
 }
 
-//sys	bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error)
-//bind(fd _C_int, sa *RawSockaddrAny, len Socklen_t) _C_int
-
 func Bind(fd int, sa Sockaddr) (err error) {
 	ptr, n, err := sa.sockaddr()
 	if err != nil {
@@ -188,9 +185,6 @@ 
 	return bind(fd, ptr, n)
 }
 
-//sys	connect(s int, addr *RawSockaddrAny, addrlen Socklen_t) (err error)
-//connect(s _C_int, addr *RawSockaddrAny, addrlen Socklen_t) _C_int
-
 func Connect(fd int, sa Sockaddr) (err error) {
 	ptr, n, err := sa.sockaddr()
 	if err != nil {
@@ -199,9 +193,6 @@ 
 	return connect(fd, ptr, n)
 }
 
-//sysnb	socket(domain int, typ int, proto int) (fd int, err error)
-//socket(domain _C_int, typ _C_int, protocol _C_int) _C_int
-
 func Socket(domain, typ, proto int) (fd int, err error) {
 	if domain == AF_INET6 && SocketDisableIPv6 {
 		return -1, EAFNOSUPPORT
@@ -210,9 +201,6 @@ 
 	return
 }
 
-//sysnb	socketpair(domain int, typ int, proto int, fd *[2]_C_int) (err error)
-//socketpair(domain _C_int, typ _C_int, protocol _C_int, fd *[2]_C_int) _C_int
-
 func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
 	var fdx [2]_C_int
 	err = socketpair(domain, typ, proto, &fdx)
@@ -223,9 +211,6 @@ 
 	return
 }
 
-//sys	getsockopt(s int, level int, name int, val uintptr, vallen *Socklen_t) (err error)
-//getsockopt(s _C_int, level _C_int, name _C_int, val *byte, vallen *Socklen_t) _C_int
-
 func GetsockoptByte(fd, level, opt int) (value byte, err error) {
 	var n byte
 	vallen := Socklen_t(1)
@@ -326,9 +311,6 @@ 
 	return
 }
 
-//sys	sendto(s int, buf []byte, flags int, to *RawSockaddrAny, tolen Socklen_t) (err error)
-//sendto(s _C_int, buf *byte, len Size_t, flags _C_int, to *RawSockaddrAny, tolen Socklen_t) Ssize_t
-
 func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) {
 	ptr, n, err := to.sockaddr()
 	if err != nil {
@@ -337,9 +319,6 @@ 
 	return sendto(fd, p, flags, ptr, n)
 }
 
-//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
-//recvmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t
-
 func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
 	var msg Msghdr
 	var rsa RawSockaddrAny
@@ -374,9 +353,6 @@ 
 	return
 }
 
-//sys	sendmsg(s int, msg *Msghdr, flags int) (err error)
-//sendmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t
-
 func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
 	var ptr *RawSockaddrAny
 	var salen Socklen_t
diff -r 3b1c3cceaf02 libgo/go/syscall/socket_posix.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/syscall/socket_posix.go	Wed Feb 20 12:01:58 2013 -0800
@@ -0,0 +1,32 @@ 
+// socket_posix.go -- Socket handling for generic POSIX systems.
+
+// Copyright 2013 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.
+
+package syscall
+
+//sys	bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error)
+//bind(fd _C_int, sa *RawSockaddrAny, len Socklen_t) _C_int
+
+//sys	connect(s int, addr *RawSockaddrAny, addrlen Socklen_t) (err error)
+//connect(s _C_int, addr *RawSockaddrAny, addrlen Socklen_t) _C_int
+
+//sysnb	socket(domain int, typ int, proto int) (fd int, err error)
+//socket(domain _C_int, typ _C_int, protocol _C_int) _C_int
+
+//sysnb	socketpair(domain int, typ int, proto int, fd *[2]_C_int) (err error)
+//socketpair(domain _C_int, typ _C_int, protocol _C_int, fd *[2]_C_int) _C_int
+
+//sys	getsockopt(s int, level int, name int, val uintptr, vallen *Socklen_t) (err error)
+//getsockopt(s _C_int, level _C_int, name _C_int, val *byte, vallen *Socklen_t) _C_int
+
+//sys	sendto(s int, buf []byte, flags int, to *RawSockaddrAny, tolen Socklen_t) (err error)
+//sendto(s _C_int, buf *byte, len Size_t, flags _C_int, to *RawSockaddrAny, tolen Socklen_t) Ssize_t
+
+//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//recvmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t
+
+//sys	sendmsg(s int, msg *Msghdr, flags int) (err error)
+//sendmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t
+
diff -r 3b1c3cceaf02 libgo/go/syscall/socket_xnet.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/syscall/socket_xnet.go	Wed Feb 20 12:01:58 2013 -0800
@@ -0,0 +1,33 @@ 
+// socket_xnet.go -- Socket handling specific to Solaris.
+// Enforce use of XPG 4.2 versions of socket functions.
+
+// Copyright 2013 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.
+
+package syscall
+
+//sys	bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error)
+//__xnet_bind(fd _C_int, sa *RawSockaddrAny, len Socklen_t) _C_int
+
+//sys	connect(s int, addr *RawSockaddrAny, addrlen Socklen_t) (err error)
+//__xnet_connect(s _C_int, addr *RawSockaddrAny, addrlen Socklen_t) _C_int
+
+//sysnb	socket(domain int, typ int, proto int) (fd int, err error)
+//__xnet_socket(domain _C_int, typ _C_int, protocol _C_int) _C_int
+
+//sysnb	socketpair(domain int, typ int, proto int, fd *[2]_C_int) (err error)
+//__xnet_socketpair(domain _C_int, typ _C_int, protocol _C_int, fd *[2]_C_int) _C_int
+
+//sys	getsockopt(s int, level int, name int, val uintptr, vallen *Socklen_t) (err error)
+//__xnet_getsockopt(s _C_int, level _C_int, name _C_int, val *byte, vallen *Socklen_t) _C_int
+
+//sys	sendto(s int, buf []byte, flags int, to *RawSockaddrAny, tolen Socklen_t) (err error)
+//__xnet_sendto(s _C_int, buf *byte, len Size_t, flags _C_int, to *RawSockaddrAny, tolen Socklen_t) Ssize_t
+
+//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+//__xnet_recvmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t
+
+//sys	sendmsg(s int, msg *Msghdr, flags int) (err error)
+//__xnet_sendmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t
+