aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/lock_futex.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2017-03-23 22:47:56 -0400
committerCherry Zhang <cherryyz@google.com>2017-03-24 15:37:56 +0000
commit3a1ce1085ad08296557e8a87573fae4634ce7d8e (patch)
tree5b0391e8e96fad3998dfcf6156eb50a989eef93a /src/runtime/lock_futex.go
parent48de5a85fbc452bfc3af7422cd8aba0fab132d3d (diff)
downloadgo-3a1ce1085ad08296557e8a87573fae4634ce7d8e.tar.gz
go-3a1ce1085ad08296557e8a87573fae4634ce7d8e.zip
runtime: access _cgo_yield indirectly
The darwin linker for ARM does not allow PC-relative relocation of external symbol in text section. Work around it by accessing it indirectly: putting its address in a global variable (which is not external), and accessing through that variable. Fixes #19684. Change-Id: I41361bbb281b5dbdda0d100ae49d32c69ed85a81 Reviewed-on: https://go-review.googlesource.com/38596 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Elias Naur <elias.naur@gmail.com>
Diffstat (limited to 'src/runtime/lock_futex.go')
-rw-r--r--src/runtime/lock_futex.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/runtime/lock_futex.go b/src/runtime/lock_futex.go
index c3ed3be00b..45d3da64a4 100644
--- a/src/runtime/lock_futex.go
+++ b/src/runtime/lock_futex.go
@@ -141,15 +141,15 @@ func notesleep(n *note) {
throw("notesleep not on g0")
}
ns := int64(-1)
- if _cgo_yield != nil {
+ if *cgo_yield != nil {
// Sleep for an arbitrary-but-moderate interval to poll libc interceptors.
ns = 10e6
}
for atomic.Load(key32(&n.key)) == 0 {
gp.m.blocked = true
futexsleep(key32(&n.key), 0, ns)
- if _cgo_yield != nil {
- asmcgocall(_cgo_yield, nil)
+ if *cgo_yield != nil {
+ asmcgocall(*cgo_yield, nil)
}
gp.m.blocked = false
}
@@ -164,15 +164,15 @@ func notetsleep_internal(n *note, ns int64) bool {
gp := getg()
if ns < 0 {
- if _cgo_yield != nil {
+ if *cgo_yield != nil {
// Sleep for an arbitrary-but-moderate interval to poll libc interceptors.
ns = 10e6
}
for atomic.Load(key32(&n.key)) == 0 {
gp.m.blocked = true
futexsleep(key32(&n.key), 0, ns)
- if _cgo_yield != nil {
- asmcgocall(_cgo_yield, nil)
+ if *cgo_yield != nil {
+ asmcgocall(*cgo_yield, nil)
}
gp.m.blocked = false
}
@@ -185,13 +185,13 @@ func notetsleep_internal(n *note, ns int64) bool {
deadline := nanotime() + ns
for {
- if _cgo_yield != nil && ns > 10e6 {
+ if *cgo_yield != nil && ns > 10e6 {
ns = 10e6
}
gp.m.blocked = true
futexsleep(key32(&n.key), 0, ns)
- if _cgo_yield != nil {
- asmcgocall(_cgo_yield, nil)
+ if *cgo_yield != nil {
+ asmcgocall(*cgo_yield, nil)
}
gp.m.blocked = false
if atomic.Load(key32(&n.key)) != 0 {