mirror of https://github.com/F-Stack/f-stack.git
kevent copyout directly without
This commit is contained in:
parent
1a78ce8ea6
commit
850cbeb422
|
@ -24,43 +24,43 @@
|
|||
int
|
||||
ff_epoll_create(int size __attribute__((__unused__)))
|
||||
{
|
||||
return ff_kqueue();
|
||||
return ff_kqueue();
|
||||
}
|
||||
|
||||
int
|
||||
ff_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
|
||||
{
|
||||
struct kevent kev[3];
|
||||
struct kevent kev[3];
|
||||
|
||||
if (!event && op != EPOLL_CTL_DEL) {
|
||||
if (!event && op != EPOLL_CTL_DEL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (op == EPOLL_CTL_ADD){
|
||||
EV_SET(&kev[0], fd, EVFILT_READ,
|
||||
EV_ADD | (event->events & EPOLLIN ? 0 : EV_DISABLE), 0, 0, NULL);
|
||||
EV_SET(&kev[1], fd, EVFILT_WRITE,
|
||||
EV_ADD | (event->events & EPOLLOUT ? 0 : EV_DISABLE), 0, 0, NULL);
|
||||
EV_SET(&kev[2], fd, EVFILT_USER, EV_ADD,
|
||||
event->events & EPOLLRDHUP ? 1 : 0, 0, NULL);
|
||||
} else if (op == EPOLL_CTL_DEL) {
|
||||
EV_SET(&kev[0], fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
|
||||
EV_SET(&kev[1], fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
|
||||
EV_SET(&kev[2], fd, EVFILT_USER, EV_DELETE, 0, 0, NULL);
|
||||
} else if (op == EPOLL_CTL_MOD) {
|
||||
EV_SET(&kev[0], fd, EVFILT_READ,
|
||||
event->events & EPOLLIN ? EV_ENABLE : EV_DISABLE, 0, 0, NULL);
|
||||
EV_SET(&kev[1], fd, EVFILT_WRITE,
|
||||
event->events & EPOLLOUT ? EV_ENABLE : EV_DISABLE, 0, 0, NULL);
|
||||
EV_SET(&kev[2], fd, EVFILT_USER, 0,
|
||||
NOTE_FFCOPY | (event->events & EPOLLRDHUP ? 1 : 0), 0, NULL);
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (op == EPOLL_CTL_ADD){
|
||||
EV_SET(&kev[0], fd, EVFILT_READ,
|
||||
EV_ADD | (event->events & EPOLLIN ? 0 : EV_DISABLE), 0, 0, NULL);
|
||||
EV_SET(&kev[1], fd, EVFILT_WRITE,
|
||||
EV_ADD | (event->events & EPOLLOUT ? 0 : EV_DISABLE), 0, 0, NULL);
|
||||
EV_SET(&kev[2], fd, EVFILT_USER, EV_ADD,
|
||||
event->events & EPOLLRDHUP ? 1 : 0, 0, NULL);
|
||||
} else if (op == EPOLL_CTL_DEL) {
|
||||
EV_SET(&kev[0], fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
|
||||
EV_SET(&kev[1], fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
|
||||
EV_SET(&kev[2], fd, EVFILT_USER, EV_DELETE, 0, 0, NULL);
|
||||
} else if (op == EPOLL_CTL_MOD) {
|
||||
EV_SET(&kev[0], fd, EVFILT_READ,
|
||||
event->events & EPOLLIN ? EV_ENABLE : EV_DISABLE, 0, 0, NULL);
|
||||
EV_SET(&kev[1], fd, EVFILT_WRITE,
|
||||
event->events & EPOLLOUT ? EV_ENABLE : EV_DISABLE, 0, 0, NULL);
|
||||
EV_SET(&kev[2], fd, EVFILT_USER, 0,
|
||||
NOTE_FFCOPY | (event->events & EPOLLRDHUP ? 1 : 0), 0, NULL);
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ff_kevent(epfd, kev, 3, NULL, 0, NULL);
|
||||
return ff_kevent(epfd, kev, 3, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -93,11 +93,11 @@ int
|
|||
ff_epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
|
||||
{
|
||||
int i, ret;
|
||||
if (!events || maxevents < 1) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!events || maxevents < 1) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ff_kevent_do_each(epfd, NULL, 0, events, maxevents, NULL, ff_event_to_epoll);
|
||||
return ff_kevent_do_each(epfd, NULL, 0, events, maxevents, NULL, ff_event_to_epoll);
|
||||
}
|
||||
|
||||
|
|
|
@ -946,19 +946,18 @@ static int
|
|||
kevent_copyout(void *arg, struct kevent *kevp, int count)
|
||||
{
|
||||
int i;
|
||||
struct kevent *ke, **el;
|
||||
struct kevent *ke;
|
||||
struct sys_kevent_args *uap;
|
||||
|
||||
uap = (struct sys_kevent_args *)arg;
|
||||
|
||||
for (ke = kevp, i = 0; i < count; i++, ke++) {
|
||||
if (uap->do_each) {
|
||||
uap->do_each(&(uap->eventlist), ke);
|
||||
if (!uap->do_each) {
|
||||
bcopy(kevp, uap->eventlist, count * sizeof *kevp);
|
||||
uap->eventlist = (void *)((struct kevent *)(uap->eventlist) + count);
|
||||
|
||||
} else {
|
||||
el = (struct kevent **)(&uap->eventlist);
|
||||
**el = *ke;
|
||||
(*el)++;
|
||||
} else {
|
||||
for (ke = kevp, i = 0; i < count; i++, ke++) {
|
||||
uap->do_each(&(uap->eventlist), ke);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue