mirror of
https://github.com/golang/go
synced 2024-11-12 06:30:21 -07:00
runtime: change PollDesc.fd from int32 to uintptr
This is in preparation for netpoll windows version. R=golang-dev, bradfitz CC=dvyukov, golang-dev, mikioh.mikioh https://golang.org/cl/9569043
This commit is contained in:
parent
fee1d1cda0
commit
38abb09a2e
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func runtime_pollServerInit()
|
||||
func runtime_pollOpen(fd int) (uintptr, int)
|
||||
func runtime_pollOpen(fd uintptr) (uintptr, int)
|
||||
func runtime_pollClose(ctx uintptr)
|
||||
func runtime_pollWait(ctx uintptr, mode int) int
|
||||
func runtime_pollReset(ctx uintptr, mode int) int
|
||||
@ -33,7 +33,7 @@ func sysInit() {
|
||||
|
||||
func (pd *pollDesc) Init(fd *netFD) error {
|
||||
serverInit.Do(runtime_pollServerInit)
|
||||
ctx, errno := runtime_pollOpen(fd.sysfd)
|
||||
ctx, errno := runtime_pollOpen(uintptr(fd.sysfd))
|
||||
if errno != 0 {
|
||||
return syscall.Errno(errno)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ package net
|
||||
// Integrated network poller (platform-independent part).
|
||||
// A particular implementation (epoll/kqueue) must define the following functions:
|
||||
// void runtime·netpollinit(void); // to initialize the poller
|
||||
// int32 runtime·netpollopen(int32 fd, PollDesc *pd); // to arm edge-triggered notifications
|
||||
// int32 runtime·netpollopen(uintptr fd, PollDesc *pd); // to arm edge-triggered notifications
|
||||
// and associate fd with pd.
|
||||
// An implementation must call the following function to denote that the pd is ready.
|
||||
// void runtime·netpollready(G **gpp, PollDesc *pd, int32 mode);
|
||||
@ -25,7 +25,7 @@ struct PollDesc
|
||||
{
|
||||
PollDesc* link; // in pollcache, protected by pollcache.Lock
|
||||
Lock; // protectes the following fields
|
||||
int32 fd;
|
||||
uintptr fd;
|
||||
bool closing;
|
||||
uintptr seq; // protects from stale timers and ready notifications
|
||||
G* rg; // G waiting for read or READY (binary semaphore)
|
||||
@ -63,7 +63,7 @@ func runtime_pollServerInit() {
|
||||
runtime·netpollinit();
|
||||
}
|
||||
|
||||
func runtime_pollOpen(fd int) (pd *PollDesc, errno int) {
|
||||
func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
|
||||
pd = allocPollDesc();
|
||||
runtime·lock(pd);
|
||||
if(pd->wg != nil && pd->wg != READY)
|
||||
|
@ -31,24 +31,24 @@ runtime·netpollinit(void)
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·netpollopen(int32 fd, PollDesc *pd)
|
||||
runtime·netpollopen(uintptr fd, PollDesc *pd)
|
||||
{
|
||||
EpollEvent ev;
|
||||
int32 res;
|
||||
|
||||
ev.events = EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET;
|
||||
ev.data = (uint64)pd;
|
||||
res = runtime·epollctl(epfd, EPOLL_CTL_ADD, fd, &ev);
|
||||
res = runtime·epollctl(epfd, EPOLL_CTL_ADD, (int32)fd, &ev);
|
||||
return -res;
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·netpollclose(int32 fd)
|
||||
runtime·netpollclose(uintptr fd)
|
||||
{
|
||||
EpollEvent ev;
|
||||
int32 res;
|
||||
|
||||
res = runtime·epollctl(epfd, EPOLL_CTL_DEL, fd, &ev);
|
||||
res = runtime·epollctl(epfd, EPOLL_CTL_DEL, (int32)fd, &ev);
|
||||
return -res;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ runtime·netpollinit(void)
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·netpollopen(int32 fd, PollDesc *pd)
|
||||
runtime·netpollopen(uintptr fd, PollDesc *pd)
|
||||
{
|
||||
Kevent ev[2];
|
||||
int32 n;
|
||||
@ -35,7 +35,7 @@ runtime·netpollopen(int32 fd, PollDesc *pd)
|
||||
// Arm both EVFILT_READ and EVFILT_WRITE in edge-triggered mode (EV_CLEAR)
|
||||
// for the whole fd lifetime. The notifications are automatically unregistered
|
||||
// when fd is closed.
|
||||
ev[0].ident = fd;
|
||||
ev[0].ident = (uint32)fd;
|
||||
ev[0].filter = EVFILT_READ;
|
||||
ev[0].flags = EV_ADD|EV_RECEIPT|EV_CLEAR;
|
||||
ev[0].fflags = 0;
|
||||
@ -47,8 +47,8 @@ runtime·netpollopen(int32 fd, PollDesc *pd)
|
||||
if(n < 0)
|
||||
return -n;
|
||||
if(n != 2 ||
|
||||
(ev[0].flags&EV_ERROR) == 0 || ev[0].ident != fd || ev[0].filter != EVFILT_READ ||
|
||||
(ev[1].flags&EV_ERROR) == 0 || ev[1].ident != fd || ev[1].filter != EVFILT_WRITE)
|
||||
(ev[0].flags&EV_ERROR) == 0 || ev[0].ident != (uint32)fd || ev[0].filter != EVFILT_READ ||
|
||||
(ev[1].flags&EV_ERROR) == 0 || ev[1].ident != (uint32)fd || ev[1].filter != EVFILT_WRITE)
|
||||
return EFAULT; // just to mark out from other errors
|
||||
if(ev[0].data != 0)
|
||||
return ev[0].data;
|
||||
@ -58,7 +58,7 @@ runtime·netpollopen(int32 fd, PollDesc *pd)
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·netpollclose(int32 fd)
|
||||
runtime·netpollclose(uintptr fd)
|
||||
{
|
||||
// Don't need to unregister because calling close()
|
||||
// on fd will remove any kevents that reference the descriptor.
|
||||
|
@ -803,8 +803,8 @@ void runtime·addtimer(Timer*);
|
||||
bool runtime·deltimer(Timer*);
|
||||
G* runtime·netpoll(bool);
|
||||
void runtime·netpollinit(void);
|
||||
int32 runtime·netpollopen(int32, PollDesc*);
|
||||
int32 runtime·netpollclose(int32);
|
||||
int32 runtime·netpollopen(uintptr, PollDesc*);
|
||||
int32 runtime·netpollclose(uintptr);
|
||||
void runtime·netpollready(G**, PollDesc*, int32);
|
||||
void runtime·crash(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user