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
This commit is contained in:
Adin Scannell 2020-11-23 14:25:37 -08:00 committed by gVisor bot
parent 2320ce5b7d
commit 3deb5d0c04
3 changed files with 27 additions and 1 deletions

View File

@ -40,6 +40,7 @@ go_library(
"race_unsafe.go",
"rwmutex_unsafe.go",
"seqcount.go",
"spin_legacy_unsafe.go",
"spin_unsafe.go",
"sync.go",
],

View File

@ -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()
}

View File

@ -3,7 +3,7 @@
// 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
// +build !go1.17
// Check go:linkname function signatures when updating Go version.