From patchwork Wed Sep 20 14:59:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 816284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-462605-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lHwBawSI"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xy2wJ57Wcz9sNr for ; Thu, 21 Sep 2017 01:00:00 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=B3A/wJr+1XHtw+srsy4hBxSJxdJZuEXO2EpV337AyuBmam xmRVyLIm7+n1r+1CiCgwKyTf+uQ5lhUAtPbH4/wFR/xNUKFI7QmMcmKHlNxsTmTt SpeSXyvNLKJAoEJjs2rSqsFLnSozxZMaMW6ssIcUSnObLFN5mN6KJycRDlefY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=+HPlQJyNCGLCQn++DZ+JbUYc21I=; b=lHwBawSIphYNIgyTGt1/ lGab88S3kIY/u4XWDKwvddClMyuSxXMgokrMMQcmHR/Jagd5azCvZRNTlWztu6fe /sKVz9wMZK6W5J9q5HBTCGiV/SqDwj8IUtNmg96rDU4qGbfeCCg+1ZkSTR5lG/j7 OZEwfs8+Iqmr9Z7gmCzRRmc= Received: (qmail 57551 invoked by alias); 20 Sep 2017 14:59:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 56751 invoked by uid 89); 20 Sep 2017 14:59:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=LICENSE, acct X-HELO: mail-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 14:59:48 +0000 Received: by mail-oi0-f44.google.com with SMTP id i6so3011475oih.8 for ; Wed, 20 Sep 2017 07:59:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9ueHTJ2xfUrEVMMa7/6vB3fDkmcWTr4u6Yu/pKENUzU=; b=DEoYsfFpSRua5TS7GZbMtPuMtfV3ClMSRbWPMLummWF2446VVFySGdOGiyYuz9Bd4H yXvy8lf9YbJWcFuQUT8VMcAVB+X/ex5CLovW8KdNe29EJTHjNz7NVXx0JOwvBCTcP9q/ 0fj2Cass7319jzH/wWL7DmZ1bC0l9qAo2uCcfdZL4+2R+8Yh3oJ60T6ng1BQFwLUWxr+ 3xJokxr8mSAjKmgEG2Ci6eaXu5xTkUMIQ3JFy0i/RUuWKwQsOKLMgq5340iC+Kv5nGjr 9ZEcafmSWydEfjIuAwJZZo3M/e2uQYdLOXyXHF5pYWVjp80h6fTQCxLx+EuctOzUB7Cu xIkA== X-Gm-Message-State: AHPjjUh8wu/+sUPNi+kmTgaDL+2zr1/+bMNAx+tXLUp/yMe32yKJaMSD YC5d/l8/z1zZz55pybOe2jfDpZnnFMR1t2aE6hCRq4GZ X-Google-Smtp-Source: AOwi7QAcADML+vQtoP8N8WC+UcCskYEfxvmcOiP+HzK3c9PJF0pQCCgUz7WqT18bBHEKJ76kc6Sq2i8MzCOUfJKk/xQ= X-Received: by 10.202.78.207 with SMTP id c198mr6258509oib.2.1505919586303; Wed, 20 Sep 2017 07:59:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.168.117.78 with HTTP; Wed, 20 Sep 2017 07:59:45 -0700 (PDT) From: Ian Lance Taylor Date: Wed, 20 Sep 2017 07:59:45 -0700 Message-ID: Subject: libgo patch commited: AIX updates To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch by Tony Reix adds some AIX updates, notably for the recent 1.9 update. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 252991) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -5fb74cd7192123a9ea06dcae0d5d8d0b3538db8f +90fe3da36d904b62d47c00ee40eef4fd2693a5da The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/cmd/go/internal/base/signal_unix.go =================================================================== --- libgo/go/cmd/go/internal/base/signal_unix.go (revision 252767) +++ libgo/go/cmd/go/internal/base/signal_unix.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris package base Index: libgo/go/internal/poll/export_posix_test.go =================================================================== --- libgo/go/internal/poll/export_posix_test.go (revision 252767) +++ libgo/go/internal/poll/export_posix_test.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows // Export guts for testing on posix. // Since testing imports os and os imports internal/poll, Index: libgo/go/internal/poll/fd_poll_runtime.go =================================================================== --- libgo/go/internal/poll/fd_poll_runtime.go (revision 252767) +++ libgo/go/internal/poll/fd_poll_runtime.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd windows solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd windows solaris package poll Index: libgo/go/internal/poll/fd_posix.go =================================================================== --- libgo/go/internal/poll/fd_posix.go (revision 252767) +++ libgo/go/internal/poll/fd_posix.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows package poll Index: libgo/go/internal/poll/fd_posix_test.go =================================================================== --- libgo/go/internal/poll/fd_posix_test.go (revision 252767) +++ libgo/go/internal/poll/fd_posix_test.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows package poll_test Index: libgo/go/internal/poll/fd_unix.go =================================================================== --- libgo/go/internal/poll/fd_unix.go (revision 252767) +++ libgo/go/internal/poll/fd_unix.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris package poll Index: libgo/go/internal/poll/hook_unix.go =================================================================== --- libgo/go/internal/poll/hook_unix.go (revision 252767) +++ libgo/go/internal/poll/hook_unix.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris package poll Index: libgo/go/internal/poll/sockopt.go =================================================================== --- libgo/go/internal/poll/sockopt.go (revision 252767) +++ libgo/go/internal/poll/sockopt.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package poll Index: libgo/go/internal/poll/sockoptip.go =================================================================== --- libgo/go/internal/poll/sockoptip.go (revision 252767) +++ libgo/go/internal/poll/sockoptip.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd windows +// +build aix darwin dragonfly freebsd linux netbsd openbsd windows package poll Index: libgo/go/internal/poll/sys_cloexec.go =================================================================== --- libgo/go/internal/poll/sys_cloexec.go (revision 252767) +++ libgo/go/internal/poll/sys_cloexec.go (working copy) @@ -5,7 +5,7 @@ // This file implements sysSocket and accept for platforms that do not // provide a fast path for setting SetNonblock and CloseOnExec. -// +build darwin nacl netbsd openbsd solaris +// +build aix darwin nacl netbsd openbsd solaris package poll Index: libgo/go/net/error_posix.go =================================================================== --- libgo/go/net/error_posix.go (revision 252767) +++ libgo/go/net/error_posix.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows package net Index: libgo/go/os/user/cgo_lookup_unix.go =================================================================== --- libgo/go/os/user/cgo_lookup_unix.go (revision 252767) +++ libgo/go/os/user/cgo_lookup_unix.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd !android,linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd !android,linux netbsd openbsd solaris // +build cgo package user Index: libgo/go/runtime/export_unix_test.go =================================================================== --- libgo/go/runtime/export_unix_test.go (revision 252767) +++ libgo/go/runtime/export_unix_test.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package runtime Index: libgo/go/runtime/netpoll_aix.go =================================================================== --- libgo/go/runtime/netpoll_aix.go (revision 251948) +++ libgo/go/runtime/netpoll_aix.go (working copy) @@ -64,14 +64,14 @@ func netpollinit() { var p [2]int32 if ps = pollset_create(-1); ps < 0 { - throw("netpollinit: failed to create pollset") + throw("runtime: netpollinit failed to create pollset") } // It is not possible to add or remove descriptors from // the pollset while pollset_poll is active. // We use a pipe to wakeup pollset_poll when the pollset // needs to be updated. if err := libc_pipe(&p[0]); err < 0 { - throw("netpollinit: failed to create pipe") + throw("runtime: netpollinit failed to create pipe") } rdwake = p[0] wrwake = p[1] @@ -90,12 +90,17 @@ func netpollinit() { pctl.fd = rdwake pctl.events = _POLLIN if pollset_ctl(ps, &pctl, 1) != 0 { - throw("netpollinit: failed to register pipe") + throw("runtime: netpollinit failed to register pipe") } mpfds = make(map[int32]*pollDesc) } +func netpolldescriptor() uintptr { + // ps is not a real file descriptor. + return ^uintptr(0) +} + func netpollopen(fd uintptr, pd *pollDesc) int32 { // pollset_ctl will block if pollset_poll is active // so wakeup pollset_poll first. @@ -144,7 +149,7 @@ func netpollclose(fd uintptr) int32 { } func netpollarm(pd *pollDesc, mode int) { - throw("unused") + throw("runtime: unused") } func netpoll(block bool) *g { @@ -168,7 +173,7 @@ retry: if nfound < 0 { e := errno() if e != _EINTR { - throw("pollset_poll failed") + throw("runtime: pollset_poll failed") } goto retry } Index: libgo/go/syscall/forkpipe_bsd.go =================================================================== --- libgo/go/syscall/forkpipe_bsd.go (revision 252866) +++ libgo/go/syscall/forkpipe_bsd.go (working copy) @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly netbsd openbsd solaris +// +build aix darwin dragonfly netbsd openbsd solaris package syscall Index: libgo/go/syscall/libcall_aix.go =================================================================== --- libgo/go/syscall/libcall_aix.go (revision 251948) +++ libgo/go/syscall/libcall_aix.go (working copy) @@ -6,6 +6,136 @@ package syscall +import ( + "unsafe" +) + +//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) +//open64at(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int + +//sys ptrace(request int, id int, addr uintptr, data int, buff uintptr) (val int) +//ptrace(request _C_int, id int, addr uintptr, data _C_int, buff *byte) _C_int + +//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 { + if request == _PTRACE_TRACEME { + // Convert to AIX ptrace call. + err := ptrace64(_PT_TRACE_ME, 0, 0, 0, 0) + if err != nil { + return err.(Errno) + } + return 0 + } return ENOSYS } + +func ptracePeek(pid int, addr uintptr, out []byte) (count int, err error) { + n := 0 + for len(out) > 0 { + bsize := len(out) + if bsize > 1024 { + bsize = 1024 + } + err = ptrace64(_PT_READ_BLOCK, int64(pid), int64(addr), bsize, uintptr(unsafe.Pointer(&out[0]))) + if err != nil { + return 0, err + } + addr += uintptr(bsize) + n += bsize + out = out[n:] + } + return n, nil +} + +func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) { + return ptracePeek(pid, addr, out) +} + +func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) { + return ptracePeek(pid, addr, out) +} + +func ptracePoke(pid int, addr uintptr, data []byte) (count int, err error) { + n := 0 + for len(data) > 0 { + bsize := len(data) + if bsize > 1024 { + bsize = 1024 + } + err = ptrace64(_PT_WRITE_BLOCK, int64(pid), int64(addr), bsize, uintptr(unsafe.Pointer(&data[0]))) + if err != nil { + return 0, err + } + addr += uintptr(bsize) + n += bsize + data = data[n:] + } + return n, nil +} + +func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) { + return ptracePoke(pid, addr, data) +} + +func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) { + return ptracePoke(pid, addr, data) +} + +func PtraceCont(pid int, signal int) (err error) { + return ptrace64(_PT_CONTINUE, int64(pid), 1, signal, 0) +} + +func PtraceSingleStep(pid int) (err error) { return ptrace64(_PT_STEP, int64(pid), 1, 0, 0) } + +func PtraceAttach(pid int) (err error) { return ptrace64(_PT_ATTACH, int64(pid), 0, 0, 0) } + +func PtraceDetach(pid int) (err error) { return ptrace64(_PT_DETACH, int64(pid), 0, 0, 0) } + +//sys reboot(how int) (err error) +//__linux_reboot(how _C_int) _C_int +func Reboot(how int) (err error) { + return reboot(how) +} + +//sys Acct(path string) (err error) +//acct(path *byte) _C_int + +//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) +//faccessat(dirfd _C_int, pathname *byte, mode _C_int, flags _C_int) _C_int + +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) +//fchmodat(dirfd _C_int, pathname *byte, mode Mode_t, flags _C_int) _C_int + +//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) +//fchownat(dirfd _C_int, path *byte, owner Uid_t, group Gid_t, flags _C_int) _C_int + +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//fstatfs64(fd _C_int, buf *Statfs_t) _C_int + +//sys Mkdirat(dirfd int, path string, mode uint32) (err error) +//mkdirat(dirfd _C_int, path *byte, mode Mode_t) _C_int + +//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//mknodat(dirfd _C_int, path *byte, mode Mode_t, dev _dev_t) _C_int + +//sys getdirent(fd int, buf []byte) (n int, err error) +//getdirent64(fd _C_int, buf *byte, nbyte Size_t) _C_int + +func ReadDirent(fd int, buf []byte) (n int, err error) { + return getdirent(fd, buf) +} + +//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) +//renameat(olddirfd _C_int, oldpath *byte, newdirfd _C_int, newpath *byte) _C_int + +//sys Statfs(path string, buf *Statfs_t) (err error) +//statfs64(path *byte, buf *Statfs_t) _C_int + +//sys unlinkat(dirfd int, path string, flags int) (err error) +//unlinkat(dirfd _C_int, path *byte, flags _C_int) _C_int + +func Unlinkat(dirfd int, path string) (err error) { + return unlinkat(dirfd, path, 0) +}