Use __builtin_memmove for trivially copyable types
[official-gcc.git] / libgo / go / syscall / syscall_aix_ppc64.go
blob82388cad14028a0573f08544dee59aff9a3d0c01
1 // syscall_aix_ppc64.go -- AIX 64-bit specific support
3 // Copyright 2017 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 package syscall
9 import "unsafe"
11 // AIX does not define a specific structure but instead uses separate
12 // ptrace calls for the different registers.
13 type PtraceRegs struct {
14 Gpr [32]uint64
15 Iar uint64
16 Msr uint64
17 Cr uint64
18 Lr uint64
19 Ctr uint64
20 Xer uint64
23 func (r *PtraceRegs) PC() uint64 { return r.Iar }
25 func (r *PtraceRegs) SetPC(pc uint64) { r.Iar = pc }
27 func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
28 ptrace64(_PT_REGSET, int64(pid), int64(uintptr(unsafe.Pointer(&regsout.Gpr[0]))), 0, 0)
29 ptrace64(_PT_READ_GPR, int64(pid), 128, 0, uintptr(unsafe.Pointer(&regsout.Iar)))
30 ptrace64(_PT_READ_GPR, int64(pid), 129, 0, uintptr(unsafe.Pointer(&regsout.Msr)))
31 ptrace64(_PT_READ_GPR, int64(pid), 130, 0, uintptr(unsafe.Pointer(&regsout.Cr)))
32 ptrace64(_PT_READ_GPR, int64(pid), 131, 0, uintptr(unsafe.Pointer(&regsout.Lr)))
33 ptrace64(_PT_READ_GPR, int64(pid), 132, 0, uintptr(unsafe.Pointer(&regsout.Ctr)))
34 ptrace64(_PT_READ_GPR, int64(pid), 133, 0, uintptr(unsafe.Pointer(&regsout.Xer)))
35 return nil
38 func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
39 for i := 0; i < len(regs.Gpr); i++ {
40 ptrace64(_PT_WRITE_GPR, int64(pid), int64(i), 0, uintptr(unsafe.Pointer(&regs.Gpr[i])))
42 ptrace64(_PT_WRITE_GPR, int64(pid), 128, 0, uintptr(unsafe.Pointer(&regs.Iar)))
43 ptrace64(_PT_WRITE_GPR, int64(pid), 129, 0, uintptr(unsafe.Pointer(&regs.Msr)))
44 ptrace64(_PT_WRITE_GPR, int64(pid), 130, 0, uintptr(unsafe.Pointer(&regs.Cr)))
45 ptrace64(_PT_WRITE_GPR, int64(pid), 131, 0, uintptr(unsafe.Pointer(&regs.Lr)))
46 ptrace64(_PT_WRITE_GPR, int64(pid), 132, 0, uintptr(unsafe.Pointer(&regs.Ctr)))
47 ptrace64(_PT_WRITE_GPR, int64(pid), 133, 0, uintptr(unsafe.Pointer(&regs.Xer)))
48 return nil