Lines Matching refs:devpollop
56 struct devpollop { struct
85 devpoll_commit(struct devpollop *devpollop) in devpoll_commit() argument
91 if (pwrite(devpollop->dpfd, devpollop->changes, in devpoll_commit()
92 sizeof(struct pollfd) * devpollop->nchanges, 0) == -1) in devpoll_commit()
95 devpollop->nchanges = 0; in devpoll_commit()
100 devpoll_queue(struct devpollop *devpollop, int fd, int events) { in devpoll_queue() argument
103 if (devpollop->nchanges >= devpollop->nevents) { in devpoll_queue()
108 if (devpoll_commit(devpollop) != 0) in devpoll_queue()
112 pfd = &devpollop->changes[devpollop->nchanges++]; in devpoll_queue()
125 struct devpollop *devpollop; in devpoll_init() local
127 if (!(devpollop = mm_calloc(1, sizeof(struct devpollop)))) in devpoll_init()
137 mm_free(devpollop); in devpoll_init()
141 devpollop->dpfd = dpfd; in devpoll_init()
146 devpollop->events = mm_calloc(nfiles, sizeof(struct pollfd)); in devpoll_init()
147 if (devpollop->events == NULL) { in devpoll_init()
148 mm_free(devpollop); in devpoll_init()
152 devpollop->nevents = nfiles; in devpoll_init()
154 devpollop->changes = mm_calloc(nfiles, sizeof(struct pollfd)); in devpoll_init()
155 if (devpollop->changes == NULL) { in devpoll_init()
156 mm_free(devpollop->events); in devpoll_init()
157 mm_free(devpollop); in devpoll_init()
164 return (devpollop); in devpoll_init()
170 struct devpollop *devpollop = base->evbase; in devpoll_dispatch() local
171 struct pollfd *events = devpollop->events; in devpoll_dispatch()
175 if (devpollop->nchanges) in devpoll_dispatch()
176 devpoll_commit(devpollop); in devpoll_dispatch()
181 dvp.dp_fds = devpollop->events; in devpoll_dispatch()
182 dvp.dp_nfds = devpollop->nevents; in devpoll_dispatch()
187 res = ioctl(devpollop->dpfd, DP_POLL, &dvp); in devpoll_dispatch()
230 struct devpollop *devpollop = base->evbase; in devpoll_add() local
247 if (devpoll_queue(devpollop, fd, res) != 0) in devpoll_add()
256 struct devpollop *devpollop = base->evbase; in devpoll_del() local
273 if (devpoll_queue(devpollop, fd, POLLREMOVE) != 0) in devpoll_del()
284 devpoll_queue(devpollop, fd, POLLOUT); in devpoll_del()
287 devpoll_queue(devpollop, fd, POLLIN); in devpoll_del()
297 struct devpollop *devpollop = base->evbase; in devpoll_dealloc() local
300 if (devpollop->events) in devpoll_dealloc()
301 mm_free(devpollop->events); in devpoll_dealloc()
302 if (devpollop->changes) in devpoll_dealloc()
303 mm_free(devpollop->changes); in devpoll_dealloc()
304 if (devpollop->dpfd >= 0) in devpoll_dealloc()
305 close(devpollop->dpfd); in devpoll_dealloc()
307 memset(devpollop, 0, sizeof(struct devpollop)); in devpoll_dealloc()
308 mm_free(devpollop); in devpoll_dealloc()