syscall, golang_org/x/net/lif: fixes for gccgo on Solaris
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 18 Jan 2017 03:37:52 +0000 (03:37 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 18 Jan 2017 03:37:52 +0000 (03:37 +0000)
    Reviewed-on: https://go-review.googlesource.com/35390

From-SVN: r244563

gcc/go/gofrontend/MERGE
libgo/go/golang_org/x/net/lif/link.go
libgo/go/golang_org/x/net/lif/syscall.go
libgo/go/golang_org/x/net/lif/zsys_solaris.go [new file with mode: 0644]
libgo/go/golang_org/x/net/lif/zsys_solaris_amd64.go [deleted file]
libgo/go/syscall/syscall_solaris.go

index 375ce176764a6360bea28129f222f314a4abfbc8..f9897529b735cfd7379c8ca655a5629f36ad5a8d 100644 (file)
@@ -1,4 +1,4 @@
-223cba75b947afc1ee5a13a60c15c66f6ff355c1
+2b3d389f961b8461b3fdf42318a628f68b56f8b1
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 76fa6c68756a94a51d9ad161e59f1f3b26af7963..6a77a8f5d800cfa40ed609e95b261a0061bf271e 100644 (file)
@@ -84,7 +84,7 @@ func links(eps []endpoint, name string) ([]Link, error) {
                b := make([]byte, lifn.Count*sizeofLifreq)
                lifc.Family = uint16(ep.af)
                lifc.Len = lifn.Count * sizeofLifreq
-               littleEndian.PutUint64(lifc.Lifcu[:], uint64(uintptr(unsafe.Pointer(&b[0]))))
+               lifc.Lifcu = unsafe.Pointer(&b[0])
                ioc = int64(sysSIOCGLIFCONF)
                if err := ioctl(ep.s, uintptr(ioc), unsafe.Pointer(&lifc)); err != nil {
                        continue
index 5fe073620a4a67abb747f3bb46bb29b2d4b9b701..ea7541456bd7bae3947d7624cc0742e829948d45 100644 (file)
@@ -11,23 +11,12 @@ import (
        "unsafe"
 )
 
-//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
-
-//go:linkname procIoctl libc_ioctl
-
-var procIoctl uintptr
-
-func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno)
-
-// TODO: replace with runtime.KeepAlive when available
-//go:noescape
-func keepAlive(p unsafe.Pointer)
+//extern __go_ioctl_ptr
+func libc_ioctl(int32, int32, unsafe.Pointer) int32
 
 func ioctl(s, ioc uintptr, arg unsafe.Pointer) error {
-       _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procIoctl)), 3, s, ioc, uintptr(arg), 0, 0, 0)
-       keepAlive(arg)
-       if errno != 0 {
-               return error(errno)
+       if libc_ioctl(int32(s), int32(ioc), arg) < 0 {
+               return syscall.GetErrno()
        }
        return nil
 }
