diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2017-11-21 20:46:40 +0000 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2017-11-21 21:52:58 +0000 |
| commit | 1e3f563b145ad98d2a5fcd4809e25a6a0bc8f892 (patch) | |
| tree | bd7ee8003095b41e3540d89d7439c51d763cfb84 /src/runtime/runtime_linux_test.go | |
| parent | 597213c87c70166e86753350b203622326728138 (diff) | |
| download | go-1e3f563b145ad98d2a5fcd4809e25a6a0bc8f892.tar.xz | |
runtime: fix build on non-Linux platforms
CL 78538 was updated after running TryBots to depend on
syscall.NanoSleep which isn't available on all non-Linux platforms.
Change-Id: I1fa615232b3920453431861310c108b208628441
Reviewed-on: https://go-review.googlesource.com/79175
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/runtime_linux_test.go')
| -rw-r--r-- | src/runtime/runtime_linux_test.go | 12 |
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) { |
