runtime: convert netpoll to Go
The common code is converted, epoll and kqueue are converted.
Windows and solaris are still C.
LGTM=rsc
R=golang-codereviews, rsc, dave
CC=golang-codereviews, iant, khr, rsc
https://golang.org/cl/132910043
diff --git a/src/pkg/runtime/time.go b/src/pkg/runtime/time.go
index 102539b..8cf9eec 100644
--- a/src/pkg/runtime/time.go
+++ b/src/pkg/runtime/time.go
@@ -9,7 +9,7 @@
import "unsafe"
// Package time knows the layout of this structure.
-// If this struct changes, adjust ../time/sleep.go:/runtimeTimer and netpoll.goc:/timer.
+// If this struct changes, adjust ../time/sleep.go:/runtimeTimer.
// For GOOS=nacl, package syscall knows the layout of this structure.
// If this struct changes, adjust ../syscall/net_nacl.go:/runtimeTimer.
type timer struct {
@@ -20,8 +20,9 @@
// a well-behaved function and not block.
when int64
period int64
- f func(interface{})
+ f func(interface{}, uintptr)
arg interface{}
+ seq uintptr
}
var timers struct {
@@ -74,7 +75,7 @@
// Go runtime.
// Ready the goroutine arg.
-func goroutineReady(arg interface{}) {
+func goroutineReady(arg interface{}, seq uintptr) {
goready(arg.(*g))
}
@@ -185,11 +186,12 @@
}
f := t.f
arg := t.arg
+ seq := t.seq
unlock(&timers.lock)
if raceenabled {
raceacquire(unsafe.Pointer(t))
}
- f(arg)
+ f(arg, seq)
lock(&timers.lock)
}
if delta < 0 {