diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-02-20 20:04:36 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-02-20 20:04:36 +0000 |
commit | f46d686ef1acd844dd00b4f3c327bd42606efbea (patch) | |
tree | dff5156dfe573447879d9fd15abd7f5df573c922 /libgo | |
parent | aa777e7a23c38690a205ece9ebee9d2d4ad23097 (diff) | |
download | gcc-f46d686ef1acd844dd00b4f3c327bd42606efbea.zip gcc-f46d686ef1acd844dd00b4f3c327bd42606efbea.tar.gz gcc-f46d686ef1acd844dd00b4f3c327bd42606efbea.tar.bz2 |
re PR go/56171 (syscall FAILs on Solaris)
PR go/56171
syscall: Solaris fixes for passing file descriptor.
From Rainer Orth.
From-SVN: r196180
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/Makefile.am | 19 | ||||
-rw-r--r-- | libgo/Makefile.in | 16 | ||||
-rw-r--r-- | libgo/go/syscall/sockcmsg_unix.go | 10 | ||||
-rw-r--r-- | libgo/go/syscall/socket.go | 24 | ||||
-rw-r--r-- | libgo/go/syscall/socket_posix.go | 31 | ||||
-rw-r--r-- | libgo/go/syscall/socket_xnet.go | 32 |
6 files changed, 103 insertions, 29 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am index c153ae2..ea90318 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -1656,6 +1656,13 @@ endif 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 @@ go_base_syscall_files = \ $(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_test_files = \ 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 --git a/libgo/Makefile.in b/libgo/Makefile.in index c74c4f6..2ec60d3 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -1849,6 +1849,10 @@ go_unicode_utf8_files = \ # Define socket sizes and types. @LIBGO_IS_LINUX_TRUE@syscall_socket_file = go/syscall/socket_linux.go epoll.go +@LIBGO_IS_SOLARIS_FALSE@syscall_socket_os_file = go/syscall/socket_posix.go + +# Define socket functions. +@LIBGO_IS_SOLARIS_TRUE@syscall_socket_os_file = go/syscall/socket_xnet.go @LIBGO_IS_386_FALSE@@LIBGO_IS_SOLARIS_TRUE@syscall_uname_file = go/syscall/libcall_uname.go # Support for uname. @@ -1894,6 +1898,7 @@ go_base_syscall_files = \ $(syscall_errstr_file) \ $(syscall_size_file) \ $(syscall_socket_file) \ + $(syscall_socket_os_file) \ $(syscall_uname_file) \ $(syscall_netlink_file) \ $(syscall_lsf_file) \ @@ -4448,13 +4453,20 @@ s-version: Makefile $(STAMP) $@ 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 --git a/libgo/go/syscall/sockcmsg_unix.go b/libgo/go/syscall/sockcmsg_unix.go index fc83df1..951bc18 100644 --- a/libgo/go/syscall/sockcmsg_unix.go +++ b/libgo/go/syscall/sockcmsg_unix.go @@ -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 @@ func cmsgAlignOf(salen int) int { 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 --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go index 3aa92012..a625eb6 100644 --- a/libgo/go/syscall/socket.go +++ b/libgo/go/syscall/socket.go @@ -177,9 +177,6 @@ func Getpeername(fd int) (sa Sockaddr, err error) { 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 @@ func Bind(fd int, sa Sockaddr) (err error) { 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 @@ func Connect(fd int, sa Sockaddr) (err error) { 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 @@ func Socket(domain, typ, proto int) (fd int, err error) { 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 @@ func Socketpair(domain, typ, proto int) (fd [2]int, err error) { 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 @@ func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { 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 @@ func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) { 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 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from 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 --git a/libgo/go/syscall/socket_posix.go b/libgo/go/syscall/socket_posix.go new file mode 100644 index 0000000..06d7dab --- /dev/null +++ b/libgo/go/syscall/socket_posix.go @@ -0,0 +1,31 @@ +// 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 --git a/libgo/go/syscall/socket_xnet.go b/libgo/go/syscall/socket_xnet.go new file mode 100644 index 0000000..8f86c62 --- /dev/null +++ b/libgo/go/syscall/socket_xnet.go @@ -0,0 +1,32 @@ +// 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 |