diff --git a/libgo/go/golang_org/x/net/lif/zsys_solaris.go b/libgo/go/golang_org/x/net/lif/zsys_solaris.go
new file mode 100644 (file)
index 0000000..6452dd8
--- /dev/null
@@ -0,0 +1,98 @@
+// Created by cgo -godefs - DO NOT EDIT
+// cgo -godefs defs_solaris.go
+
+package lif
+
+import "unsafe"
+
+const (
+       sysAF_UNSPEC = 0x0
+       sysAF_INET   = 0x2
+       sysAF_INET6  = 0x1a
+
+       sysSOCK_DGRAM = 0x1
+)
+
+type sockaddrStorage struct {
+       Family     uint16
+       X_ss_pad1  [6]int8
+       X_ss_align float64
+       X_ss_pad2  [240]int8
+}
+
+const (
+       sysLIFC_NOXMIT          = 0x1
+       sysLIFC_EXTERNAL_SOURCE = 0x2
+       sysLIFC_TEMPORARY       = 0x4
+       sysLIFC_ALLZONES        = 0x8
+       sysLIFC_UNDER_IPMP      = 0x10
+       sysLIFC_ENABLED         = 0x20
+
+       sysSIOCGLIFADDR    = -0x3f87968f
+       sysSIOCGLIFDSTADDR = -0x3f87968d
+       sysSIOCGLIFFLAGS   = -0x3f87968b
+       sysSIOCGLIFMTU     = -0x3f879686
+       sysSIOCGLIFNETMASK = -0x3f879683
+       sysSIOCGLIFMETRIC  = -0x3f879681
+       sysSIOCGLIFNUM     = -0x3ff3967e
+       sysSIOCGLIFINDEX   = -0x3f87967b
+       sysSIOCGLIFSUBNET  = -0x3f879676
+       sysSIOCGLIFLNKINFO = -0x3f879674
+       sysSIOCGLIFCONF    = -0x3fef965b
+       sysSIOCGLIFHWADDR  = -0x3f879640
+)
+
+const (
+       sysIFF_UP          = 0x1
+       sysIFF_BROADCAST   = 0x2
+       sysIFF_DEBUG       = 0x4
+       sysIFF_LOOPBACK    = 0x8
+       sysIFF_POINTOPOINT = 0x10
+       sysIFF_NOTRAILERS  = 0x20
+       sysIFF_RUNNING     = 0x40
+       sysIFF_NOARP       = 0x80
+       sysIFF_PROMISC     = 0x100
+       sysIFF_ALLMULTI    = 0x200
+       sysIFF_INTELLIGENT = 0x400
+       sysIFF_MULTICAST   = 0x800
+       sysIFF_MULTI_BCAST = 0x1000
+       sysIFF_UNNUMBERED  = 0x2000
+       sysIFF_PRIVATE     = 0x8000
+)
+
+const (
+       sizeofLifreq       = 0x178
+)
+
+type sysLifnum struct {
+       Family    uint16
+       Flags     int32
+       Count     int32
+}
+
+type lifreq struct {
+       Name   [32]int8
+       Lifru1 [4]byte
+       Type   uint32
+       Lifru  [336]byte
+}
+
+type lifconf struct {
+       Family    uint16
+       Flags     int32
+       Len       int32
+       Lifcu     unsafe.Pointer
+}
+
+type lifIfinfoReq struct {
+       Maxhops      uint8
+       Reachtime    uint32
+       Reachretrans uint32
+       Maxmtu       uint32
+}
+
+const (
+       sysIFT_IPV4 = 0xc8
+       sysIFT_IPV6 = 0xc9
+       sysIFT_6TO4 = 0xca
+)
diff --git a/libgo/go/golang_org/x/net/lif/zsys_solaris_amd64.go b/libgo/go/golang_org/x/net/lif/zsys_solaris_amd64.go
deleted file mode 100644 (file)
index 94231c4..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs defs_solaris.go
-
-package lif
-
-const (
-       sysAF_UNSPEC = 0x0
-       sysAF_INET   = 0x2
-       sysAF_INET6  = 0x1a
-
-       sysSOCK_DGRAM = 0x1
-)
-
-type sockaddrStorage struct {
-       Family     uint16
-       X_ss_pad1  [6]int8
-       X_ss_align float64
-       X_ss_pad2  [240]int8
-}
-
-const (
-       sysLIFC_NOXMIT          = 0x1
-       sysLIFC_EXTERNAL_SOURCE = 0x2
-       sysLIFC_TEMPORARY       = 0x4
-       sysLIFC_ALLZONES        = 0x8
-       sysLIFC_UNDER_IPMP      = 0x10
-       sysLIFC_ENABLED         = 0x20
-
-       sysSIOCGLIFADDR    = -0x3f87968f
-       sysSIOCGLIFDSTADDR = -0x3f87968d
-       sysSIOCGLIFFLAGS   = -0x3f87968b
-       sysSIOCGLIFMTU     = -0x3f879686
-       sysSIOCGLIFNETMASK = -0x3f879683
-       sysSIOCGLIFMETRIC  = -0x3f879681
-       sysSIOCGLIFNUM     = -0x3ff3967e
-       sysSIOCGLIFINDEX   = -0x3f87967b
-       sysSIOCGLIFSUBNET  = -0x3f879676
-       sysSIOCGLIFLNKINFO = -0x3f879674
-       sysSIOCGLIFCONF    = -0x3fef965b
-       sysSIOCGLIFHWADDR  = -0x3f879640
-)
-
-const (
-       sysIFF_UP          = 0x1
-       sysIFF_BROADCAST   = 0x2
-       sysIFF_DEBUG       = 0x4
-       sysIFF_LOOPBACK    = 0x8
-       sysIFF_POINTOPOINT = 0x10
-       sysIFF_NOTRAILERS  = 0x20
-       sysIFF_RUNNING     = 0x40
-       sysIFF_NOARP       = 0x80
-       sysIFF_PROMISC     = 0x100
-       sysIFF_ALLMULTI    = 0x200
-       sysIFF_INTELLIGENT = 0x400
-       sysIFF_MULTICAST   = 0x800
-       sysIFF_MULTI_BCAST = 0x1000
-       sysIFF_UNNUMBERED  = 0x2000
-       sysIFF_PRIVATE     = 0x8000
-)
-
-const (
-       sizeofLifnum       = 0xc
-       sizeofLifreq       = 0x178
-       sizeofLifconf      = 0x18
-       sizeofLifIfinfoReq = 0x10
-)
-
-type sysLifnum struct {
-       Family    uint16
-       Pad_cgo_0 [2]byte
-       Flags     int32
-       Count     int32
-}
-
-type lifreq struct {
-       Name   [32]int8
-       Lifru1 [4]byte
-       Type   uint32
-       Lifru  [336]byte
-}
-
-type lifconf struct {
-       Family    uint16
-       Pad_cgo_0 [2]byte
-       Flags     int32
-       Len       int32
-       Pad_cgo_1 [4]byte
-       Lifcu     [8]byte
-}
-
-type lifIfinfoReq struct {
-       Maxhops      uint8
-       Pad_cgo_0    [3]byte
-       Reachtime    uint32
-       Reachretrans uint32
-       Maxmtu       uint32
-}
-
-const (
-       sysIFT_IPV4 = 0xc8
-       sysIFT_IPV6 = 0xc9
-       sysIFT_6TO4 = 0xca
-)
index 0b2d7483e42be1cf0d5582faba0632b5461f8ec0..673ba8223fc8fef58a00a7fe47d0af6c4be5002a 100644 (file)
@@ -29,3 +29,20 @@ func direntNamlen(buf []byte) (uint64, bool) {
        }
        return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true
 }
+
+//sysnb getexecname() (execname unsafe.Pointer, err error)
+//getexecname() *byte
+
+func Getexecname() (path string, err error) {
+       ptr, err := getexecname()
+       if err != nil {
+               return "", err
+       }
+       bytes := (*[1 << 29]byte)(ptr)[:]
+       for i, b := range bytes {
+               if b == 0 {
+                       return string(bytes[:i]), nil
+               }
+       }
+       panic("unreachable")
+}