mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
597213c87c
commit
1e3f563b14
2 changed files with 22 additions and 8 deletions
|
|
@ -750,16 +750,18 @@ func BenchmarkWakeupParallelSpinning(b *testing.B) {
|
|||
})
|
||||
}
|
||||
|
||||
// sysNanosleep is defined by OS-specific files (such as runtime_linux_test.go)
|
||||
// to sleep for the given duration. If nil, dependent tests are skipped.
|
||||
// The implementation should invoke a blocking system call and not
|
||||
// call time.Sleep, which would deschedule the goroutine.
|
||||
var sysNanosleep func(d time.Duration)
|
||||
|
||||
func BenchmarkWakeupParallelSyscall(b *testing.B) {
|
||||
if sysNanosleep == nil {
|
||||
b.Skipf("skipping on %v; sysNanosleep not defined", runtime.GOOS)
|
||||
}
|
||||
benchmarkWakeupParallel(b, 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
|
||||
}
|
||||
}
|
||||
sysNanosleep(d)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue