This libgo patch by Nikhil Benesch only compiles the ptrace varargs
shim on GNU/Linux, to avoid compilation failures on some other
platforms. The C ptrace function is not entirely portable (e.g.,
NetBSD has `int data` instead of `void* data`), and so far Linux is
the only platform that needs the varargs shim.

Additionally, make the types in the ptrace and raw_ptrace function
declarations match. This makes it more clear that the only difference
between the two is that calls via the former are allowed to block
while calls via the latter are not.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
c3627fd56a707b6059b86e7ca018166f080b5403
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index aedaf4664d5..384ca6e8864 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-64c25b2365f7125a32b3146618b627f26a78c1fc
+fa66bd11bbe58943e273cfa74356771c996f5b24
 
 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/exec_bsd.go b/libgo/go/syscall/exec_bsd.go
index 7e06943f13e..ca7fdc0825e 100644
--- a/libgo/go/syscall/exec_bsd.go
+++ b/libgo/go/syscall/exec_bsd.go
@@ -93,7 +93,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, 
chroot, dir *byte, attr
 
        // Enable tracing if requested.
        if sys.Ptrace {
-               err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil)
+               err1 = raw_ptrace(_PTRACE_TRACEME, 0, 0, 0)
                if err1 != 0 {
                        goto childerror
                }
diff --git a/libgo/go/syscall/exec_linux.go b/libgo/go/syscall/exec_linux.go
index 2f0a34fef0b..38975810432 100644
--- a/libgo/go/syscall/exec_linux.go
+++ b/libgo/go/syscall/exec_linux.go
@@ -538,7 +538,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, 
chroot, dir *byte, att
        // Do this right before exec so that we don't unnecessarily trace the 
runtime
        // setting up after the fork. See issue #21428.
        if sys.Ptrace {
-               err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil)
+               err1 = raw_ptrace(_PTRACE_TRACEME, 0, 0, 0)
                if err1 != 0 {
                        goto childerror
                }
diff --git a/libgo/go/syscall/exec_stubs.go b/libgo/go/syscall/exec_stubs.go
index e95b4158e1a..c837cf7a4e2 100644
--- a/libgo/go/syscall/exec_stubs.go
+++ b/libgo/go/syscall/exec_stubs.go
@@ -30,6 +30,6 @@ func (w WaitStatus) Signal() int     { return 0 }
 func (w WaitStatus) StopSignal() int { return 0 }
 func (w WaitStatus) TrapCause() int  { return 0 }
 
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
        return ENOSYS
 }
diff --git a/libgo/go/syscall/libcall_aix.go b/libgo/go/syscall/libcall_aix.go
index 27b469e1e47..92c7f3cc232 100644
--- a/libgo/go/syscall/libcall_aix.go
+++ b/libgo/go/syscall/libcall_aix.go
@@ -19,7 +19,7 @@ const SYS_EXECVE = 0
 //sys  ptrace64(request int, id int64, addr int64, data int, buff uintptr) 
(err error)
 //ptrace64(request _C_int, id int64, addr int64, data _C_int, buff *byte) 
_C_int
 
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
        if request == _PTRACE_TRACEME {
                // Convert to AIX ptrace call.
                err := ptrace64(_PT_TRACE_ME, 0, 0, 0, 0)
diff --git a/libgo/go/syscall/libcall_glibc.go 
b/libgo/go/syscall/libcall_glibc.go
index 823343d5075..a32d6968f24 100644
--- a/libgo/go/syscall/libcall_glibc.go
+++ b/libgo/go/syscall/libcall_glibc.go
@@ -31,9 +31,6 @@ func Futimes(fd int, tv []Timeval) (err error) {
        return Utimes("/proc/self/fd/"+itoa(fd), tv)
 }
 
-//sys  ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
-//__go_ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
-
 //sys  accept4(fd int, sa *RawSockaddrAny, len *Socklen_t, flags int) (nfd 
int, err error)
 //accept4(fd _C_int, sa *RawSockaddrAny, len *Socklen_t, flags _C_int) _C_int
 
