aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime_linux_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-12-06 00:35:28 -0500
committerRuss Cox <rsc@golang.org>2017-12-06 01:03:36 -0500
commit185e6094fd968b35b80e56aad1286c66bb2cc261 (patch)
tree411babe570d6faa1e99251a9167123afd07407d2 /src/runtime/runtime_linux_test.go
parentc36033a379a4907fb75309416ffcf2904e613ab9 (diff)
parenta032f74bf0b40a94669159e7d7e96722eb76199b (diff)
downloadgo-185e6094fd968b35b80e56aad1286c66bb2cc261.tar.xz
[dev.boringcrypto] all: merge master (nearly Go 1.10 beta 1) into dev.boringcrypto
This is a git merge of master into dev.boringcrypto. The branch was previously based on release-branch.go1.9, so there are a handful of spurious conflicts that would also arise if trying to merge master into release-branch.go1.9 (which we never do). Those have all been resolved by taking the original file from master, discarding any Go 1.9-specific edits. all.bash passes on darwin/amd64, which is to say without actually using BoringCrypto. Go 1.10-related fixes to BoringCrypto itself will be in a followup CL. This CL is just the merge. Change-Id: I4c97711fec0fb86761913dcde28d25c001246c35
Diffstat (limited to 'src/runtime/runtime_linux_test.go')
-rw-r--r--src/runtime/runtime_linux_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/runtime_linux_test.go b/src/runtime/runtime_linux_test.go
index 2b6daecbfc..612397293f 100644
--- a/src/runtime/runtime_linux_test.go
+++ b/src/runtime/runtime_linux_test.go
@@ -8,6 +8,7 @@ import (
. "runtime"
"syscall"
"testing"
+ "time"
"unsafe"
)
@@ -21,6 +22,17 @@ func init() {
// for how it is used in init (must be on main thread).
pid, tid = syscall.Getpid(), syscall.Gettid()
LockOSThread()
+
+ sysNanosleep = func(d time.Duration) {
+ // Invoke a blocking syscall directly; calling time.Sleep()
+ // would deschedule the goroutine instead.
+ ts := syscall.NsecToTimespec(d.Nanoseconds())
+ for {
+ if err := syscall.Nanosleep(&ts, &ts); err != syscall.EINTR {
+ return
+ }
+ }
+ }
}
func TestLockOSThread(t *testing.T) {