]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: replace the type of netpollWakeSig from a uintptr to a uint32
authorAndy Pan <panjf2000@gmail.com>
Fri, 10 Apr 2020 02:45:58 +0000 (10:45 +0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 10 Apr 2020 03:29:25 +0000 (03:29 +0000)
There's no need for netpollWakeSig to use a uintptr type, a uint32 is enough.

Relevant CL: CL 212737

Change-Id: Ide24478b217a02bad62f7e000a9680c26a8c5366
Reviewed-on: https://go-review.googlesource.com/c/go/+/227798
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/netpoll_aix.go
src/runtime/netpoll_epoll.go
src/runtime/netpoll_kqueue.go
src/runtime/netpoll_solaris.go
src/runtime/netpoll_windows.go

index 3c1f70874d65c3b70473e8ba5434fbb62dc3fb62..4590ed81a60c099d956c3cf0bdc0745213a28981 100644 (file)
@@ -45,7 +45,7 @@ var (
        wrwake         int32
        pendingUpdates int32
 
-       netpollWakeSig uintptr // used to avoid duplicate calls of netpollBreak
+       netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
 )
 
 func netpollinit() {
@@ -135,7 +135,7 @@ func netpollarm(pd *pollDesc, mode int) {
 
 // netpollBreak interrupts a poll.
 func netpollBreak() {
-       if atomic.Casuintptr(&netpollWakeSig, 0, 1) {
+       if atomic.Cas(&netpollWakeSig, 0, 1) {
                b := [1]byte{0}
                write(uintptr(wrwake), unsafe.Pointer(&b[0]), 1)
        }
@@ -192,7 +192,7 @@ retry:
                        var b [1]byte
                        for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 {
                        }
-                       atomic.Storeuintptr(&netpollWakeSig, 0)
+                       atomic.Store(&netpollWakeSig, 0)
                }
                // Still look at the other fds even if the mode may have
                // changed, as netpollBreak might have been called.
index cc4c36f796370e94ee8685fc9a007e5fe3092c01..58f4fa875417cc4b5491cc0761685cdb8af8eab3 100644 (file)
@@ -26,7 +26,7 @@ var (
 
        netpollBreakRd, netpollBreakWr uintptr // for netpollBreak
 
-       netpollWakeSig uintptr // used to avoid duplicate calls of netpollBreak
+       netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
 )
 
 func netpollinit() {
@@ -79,7 +79,7 @@ func netpollarm(pd *pollDesc, mode int) {
 
 // netpollBreak interrupts an epollwait.
 func netpollBreak() {
-       if atomic.Casuintptr(&netpollWakeSig, 0, 1) {
+       if atomic.Cas(&netpollWakeSig, 0, 1) {
                for {
                        var b byte
                        n := write(netpollBreakWr, unsafe.Pointer(&b), 1)
@@ -154,7 +154,7 @@ retry:
                                // if blocking.
                                var tmp [16]byte
                                read(int32(netpollBreakRd), noescape(unsafe.Pointer(&tmp[0])), int32(len(tmp)))
-                               atomic.Storeuintptr(&netpollWakeSig, 0)
+                               atomic.Store(&netpollWakeSig, 0)
                        }
                        continue
                }
index 2ff21d8fcba3028867c9b42b79eeb4617668bc79..3bd93c1f208dbde571b056f28c1ecf341a06a8ad 100644 (file)
@@ -18,7 +18,7 @@ var (
 
        netpollBreakRd, netpollBreakWr uintptr // for netpollBreak
 
-       netpollWakeSig uintptr // used to avoid duplicate calls of netpollBreak
+       netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
 )
 
 func netpollinit() {
@@ -83,7 +83,7 @@ func netpollarm(pd *pollDesc, mode int) {
 
 // netpollBreak interrupts a kevent.
 func netpollBreak() {
-       if atomic.Casuintptr(&netpollWakeSig, 0, 1) {
+       if atomic.Cas(&netpollWakeSig, 0, 1) {
                for {
                        var b byte
                        n := write(netpollBreakWr, unsafe.Pointer(&b), 1)
@@ -152,7 +152,7 @@ retry:
                                // if blocking.
                                var tmp [16]byte
                                read(int32(netpollBreakRd), noescape(unsafe.Pointer(&tmp[0])), int32(len(tmp)))
-                               atomic.Storeuintptr(&netpollWakeSig, 0)
+                               atomic.Store(&netpollWakeSig, 0)
                        }
                        continue
                }
index 34b3ee9308ea7ed4b1b232284dd04620f18c408e..d217d5b1604ae711db57ceb85fc7283c9042899d 100644 (file)
@@ -88,7 +88,7 @@ var (
        libc_port_dissociate,
        libc_port_getn,
        libc_port_alert libcFunc
-       netpollWakeSig uintptr // used to avoid duplicate calls of netpollBreak
+       netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
 )
 
 func errno() int32 {
@@ -191,7 +191,7 @@ func netpollarm(pd *pollDesc, mode int) {
 
 // netpollBreak interrupts a port_getn wait.
 func netpollBreak() {
-       if atomic.Casuintptr(&netpollWakeSig, 0, 1) {
+       if atomic.Cas(&netpollWakeSig, 0, 1) {
                // Use port_alert to put portfd into alert mode.
                // This will wake up all threads sleeping in port_getn on portfd,
                // and cause their calls to port_getn to return immediately.
@@ -274,7 +274,7 @@ retry:
                                        println("runtime: port_alert failed with", e)
                                        throw("runtime: netpoll: port_alert failed")
                                }
-                               atomic.Storeuintptr(&netpollWakeSig, 0)
+                               atomic.Store(&netpollWakeSig, 0)
                        }
                        continue
                }
index 56a0798559123e996a69700a59f87227860a2cf7..4c1cd2633a86ba1bbdb99b25d27446df2e800b33 100644 (file)
@@ -35,7 +35,7 @@ type overlappedEntry struct {
 var (
        iocphandle uintptr = _INVALID_HANDLE_VALUE // completion port io handle
 
-       netpollWakeSig uintptr // used to avoid duplicate calls of netpollBreak
+       netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
 )
 
 func netpollinit() {
@@ -67,7 +67,7 @@ func netpollarm(pd *pollDesc, mode int) {
 }
 
 func netpollBreak() {
-       if atomic.Casuintptr(&netpollWakeSig, 0, 1) {
+       if atomic.Cas(&netpollWakeSig, 0, 1) {
                if stdcall4(_PostQueuedCompletionStatus, iocphandle, 0, 0, 0) == 0 {
                        println("runtime: netpoll: PostQueuedCompletionStatus failed (errno=", getlasterror(), ")")
                        throw("runtime: netpoll: PostQueuedCompletionStatus failed")
@@ -133,7 +133,7 @@ func netpoll(delay int64) gList {
                        }
                        handlecompletion(&toRun, op, errno, qty)
                } else {
-                       atomic.Storeuintptr(&netpollWakeSig, 0)
+                       atomic.Store(&netpollWakeSig, 0)
                        if delay == 0 {
                                // Forward the notification to the
                                // blocked poller.