diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-08-06 00:36:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-08-06 00:36:33 +0000 |
commit | e0f69f36ea1e068cb9aa48ea0d274b98530f2488 (patch) | |
tree | 8925fdf222aa5a7635a6eb748602b694043eafb7 /libgo/go | |
parent | d712e9a7e2ec4de5e6e9f72b85b620e719757ee3 (diff) | |
download | gcc-e0f69f36ea1e068cb9aa48ea0d274b98530f2488.zip gcc-e0f69f36ea1e068cb9aa48ea0d274b98530f2488.tar.gz gcc-e0f69f36ea1e068cb9aa48ea0d274b98530f2488.tar.bz2 |
libgo: change build procedure to use build tags
Previously the libgo Makefile explicitly listed the set of files to
compile for each package. For packages that use build tags, this
required a lot of awkward automake conditionals in the Makefile.
This CL changes the build to look at the build tags in the files.
The new shell script libgo/match.sh does the matching. This required
adjusting a lot of build tags, and removing some files that are never
used. I verified that the exact same sets of files are compiled on
amd64 GNU/Linux. I also tested the build on i386 Solaris.
Writing match.sh revealed some bugs in the build tag handling that
already exists, in a slightly different form, in the gotest shell
script. This CL fixes those problems as well.
The old code used automake conditionals to handle systems that were
missing strerror_r and wait4. Rather than deal with those in Go, those
functions are now implemented in runtime/go-nosys.c when necessary, so
the Go code can simply assume that they exist.
The os testsuite looked for dir_unix.go, which was never built for gccgo
and has now been removed. I changed the testsuite to look for dir.go
instead.
Reviewed-on: https://go-review.googlesource.com/25546
From-SVN: r239189
Diffstat (limited to 'libgo/go')
102 files changed, 140 insertions, 2226 deletions
diff --git a/libgo/go/crypto/aes/aes_gcm.go b/libgo/go/crypto/aes/aes_gcm.go index a894a68..b59e867 100644 --- a/libgo/go/crypto/aes/aes_gcm.go +++ b/libgo/go/crypto/aes/aes_gcm.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 +// +build ignore +// -build amd64 package aes diff --git a/libgo/go/crypto/aes/cipher_amd64.go b/libgo/go/crypto/aes/cipher_amd64.go index b33c8ff..22769b9 100644 --- a/libgo/go/crypto/aes/cipher_amd64.go +++ b/libgo/go/crypto/aes/cipher_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package aes import ( diff --git a/libgo/go/crypto/aes/cipher_generic.go b/libgo/go/crypto/aes/cipher_generic.go index f807034..2c8d299 100644 --- a/libgo/go/crypto/aes/cipher_generic.go +++ b/libgo/go/crypto/aes/cipher_generic.go @@ -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 !amd64,!s390x +// -build !amd64,!s390x package aes diff --git a/libgo/go/crypto/aes/cipher_s390x.go b/libgo/go/crypto/aes/cipher_s390x.go index bec5933..c9d60e9 100644 --- a/libgo/go/crypto/aes/cipher_s390x.go +++ b/libgo/go/crypto/aes/cipher_s390x.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package aes import ( diff --git a/libgo/go/crypto/elliptic/p256.go b/libgo/go/crypto/elliptic/p256.go index 05a3311..688e0b4 100644 --- a/libgo/go/crypto/elliptic/p256.go +++ b/libgo/go/crypto/elliptic/p256.go @@ -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 !amd64 +// -build !amd64 package elliptic diff --git a/libgo/go/crypto/elliptic/p256_amd64.go b/libgo/go/crypto/elliptic/p256_amd64.go index 66b7cf8..8f3db07 100644 --- a/libgo/go/crypto/elliptic/p256_amd64.go +++ b/libgo/go/crypto/elliptic/p256_amd64.go @@ -10,6 +10,7 @@ // http://link.springer.com/article/10.1007%2Fs13389-014-0090-x // https://eprint.iacr.org/2013/816.pdf +// +build ignore // +build amd64 package elliptic diff --git a/libgo/go/crypto/md5/md5block_decl.go b/libgo/go/crypto/md5/md5block_decl.go index 1e6f6e6..4de38cf 100644 --- a/libgo/go/crypto/md5/md5block_decl.go +++ b/libgo/go/crypto/md5/md5block_decl.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 amd64p32 386 arm ppc64le s390x +// +build ignore +// -build amd64 amd64p32 386 arm ppc64le s390x package md5 diff --git a/libgo/go/crypto/md5/md5block_generic.go b/libgo/go/crypto/md5/md5block_generic.go index 726e09b..c23d02b 100644 --- a/libgo/go/crypto/md5/md5block_generic.go +++ b/libgo/go/crypto/md5/md5block_generic.go @@ -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 !amd64,!amd64p32,!386,!arm,!ppc64le,!s390x +// -build !amd64,!amd64p32,!386,!arm,!ppc64le,!s390x package md5 diff --git a/libgo/go/crypto/rc4/rc4_asm.go b/libgo/go/crypto/rc4/rc4_asm.go index 02e5b67..687ea23 100644 --- a/libgo/go/crypto/rc4/rc4_asm.go +++ b/libgo/go/crypto/rc4/rc4_asm.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // +build amd64 amd64p32 arm,!nacl 386 package rc4 diff --git a/libgo/go/crypto/rc4/rc4_ref.go b/libgo/go/crypto/rc4/rc4_ref.go index e34bd34..bf56b51 100644 --- a/libgo/go/crypto/rc4/rc4_ref.go +++ b/libgo/go/crypto/rc4/rc4_ref.go @@ -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 !amd64,!amd64p32,!arm,!386 arm,nacl +// -build !amd64,!amd64p32,!arm,!386 arm,nacl package rc4 diff --git a/libgo/go/crypto/sha1/fallback_test.go b/libgo/go/crypto/sha1/fallback_test.go index 08acd04..a47b3f4 100644 --- a/libgo/go/crypto/sha1/fallback_test.go +++ b/libgo/go/crypto/sha1/fallback_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore // +build s390x package sha1 diff --git a/libgo/go/crypto/sha1/sha1block_amd64.go b/libgo/go/crypto/sha1/sha1block_amd64.go index fd85a42..95d89a7 100644 --- a/libgo/go/crypto/sha1/sha1block_amd64.go +++ b/libgo/go/crypto/sha1/sha1block_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package sha1 //go:noescape diff --git a/libgo/go/crypto/sha1/sha1block_decl.go b/libgo/go/crypto/sha1/sha1block_decl.go index 6d2d073..bb18cbf 100644 --- a/libgo/go/crypto/sha1/sha1block_decl.go +++ b/libgo/go/crypto/sha1/sha1block_decl.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore // +build amd64p32 arm 386 s390x package sha1 diff --git a/libgo/go/crypto/sha1/sha1block_generic.go b/libgo/go/crypto/sha1/sha1block_generic.go index f0194626..e7515c9 100644 --- a/libgo/go/crypto/sha1/sha1block_generic.go +++ b/libgo/go/crypto/sha1/sha1block_generic.go @@ -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 !amd64,!amd64p32,!386,!arm,!s390x +// -build !amd64,!amd64p32,!386,!arm,!s390x package sha1 diff --git a/libgo/go/crypto/sha1/sha1block_s390x.go b/libgo/go/crypto/sha1/sha1block_s390x.go index aac7c11..9edcbb0 100644 --- a/libgo/go/crypto/sha1/sha1block_s390x.go +++ b/libgo/go/crypto/sha1/sha1block_s390x.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package sha1 // featureCheck reports whether the CPU supports the diff --git a/libgo/go/crypto/sha256/sha256block_decl.go b/libgo/go/crypto/sha256/sha256block_decl.go index e6caff9..eca42c2 100644 --- a/libgo/go/crypto/sha256/sha256block_decl.go +++ b/libgo/go/crypto/sha256/sha256block_decl.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore // +build 386 amd64 s390x package sha256 diff --git a/libgo/go/crypto/sha256/sha256block_generic.go b/libgo/go/crypto/sha256/sha256block_generic.go index 1a01969..d7d78fd 100644 --- a/libgo/go/crypto/sha256/sha256block_generic.go +++ b/libgo/go/crypto/sha256/sha256block_generic.go @@ -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 !amd64,!386,!s390x +// -build !amd64,!386,!s390x package sha256 diff --git a/libgo/go/crypto/sha256/sha256block_s390x.go b/libgo/go/crypto/sha256/sha256block_s390x.go index b7beefe..8e5f69d 100644 --- a/libgo/go/crypto/sha256/sha256block_s390x.go +++ b/libgo/go/crypto/sha256/sha256block_s390x.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package sha256 // featureCheck reports whether the CPU supports the diff --git a/libgo/go/crypto/sha512/fallback_test.go b/libgo/go/crypto/sha512/fallback_test.go index 9024ce6..1408131 100644 --- a/libgo/go/crypto/sha512/fallback_test.go +++ b/libgo/go/crypto/sha512/fallback_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore // +build s390x package sha512 diff --git a/libgo/go/crypto/sha512/sha512block_decl.go b/libgo/go/crypto/sha512/sha512block_decl.go index 47d656a..1c8f66e 100644 --- a/libgo/go/crypto/sha512/sha512block_decl.go +++ b/libgo/go/crypto/sha512/sha512block_decl.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 s390x +// +build ignore +// -build amd64 s390x package sha512 diff --git a/libgo/go/crypto/sha512/sha512block_generic.go b/libgo/go/crypto/sha512/sha512block_generic.go index 2c691ba..67ac948 100644 --- a/libgo/go/crypto/sha512/sha512block_generic.go +++ b/libgo/go/crypto/sha512/sha512block_generic.go @@ -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 !amd64,!s390x +// -build !amd64,!s390x package sha512 diff --git a/libgo/go/crypto/sha512/sha512block_s390x.go b/libgo/go/crypto/sha512/sha512block_s390x.go index f05dc18..26896fc 100644 --- a/libgo/go/crypto/sha512/sha512block_s390x.go +++ b/libgo/go/crypto/sha512/sha512block_s390x.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package sha512 // featureCheck reports whether the CPU supports the diff --git a/libgo/go/hash/crc32/crc32_amd64.go b/libgo/go/hash/crc32/crc32_amd64.go index a0180a1..8eae850 100644 --- a/libgo/go/hash/crc32/crc32_amd64.go +++ b/libgo/go/hash/crc32/crc32_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package crc32 // This file contains the code to call the SSE 4.2 version of the Castagnoli diff --git a/libgo/go/hash/crc32/crc32_generic.go b/libgo/go/hash/crc32/crc32_generic.go index 10a6367..e9096ce 100644 --- a/libgo/go/hash/crc32/crc32_generic.go +++ b/libgo/go/hash/crc32/crc32_generic.go @@ -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 !amd64,!amd64p32,!s390x +// -build !amd64,!amd64p32,!s390x package crc32 diff --git a/libgo/go/log/syslog/syslog_libc.go b/libgo/go/log/syslog/syslog_libc.go index cf370ef..48963b4 100644 --- a/libgo/go/log/syslog/syslog_libc.go +++ b/libgo/go/log/syslog/syslog_libc.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build solaris irix + // gccgo specific implementation of syslog for Solaris. Solaris uses // STREAMS to communicate with syslogd. That is enough of a pain that // we just call the libc function. diff --git a/libgo/go/log/syslog/syslog_unix.go b/libgo/go/log/syslog/syslog_unix.go index 1cdabec..356b98d 100644 --- a/libgo/go/log/syslog/syslog_unix.go +++ b/libgo/go/log/syslog/syslog_unix.go @@ -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 !windows,!nacl,!plan9 +// +build !windows,!nacl,!plan9,!solaris,!irix package syslog diff --git a/libgo/go/math/big/arith_decl.go b/libgo/go/math/big/arith_decl.go index 5433b6d..5538833 100644 --- a/libgo/go/math/big/arith_decl.go +++ b/libgo/go/math/big/arith_decl.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore // +build !math_big_pure_go package big diff --git a/libgo/go/math/big/arith_decl_pure.go b/libgo/go/math/big/arith_decl_pure.go index 21775dd..5c04414 100644 --- a/libgo/go/math/big/arith_decl_pure.go +++ b/libgo/go/math/big/arith_decl_pure.go @@ -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 math_big_pure_go +// -build math_big_pure_go package big diff --git a/libgo/go/math/floor_asm.go b/libgo/go/math/floor_asm.go index 28e56a5..9a2487a 100644 --- a/libgo/go/math/floor_asm.go +++ b/libgo/go/math/floor_asm.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 amd64p32 +// +build ignore +// -build amd64 amd64p32 package math diff --git a/libgo/go/net/fd_select.go b/libgo/go/net/fd_select.go deleted file mode 100644 index 4103c57..0000000 --- a/libgo/go/net/fd_select.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2010 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. - -// Waiting for FDs via select(2). - -package net - -import ( - "errors" - "os" - "syscall" -) - -type pollster struct { - readFds, writeFds, repeatFds *syscall.FdSet - maxFd int - readyReadFds, readyWriteFds *syscall.FdSet - nReady int - lastFd int - closed bool -} - -func newpollster() (p *pollster, err error) { - p = new(pollster) - p.readFds = new(syscall.FdSet) - p.writeFds = new(syscall.FdSet) - p.repeatFds = new(syscall.FdSet) - p.readyReadFds = new(syscall.FdSet) - p.readyWriteFds = new(syscall.FdSet) - p.maxFd = -1 - p.nReady = 0 - p.lastFd = 0 - return p, nil -} - -func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, error) { - // pollServer is locked. - - if p.closed { - return false, errors.New("pollster closed") - } - - if mode == 'r' { - syscall.FDSet(fd, p.readFds) - } else { - syscall.FDSet(fd, p.writeFds) - } - - if repeat { - syscall.FDSet(fd, p.repeatFds) - } - - if fd > p.maxFd { - p.maxFd = fd - } - - return true, nil -} - -func (p *pollster) DelFD(fd int, mode int) bool { - // pollServer is locked. - - if p.closed { - return false - } - - if mode == 'r' { - if !syscall.FDIsSet(fd, p.readFds) { - print("Select unexpected fd=", fd, " for read\n") - return false - } - syscall.FDClr(fd, p.readFds) - } else { - if !syscall.FDIsSet(fd, p.writeFds) { - print("Select unexpected fd=", fd, " for write\n") - return false - } - syscall.FDClr(fd, p.writeFds) - } - - // Doesn't matter if not already present. - syscall.FDClr(fd, p.repeatFds) - - // We don't worry about maxFd here. - - return true -} - -func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) { - if p.nReady == 0 { - var timeout *syscall.Timeval - var tv syscall.Timeval - timeout = nil - if nsec > 0 { - tv = syscall.NsecToTimeval(nsec) - timeout = &tv - } - - var n int - var e error - var tmpReadFds, tmpWriteFds syscall.FdSet - for { - if p.closed { - return -1, 0, errors.New("pollster closed") - } - - // Temporary syscall.FdSet's into which the values are copied - // because select mutates the values. - tmpReadFds = *p.readFds - tmpWriteFds = *p.writeFds - - s.Unlock() - n, e = syscall.Select(p.maxFd+1, &tmpReadFds, &tmpWriteFds, nil, timeout) - s.Lock() - - if e != syscall.EINTR { - break - } - } - if e == syscall.EBADF { - // Some file descriptor has been closed. - tmpReadFds = syscall.FdSet{} - tmpWriteFds = syscall.FdSet{} - n = 0 - for i := 0; i < p.maxFd+1; i++ { - if syscall.FDIsSet(i, p.readFds) { - var s syscall.Stat_t - if syscall.Fstat(i, &s) == syscall.EBADF { - syscall.FDSet(i, &tmpReadFds) - n++ - } - } else if syscall.FDIsSet(i, p.writeFds) { - var s syscall.Stat_t - if syscall.Fstat(i, &s) == syscall.EBADF { - syscall.FDSet(i, &tmpWriteFds) - n++ - } - } - } - } else if e != nil { - return -1, 0, os.NewSyscallError("select", e) - } - if n == 0 { - return -1, 0, nil - } - - p.nReady = n - *p.readyReadFds = tmpReadFds - *p.readyWriteFds = tmpWriteFds - p.lastFd = 0 - } - - flag := false - for i := p.lastFd; i < p.maxFd+1; i++ { - if syscall.FDIsSet(i, p.readyReadFds) { - flag = true - mode = 'r' - syscall.FDClr(i, p.readyReadFds) - } else if syscall.FDIsSet(i, p.readyWriteFds) { - flag = true - mode = 'w' - syscall.FDClr(i, p.readyWriteFds) - } - if flag { - if !syscall.FDIsSet(i, p.repeatFds) { - p.DelFD(i, mode) - } - p.nReady-- - p.lastFd = i - return i, mode, nil - } - } - - // Will not reach here. Just to shut up the compiler. - return -1, 0, nil -} - -func (p *pollster) Close() error { - p.closed = true - return nil -} diff --git a/libgo/go/net/newpollserver_rtems.go b/libgo/go/net/newpollserver_rtems.go index 410f932..2add814 100644 --- a/libgo/go/net/newpollserver_rtems.go +++ b/libgo/go/net/newpollserver_rtems.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build rtems + package net import ( diff --git a/libgo/go/os/dir_largefile.go b/libgo/go/os/dir_largefile.go index 2555c7b..2873342 100644 --- a/libgo/go/os/dir_largefile.go +++ b/libgo/go/os/dir_largefile.go @@ -5,6 +5,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux solaris,386 solaris,sparc + package os import "syscall" diff --git a/libgo/go/os/dir_regfile.go b/libgo/go/os/dir_regfile.go index e5f7c57..adea87d 100644 --- a/libgo/go/os/dir_regfile.go +++ b/libgo/go/os/dir_regfile.go @@ -5,6 +5,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !linux +// +build !solaris,386 +// +build !solaris,sparc + package os import "syscall" diff --git a/libgo/go/os/dir_unix.go b/libgo/go/os/dir_unix.go deleted file mode 100644 index 589db85..0000000 --- a/libgo/go/os/dir_unix.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2009 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. - -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris - -package os - -import ( - "io" - "syscall" -) - -const ( - blockSize = 4096 -) - -func (f *File) readdirnames(n int) (names []string, err error) { - // If this file has no dirinfo, create one. - if f.dirinfo == nil { - f.dirinfo = new(dirInfo) - // The buffer must be at least a block long. - f.dirinfo.buf = make([]byte, blockSize) - } - d := f.dirinfo - - size := n - if size <= 0 { - size = 100 - n = -1 - } - - names = make([]string, 0, size) // Empty with room to grow. - for n != 0 { - // Refill the buffer if necessary - if d.bufp >= d.nbuf { - d.bufp = 0 - var errno error - d.nbuf, errno = fixCount(syscall.ReadDirent(f.fd, d.buf)) - if errno != nil { - return names, NewSyscallError("readdirent", errno) - } - if d.nbuf <= 0 { - break // EOF - } - } - - // Drain the buffer - var nb, nc int - nb, nc, names = syscall.ParseDirent(d.buf[d.bufp:d.nbuf], n, names) - d.bufp += nb - n -= nc - } - if n >= 0 && len(names) == 0 { - return names, io.EOF - } - return names, nil -} diff --git a/libgo/go/os/os_test.go b/libgo/go/os/os_test.go index abc638e..a3885a8 100644 --- a/libgo/go/os/os_test.go +++ b/libgo/go/os/os_test.go @@ -28,7 +28,7 @@ import ( var supportsSymlinks = true var dot = []string{ - "dir_unix.go", + "dir.go", "env.go", "error.go", "file.go", diff --git a/libgo/go/os/stat.go b/libgo/go/os/stat.go index 9758d33..59cac9c 100644 --- a/libgo/go/os/stat.go +++ b/libgo/go/os/stat.go @@ -2,6 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !darwin +// +build !freebsd +// +build !linux +// +build !netbsd +// +build !openbsd +// +build !solaris + package os import ( diff --git a/libgo/go/os/stat_atim.go b/libgo/go/os/stat_atim.go index 69e6323..ef8a574 100644 --- a/libgo/go/os/stat_atim.go +++ b/libgo/go/os/stat_atim.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux openbsd solaristag + package os import ( diff --git a/libgo/go/os/stat_atimespec.go b/libgo/go/os/stat_atimespec.go index 9dc7a99..c6ce2bc 100644 --- a/libgo/go/os/stat_atimespec.go +++ b/libgo/go/os/stat_atimespec.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd netbsd + package os import ( diff --git a/libgo/go/os/stat_solaris.go b/libgo/go/os/stat_solaris.go index aad429d..1f1b4ab 100644 --- a/libgo/go/os/stat_solaris.go +++ b/libgo/go/os/stat_solaris.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !solaristag + package os import ( diff --git a/libgo/go/os/sys_uname.go b/libgo/go/os/sys_uname.go index 16568b6..71fa867 100644 --- a/libgo/go/os/sys_uname.go +++ b/libgo/go/os/sys_uname.go @@ -4,6 +4,8 @@ // For systems which only store the hostname in uname (Solaris). +// +build solaris irix rtems + package os import "syscall" diff --git a/libgo/go/runtime/cgo_mips64x.go b/libgo/go/runtime/cgo_mips64x.go deleted file mode 100644 index f718e92..0000000 --- a/libgo/go/runtime/cgo_mips64x.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 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. - -// +build mips64 mips64le - -package runtime - -// crosscall1 calls into the runtime to set up the registers the -// Go runtime expects and so the symbol it calls needs to be exported -// for external linking to work. -//go:cgo_export_static _cgo_reginit diff --git a/libgo/go/runtime/cgo_mmap.go b/libgo/go/runtime/cgo_mmap.go index a23cc79..bcdd6cd 100644 --- a/libgo/go/runtime/cgo_mmap.go +++ b/libgo/go/runtime/cgo_mmap.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // Support for memory sanitizer. See runtime/cgo/mmap.go. // +build linux,amd64 diff --git a/libgo/go/runtime/cgo_ppc64x.go b/libgo/go/runtime/cgo_ppc64x.go deleted file mode 100644 index fb2da32..0000000 --- a/libgo/go/runtime/cgo_ppc64x.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 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. - -// +build ppc64 ppc64le - -package runtime - -// crosscall_ppc64 calls into the runtime to set up the registers the -// Go runtime expects and so the symbol it calls needs to be exported -// for external linking to work. -//go:cgo_export_static _cgo_reginit diff --git a/libgo/go/runtime/cgocheck.go b/libgo/go/runtime/cgocheck.go index 2d06414..7e38d9c4 100644 --- a/libgo/go/runtime/cgocheck.go +++ b/libgo/go/runtime/cgocheck.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // Code to check that pointer writes follow the cgo rules. // These functions are invoked via the write barrier when debug.cgocheck > 1. diff --git a/libgo/go/runtime/defs_linux_mips64x.go b/libgo/go/runtime/defs_linux_mips64x.go deleted file mode 100644 index bb3cd98..0000000 --- a/libgo/go/runtime/defs_linux_mips64x.go +++ /dev/null @@ -1,183 +0,0 @@ -// +build mips64 mips64le -// +build linux - -package runtime - -const ( - _EINTR = 0x4 - _EAGAIN = 0xb - _ENOMEM = 0xc - - _PROT_NONE = 0x0 - _PROT_READ = 0x1 - _PROT_WRITE = 0x2 - _PROT_EXEC = 0x4 - - _MAP_ANON = 0x800 - _MAP_PRIVATE = 0x2 - _MAP_FIXED = 0x10 - - _MADV_DONTNEED = 0x4 - _MADV_HUGEPAGE = 0xe - _MADV_NOHUGEPAGE = 0xf - - _SA_RESTART = 0x10000000 - _SA_ONSTACK = 0x8000000 - _SA_SIGINFO = 0x8 - - _SIGHUP = 0x1 - _SIGINT = 0x2 - _SIGQUIT = 0x3 - _SIGILL = 0x4 - _SIGTRAP = 0x5 - _SIGABRT = 0x6 - _SIGEMT = 0x7 - _SIGFPE = 0x8 - _SIGKILL = 0x9 - _SIGBUS = 0xa - _SIGSEGV = 0xb - _SIGSYS = 0xc - _SIGPIPE = 0xd - _SIGALRM = 0xe - _SIGUSR1 = 0x10 - _SIGUSR2 = 0x11 - _SIGCHLD = 0x12 - _SIGPWR = 0x13 - _SIGWINCH = 0x14 - _SIGURG = 0x15 - _SIGIO = 0x16 - _SIGSTOP = 0x17 - _SIGTSTP = 0x18 - _SIGCONT = 0x19 - _SIGTTIN = 0x1a - _SIGTTOU = 0x1b - _SIGVTALRM = 0x1c - _SIGPROF = 0x1d - _SIGXCPU = 0x1e - _SIGXFSZ = 0x1f - - _FPE_INTDIV = 0x1 - _FPE_INTOVF = 0x2 - _FPE_FLTDIV = 0x3 - _FPE_FLTOVF = 0x4 - _FPE_FLTUND = 0x5 - _FPE_FLTRES = 0x6 - _FPE_FLTINV = 0x7 - _FPE_FLTSUB = 0x8 - - _BUS_ADRALN = 0x1 - _BUS_ADRERR = 0x2 - _BUS_OBJERR = 0x3 - - _SEGV_MAPERR = 0x1 - _SEGV_ACCERR = 0x2 - - _ITIMER_REAL = 0x0 - _ITIMER_VIRTUAL = 0x1 - _ITIMER_PROF = 0x2 - - _EPOLLIN = 0x1 - _EPOLLOUT = 0x4 - _EPOLLERR = 0x8 - _EPOLLHUP = 0x10 - _EPOLLRDHUP = 0x2000 - _EPOLLET = 0x80000000 - _EPOLL_CLOEXEC = 0x80000 - _EPOLL_CTL_ADD = 0x1 - _EPOLL_CTL_DEL = 0x2 - _EPOLL_CTL_MOD = 0x3 -) - -//struct Sigset { -// uint64 sig[1]; -//}; -//typedef uint64 Sigset; - -type timespec struct { - tv_sec int64 - tv_nsec int64 -} - -func (ts *timespec) set_sec(x int64) { - ts.tv_sec = x -} - -func (ts *timespec) set_nsec(x int32) { - ts.tv_nsec = int64(x) -} - -type timeval struct { - tv_sec int64 - tv_usec int64 -} - -func (tv *timeval) set_usec(x int32) { - tv.tv_usec = int64(x) -} - -type sigactiont struct { - sa_flags uint32 - sa_handler uintptr - sa_mask [2]uint64 - // linux header does not have sa_restorer field, - // but it is used in setsig(). it is no harm to put it here - sa_restorer uintptr -} - -type siginfo struct { - si_signo int32 - si_code int32 - si_errno int32 - __pad0 [1]int32 - // below here is a union; si_addr is the only field we use - si_addr uint64 -} - -type itimerval struct { - it_interval timeval - it_value timeval -} - -type epollevent struct { - events uint32 - pad_cgo_0 [4]byte - data [8]byte // unaligned uintptr -} - -const ( - _O_RDONLY = 0x0 - _O_CLOEXEC = 0x80000 - _SA_RESTORER = 0 -) - -type sigaltstackt struct { - ss_sp *byte - ss_size uintptr - ss_flags int32 -} - -type sigcontext struct { - sc_regs [32]uint64 - sc_fpregs [32]uint64 - sc_mdhi uint64 - sc_hi1 uint64 - sc_hi2 uint64 - sc_hi3 uint64 - sc_mdlo uint64 - sc_lo1 uint64 - sc_lo2 uint64 - sc_lo3 uint64 - sc_pc uint64 - sc_fpc_csr uint32 - sc_used_math uint32 - sc_dsp uint32 - sc_reserved uint32 -} - -type ucontext struct { - uc_flags uint64 - uc_link *ucontext - uc_stack sigaltstackt - uc_mcontext sigcontext - uc_sigmask uint64 -} diff --git a/libgo/go/runtime/defs_linux_s390x.go b/libgo/go/runtime/defs_linux_s390x.go deleted file mode 100644 index 5f55d5a..0000000 --- a/libgo/go/runtime/defs_linux_s390x.go +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2016 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 runtime - -const ( - _EINTR = 0x4 - _EAGAIN = 0xb - _ENOMEM = 0xc - - _PROT_NONE = 0x0 - _PROT_READ = 0x1 - _PROT_WRITE = 0x2 - _PROT_EXEC = 0x4 - - _MAP_ANON = 0x20 - _MAP_PRIVATE = 0x2 - _MAP_FIXED = 0x10 - - _MADV_DONTNEED = 0x4 - _MADV_HUGEPAGE = 0xe - _MADV_NOHUGEPAGE = 0xf - - _SA_RESTART = 0x10000000 - _SA_ONSTACK = 0x8000000 - _SA_SIGINFO = 0x4 - - _SIGHUP = 0x1 - _SIGINT = 0x2 - _SIGQUIT = 0x3 - _SIGILL = 0x4 - _SIGTRAP = 0x5 - _SIGABRT = 0x6 - _SIGBUS = 0x7 - _SIGFPE = 0x8 - _SIGKILL = 0x9 - _SIGUSR1 = 0xa - _SIGSEGV = 0xb - _SIGUSR2 = 0xc - _SIGPIPE = 0xd - _SIGALRM = 0xe - _SIGSTKFLT = 0x10 - _SIGCHLD = 0x11 - _SIGCONT = 0x12 - _SIGSTOP = 0x13 - _SIGTSTP = 0x14 - _SIGTTIN = 0x15 - _SIGTTOU = 0x16 - _SIGURG = 0x17 - _SIGXCPU = 0x18 - _SIGXFSZ = 0x19 - _SIGVTALRM = 0x1a - _SIGPROF = 0x1b - _SIGWINCH = 0x1c - _SIGIO = 0x1d - _SIGPWR = 0x1e - _SIGSYS = 0x1f - - _FPE_INTDIV = 0x1 - _FPE_INTOVF = 0x2 - _FPE_FLTDIV = 0x3 - _FPE_FLTOVF = 0x4 - _FPE_FLTUND = 0x5 - _FPE_FLTRES = 0x6 - _FPE_FLTINV = 0x7 - _FPE_FLTSUB = 0x8 - - _BUS_ADRALN = 0x1 - _BUS_ADRERR = 0x2 - _BUS_OBJERR = 0x3 - - _SEGV_MAPERR = 0x1 - _SEGV_ACCERR = 0x2 - - _ITIMER_REAL = 0x0 - _ITIMER_VIRTUAL = 0x1 - _ITIMER_PROF = 0x2 - - _EPOLLIN = 0x1 - _EPOLLOUT = 0x4 - _EPOLLERR = 0x8 - _EPOLLHUP = 0x10 - _EPOLLRDHUP = 0x2000 - _EPOLLET = 0x80000000 - _EPOLL_CLOEXEC = 0x80000 - _EPOLL_CTL_ADD = 0x1 - _EPOLL_CTL_DEL = 0x2 - _EPOLL_CTL_MOD = 0x3 -) - -type timespec struct { - tv_sec int64 - tv_nsec int64 -} - -func (ts *timespec) set_sec(x int64) { - ts.tv_sec = x -} - -func (ts *timespec) set_nsec(x int32) { - ts.tv_nsec = int64(x) -} - -type timeval struct { - tv_sec int64 - tv_usec int64 -} - -func (tv *timeval) set_usec(x int32) { - tv.tv_usec = int64(x) -} - -type sigactiont struct { - sa_handler uintptr - sa_flags uint64 - sa_restorer uintptr - sa_mask uint64 -} - -type siginfo struct { - si_signo int32 - si_errno int32 - si_code int32 - // below here is a union; si_addr is the only field we use - si_addr uint64 -} - -type itimerval struct { - it_interval timeval - it_value timeval -} - -type epollevent struct { - events uint32 - pad_cgo_0 [4]byte - data [8]byte // unaligned uintptr -} - -const ( - _O_RDONLY = 0x0 - _O_CLOEXEC = 0x80000 - _SA_RESTORER = 0 -) - -type sigaltstackt struct { - ss_sp *byte - ss_flags int32 - ss_size uintptr -} - -type sigcontext struct { - psw_mask uint64 - psw_addr uint64 - gregs [16]uint64 - aregs [16]uint32 - fpc uint32 - fpregs [16]uint64 -} - -type ucontext struct { - uc_flags uint64 - uc_link *ucontext - uc_stack sigaltstackt - uc_mcontext sigcontext - uc_sigmask uint64 -} diff --git a/libgo/go/runtime/defs_plan9_arm.go b/libgo/go/runtime/defs_plan9_arm.go deleted file mode 100644 index 9c700ae..0000000 --- a/libgo/go/runtime/defs_plan9_arm.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015 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 runtime - -const _PAGESIZE = 0x1000 - -type ureg struct { - r0 uint32 /* general registers */ - r1 uint32 /* ... */ - r2 uint32 /* ... */ - r3 uint32 /* ... */ - r4 uint32 /* ... */ - r5 uint32 /* ... */ - r6 uint32 /* ... */ - r7 uint32 /* ... */ - r8 uint32 /* ... */ - r9 uint32 /* ... */ - r10 uint32 /* ... */ - r11 uint32 /* ... */ - r12 uint32 /* ... */ - sp uint32 - link uint32 /* ... */ - trap uint32 /* trap type */ - psr uint32 - pc uint32 /* interrupted addr */ -} - -type sigctxt struct { - u *ureg -} - -func (c *sigctxt) pc() uintptr { return uintptr(c.u.pc) } -func (c *sigctxt) sp() uintptr { return uintptr(c.u.sp) } -func (c *sigctxt) lr() uintptr { return uintptr(c.u.link) } - -func (c *sigctxt) setpc(x uintptr) { c.u.pc = uint32(x) } -func (c *sigctxt) setsp(x uintptr) { c.u.sp = uint32(x) } -func (c *sigctxt) setlr(x uintptr) { c.u.link = uint32(x) } -func (c *sigctxt) savelr(x uintptr) { c.u.r0 = uint32(x) } - -func dumpregs(u *ureg) { - print("r0 ", hex(u.r0), "\n") - print("r1 ", hex(u.r1), "\n") - print("r2 ", hex(u.r2), "\n") - print("r3 ", hex(u.r3), "\n") - print("r4 ", hex(u.r4), "\n") - print("r5 ", hex(u.r5), "\n") - print("r6 ", hex(u.r6), "\n") - print("r7 ", hex(u.r7), "\n") - print("r8 ", hex(u.r8), "\n") - print("r9 ", hex(u.r9), "\n") - print("r10 ", hex(u.r10), "\n") - print("r11 ", hex(u.r11), "\n") - print("r12 ", hex(u.r12), "\n") - print("sp ", hex(u.sp), "\n") - print("link ", hex(u.link), "\n") - print("pc ", hex(u.pc), "\n") - print("psr ", hex(u.psr), "\n") -} - -func sigpanictramp() diff --git a/libgo/go/runtime/fastlog2.go b/libgo/go/runtime/fastlog2.go index b22e825..1029de2 100644 --- a/libgo/go/runtime/fastlog2.go +++ b/libgo/go/runtime/fastlog2.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package runtime import "unsafe" diff --git a/libgo/go/runtime/fastlog2table.go b/libgo/go/runtime/fastlog2table.go index c36d583..47ae5e8 100644 --- a/libgo/go/runtime/fastlog2table.go +++ b/libgo/go/runtime/fastlog2table.go @@ -2,6 +2,8 @@ // Run go generate from src/runtime to update. // See mkfastlog2table.go for comments. +// +build ignore + package runtime const fastlogNumBits = 5 diff --git a/libgo/go/runtime/lfstack_64bit.go b/libgo/go/runtime/lfstack_64bit.go index 5367f08..3b0eb98 100644 --- a/libgo/go/runtime/lfstack_64bit.go +++ b/libgo/go/runtime/lfstack_64bit.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // +build amd64 arm64 mips64 mips64le ppc64 ppc64le s390x package runtime diff --git a/libgo/go/runtime/mmap.go b/libgo/go/runtime/mmap.go index 53617e4..02aafdd 100644 --- a/libgo/go/runtime/mmap.go +++ b/libgo/go/runtime/mmap.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // +build !plan9 // +build !solaris // +build !windows diff --git a/libgo/go/runtime/msan.go b/libgo/go/runtime/msan.go deleted file mode 100644 index 7177c8e..0000000 --- a/libgo/go/runtime/msan.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2015 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. - -// +build msan - -package runtime - -import ( - "unsafe" -) - -// Public memory sanitizer API. - -func MSanRead(addr unsafe.Pointer, len int) { - msanread(addr, uintptr(len)) -} - -func MSanWrite(addr unsafe.Pointer, len int) { - msanwrite(addr, uintptr(len)) -} - -// Private interface for the runtime. -const msanenabled = true - -// If we are running on the system stack, the C program may have -// marked part of that stack as uninitialized. We don't instrument -// the runtime, but operations like a slice copy can call msanread -// anyhow for values on the stack. Just ignore msanread when running -// on the system stack. The other msan functions are fine. -func msanread(addr unsafe.Pointer, sz uintptr) { - g := getg() - if g == g.m.g0 || g == g.m.gsignal { - return - } - domsanread(addr, sz) -} - -//go:noescape -func domsanread(addr unsafe.Pointer, sz uintptr) - -//go:noescape -func msanwrite(addr unsafe.Pointer, sz uintptr) - -//go:noescape -func msanmalloc(addr unsafe.Pointer, sz uintptr) - -//go:noescape -func msanfree(addr unsafe.Pointer, sz uintptr) - -// These are called from msan_amd64.s -//go:cgo_import_static __msan_read_go -//go:cgo_import_static __msan_write_go -//go:cgo_import_static __msan_malloc_go -//go:cgo_import_static __msan_free_go diff --git a/libgo/go/runtime/msan0.go b/libgo/go/runtime/msan0.go index 117c5e5..48ae3e4 100644 --- a/libgo/go/runtime/msan0.go +++ b/libgo/go/runtime/msan0.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore // +build !msan // Dummy MSan support API, used when not built with -msan. diff --git a/libgo/go/runtime/mstkbar.go b/libgo/go/runtime/mstkbar.go index 1bf9d57..6d0b5ac 100644 --- a/libgo/go/runtime/mstkbar.go +++ b/libgo/go/runtime/mstkbar.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // Garbage collector: stack barriers // // Stack barriers enable the garbage collector to determine how much diff --git a/libgo/go/runtime/os_android.go b/libgo/go/runtime/os_android.go deleted file mode 100644 index 52c8c86..0000000 --- a/libgo/go/runtime/os_android.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 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 runtime - -import _ "unsafe" // for go:cgo_export_static and go:cgo_export_dynamic - -// Export the main function. -// -// Used by the app package to start all-Go Android apps that are -// loaded via JNI. See golang.org/x/mobile/app. - -//go:cgo_export_static main.main -//go:cgo_export_dynamic main.main diff --git a/libgo/go/runtime/os_linux_generic.go b/libgo/go/runtime/os_linux_generic.go deleted file mode 100644 index a16d140..0000000 --- a/libgo/go/runtime/os_linux_generic.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2009 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. - -// +build !mips64 -// +build !mips64le -// +build !s390x -// +build linux - -package runtime - -const ( - _SS_DISABLE = 2 - _NSIG = 65 - _SI_USER = 0 - _SIG_BLOCK = 0 - _SIG_UNBLOCK = 1 - _SIG_SETMASK = 2 - _RLIMIT_AS = 9 -) - -// It's hard to tease out exactly how big a Sigset is, but -// rt_sigprocmask crashes if we get it wrong, so if binaries -// are running, this is right. -type sigset [2]uint32 - -type rlimit struct { - rlim_cur uintptr - rlim_max uintptr -} - -var sigset_all = sigset{^uint32(0), ^uint32(0)} - -func sigaddset(mask *sigset, i int) { - (*mask)[(i-1)/32] |= 1 << ((uint32(i) - 1) & 31) -} - -func sigdelset(mask *sigset, i int) { - (*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31) -} - -func sigfillset(mask *uint64) { - *mask = ^uint64(0) -} - -func sigcopyset(mask *sigset, m sigmask) { - copy((*mask)[:], m[:]) -} diff --git a/libgo/go/runtime/os_linux_mips64x.go b/libgo/go/runtime/os_linux_mips64x.go deleted file mode 100644 index 8039b2f..0000000 --- a/libgo/go/runtime/os_linux_mips64x.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 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. - -// +build linux -// +build mips64 mips64le - -package runtime - -var randomNumber uint32 - -func archauxv(tag, val uintptr) { - switch tag { - case _AT_RANDOM: - // sysargs filled in startupRandomData, but that - // pointer may not be word aligned, so we must treat - // it as a byte array. - randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 | - uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24 - } -} - -//go:nosplit -func cputicks() int64 { - // Currently cputicks() is used in blocking profiler and to seed fastrand1(). - // nanotime() is a poor approximation of CPU ticks that is enough for the profiler. - // randomNumber provides better seeding of fastrand1. - return nanotime() + int64(randomNumber) -} - -const ( - _SS_DISABLE = 2 - _NSIG = 65 - _SI_USER = 0 - _SIG_BLOCK = 1 - _SIG_UNBLOCK = 2 - _SIG_SETMASK = 3 - _RLIMIT_AS = 6 -) - -type sigset [2]uint64 - -type rlimit struct { - rlim_cur uintptr - rlim_max uintptr -} - -var sigset_all = sigset{^uint64(0), ^uint64(0)} - -func sigaddset(mask *sigset, i int) { - (*mask)[(i-1)/64] |= 1 << ((uint32(i) - 1) & 63) -} - -func sigdelset(mask *sigset, i int) { - (*mask)[(i-1)/64] &^= 1 << ((uint32(i) - 1) & 63) -} - -func sigfillset(mask *[2]uint64) { - (*mask)[0], (*mask)[1] = ^uint64(0), ^uint64(0) -} - -func sigcopyset(mask *sigset, m sigmask) { - (*mask)[0] = uint64(m[0]) | uint64(m[1])<<32 -} diff --git a/libgo/go/runtime/os_linux_noauxv.go b/libgo/go/runtime/os_linux_noauxv.go deleted file mode 100644 index 22522dd..0000000 --- a/libgo/go/runtime/os_linux_noauxv.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 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. - -// +build !amd64,!arm,!arm64,!mips64,!mips64le - -package runtime - -func archauxv(tag, val uintptr) { -} diff --git a/libgo/go/runtime/os_linux_s390x.go b/libgo/go/runtime/os_linux_s390x.go deleted file mode 100644 index e659dff..0000000 --- a/libgo/go/runtime/os_linux_s390x.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 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 runtime - -const ( - _SS_DISABLE = 2 - _NSIG = 65 - _SI_USER = 0 - _SIG_BLOCK = 0 - _SIG_UNBLOCK = 1 - _SIG_SETMASK = 2 - _RLIMIT_AS = 9 -) - -type sigset uint64 - -type rlimit struct { - rlim_cur uintptr - rlim_max uintptr -} - -var sigset_all = sigset(^uint64(0)) - -func sigaddset(mask *sigset, i int) { - if i > 64 { - throw("unexpected signal greater than 64") - } - *mask |= 1 << (uint(i) - 1) -} - -func sigdelset(mask *sigset, i int) { - if i > 64 { - throw("unexpected signal greater than 64") - } - *mask &^= 1 << (uint(i) - 1) -} - -func sigfillset(mask *uint64) { - *mask = ^uint64(0) -} - -func sigcopyset(mask *sigset, m sigmask) { - *mask = sigset(uint64(m[0]) | uint64(m[1])<<32) -} diff --git a/libgo/go/runtime/os_netbsd_386.go b/libgo/go/runtime/os_netbsd_386.go deleted file mode 100644 index 037f7e3..0000000 --- a/libgo/go/runtime/os_netbsd_386.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2009 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 runtime - -import "unsafe" - -func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) { - // Machine dependent mcontext initialisation for LWP. - mc.__gregs[_REG_EIP] = uint32(funcPC(lwp_tramp)) - mc.__gregs[_REG_UESP] = uint32(uintptr(stk)) - mc.__gregs[_REG_EBX] = uint32(uintptr(unsafe.Pointer(mp))) - mc.__gregs[_REG_EDX] = uint32(uintptr(unsafe.Pointer(gp))) - mc.__gregs[_REG_ESI] = uint32(fn) -} diff --git a/libgo/go/runtime/os_netbsd_amd64.go b/libgo/go/runtime/os_netbsd_amd64.go deleted file mode 100644 index 5118b0c..0000000 --- a/libgo/go/runtime/os_netbsd_amd64.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2009 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 runtime - -import "unsafe" - -func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) { - // Machine dependent mcontext initialisation for LWP. - mc.__gregs[_REG_RIP] = uint64(funcPC(lwp_tramp)) - mc.__gregs[_REG_RSP] = uint64(uintptr(stk)) - mc.__gregs[_REG_R8] = uint64(uintptr(unsafe.Pointer(mp))) - mc.__gregs[_REG_R9] = uint64(uintptr(unsafe.Pointer(gp))) - mc.__gregs[_REG_R12] = uint64(fn) -} diff --git a/libgo/go/runtime/os_plan9_arm.go b/libgo/go/runtime/os_plan9_arm.go deleted file mode 100644 index 30cde8f..0000000 --- a/libgo/go/runtime/os_plan9_arm.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 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 runtime - -func checkgoarm() { - return // TODO(minux) -} - -//go:nosplit -func cputicks() int64 { - // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1(). - // runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler. - // TODO: need more entropy to better seed fastrand1. - return nanotime() -} diff --git a/libgo/go/runtime/print.go b/libgo/go/runtime/print.go index 32626c1..97d595f 100644 --- a/libgo/go/runtime/print.go +++ b/libgo/go/runtime/print.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package runtime import "unsafe" diff --git a/libgo/go/runtime/signal2_unix.go b/libgo/go/runtime/signal2_unix.go index b137169..b7479a7 100644 --- a/libgo/go/runtime/signal2_unix.go +++ b/libgo/go/runtime/signal2_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // +build darwin dragonfly freebsd linux netbsd openbsd package runtime diff --git a/libgo/go/runtime/signal_linux_mips64x.go b/libgo/go/runtime/signal_linux_mips64x.go deleted file mode 100644 index 0f590e4..0000000 --- a/libgo/go/runtime/signal_linux_mips64x.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 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. - -// +build linux -// +build mips64 mips64le - -package runtime - -import ( - "runtime/internal/sys" - "unsafe" -) - -type sigctxt struct { - info *siginfo - ctxt unsafe.Pointer -} - -func (c *sigctxt) regs() *sigcontext { return &(*ucontext)(c.ctxt).uc_mcontext } -func (c *sigctxt) r0() uint64 { return c.regs().sc_regs[0] } -func (c *sigctxt) r1() uint64 { return c.regs().sc_regs[1] } -func (c *sigctxt) r2() uint64 { return c.regs().sc_regs[2] } -func (c *sigctxt) r3() uint64 { return c.regs().sc_regs[3] } -func (c *sigctxt) r4() uint64 { return c.regs().sc_regs[4] } -func (c *sigctxt) r5() uint64 { return c.regs().sc_regs[5] } -func (c *sigctxt) r6() uint64 { return c.regs().sc_regs[6] } -func (c *sigctxt) r7() uint64 { return c.regs().sc_regs[7] } -func (c *sigctxt) r8() uint64 { return c.regs().sc_regs[8] } -func (c *sigctxt) r9() uint64 { return c.regs().sc_regs[9] } -func (c *sigctxt) r10() uint64 { return c.regs().sc_regs[10] } -func (c *sigctxt) r11() uint64 { return c.regs().sc_regs[11] } -func (c *sigctxt) r12() uint64 { return c.regs().sc_regs[12] } -func (c *sigctxt) r13() uint64 { return c.regs().sc_regs[13] } -func (c *sigctxt) r14() uint64 { return c.regs().sc_regs[14] } -func (c *sigctxt) r15() uint64 { return c.regs().sc_regs[15] } -func (c *sigctxt) r16() uint64 { return c.regs().sc_regs[16] } -func (c *sigctxt) r17() uint64 { return c.regs().sc_regs[17] } -func (c *sigctxt) r18() uint64 { return c.regs().sc_regs[18] } -func (c *sigctxt) r19() uint64 { return c.regs().sc_regs[19] } -func (c *sigctxt) r20() uint64 { return c.regs().sc_regs[20] } -func (c *sigctxt) r21() uint64 { return c.regs().sc_regs[21] } -func (c *sigctxt) r22() uint64 { return c.regs().sc_regs[22] } -func (c *sigctxt) r23() uint64 { return c.regs().sc_regs[23] } -func (c *sigctxt) r24() uint64 { return c.regs().sc_regs[24] } -func (c *sigctxt) r25() uint64 { return c.regs().sc_regs[25] } -func (c *sigctxt) r26() uint64 { return c.regs().sc_regs[26] } -func (c *sigctxt) r27() uint64 { return c.regs().sc_regs[27] } -func (c *sigctxt) r28() uint64 { return c.regs().sc_regs[28] } -func (c *sigctxt) r29() uint64 { return c.regs().sc_regs[29] } -func (c *sigctxt) r30() uint64 { return c.regs().sc_regs[30] } -func (c *sigctxt) r31() uint64 { return c.regs().sc_regs[31] } -func (c *sigctxt) sp() uint64 { return c.regs().sc_regs[29] } -func (c *sigctxt) pc() uint64 { return c.regs().sc_pc } -func (c *sigctxt) link() uint64 { return c.regs().sc_regs[31] } -func (c *sigctxt) lo() uint64 { return c.regs().sc_mdlo } -func (c *sigctxt) hi() uint64 { return c.regs().sc_mdhi } - -func (c *sigctxt) sigcode() uint32 { return uint32(c.info.si_code) } -func (c *sigctxt) sigaddr() uint64 { return c.info.si_addr } - -func (c *sigctxt) set_r30(x uint64) { c.regs().sc_regs[30] = x } -func (c *sigctxt) set_pc(x uint64) { c.regs().sc_pc = x } -func (c *sigctxt) set_sp(x uint64) { c.regs().sc_regs[29] = x } -func (c *sigctxt) set_link(x uint64) { c.regs().sc_regs[31] = x } - -func (c *sigctxt) set_sigcode(x uint32) { c.info.si_code = int32(x) } -func (c *sigctxt) set_sigaddr(x uint64) { - *(*uintptr)(add(unsafe.Pointer(c.info), 2*sys.PtrSize)) = uintptr(x) -} diff --git a/libgo/go/runtime/signal_linux_s390x.go b/libgo/go/runtime/signal_linux_s390x.go deleted file mode 100644 index 155d3a3..0000000 --- a/libgo/go/runtime/signal_linux_s390x.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2016 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 runtime - -import ( - "runtime/internal/sys" - "unsafe" -) - -type sigctxt struct { - info *siginfo - ctxt unsafe.Pointer -} - -func (c *sigctxt) regs() *sigcontext { - return (*sigcontext)(unsafe.Pointer(&(*ucontext)(c.ctxt).uc_mcontext)) -} -func (c *sigctxt) r0() uint64 { return c.regs().gregs[0] } -func (c *sigctxt) r1() uint64 { return c.regs().gregs[1] } -func (c *sigctxt) r2() uint64 { return c.regs().gregs[2] } -func (c *sigctxt) r3() uint64 { return c.regs().gregs[3] } -func (c *sigctxt) r4() uint64 { return c.regs().gregs[4] } -func (c *sigctxt) r5() uint64 { return c.regs().gregs[5] } -func (c *sigctxt) r6() uint64 { return c.regs().gregs[6] } -func (c *sigctxt) r7() uint64 { return c.regs().gregs[7] } -func (c *sigctxt) r8() uint64 { return c.regs().gregs[8] } -func (c *sigctxt) r9() uint64 { return c.regs().gregs[9] } -func (c *sigctxt) r10() uint64 { return c.regs().gregs[10] } -func (c *sigctxt) r11() uint64 { return c.regs().gregs[11] } -func (c *sigctxt) r12() uint64 { return c.regs().gregs[12] } -func (c *sigctxt) r13() uint64 { return c.regs().gregs[13] } -func (c *sigctxt) r14() uint64 { return c.regs().gregs[14] } -func (c *sigctxt) r15() uint64 { return c.regs().gregs[15] } -func (c *sigctxt) link() uint64 { return c.regs().gregs[14] } -func (c *sigctxt) sp() uint64 { return c.regs().gregs[15] } -func (c *sigctxt) pc() uint64 { return c.regs().psw_addr } -func (c *sigctxt) sigcode() uint32 { return uint32(c.info.si_code) } -func (c *sigctxt) sigaddr() uint64 { return c.info.si_addr } - -func (c *sigctxt) set_r0(x uint64) { c.regs().gregs[0] = x } -func (c *sigctxt) set_r13(x uint64) { c.regs().gregs[13] = x } -func (c *sigctxt) set_link(x uint64) { c.regs().gregs[14] = x } -func (c *sigctxt) set_sp(x uint64) { c.regs().gregs[15] = x } -func (c *sigctxt) set_pc(x uint64) { c.regs().psw_addr = x } -func (c *sigctxt) set_sigcode(x uint32) { c.info.si_code = int32(x) } -func (c *sigctxt) set_sigaddr(x uint64) { - *(*uintptr)(add(unsafe.Pointer(c.info), 2*sys.PtrSize)) = uintptr(x) -} - -func dumpregs(c *sigctxt) { - print("r0 ", hex(c.r0()), "\t") - print("r1 ", hex(c.r1()), "\n") - print("r2 ", hex(c.r2()), "\t") - print("r3 ", hex(c.r3()), "\n") - print("r4 ", hex(c.r4()), "\t") - print("r5 ", hex(c.r5()), "\n") - print("r6 ", hex(c.r6()), "\t") - print("r7 ", hex(c.r7()), "\n") - print("r8 ", hex(c.r8()), "\t") - print("r9 ", hex(c.r9()), "\n") - print("r10 ", hex(c.r10()), "\t") - print("r11 ", hex(c.r11()), "\n") - print("r12 ", hex(c.r12()), "\t") - print("r13 ", hex(c.r13()), "\n") - print("r14 ", hex(c.r14()), "\t") - print("r15 ", hex(c.r15()), "\n") - print("pc ", hex(c.pc()), "\t") - print("link ", hex(c.link()), "\n") -} - -var crashing int32 - -// May run during STW, so write barriers are not allowed. -// -//go:nowritebarrierrec -func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) { - _g_ := getg() - c := &sigctxt{info, ctxt} - - if sig == _SIGPROF { - sigprof(uintptr(c.pc()), uintptr(c.sp()), uintptr(c.link()), gp, _g_.m) - return - } - flags := int32(_SigThrow) - if sig < uint32(len(sigtable)) { - flags = sigtable[sig].flags - } - if c.sigcode() != _SI_USER && flags&_SigPanic != 0 { - // Make it look like a call to the signal func. - // Have to pass arguments out of band since - // augmenting the stack frame would break - // the unwinding code. - gp.sig = sig - gp.sigcode0 = uintptr(c.sigcode()) - gp.sigcode1 = uintptr(c.sigaddr()) - gp.sigpc = uintptr(c.pc()) - - // We arrange link, and pc to pretend the panicking - // function calls sigpanic directly. - // Always save LINK to stack so that panics in leaf - // functions are correctly handled. This smashes - // the stack frame but we're not going back there - // anyway. - sp := c.sp() - sys.MinFrameSize - c.set_sp(sp) - *(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link() - - pc := uintptr(gp.sigpc) - - // If we don't recognize the PC as code - // but we do recognize the link register as code, - // then assume this was a call to non-code and treat like - // pc == 0, to make unwinding show the context. - if pc != 0 && findfunc(pc) == nil && findfunc(uintptr(c.link())) != nil { - pc = 0 - } - - // Don't bother saving PC if it's zero, which is - // probably a call to a nil func: the old link register - // is more useful in the stack trace. - if pc != 0 { - c.set_link(uint64(pc)) - } - - // In case we are panicking from external C code - c.set_r0(0) - c.set_r13(uint64(uintptr(unsafe.Pointer(gp)))) - c.set_pc(uint64(funcPC(sigpanic))) - return - } - - if c.sigcode() == _SI_USER || flags&_SigNotify != 0 { - if sigsend(sig) { - return - } - } - - if c.sigcode() == _SI_USER && signal_ignored(sig) { - return - } - - if flags&_SigKill != 0 { - dieFromSignal(int32(sig)) - } - - if flags&_SigThrow == 0 { - return - } - - _g_.m.throwing = 1 - _g_.m.caughtsig.set(gp) - - if crashing == 0 { - startpanic() - } - - if sig < uint32(len(sigtable)) { - print(sigtable[sig].name, "\n") - } else { - print("Signal ", sig, "\n") - } - - print("PC=", hex(c.pc()), " m=", _g_.m.id, "\n") - if _g_.m.lockedg != nil && _g_.m.ncgo > 0 && gp == _g_.m.g0 { - print("signal arrived during cgo execution\n") - gp = _g_.m.lockedg - } - print("\n") - - level, _, docrash := gotraceback() - if level > 0 { - goroutineheader(gp) - tracebacktrap(uintptr(c.pc()), uintptr(c.sp()), uintptr(c.link()), gp) - if crashing > 0 && gp != _g_.m.curg && _g_.m.curg != nil && readgstatus(_g_.m.curg)&^_Gscan == _Grunning { - // tracebackothers on original m skipped this one; trace it now. - goroutineheader(_g_.m.curg) - traceback(^uintptr(0), ^uintptr(0), 0, gp) - } else if crashing == 0 { - tracebackothers(gp) - print("\n") - } - dumpregs(c) - } - - if docrash { - crashing++ - if crashing < sched.mcount { - // There are other m's that need to dump their stacks. - // Relay SIGQUIT to the next m by sending it to the current process. - // All m's that have already received SIGQUIT have signal masks blocking - // receipt of any signals, so the SIGQUIT will go to an m that hasn't seen it yet. - // When the last m receives the SIGQUIT, it will fall through to the call to - // crash below. Just in case the relaying gets botched, each m involved in - // the relay sleeps for 5 seconds and then does the crash/exit itself. - // In expected operation, the last m has received the SIGQUIT and run - // crash/exit and the process is gone, all long before any of the - // 5-second sleeps have finished. - print("\n-----\n\n") - raiseproc(_SIGQUIT) - usleep(5 * 1000 * 1000) - } - crash() - } - - exit(2) -} diff --git a/libgo/go/runtime/signal_mips64x.go b/libgo/go/runtime/signal_mips64x.go deleted file mode 100644 index 4dbeb42..0000000 --- a/libgo/go/runtime/signal_mips64x.go +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2015 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. - -// +build linux -// +build mips64 mips64le - -package runtime - -import ( - "runtime/internal/sys" - "unsafe" -) - -func dumpregs(c *sigctxt) { - print("r0 ", hex(c.r0()), "\t") - print("r1 ", hex(c.r1()), "\n") - print("r2 ", hex(c.r2()), "\t") - print("r3 ", hex(c.r3()), "\n") - print("r4 ", hex(c.r4()), "\t") - print("r5 ", hex(c.r5()), "\n") - print("r6 ", hex(c.r6()), "\t") - print("r7 ", hex(c.r7()), "\n") - print("r8 ", hex(c.r8()), "\t") - print("r9 ", hex(c.r9()), "\n") - print("r10 ", hex(c.r10()), "\t") - print("r11 ", hex(c.r11()), "\n") - print("r12 ", hex(c.r12()), "\t") - print("r13 ", hex(c.r13()), "\n") - print("r14 ", hex(c.r14()), "\t") - print("r15 ", hex(c.r15()), "\n") - print("r16 ", hex(c.r16()), "\t") - print("r17 ", hex(c.r17()), "\n") - print("r18 ", hex(c.r18()), "\t") - print("r19 ", hex(c.r19()), "\n") - print("r20 ", hex(c.r20()), "\t") - print("r21 ", hex(c.r21()), "\n") - print("r22 ", hex(c.r22()), "\t") - print("r23 ", hex(c.r23()), "\n") - print("r24 ", hex(c.r24()), "\t") - print("r25 ", hex(c.r25()), "\n") - print("r26 ", hex(c.r26()), "\t") - print("r27 ", hex(c.r27()), "\n") - print("r28 ", hex(c.r28()), "\t") - print("r29 ", hex(c.r29()), "\n") - print("r30 ", hex(c.r30()), "\t") - print("r31 ", hex(c.r31()), "\n") - print("pc ", hex(c.pc()), "\t") - print("link ", hex(c.link()), "\n") - print("lo ", hex(c.lo()), "\t") - print("hi ", hex(c.hi()), "\n") -} - -var crashing int32 - -// May run during STW, so write barriers are not allowed. -// -//go:nowritebarrierrec -func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) { - _g_ := getg() - c := &sigctxt{info, ctxt} - - if sig == _SIGPROF { - sigprof(uintptr(c.pc()), uintptr(c.sp()), uintptr(c.link()), gp, _g_.m) - return - } - flags := int32(_SigThrow) - if sig < uint32(len(sigtable)) { - flags = sigtable[sig].flags - } - if c.sigcode() != _SI_USER && flags&_SigPanic != 0 { - // Make it look like a call to the signal func. - // Have to pass arguments out of band since - // augmenting the stack frame would break - // the unwinding code. - gp.sig = sig - gp.sigcode0 = uintptr(c.sigcode()) - gp.sigcode1 = uintptr(c.sigaddr()) - gp.sigpc = uintptr(c.pc()) - - // We arrange link, and pc to pretend the panicking - // function calls sigpanic directly. - // Always save LINK to stack so that panics in leaf - // functions are correctly handled. This smashes - // the stack frame but we're not going back there - // anyway. - sp := c.sp() - sys.PtrSize - c.set_sp(sp) - *(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link() - - pc := gp.sigpc - - // If we don't recognize the PC as code - // but we do recognize the link register as code, - // then assume this was a call to non-code and treat like - // pc == 0, to make unwinding show the context. - if pc != 0 && findfunc(pc) == nil && findfunc(uintptr(c.link())) != nil { - pc = 0 - } - - // Don't bother saving PC if it's zero, which is - // probably a call to a nil func: the old link register - // is more useful in the stack trace. - if pc != 0 { - c.set_link(uint64(pc)) - } - - // In case we are panicking from external C code - c.set_r30(uint64(uintptr(unsafe.Pointer(gp)))) - c.set_pc(uint64(funcPC(sigpanic))) - return - } - - if c.sigcode() == _SI_USER || flags&_SigNotify != 0 { - if sigsend(sig) { - return - } - } - - if c.sigcode() == _SI_USER && signal_ignored(sig) { - return - } - - if flags&_SigKill != 0 { - dieFromSignal(int32(sig)) - } - - if flags&_SigThrow == 0 { - return - } - - _g_.m.throwing = 1 - _g_.m.caughtsig.set(gp) - - if crashing == 0 { - startpanic() - } - - if sig < uint32(len(sigtable)) { - print(sigtable[sig].name, "\n") - } else { - print("Signal ", sig, "\n") - } - - print("PC=", hex(c.pc()), " m=", _g_.m.id, "\n") - if _g_.m.lockedg != nil && _g_.m.ncgo > 0 && gp == _g_.m.g0 { - print("signal arrived during cgo execution\n") - gp = _g_.m.lockedg - } - print("\n") - - level, _, docrash := gotraceback() - if level > 0 { - goroutineheader(gp) - tracebacktrap(uintptr(c.pc()), uintptr(c.sp()), uintptr(c.link()), gp) - if crashing > 0 && gp != _g_.m.curg && _g_.m.curg != nil && readgstatus(_g_.m.curg)&^_Gscan == _Grunning { - // tracebackothers on original m skipped this one; trace it now. - goroutineheader(_g_.m.curg) - traceback(^uintptr(0), ^uintptr(0), 0, gp) - } else if crashing == 0 { - tracebackothers(gp) - print("\n") - } - dumpregs(c) - } - - if docrash { - crashing++ - if crashing < sched.mcount { - // There are other m's that need to dump their stacks. - // Relay SIGQUIT to the next m by sending it to the current process. - // All m's that have already received SIGQUIT have signal masks blocking - // receipt of any signals, so the SIGQUIT will go to an m that hasn't seen it yet. - // When the last m receives the SIGQUIT, it will fall through to the call to - // crash below. Just in case the relaying gets botched, each m involved in - // the relay sleeps for 5 seconds and then does the crash/exit itself. - // In expected operation, the last m has received the SIGQUIT and run - // crash/exit and the process is gone, all long before any of the - // 5-second sleeps have finished. - print("\n-----\n\n") - raiseproc(_SIGQUIT) - usleep(5 * 1000 * 1000) - } - crash() - } - - exit(2) -} diff --git a/libgo/go/runtime/signal_sigtramp.go b/libgo/go/runtime/signal_sigtramp.go index dbbbcd0..f4a6ebd 100644 --- a/libgo/go/runtime/signal_sigtramp.go +++ b/libgo/go/runtime/signal_sigtramp.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + // +build dragonfly linux netbsd package runtime diff --git a/libgo/go/runtime/sigtab_linux_generic.go b/libgo/go/runtime/sigtab_linux_generic.go deleted file mode 100644 index ea36bf3..0000000 --- a/libgo/go/runtime/sigtab_linux_generic.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2009 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. - -// +build !mips64 -// +build !mips64le -// +build linux - -package runtime - -type sigTabT struct { - flags int32 - name string -} - -var sigtable = [...]sigTabT{ - /* 0 */ {0, "SIGNONE: no trap"}, - /* 1 */ {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"}, - /* 2 */ {_SigNotify + _SigKill, "SIGINT: interrupt"}, - /* 3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit"}, - /* 4 */ {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"}, - /* 5 */ {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"}, - /* 6 */ {_SigNotify + _SigThrow, "SIGABRT: abort"}, - /* 7 */ {_SigPanic + _SigUnblock, "SIGBUS: bus error"}, - /* 8 */ {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"}, - /* 9 */ {0, "SIGKILL: kill"}, - /* 10 */ {_SigNotify, "SIGUSR1: user-defined signal 1"}, - /* 11 */ {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"}, - /* 12 */ {_SigNotify, "SIGUSR2: user-defined signal 2"}, - /* 13 */ {_SigNotify, "SIGPIPE: write to broken pipe"}, - /* 14 */ {_SigNotify, "SIGALRM: alarm clock"}, - /* 15 */ {_SigNotify + _SigKill, "SIGTERM: termination"}, - /* 16 */ {_SigThrow + _SigUnblock, "SIGSTKFLT: stack fault"}, - /* 17 */ {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"}, - /* 18 */ {_SigNotify + _SigDefault, "SIGCONT: continue"}, - /* 19 */ {0, "SIGSTOP: stop, unblockable"}, - /* 20 */ {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"}, - /* 21 */ {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"}, - /* 22 */ {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"}, - /* 23 */ {_SigNotify, "SIGURG: urgent condition on socket"}, - /* 24 */ {_SigNotify, "SIGXCPU: cpu limit exceeded"}, - /* 25 */ {_SigNotify, "SIGXFSZ: file size limit exceeded"}, - /* 26 */ {_SigNotify, "SIGVTALRM: virtual alarm clock"}, - /* 27 */ {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"}, - /* 28 */ {_SigNotify, "SIGWINCH: window size change"}, - /* 29 */ {_SigNotify, "SIGIO: i/o now possible"}, - /* 30 */ {_SigNotify, "SIGPWR: power failure restart"}, - /* 31 */ {_SigThrow, "SIGSYS: bad system call"}, - /* 32 */ {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */ - /* 33 */ {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */ - /* 34 */ {_SigNotify, "signal 34"}, - /* 35 */ {_SigNotify, "signal 35"}, - /* 36 */ {_SigNotify, "signal 36"}, - /* 37 */ {_SigNotify, "signal 37"}, - /* 38 */ {_SigNotify, "signal 38"}, - /* 39 */ {_SigNotify, "signal 39"}, - /* 40 */ {_SigNotify, "signal 40"}, - /* 41 */ {_SigNotify, "signal 41"}, - /* 42 */ {_SigNotify, "signal 42"}, - /* 43 */ {_SigNotify, "signal 43"}, - /* 44 */ {_SigNotify, "signal 44"}, - /* 45 */ {_SigNotify, "signal 45"}, - /* 46 */ {_SigNotify, "signal 46"}, - /* 47 */ {_SigNotify, "signal 47"}, - /* 48 */ {_SigNotify, "signal 48"}, - /* 49 */ {_SigNotify, "signal 49"}, - /* 50 */ {_SigNotify, "signal 50"}, - /* 51 */ {_SigNotify, "signal 51"}, - /* 52 */ {_SigNotify, "signal 52"}, - /* 53 */ {_SigNotify, "signal 53"}, - /* 54 */ {_SigNotify, "signal 54"}, - /* 55 */ {_SigNotify, "signal 55"}, - /* 56 */ {_SigNotify, "signal 56"}, - /* 57 */ {_SigNotify, "signal 57"}, - /* 58 */ {_SigNotify, "signal 58"}, - /* 59 */ {_SigNotify, "signal 59"}, - /* 60 */ {_SigNotify, "signal 60"}, - /* 61 */ {_SigNotify, "signal 61"}, - /* 62 */ {_SigNotify, "signal 62"}, - /* 63 */ {_SigNotify, "signal 63"}, - /* 64 */ {_SigNotify, "signal 64"}, -} diff --git a/libgo/go/runtime/sigtab_linux_mips64x.go b/libgo/go/runtime/sigtab_linux_mips64x.go deleted file mode 100644 index 201fe3d..0000000 --- a/libgo/go/runtime/sigtab_linux_mips64x.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2015 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. - -// +build mips64 mips64le -// +build linux - -package runtime - -type sigTabT struct { - flags int32 - name string -} - -var sigtable = [...]sigTabT{ - /* 0 */ {0, "SIGNONE: no trap"}, - /* 1 */ {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"}, - /* 2 */ {_SigNotify + _SigKill, "SIGINT: interrupt"}, - /* 3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit"}, - /* 4 */ {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"}, - /* 5 */ {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"}, - /* 6 */ {_SigNotify + _SigThrow, "SIGABRT: abort"}, - /* 7 */ {_SigThrow, "SIGEMT"}, - /* 8 */ {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"}, - /* 9 */ {0, "SIGKILL: kill"}, - /* 10 */ {_SigPanic + _SigUnblock, "SIGBUS: bus error"}, - /* 11 */ {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"}, - /* 12 */ {_SigThrow, "SIGSYS: bad system call"}, - /* 13 */ {_SigNotify, "SIGPIPE: write to broken pipe"}, - /* 14 */ {_SigNotify, "SIGALRM: alarm clock"}, - /* 15 */ {_SigNotify + _SigKill, "SIGTERM: termination"}, - /* 16 */ {_SigNotify, "SIGUSR1: user-defined signal 1"}, - /* 17 */ {_SigNotify, "SIGUSR2: user-defined signal 2"}, - /* 18 */ {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"}, - /* 19 */ {_SigNotify, "SIGPWR: power failure restart"}, - /* 20 */ {_SigNotify, "SIGWINCH: window size change"}, - /* 21 */ {_SigNotify, "SIGURG: urgent condition on socket"}, - /* 22 */ {_SigNotify, "SIGIO: i/o now possible"}, - /* 23 */ {0, "SIGSTOP: stop, unblockable"}, - /* 24 */ {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"}, - /* 25 */ {_SigNotify + _SigDefault, "SIGCONT: continue"}, - /* 26 */ {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"}, - /* 27 */ {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"}, - /* 28 */ {_SigNotify, "SIGVTALRM: virtual alarm clock"}, - /* 29 */ {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"}, - /* 30 */ {_SigNotify, "SIGXCPU: cpu limit exceeded"}, - /* 31 */ {_SigNotify, "SIGXFSZ: file size limit exceeded"}, - /* 32 */ {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */ - /* 33 */ {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */ - /* 34 */ {_SigNotify, "signal 34"}, - /* 35 */ {_SigNotify, "signal 35"}, - /* 36 */ {_SigNotify, "signal 36"}, - /* 37 */ {_SigNotify, "signal 37"}, - /* 38 */ {_SigNotify, "signal 38"}, - /* 39 */ {_SigNotify, "signal 39"}, - /* 40 */ {_SigNotify, "signal 40"}, - /* 41 */ {_SigNotify, "signal 41"}, - /* 42 */ {_SigNotify, "signal 42"}, - /* 43 */ {_SigNotify, "signal 43"}, - /* 44 */ {_SigNotify, "signal 44"}, - /* 45 */ {_SigNotify, "signal 45"}, - /* 46 */ {_SigNotify, "signal 46"}, - /* 47 */ {_SigNotify, "signal 47"}, - /* 48 */ {_SigNotify, "signal 48"}, - /* 49 */ {_SigNotify, "signal 49"}, - /* 50 */ {_SigNotify, "signal 50"}, - /* 51 */ {_SigNotify, "signal 51"}, - /* 52 */ {_SigNotify, "signal 52"}, - /* 53 */ {_SigNotify, "signal 53"}, - /* 54 */ {_SigNotify, "signal 54"}, - /* 55 */ {_SigNotify, "signal 55"}, - /* 56 */ {_SigNotify, "signal 56"}, - /* 57 */ {_SigNotify, "signal 57"}, - /* 58 */ {_SigNotify, "signal 58"}, - /* 59 */ {_SigNotify, "signal 59"}, - /* 60 */ {_SigNotify, "signal 60"}, - /* 61 */ {_SigNotify, "signal 61"}, - /* 62 */ {_SigNotify, "signal 62"}, - /* 63 */ {_SigNotify, "signal 63"}, - /* 64 */ {_SigNotify, "signal 64"}, -} diff --git a/libgo/go/runtime/stack.go b/libgo/go/runtime/stack.go index 8398a10..708a4c2 100644 --- a/libgo/go/runtime/stack.go +++ b/libgo/go/runtime/stack.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package runtime import ( diff --git a/libgo/go/runtime/sys_mips64x.go b/libgo/go/runtime/sys_mips64x.go deleted file mode 100644 index 9e7d805..0000000 --- a/libgo/go/runtime/sys_mips64x.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 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. - -// +build mips64 mips64le - -package runtime - -import "unsafe" - -// adjust Gobuf as if it executed a call to fn with context ctxt -// and then did an immediate Gosave. -func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) { - if buf.lr != 0 { - throw("invalid use of gostartcall") - } - buf.lr = buf.pc - buf.pc = uintptr(fn) - buf.ctxt = ctxt -} - -// Called to rewind context saved during morestack back to beginning of function. -// To help us, the linker emits a jmp back to the beginning right after the -// call to morestack. We just have to decode and apply that jump. -func rewindmorestack(buf *gobuf) { - var inst uint32 - if buf.pc&3 == 0 && buf.pc != 0 { - inst = *(*uint32)(unsafe.Pointer(buf.pc)) - if inst>>26 == 2 { // JMP addr - //print("runtime: rewind pc=", hex(buf.pc), " to pc=", hex(buf.pc &^ uintptr(1<<28-1) | uintptr((inst&^0xfc000000)<<2)), "\n"); - buf.pc &^= 1<<28 - 1 - buf.pc |= uintptr((inst &^ 0xfc000000) << 2) - return - } - if inst>>16 == 0x1000 { // BEQ R0, R0, offset - //print("runtime: rewind pc=", hex(buf.pc), " to pc=", hex(buf.pc + uintptr(int32(int16(inst&0xffff))<<2 + 4)), "\n"); - buf.pc += uintptr(int32(int16(inst&0xffff))<<2 + 4) - return - } - } - print("runtime: pc=", hex(buf.pc), " ", hex(inst), "\n") - throw("runtime: misuse of rewindmorestack") -} diff --git a/libgo/go/runtime/sys_nonppc64x.go b/libgo/go/runtime/sys_nonppc64x.go deleted file mode 100644 index 4409374..0000000 --- a/libgo/go/runtime/sys_nonppc64x.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2015 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. - -// +build !ppc64,!ppc64le - -package runtime - -func prepGoExitFrame(sp uintptr) { -} diff --git a/libgo/go/runtime/sys_s390x.go b/libgo/go/runtime/sys_s390x.go deleted file mode 100644 index 2aa81e7..0000000 --- a/libgo/go/runtime/sys_s390x.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 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 runtime - -import "unsafe" - -// adjust Gobuf as if it executed a call to fn with context ctxt -// and then did an immediate Gosave. -func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) { - if buf.lr != 0 { - throw("invalid use of gostartcall") - } - buf.lr = buf.pc - buf.pc = uintptr(fn) - buf.ctxt = ctxt -} - -// Called to rewind context saved during morestack back to beginning of function. -// To help us, the linker emits a jmp back to the beginning right after the -// call to morestack. We just have to decode and apply that jump. -func rewindmorestack(buf *gobuf) { - var inst uint64 - if buf.pc&1 == 0 && buf.pc != 0 { - inst = *(*uint64)(unsafe.Pointer(buf.pc)) - switch inst >> 48 { - case 0xa7f4: // BRC (branch relative on condition) instruction. - inst >>= 32 - inst &= 0xFFFF - offset := int64(int16(inst)) - offset <<= 1 - buf.pc += uintptr(offset) - return - case 0xc0f4: // BRCL (branch relative on condition long) instruction. - inst >>= 16 - inst = inst & 0xFFFFFFFF - inst = (inst << 1) & 0xFFFFFFFF - buf.pc += uintptr(int32(inst)) - return - } - } - print("runtime: pc=", hex(buf.pc), " ", hex(inst), "\n") - throw("runtime: misuse of rewindmorestack") -} diff --git a/libgo/go/runtime/vlrt.go b/libgo/go/runtime/vlrt.go deleted file mode 100644 index cd37828..0000000 --- a/libgo/go/runtime/vlrt.go +++ /dev/null @@ -1,257 +0,0 @@ -// Inferno's libkern/vlrt-arm.c -// http://code.google.com/p/inferno-os/source/browse/libkern/vlrt-arm.c -// -// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. -// Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. -// Portions Copyright 2009 The Go Authors. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// +build arm 386 - -package runtime - -import "unsafe" - -const ( - sign32 = 1 << (32 - 1) - sign64 = 1 << (64 - 1) -) - -func float64toint64(d float64) (y uint64) { - _d2v(&y, d) - return -} - -func float64touint64(d float64) (y uint64) { - _d2v(&y, d) - return -} - -func int64tofloat64(y int64) float64 { - if y < 0 { - return -uint64tofloat64(-uint64(y)) - } - return uint64tofloat64(uint64(y)) -} - -func uint64tofloat64(y uint64) float64 { - hi := float64(uint32(y >> 32)) - lo := float64(uint32(y)) - d := hi*(1<<32) + lo - return d -} - -func _d2v(y *uint64, d float64) { - x := *(*uint64)(unsafe.Pointer(&d)) - - xhi := uint32(x>>32)&0xfffff | 0x100000 - xlo := uint32(x) - sh := 1075 - int32(uint32(x>>52)&0x7ff) - - var ylo, yhi uint32 - if sh >= 0 { - sh := uint32(sh) - /* v = (hi||lo) >> sh */ - if sh < 32 { - if sh == 0 { - ylo = xlo - yhi = xhi - } else { - ylo = xlo>>sh | xhi<<(32-sh) - yhi = xhi >> sh - } - } else { - if sh == 32 { - ylo = xhi - } else if sh < 64 { - ylo = xhi >> (sh - 32) - } - } - } else { - /* v = (hi||lo) << -sh */ - sh := uint32(-sh) - if sh <= 11 { - ylo = xlo << sh - yhi = xhi<<sh | xlo>>(32-sh) - } else { - /* overflow */ - yhi = uint32(d) /* causes something awful */ - } - } - if x&sign64 != 0 { - if ylo != 0 { - ylo = -ylo - yhi = ^yhi - } else { - yhi = -yhi - } - } - - *y = uint64(yhi)<<32 | uint64(ylo) -} - -func uint64div(n, d uint64) uint64 { - // Check for 32 bit operands - if uint32(n>>32) == 0 && uint32(d>>32) == 0 { - if uint32(d) == 0 { - panicdivide() - } - return uint64(uint32(n) / uint32(d)) - } - q, _ := dodiv(n, d) - return q -} - -func uint64mod(n, d uint64) uint64 { - // Check for 32 bit operands - if uint32(n>>32) == 0 && uint32(d>>32) == 0 { - if uint32(d) == 0 { - panicdivide() - } - return uint64(uint32(n) % uint32(d)) - } - _, r := dodiv(n, d) - return r -} - -func int64div(n, d int64) int64 { - // Check for 32 bit operands - if int64(int32(n)) == n && int64(int32(d)) == d { - if int32(n) == -0x80000000 && int32(d) == -1 { - // special case: 32-bit -0x80000000 / -1 = -0x80000000, - // but 64-bit -0x80000000 / -1 = 0x80000000. - return 0x80000000 - } - if int32(d) == 0 { - panicdivide() - } - return int64(int32(n) / int32(d)) - } - - nneg := n < 0 - dneg := d < 0 - if nneg { - n = -n - } - if dneg { - d = -d - } - uq, _ := dodiv(uint64(n), uint64(d)) - q := int64(uq) - if nneg != dneg { - q = -q - } - return q -} - -func int64mod(n, d int64) int64 { - // Check for 32 bit operands - if int64(int32(n)) == n && int64(int32(d)) == d { - if int32(d) == 0 { - panicdivide() - } - return int64(int32(n) % int32(d)) - } - - nneg := n < 0 - if nneg { - n = -n - } - if d < 0 { - d = -d - } - _, ur := dodiv(uint64(n), uint64(d)) - r := int64(ur) - if nneg { - r = -r - } - return r -} - -//go:noescape -func _mul64by32(lo64 *uint64, a uint64, b uint32) (hi32 uint32) - -//go:noescape -func _div64by32(a uint64, b uint32, r *uint32) (q uint32) - -func dodiv(n, d uint64) (q, r uint64) { - if GOARCH == "arm" { - // arm doesn't have a division instruction, so - // slowdodiv is the best that we can do. - return slowdodiv(n, d) - } - - if d > n { - return 0, n - } - - if uint32(d>>32) != 0 { - t := uint32(n>>32) / uint32(d>>32) - var lo64 uint64 - hi32 := _mul64by32(&lo64, d, t) - if hi32 != 0 || lo64 > n { - return slowdodiv(n, d) - } - return uint64(t), n - lo64 - } - - // d is 32 bit - var qhi uint32 - if uint32(n>>32) >= uint32(d) { - if uint32(d) == 0 { - panicdivide() - } - qhi = uint32(n>>32) / uint32(d) - n -= uint64(uint32(d)*qhi) << 32 - } else { - qhi = 0 - } - - var rlo uint32 - qlo := _div64by32(n, uint32(d), &rlo) - return uint64(qhi)<<32 + uint64(qlo), uint64(rlo) -} - -func slowdodiv(n, d uint64) (q, r uint64) { - if d == 0 { - panicdivide() - } - - // Set up the divisor and find the number of iterations needed. - capn := n - if n >= sign64 { - capn = sign64 - } - i := 0 - for d < capn { - d <<= 1 - i++ - } - - for ; i >= 0; i-- { - q <<= 1 - if n >= d { - n -= d - q |= 1 - } - d >>= 1 - } - return q, n -} diff --git a/libgo/go/runtime/write_err.go b/libgo/go/runtime/write_err.go deleted file mode 100644 index 6b1467b..0000000 --- a/libgo/go/runtime/write_err.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2009 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. - -// +build !android - -package runtime - -import "unsafe" - -func writeErr(b []byte) { - write(2, unsafe.Pointer(&b[0]), int32(len(b))) -} diff --git a/libgo/go/runtime/write_err_android.go b/libgo/go/runtime/write_err_android.go deleted file mode 100644 index 4411a14..0000000 --- a/libgo/go/runtime/write_err_android.go +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2014 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 runtime - -import "unsafe" - -var ( - writeHeader = []byte{6 /* ANDROID_LOG_ERROR */, 'G', 'o', 0} - writePath = []byte("/dev/log/main\x00") - writeLogd = []byte("/dev/socket/logdw\x00") - - // guarded by printlock/printunlock. - writeFD uintptr - writeBuf [1024]byte - writePos int -) - -// Prior to Android-L, logging was done through writes to /dev/log files implemented -// in kernel ring buffers. In Android-L, those /dev/log files are no longer -// accessible and logging is done through a centralized user-mode logger, logd. -// -// https://android.googlesource.com/platform/system/core/+/master/liblog/logd_write.c -type loggerType int32 - -const ( - unknown loggerType = iota - legacy - logd - // TODO(hakim): logging for emulator? -) - -var logger loggerType - -func writeErr(b []byte) { - if logger == unknown { - // Use logd if /dev/socket/logdw is available. - if v := uintptr(access(&writeLogd[0], 0x02 /* W_OK */)); v == 0 { - logger = logd - initLogd() - } else { - logger = legacy - initLegacy() - } - } - - // Write to stderr for command-line programs. - write(2, unsafe.Pointer(&b[0]), int32(len(b))) - - // Log format: "<header>\x00<message m bytes>\x00" - // - // <header> - // In legacy mode: "<priority 1 byte><tag n bytes>". - // In logd mode: "<android_log_header_t 11 bytes><priority 1 byte><tag n bytes>" - // - // The entire log needs to be delivered in a single syscall (the NDK - // does this with writev). Each log is its own line, so we need to - // buffer writes until we see a newline. - var hlen int - switch logger { - case logd: - hlen = writeLogdHeader() - case legacy: - hlen = len(writeHeader) - } - - dst := writeBuf[hlen:] - for _, v := range b { - if v == 0 { // android logging won't print a zero byte - v = '0' - } - dst[writePos] = v - writePos++ - if v == '\n' || writePos == len(dst)-1 { - dst[writePos] = 0 - write(writeFD, unsafe.Pointer(&writeBuf[0]), int32(hlen+writePos)) - memclrBytes(dst) - writePos = 0 - } - } -} - -func initLegacy() { - // In legacy mode, logs are written to /dev/log/main - writeFD = uintptr(open(&writePath[0], 0x1 /* O_WRONLY */, 0)) - if writeFD == 0 { - // It is hard to do anything here. Write to stderr just - // in case user has root on device and has run - // adb shell setprop log.redirect-stdio true - msg := []byte("runtime: cannot open /dev/log/main\x00") - write(2, unsafe.Pointer(&msg[0]), int32(len(msg))) - exit(2) - } - - // Prepopulate the invariant header part. - copy(writeBuf[:len(writeHeader)], writeHeader) -} - -// used in initLogdWrite but defined here to avoid heap allocation. -var logdAddr sockaddr_un - -func initLogd() { - // In logd mode, logs are sent to the logd via a unix domain socket. - logdAddr.family = _AF_UNIX - copy(logdAddr.path[:], writeLogd) - - // We are not using non-blocking I/O because writes taking this path - // are most likely triggered by panic, we cannot think of the advantage of - // non-blocking I/O for panic but see disadvantage (dropping panic message), - // and blocking I/O simplifies the code a lot. - fd := socket(_AF_UNIX, _SOCK_DGRAM|_O_CLOEXEC, 0) - if fd < 0 { - msg := []byte("runtime: cannot create a socket for logging\x00") - write(2, unsafe.Pointer(&msg[0]), int32(len(msg))) - exit(2) - } - - errno := connect(fd, unsafe.Pointer(&logdAddr), int32(unsafe.Sizeof(logdAddr))) - if errno < 0 { - msg := []byte("runtime: cannot connect to /dev/socket/logdw\x00") - write(2, unsafe.Pointer(&msg[0]), int32(len(msg))) - // TODO(hakim): or should we just close fd and hope for better luck next time? - exit(2) - } - writeFD = uintptr(fd) - - // Prepopulate invariant part of the header. - // The first 11 bytes will be populated later in writeLogdHeader. - copy(writeBuf[11:11+len(writeHeader)], writeHeader) -} - -// writeLogdHeader populates the header and returns the length of the payload. -func writeLogdHeader() int { - hdr := writeBuf[:11] - - // The first 11 bytes of the header corresponds to android_log_header_t - // as defined in system/core/include/private/android_logger.h - // hdr[0] log type id (unsigned char), defined in <log/log.h> - // hdr[1:2] tid (uint16_t) - // hdr[3:11] log_time defined in <log/log_read.h> - // hdr[3:7] sec unsigned uint32, little endian. - // hdr[7:11] nsec unsigned uint32, little endian. - hdr[0] = 0 // LOG_ID_MAIN - sec, nsec := time_now() - packUint32(hdr[3:7], uint32(sec)) - packUint32(hdr[7:11], uint32(nsec)) - - // TODO(hakim): hdr[1:2] = gettid? - - return 11 + len(writeHeader) -} - -func packUint32(b []byte, v uint32) { - // little-endian. - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) -} diff --git a/libgo/go/strings/strings_amd64.go b/libgo/go/strings/strings_amd64.go index 55bf2d2..4b06f8a 100644 --- a/libgo/go/strings/strings_amd64.go +++ b/libgo/go/strings/strings_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package strings // indexShortStr returns the index of the first instance of c in s, or -1 if c is not present in s. diff --git a/libgo/go/strings/strings_generic.go b/libgo/go/strings/strings_generic.go index d356f50..aef2c1e 100644 --- a/libgo/go/strings/strings_generic.go +++ b/libgo/go/strings/strings_generic.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !amd64 - package strings // TODO: implements short string optimization on non amd64 platforms diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go index aa656ca..25b0063 100644 --- a/libgo/go/syscall/errstr.go +++ b/libgo/go/syscall/errstr.go @@ -4,6 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !linux + package syscall //sysnb strerror_r(errnum int, buf []byte) (err Errno) diff --git a/libgo/go/syscall/errstr_linux.go b/libgo/go/syscall/errstr_linux.go index d10476d..7156b79 100644 --- a/libgo/go/syscall/errstr_linux.go +++ b/libgo/go/syscall/errstr_linux.go @@ -1,9 +1,12 @@ -// errstr_rtems.go -- RTEMS specific error strings. +// errstr_linux.go -- GNU/Linux specific error strings. // Copyright 2010 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. +// We use this rather than errstr.go because on GNU/Linux sterror_r +// returns a pointer to the error message, and may not use buf at all. + package syscall import "unsafe" diff --git a/libgo/go/syscall/errstr_nor.go b/libgo/go/syscall/errstr_nor.go deleted file mode 100644 index 796561a..0000000 --- a/libgo/go/syscall/errstr_nor.go +++ /dev/null @@ -1,41 +0,0 @@ -// errstr.go -- Error strings when there is no strerror_r. - -// Copyright 2011 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 ( - "sync" - "unsafe" -) - -//sysnb strerror(errnum int) (buf *byte) -//strerror(errnum _C_int) *byte - -var errstr_lock sync.Mutex - -func Errstr(errno int) string { - errstr_lock.Lock() - - bp := strerror(errno) - b := (*[1000]byte)(unsafe.Pointer(bp)) - i := 0 - for b[i] != 0 { - i++ - } - - // Lowercase first letter: Bad -> bad, but STREAM -> STREAM. - var s string - if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { - c := b[0] + 'a' - 'A' - s = string(c) + string(b[1:i]) - } else { - s = string(b[:i]) - } - - errstr_lock.Unlock() - - return s -} diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go index ab0750d..af025e4 100644 --- a/libgo/go/syscall/exec_bsd.go +++ b/libgo/go/syscall/exec_bsd.go @@ -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 netbsd openbsd +// +build darwin dragonfly freebsd netbsd openbsd solaris package syscall diff --git a/libgo/go/syscall/exec_stubs.go b/libgo/go/syscall/exec_stubs.go index 35bb174..e95b415 100644 --- a/libgo/go/syscall/exec_stubs.go +++ b/libgo/go/syscall/exec_stubs.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build rtems + // Stubs for fork, exec and wait. package syscall diff --git a/libgo/go/syscall/libcall_bsd.go b/libgo/go/syscall/libcall_bsd.go index fe6a3e3..9a4b2d6 100644 --- a/libgo/go/syscall/libcall_bsd.go +++ b/libgo/go/syscall/libcall_bsd.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin dragonfly freebsd netbsd openbsd solaris + // BSD library calls. package syscall diff --git a/libgo/go/syscall/libcall_irix.go b/libgo/go/syscall/libcall_irix.go index 50863fa..9b6cdcc 100644 --- a/libgo/go/syscall/libcall_irix.go +++ b/libgo/go/syscall/libcall_irix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build irix + package syscall //sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno) diff --git a/libgo/go/syscall/libcall_linux_ustat.go b/libgo/go/syscall/libcall_linux_ustat.go index f7f3406..261f086 100644 --- a/libgo/go/syscall/libcall_linux_ustat.go +++ b/libgo/go/syscall/libcall_linux_ustat.go @@ -4,6 +4,7 @@ // GNU/Linux library ustat call. // This is not supported on some kernels, such as arm64. +// +build !arm64 package syscall diff --git a/libgo/go/syscall/libcall_posix_largefile.go b/libgo/go/syscall/libcall_posix_largefile.go index c05d3d2..1f437b4 100644 --- a/libgo/go/syscall/libcall_posix_largefile.go +++ b/libgo/go/syscall/libcall_posix_largefile.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux solaris,386 solaris,sparc + // POSIX library calls on systems which use the largefile interface. package syscall diff --git a/libgo/go/syscall/libcall_posix_regfile.go b/libgo/go/syscall/libcall_posix_regfile.go index 7de5800..d106a7b 100644 --- a/libgo/go/syscall/libcall_posix_regfile.go +++ b/libgo/go/syscall/libcall_posix_regfile.go @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !linux +// +build !solaris !386 +// +build !solaris !sparc + // POSIX library calls on systems which do not use the largefile // interface. diff --git a/libgo/go/syscall/libcall_posix_utimesnano.go b/libgo/go/syscall/libcall_posix_utimesnano.go index e0751f5..5d9d02e 100644 --- a/libgo/go/syscall/libcall_posix_utimesnano.go +++ b/libgo/go/syscall/libcall_posix_utimesnano.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin dragonfly freebsd openbsd netbsd solaris + // General POSIX version of UtimesNano. package syscall diff --git a/libgo/go/syscall/libcall_uname.go b/libgo/go/syscall/libcall_uname.go index 1e164ef..165b3251 100644 --- a/libgo/go/syscall/libcall_uname.go +++ b/libgo/go/syscall/libcall_uname.go @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Build on all systems other than solaris/386. +// 32-bit Solaris 2/x86 needs _nuname, handled in libcall_solaris_386.go. +// +build !386 !solaris + package syscall //sysnb Uname(buf *Utsname) (err error) diff --git a/libgo/go/syscall/libcall_waitpid.go b/libgo/go/syscall/libcall_waitpid.go deleted file mode 100644 index b0e04b5..0000000 --- a/libgo/go/syscall/libcall_waitpid.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2009 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. - -// For systems with the waitpid library call. - -package syscall - -//sys waitpid(pid Pid_t, status *_C_int, options int) (wpid Pid_t, err error) -//waitpid(pid Pid_t, status *_C_int, options _C_int) Pid_t - -func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { - var status _C_int - r, err := waitpid(Pid_t(pid), &status, options) - wpid = int(r) - if wstatus != nil { - *wstatus = WaitStatus(status) - } - return -} diff --git a/libgo/go/syscall/msan.go b/libgo/go/syscall/msan.go deleted file mode 100644 index baaad6d..0000000 --- a/libgo/go/syscall/msan.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 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. - -// +build msan - -package syscall - -import ( - "runtime" - "unsafe" -) - -const msanenabled = true - -func msanRead(addr unsafe.Pointer, len int) { - runtime.MSanRead(addr, len) -} - -func msanWrite(addr unsafe.Pointer, len int) { - runtime.MSanWrite(addr, len) -} diff --git a/libgo/go/syscall/sleep_rtems.go b/libgo/go/syscall/sleep_rtems.go index 9d72203..480c775 100644 --- a/libgo/go/syscall/sleep_rtems.go +++ b/libgo/go/syscall/sleep_rtems.go @@ -4,6 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build rtems + package syscall func Sleep(nsec int64) (err error) { diff --git a/libgo/go/syscall/sleep_select.go b/libgo/go/syscall/sleep_select.go index 533f554..bb1694f 100644 --- a/libgo/go/syscall/sleep_select.go +++ b/libgo/go/syscall/sleep_select.go @@ -4,10 +4,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !rtems + package syscall func Sleep(nsec int64) (err error) { - tv := NsecToTimeval(nsec); - _, err = Select(0, nil, nil, nil, &tv); - return err; + tv := NsecToTimeval(nsec) + _, err = Select(0, nil, nil, nil, &tv) + return err } diff --git a/libgo/go/syscall/socket_bsd.go b/libgo/go/syscall/socket_bsd.go index c8da102..0f09627 100644 --- a/libgo/go/syscall/socket_bsd.go +++ b/libgo/go/syscall/socket_bsd.go @@ -4,6 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin dragonfly freebsd openbsd netbsd + package syscall const SizeofSockaddrInet4 = 16 diff --git a/libgo/go/syscall/socket_irix.go b/libgo/go/syscall/socket_irix.go index bcd1781..dc50fdd 100644 --- a/libgo/go/syscall/socket_irix.go +++ b/libgo/go/syscall/socket_irix.go @@ -4,6 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build irix + package syscall const SizeofSockaddrInet4 = 16 diff --git a/libgo/go/syscall/socket_linux_ppc64x_type.go b/libgo/go/syscall/socket_linux_ppc64x_type.go index 8a707ce..96afdeb 100644 --- a/libgo/go/syscall/socket_linux_ppc64x_type.go +++ b/libgo/go/syscall/socket_linux_ppc64x_type.go @@ -4,6 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux,ppc64 linux,ppc64le + package syscall // Type needed on ppc64le & ppc64 diff --git a/libgo/go/syscall/socket_linux_type.go b/libgo/go/syscall/socket_linux_type.go index 45b8c6e..190c11c 100644 --- a/libgo/go/syscall/socket_linux_type.go +++ b/libgo/go/syscall/socket_linux_type.go @@ -4,6 +4,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux +// +build !ppc64 +// +build !ppc64le + package syscall // Type needed if not on ppc64le or ppc64 diff --git a/libgo/go/syscall/socket_posix.go b/libgo/go/syscall/socket_posix.go index fda7dc6..fe835d3 100644 --- a/libgo/go/syscall/socket_posix.go +++ b/libgo/go/syscall/socket_posix.go @@ -4,6 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !solaris + package syscall //sys bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error) diff --git a/libgo/go/syscall/socket_xnet.go b/libgo/go/syscall/socket_xnet.go index 3c5b6b4..c0699c4 100644 --- a/libgo/go/syscall/socket_xnet.go +++ b/libgo/go/syscall/socket_xnet.go @@ -5,6 +5,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build solaris + package syscall //sys bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error) diff --git a/libgo/go/syscall/syscall_stubs.go b/libgo/go/syscall/syscall_stubs.go index 76c05cb..00288ee 100644 --- a/libgo/go/syscall/syscall_stubs.go +++ b/libgo/go/syscall/syscall_stubs.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build rtems + // These are stubs. package syscall |