aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/time.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-01-18 19:04:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-01-18 19:04:36 +0000
commit4f4a855d82a889cebcfca150a7a43909bcb6a346 (patch)
treef12bae0781920fa34669fe30b6f4615a86d9fb80 /libgo/go/runtime/time.go
parent225220d668dafb8262db7012bced688acbe63b33 (diff)
downloadgcc-4f4a855d82a889cebcfca150a7a43909bcb6a346.zip
gcc-4f4a855d82a889cebcfca150a7a43909bcb6a346.tar.gz
gcc-4f4a855d82a889cebcfca150a7a43909bcb6a346.tar.bz2
libgo: update to Go1.12beta2
Reviewed-on: https://go-review.googlesource.com/c/158019 gotools/: * Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release. (GOTOOLS_TEST_TIMEOUT): Increase to 600. (check-runtime): Export LD_LIBRARY_PATH before computing GOARCH and GOOS. (check-vet): Copy golang.org/x/tools into check-vet-dir. * Makefile.in: Regenerate. gcc/testsuite/: * go.go-torture/execute/names-1.go: Stop using debug/xcoff, which is no longer externally visible. From-SVN: r268084
Diffstat (limited to 'libgo/go/runtime/time.go')
-rw-r--r--libgo/go/runtime/time.go67
1 files changed, 35 insertions, 32 deletions
diff --git a/libgo/go/runtime/time.go b/libgo/go/runtime/time.go
index ea61baa..71e7556 100644
--- a/libgo/go/runtime/time.go
+++ b/libgo/go/runtime/time.go
@@ -7,7 +7,7 @@
package runtime
import (
- "runtime/internal/sys"
+ "internal/cpu"
"unsafe"
)
@@ -50,7 +50,7 @@ var timers [timersLen]struct {
// The padding should eliminate false sharing
// between timersBucket values.
- pad [sys.CacheLineSize - unsafe.Sizeof(timersBucket{})%sys.CacheLineSize]byte
+ pad [cpu.CacheLinePadSize - unsafe.Sizeof(timersBucket{})%cpu.CacheLinePadSize]byte
}
func (t *timer) assignBucket() *timersBucket {
@@ -156,7 +156,7 @@ func (tb *timersBucket) addtimerLocked(t *timer) bool {
}
if t.i == 0 {
// siftup moved to top: new earliest deadline.
- if tb.sleeping {
+ if tb.sleeping && tb.sleepUntil > t.when {
tb.sleeping = false
notewakeup(&tb.waitnote)
}
@@ -164,11 +164,11 @@ func (tb *timersBucket) addtimerLocked(t *timer) bool {
tb.rescheduling = false
goready(tb.gp, 0)
}
- }
- if !tb.created {
- tb.created = true
- expectSystemGoroutine()
- go timerproc(tb)
+ if !tb.created {
+ tb.created = true
+ expectSystemGoroutine()
+ go timerproc(tb)
+ }
}
return true
}
@@ -188,14 +188,22 @@ func deltimer(t *timer) bool {
tb := t.tb
lock(&tb.lock)
+ removed, ok := tb.deltimerLocked(t)
+ unlock(&tb.lock)
+ if !ok {
+ badTimer()
+ }
+ return removed
+}
+
+func (tb *timersBucket) deltimerLocked(t *timer) (removed, ok bool) {
// t may not be registered anymore and may have
// a bogus i (typically 0, if generated by Go).
// Verify it before proceeding.
i := t.i
last := len(tb.t) - 1
if i < 0 || i > last || tb.t[i] != t {
- unlock(&tb.lock)
- return false
+ return false, true
}
if i != last {
tb.t[i] = tb.t[last]
@@ -203,7 +211,7 @@ func deltimer(t *timer) bool {
}
tb.t[last] = nil
tb.t = tb.t[:last]
- ok := true
+ ok = true
if i != last {
if !siftupTimer(tb.t, i) {
ok = false
@@ -212,11 +220,26 @@ func deltimer(t *timer) bool {
ok = false
}
}
+ return true, ok
+}
+
+func modtimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) {
+ tb := t.tb
+
+ lock(&tb.lock)
+ _, ok := tb.deltimerLocked(t)
+ if ok {
+ t.when = when
+ t.period = period
+ t.f = f
+ t.arg = arg
+ t.seq = seq
+ ok = tb.addtimerLocked(t)
+ }
unlock(&tb.lock)
if !ok {
badTimer()
}
- return true
}
// Timerproc runs the time-driven events.
@@ -438,23 +461,3 @@ func siftdownTimer(t []*timer, i int) bool {
func badTimer() {
panic(errorString("racy use of timers"))
}
-
-// Entry points for net, time to call nanotime.
-
-//go:linkname poll_runtimeNano internal..z2fpoll.runtimeNano
-func poll_runtimeNano() int64 {
- return nanotime()
-}
-
-//go:linkname time_runtimeNano time.runtimeNano
-func time_runtimeNano() int64 {
- return nanotime()
-}
-
-// Monotonic times are reported as offsets from startNano.
-// We initialize startNano to nanotime() - 1 so that on systems where
-// monotonic time resolution is fairly low (e.g. Windows 2008
-// which appears to have a default resolution of 15ms),
-// we avoid ever reporting a nanotime of 0.
-// (Callers may want to use 0 as "time not set".)
-var startNano int64 = nanotime() - 1