summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2017-09-20 17:40:11 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2017-09-20 17:40:11 +0000
commit664ac495f9fe9595ce69d0332b000ba9c7737f6d (patch)
treed50a8f6f9050d90b84b0a3479b6a9d687202e5e6
parent2be5943db3ad1a65fc2dda58f0059b2c3af3a354 (diff)
downloadgcc-664ac495f9fe9595ce69d0332b000ba9c7737f6d.tar.gz
syscall: workaround for getsockname bug in AIX
Reviewed-on: https://go-review.googlesource.com/64552 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253021 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--libgo/go/syscall/socket_aix.go89
-rw-r--r--libgo/go/syscall/socket_bsd.go2
-rw-r--r--libgo/go/syscall/syscall_aix_ppc.go49
-rw-r--r--libgo/go/syscall/syscall_aix_ppc64.go49
5 files changed, 189 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index cca4a16e7ec..27b0be0a345 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-90fe3da36d904b62d47c00ee40eef4fd2693a5da
+84f827669dc76326ed99ebcc982c482aa148d8d8
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/libgo/go/syscall/socket_aix.go b/libgo/go/syscall/socket_aix.go
new file mode 100644
index 00000000000..40cf42365e2
--- /dev/null
+++ b/libgo/go/syscall/socket_aix.go
@@ -0,0 +1,89 @@
+// socket_aix.go -- Socket handling specific to AIX.
+
+// Copyright 2017 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
+
+import "unsafe"
+
+const SizeofSockaddrInet4 = 16
+const SizeofSockaddrInet6 = 28
+const SizeofSockaddrUnix = 1025
+
+type RawSockaddrInet4 struct {
+ Len uint8
+ Family uint8
+ Port uint16
+ Addr [4]byte /* in_addr */
+ Zero [8]uint8
+}
+
+func (sa *RawSockaddrInet4) setLen() Socklen_t {
+ sa.Len = SizeofSockaddrInet4
+ return SizeofSockaddrInet4
+}
+
+type RawSockaddrInet6 struct {
+ Len uint8
+ Family uint8
+ Port uint16
+ Flowinfo uint32
+ Addr [16]byte /* in6_addr */
+ Scope_id uint32
+}
+
+func (sa *RawSockaddrInet6) setLen() Socklen_t {
+ sa.Len = SizeofSockaddrInet6
+ return SizeofSockaddrInet6
+}
+
+type RawSockaddrUnix struct {
+ Len uint8
+ Family uint8
+ Path [1023]int8
+}
+
+func (sa *RawSockaddrUnix) setLen(n int) {
+ sa.Len = uint8(3 + n) // 2 for Family, Len; 1 for NUL.
+}
+
+func (sa *RawSockaddrUnix) getLen() (int, error) {
+ // Some versions of AIX have a bug in getsockname (see IV78655).
+ // We can't rely on sa.Len being set correctly.
+ n := SizeofSockaddrUnix - 3 // substract leading Family, Len, terminating NUL.
+ for i := 0; i < n; i++ {
+ if sa.Path[i] == 0 {
+ n = i
+ break
+ }
+ }
+ return n, nil
+}
+
+func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t {
+ return sl
+}
+
+type RawSockaddr struct {
+ Len uint8
+ Family uint8
+ Data [14]int8
+}
+
+// BindToDevice binds the socket associated with fd to device.
+func BindToDevice(fd int, device string) (err error) {
+ return ENOSYS
+}
+
+func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) {
+ return nil, EAFNOSUPPORT
+}
+
+func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
+ var value IPv6MTUInfo
+ vallen := Socklen_t(SizeofIPv6MTUInfo)
+ err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+ return &value, err
+}
diff --git a/libgo/go/syscall/socket_bsd.go b/libgo/go/syscall/socket_bsd.go
index ecdab060701..cf3fc4f8da0 100644
--- a/libgo/go/syscall/socket_bsd.go
+++ b/libgo/go/syscall/socket_bsd.go
@@ -4,7 +4,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build aix darwin dragonfly freebsd openbsd netbsd
+// +build darwin dragonfly freebsd openbsd netbsd
package syscall
diff --git a/libgo/go/syscall/syscall_aix_ppc.go b/libgo/go/syscall/syscall_aix_ppc.go
new file mode 100644
index 00000000000..83ed1e64c3a
--- /dev/null
+++ b/libgo/go/syscall/syscall_aix_ppc.go
@@ -0,0 +1,49 @@
+// syscall_aix_ppc.go -- AIX 32-bit specific support
+
+// Copyright 2017 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
+
+import "unsafe"
+
+// AIX does not define a specific structure but instead uses separate
+// ptrace calls for the different registers.
+type PtraceRegs struct {
+ Gpr [32]uint32
+ Iar uint32
+ Msr uint32
+ Cr uint32
+ Lr uint32
+ Ctr uint32
+ Xer uint32
+}
+
+func (r *PtraceRegs) PC() uint64 { return uint64(r.Iar) }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Iar = uint32(pc) }
+
+func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
+ ptrace(_PT_REGSET, pid, uintptr(unsafe.Pointer(&regsout.Gpr[0])), 0, 0)
+ regsout.Iar = uint32(ptrace(_PT_READ_GPR, pid, 128, 0, 0))
+ regsout.Msr = uint32(ptrace(_PT_READ_GPR, pid, 129, 0, 0))
+ regsout.Cr = uint32(ptrace(_PT_READ_GPR, pid, 130, 0, 0))
+ regsout.Lr = uint32(ptrace(_PT_READ_GPR, pid, 131, 0, 0))
+ regsout.Ctr = uint32(ptrace(_PT_READ_GPR, pid, 132, 0, 0))
+ regsout.Xer = uint32(ptrace(_PT_READ_GPR, pid, 133, 0, 0))
+ return nil
+}
+
+func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
+ for i := 0; i < len(regs.Gpr); i++ {
+ ptrace(_PT_WRITE_GPR, pid, uintptr(i), int(regs.Gpr[i]), 0)
+ }
+ ptrace(_PT_WRITE_GPR, pid, 128, int(regs.Iar), 0)
+ ptrace(_PT_WRITE_GPR, pid, 129, int(regs.Msr), 0)
+ ptrace(_PT_WRITE_GPR, pid, 130, int(regs.Cr), 0)
+ ptrace(_PT_WRITE_GPR, pid, 131, int(regs.Lr), 0)
+ ptrace(_PT_WRITE_GPR, pid, 132, int(regs.Ctr), 0)
+ ptrace(_PT_WRITE_GPR, pid, 133, int(regs.Xer), 0)
+ return nil
+}
diff --git a/libgo/go/syscall/syscall_aix_ppc64.go b/libgo/go/syscall/syscall_aix_ppc64.go
new file mode 100644
index 00000000000..82388cad140
--- /dev/null
+++ b/libgo/go/syscall/syscall_aix_ppc64.go
@@ -0,0 +1,49 @@
+// syscall_aix_ppc64.go -- AIX 64-bit specific support
+
+// Copyright 2017 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
+
+import "unsafe"
+
+// AIX does not define a specific structure but instead uses separate
+// ptrace calls for the different registers.
+type PtraceRegs struct {
+ Gpr [32]uint64
+ Iar uint64
+ Msr uint64
+ Cr uint64
+ Lr uint64
+ Ctr uint64
+ Xer uint64
+}
+
+func (r *PtraceRegs) PC() uint64 { return r.Iar }
+
+func (r *PtraceRegs) SetPC(pc uint64) { r.Iar = pc }
+
+func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
+ ptrace64(_PT_REGSET, int64(pid), int64(uintptr(unsafe.Pointer(&regsout.Gpr[0]))), 0, 0)
+ ptrace64(_PT_READ_GPR, int64(pid), 128, 0, uintptr(unsafe.Pointer(&regsout.Iar)))
+ ptrace64(_PT_READ_GPR, int64(pid), 129, 0, uintptr(unsafe.Pointer(&regsout.Msr)))
+ ptrace64(_PT_READ_GPR, int64(pid), 130, 0, uintptr(unsafe.Pointer(&regsout.Cr)))
+ ptrace64(_PT_READ_GPR, int64(pid), 131, 0, uintptr(unsafe.Pointer(&regsout.Lr)))
+ ptrace64(_PT_READ_GPR, int64(pid), 132, 0, uintptr(unsafe.Pointer(&regsout.Ctr)))
+ ptrace64(_PT_READ_GPR, int64(pid), 133, 0, uintptr(unsafe.Pointer(&regsout.Xer)))
+ return nil
+}
+
+func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
+ for i := 0; i < len(regs.Gpr); i++ {
+ ptrace64(_PT_WRITE_GPR, int64(pid), int64(i), 0, uintptr(unsafe.Pointer(&regs.Gpr[i])))
+ }
+ ptrace64(_PT_WRITE_GPR, int64(pid), 128, 0, uintptr(unsafe.Pointer(&regs.Iar)))
+ ptrace64(_PT_WRITE_GPR, int64(pid), 129, 0, uintptr(unsafe.Pointer(&regs.Msr)))
+ ptrace64(_PT_WRITE_GPR, int64(pid), 130, 0, uintptr(unsafe.Pointer(&regs.Cr)))
+ ptrace64(_PT_WRITE_GPR, int64(pid), 131, 0, uintptr(unsafe.Pointer(&regs.Lr)))
+ ptrace64(_PT_WRITE_GPR, int64(pid), 132, 0, uintptr(unsafe.Pointer(&regs.Ctr)))
+ ptrace64(_PT_WRITE_GPR, int64(pid), 133, 0, uintptr(unsafe.Pointer(&regs.Xer)))
+ return nil
+}