diff --git a/libgo/go/syscall/libcall_hurd.go b/libgo/go/syscall/libcall_hurd.go
index f0e038ca616..44ff46d1016 100644
--- a/libgo/go/syscall/libcall_hurd.go
+++ b/libgo/go/syscall/libcall_hurd.go
@@ -7,7 +7,7 @@
 package syscall
 
 // Dummy function
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
        return ENOSYS
 }
 
diff --git a/libgo/go/syscall/libcall_irix.go b/libgo/go/syscall/libcall_irix.go
index 9b6cdcca2c8..98807668d52 100644
--- a/libgo/go/syscall/libcall_irix.go
+++ b/libgo/go/syscall/libcall_irix.go
@@ -6,5 +6,5 @@
 
 package syscall
 
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err 
Errno)
 //ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
diff --git a/libgo/go/syscall/libcall_linux.go 
b/libgo/go/syscall/libcall_linux.go
index 78fda0ea7ef..96974bd3269 100644
--- a/libgo/go/syscall/libcall_linux.go
+++ b/libgo/go/syscall/libcall_linux.go
@@ -10,7 +10,10 @@ import (
        "unsafe"
 )
 
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sys  ptrace(request int, pid int, addr uintptr, data uintptr) (err Errno)
+//__go_ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
+
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err 
Errno)
 //__go_ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
 
 func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err 
error) {
diff --git a/libgo/go/syscall/libcall_solaris_386.go 
b/libgo/go/syscall/libcall_solaris_386.go
index 20eba22a302..ef86f09711d 100644
--- a/libgo/go/syscall/libcall_solaris_386.go
+++ b/libgo/go/syscall/libcall_solaris_386.go
@@ -8,5 +8,5 @@ package syscall
 //sysnb        Uname(buf *Utsname) (err error)
 //_nuname(buf *Utsname) _C_int
 
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err 
Errno)
 //ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
diff --git a/libgo/go/syscall/libcall_solaris_amd64.go 
b/libgo/go/syscall/libcall_solaris_amd64.go
index 69b11ba5ee6..f44025e1eec 100644
--- a/libgo/go/syscall/libcall_solaris_amd64.go
+++ b/libgo/go/syscall/libcall_solaris_amd64.go
@@ -5,6 +5,6 @@
 package syscall
 
 // 64-bit ptrace(3C) doesn't exist
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
        return ENOSYS
 }
diff --git a/libgo/go/syscall/libcall_solaris_sparc.go 
b/libgo/go/syscall/libcall_solaris_sparc.go
index 50863fadf18..3d50309983f 100644
--- a/libgo/go/syscall/libcall_solaris_sparc.go
+++ b/libgo/go/syscall/libcall_solaris_sparc.go
@@ -4,5 +4,5 @@
 
 package syscall
 
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err 
Errno)
 //ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
diff --git a/libgo/go/syscall/libcall_solaris_sparc64.go 
b/libgo/go/syscall/libcall_solaris_sparc64.go
index 69b11ba5ee6..f44025e1eec 100644
--- a/libgo/go/syscall/libcall_solaris_sparc64.go
+++ b/libgo/go/syscall/libcall_solaris_sparc64.go
@@ -5,6 +5,6 @@
 package syscall
 
 // 64-bit ptrace(3C) doesn't exist
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
        return ENOSYS
 }
diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c
index d8f7dc55ea4..f84860891e6 100644
--- a/libgo/runtime/go-varargs.c
+++ b/libgo/runtime/go-varargs.c
@@ -114,12 +114,11 @@ __go_syscall6(uintptr_t flag, uintptr_t a1, uintptr_t a2, 
uintptr_t a3,
 
 #endif
 
-// AIX ptrace is really different from Linux ptrace. Let syscall
-// package handles it.
-#if defined(HAVE_SYS_PTRACE_H) && !defined(_AIX)
+
+#if defined(HAVE_SYS_PTRACE_H) && defined(__linux__)
 
 // Despite documented appearances, this is actually implemented as
-// a variadic function within glibc.
+// a variadic function within glibc on Linux.
 
 long
 __go_ptrace(int request, pid_t pid, void *addr, void *data)

Reply via email to