1 | /* |
1 | /* |
2 | * libev kqueue backend |
2 | * libev kqueue backend |
3 | * |
3 | * |
4 | * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libev@schmorp.de> |
5 | * All rights reserved. |
5 | * All rights reserved. |
6 | * |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
8 | * tion, are permitted provided that the following conditions are met: |
8 | * tion, are permitted provided that the following conditions are met: |
9 | * |
9 | * |
… | |
… | |
159 | if ((backend_fd = kqueue ()) < 0) |
159 | if ((backend_fd = kqueue ()) < 0) |
160 | return 0; |
160 | return 0; |
161 | |
161 | |
162 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ |
162 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ |
163 | |
163 | |
164 | backend_fudge = 1e-9; /* apparently, they did the right thing in freebsd */ |
164 | backend_mintime = 1e-9; /* apparently, they did the right thing in freebsd */ |
165 | backend_modify = kqueue_modify; |
165 | backend_modify = kqueue_modify; |
166 | backend_poll = kqueue_poll; |
166 | backend_poll = kqueue_poll; |
167 | |
167 | |
168 | kqueue_eventmax = 64; /* initial number of events receivable per poll */ |
168 | kqueue_eventmax = 64; /* initial number of events receivable per poll */ |
169 | kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); |
169 | kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); |
170 | |
170 | |
171 | kqueue_changes = 0; |
171 | kqueue_changes = 0; |
… | |
… | |
194 | |
194 | |
195 | /* re-register interest in fds */ |
195 | /* re-register interest in fds */ |
196 | fd_rearm_all (EV_A); |
196 | fd_rearm_all (EV_A); |
197 | } |
197 | } |
198 | |
198 | |
|
|
199 | /* sys/event.h defines EV_ERROR */ |
|
|
200 | #undef EV_ERROR |
|
|
201 | |