summaryrefslogtreecommitdiffhomepage
path: root/pkg/sync/spin_legacy_unsafe.go
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-11-23 14:25:37 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-23 14:30:23 -0800
commit3deb5d0c043dcfd8523425792c6cf8ec13b19868 (patch)
tree542e91330b41918305fa8aca8c8b84462cf9f0bb /pkg/sync/spin_legacy_unsafe.go
parent2320ce5b7d992973182a90b2885e852b2059ee08 (diff)
Fix link against runtime.goyield.
This function does not exist in Go 1.13. We need to add an adaptor to build against Go 1.13, which is the default Ubuntu version. PiperOrigin-RevId: 343929132
Diffstat (limited to 'pkg/sync/spin_legacy_unsafe.go')
-rw-r--r--pkg/sync/spin_legacy_unsafe.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/sync/spin_legacy_unsafe.go b/pkg/sync/spin_legacy_unsafe.go
new file mode 100644
index 000000000..61fc7320e
--- /dev/null
+++ b/pkg/sync/spin_legacy_unsafe.go
@@ -0,0 +1,25 @@
+// Copyright 2020 The gVisor Authors.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.13
+// +build !go1.14
+
+package sync
+
+import (
+ "runtime"
+ _ "unsafe" // for go:linkname
+)
+
+//go:linkname canSpin sync.runtime_canSpin
+func canSpin(i int) bool
+
+//go:linkname doSpin sync.runtime_doSpin
+func doSpin()
+
+func goyield() {
+ // goyield is not available until Go 1.14.
+ runtime.Gosched()
+}