OLD | NEW |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build linux | 5 // +build linux |
6 | 6 |
7 #include "runtime.h" | 7 #include "runtime.h" |
8 #include "defs_GOOS_GOARCH.h" | 8 #include "defs_GOOS_GOARCH.h" |
9 | 9 |
10 int32 runtime·epollcreate(int32 size); | 10 int32 runtime·epollcreate(int32 size); |
(...skipping 19 matching lines...) Expand all Loading... |
30 runtime·throw("netpollinit: failed to create descriptor"); | 30 runtime·throw("netpollinit: failed to create descriptor"); |
31 } | 31 } |
32 | 32 |
33 int32 | 33 int32 |
34 runtime·netpollopen(uintptr fd, PollDesc *pd) | 34 runtime·netpollopen(uintptr fd, PollDesc *pd) |
35 { | 35 { |
36 EpollEvent ev; | 36 EpollEvent ev; |
37 int32 res; | 37 int32 res; |
38 | 38 |
39 ev.events = EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET; | 39 ev.events = EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET; |
40 » ev.data = (uint64)pd; | 40 » *(uintptr*)ev.data = (uintptr)pd; |
41 res = runtime·epollctl(epfd, EPOLL_CTL_ADD, (int32)fd, &ev); | 41 res = runtime·epollctl(epfd, EPOLL_CTL_ADD, (int32)fd, &ev); |
42 return -res; | 42 return -res; |
43 } | 43 } |
44 | 44 |
45 int32 | 45 int32 |
46 runtime·netpollclose(uintptr fd) | 46 runtime·netpollclose(uintptr fd) |
47 { | 47 { |
48 EpollEvent ev; | 48 EpollEvent ev; |
49 int32 res; | 49 int32 res; |
50 | 50 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 mode += 'r'; | 94 mode += 'r'; |
95 if(ev->events & (EPOLLOUT|EPOLLHUP|EPOLLERR)) | 95 if(ev->events & (EPOLLOUT|EPOLLHUP|EPOLLERR)) |
96 mode += 'w'; | 96 mode += 'w'; |
97 if(mode) | 97 if(mode) |
98 runtime·netpollready(&gp, (void*)ev->data, mode); | 98 runtime·netpollready(&gp, (void*)ev->data, mode); |
99 } | 99 } |
100 if(block && gp == nil) | 100 if(block && gp == nil) |
101 goto retry; | 101 goto retry; |
102 return gp; | 102 return gp; |
103 } | 103 } |
OLD | NEW |