mirror of git://gcc.gnu.org/git/gcc.git
libgo: Solaris portability patches.
From Rainer Orth. From-SVN: r192819
This commit is contained in:
parent
992ca0f069
commit
f99a463f8a
|
|
@ -704,7 +704,7 @@ if LIBGO_IS_SOLARIS
|
||||||
go_net_cgo_file = go/net/cgo_linux.go
|
go_net_cgo_file = go/net/cgo_linux.go
|
||||||
go_net_sock_file = go/net/sock_solaris.go
|
go_net_sock_file = go/net/sock_solaris.go
|
||||||
go_net_sockopt_file = go/net/sockopt_bsd.go
|
go_net_sockopt_file = go/net/sockopt_bsd.go
|
||||||
go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_solaris.go
|
go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
||||||
else
|
else
|
||||||
if LIBGO_IS_FREEBSD
|
if LIBGO_IS_FREEBSD
|
||||||
go_net_cgo_file = go/net/cgo_bsd.go
|
go_net_cgo_file = go/net/cgo_bsd.go
|
||||||
|
|
@ -968,6 +968,9 @@ endif
|
||||||
if LIBGO_IS_OPENBSD
|
if LIBGO_IS_OPENBSD
|
||||||
archive_tar_atim_file = go/archive/tar/stat_atim.go
|
archive_tar_atim_file = go/archive/tar/stat_atim.go
|
||||||
endif
|
endif
|
||||||
|
if LIBGO_IS_SOLARIS
|
||||||
|
archive_tar_atim_file = go/archive/tar/stat_atim.go
|
||||||
|
endif
|
||||||
if LIBGO_IS_DARWIN
|
if LIBGO_IS_DARWIN
|
||||||
archive_tar_atim_file = go/archive/tar/stat_atimespec.go
|
archive_tar_atim_file = go/archive/tar/stat_atimespec.go
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -993,7 +993,7 @@ go_mime_files = \
|
||||||
@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
||||||
@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
||||||
@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
||||||
@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_TRUE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_solaris.go
|
@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_TRUE@go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
|
||||||
@LIBGO_IS_IRIX_TRUE@@LIBGO_IS_LINUX_FALSE@go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_posix.go
|
@LIBGO_IS_IRIX_TRUE@@LIBGO_IS_LINUX_FALSE@go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_posix.go
|
||||||
@LIBGO_IS_LINUX_TRUE@go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_posix.go
|
@LIBGO_IS_LINUX_TRUE@go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_posix.go
|
||||||
@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_LINUX_FALSE@go_net_sendfile_file = go/net/sendfile_stub.go
|
@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_LINUX_FALSE@go_net_sendfile_file = go/net/sendfile_stub.go
|
||||||
|
|
@ -1174,6 +1174,7 @@ go_unicode_files = \
|
||||||
@LIBGO_IS_LINUX_TRUE@archive_tar_atim_file = go/archive/tar/stat_atim.go
|
@LIBGO_IS_LINUX_TRUE@archive_tar_atim_file = go/archive/tar/stat_atim.go
|
||||||
@LIBGO_IS_NETBSD_TRUE@archive_tar_atim_file = go/archive/tar/stat_atimespec.go
|
@LIBGO_IS_NETBSD_TRUE@archive_tar_atim_file = go/archive/tar/stat_atimespec.go
|
||||||
@LIBGO_IS_OPENBSD_TRUE@archive_tar_atim_file = go/archive/tar/stat_atim.go
|
@LIBGO_IS_OPENBSD_TRUE@archive_tar_atim_file = go/archive/tar/stat_atim.go
|
||||||
|
@LIBGO_IS_SOLARIS_TRUE@archive_tar_atim_file = go/archive/tar/stat_atim.go
|
||||||
go_archive_tar_files = \
|
go_archive_tar_files = \
|
||||||
go/archive/tar/common.go \
|
go/archive/tar/common.go \
|
||||||
go/archive/tar/reader.go \
|
go/archive/tar/reader.go \
|
||||||
|
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
// Copyright 2011 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.
|
|
||||||
|
|
||||||
// IP-level socket options for Solaris
|
|
||||||
|
|
||||||
package net
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ipv4MulticastInterface(fd *netFD) (*Interface, error) {
|
|
||||||
if err := fd.incref(false); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer fd.decref()
|
|
||||||
a, err := syscall.GetsockoptInet4Addr(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF)
|
|
||||||
if err != nil {
|
|
||||||
return nil, os.NewSyscallError("getsockopt", err)
|
|
||||||
}
|
|
||||||
return ipv4AddrToInterface(IPv4(a[0], a[1], a[2], a[3]))
|
|
||||||
}
|
|
||||||
|
|
||||||
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
|
|
||||||
ip, err := interfaceToIPv4Addr(ifi)
|
|
||||||
if err != nil {
|
|
||||||
return os.NewSyscallError("setsockopt", err)
|
|
||||||
}
|
|
||||||
var x [4]byte
|
|
||||||
copy(x[:], ip.To4())
|
|
||||||
if err := fd.incref(false); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer fd.decref()
|
|
||||||
err = syscall.SetsockoptInet4Addr(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, x)
|
|
||||||
if err != nil {
|
|
||||||
return os.NewSyscallError("setsockopt", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ipv4MulticastLoopback(fd *netFD) (bool, error) {
|
|
||||||
if err := fd.incref(false); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
defer fd.decref()
|
|
||||||
v, err := syscall.GetsockoptByte(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP)
|
|
||||||
if err != nil {
|
|
||||||
return false, os.NewSyscallError("getsockopt", err)
|
|
||||||
}
|
|
||||||
return v == 1, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setIPv4MulticastLoopback(fd *netFD, v bool) error {
|
|
||||||
if err := fd.incref(false); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer fd.decref()
|
|
||||||
err := syscall.SetsockoptByte(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, byte(boolint(v)))
|
|
||||||
if err != nil {
|
|
||||||
return os.NewSyscallError("setsockopt", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ipv4ReceiveInterface(fd *netFD) (bool, error) {
|
|
||||||
if err := fd.incref(false); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
defer fd.decref()
|
|
||||||
v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_RECVIF)
|
|
||||||
if err != nil {
|
|
||||||
return false, os.NewSyscallError("getsockopt", err)
|
|
||||||
}
|
|
||||||
return v == 1, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setIPv4ReceiveInterface(fd *netFD, v bool) error {
|
|
||||||
if err := fd.incref(false); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer fd.decref()
|
|
||||||
err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_RECVIF, boolint(v))
|
|
||||||
if err != nil {
|
|
||||||
return os.NewSyscallError("setsockopt", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2012 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
|
||||||
|
|
||||||
|
func (ts *Timestruc) Unix() (sec int64, nsec int64) {
|
||||||
|
return int64(ts.Sec), int64(ts.Nsec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *Timestruc) Nano() int64 {
|
||||||
|
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue