| 1 |
include(CheckCSourceRuns) |
| 2 |
|
| 3 |
check_c_source_runs( |
| 4 |
" |
| 5 |
#include <sys/types.h> |
| 6 |
#include <sys/time.h> |
| 7 |
#include <sys/event.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <unistd.h> |
| 10 |
#include <fcntl.h> |
| 11 |
|
| 12 |
int |
| 13 |
main(int argc, char **argv) |
| 14 |
{ |
| 15 |
int kq; |
| 16 |
int n; |
| 17 |
int fd[2]; |
| 18 |
struct kevent ev; |
| 19 |
struct timespec ts; |
| 20 |
char buf[80000]; |
| 21 |
|
| 22 |
if (pipe(fd) == -1) |
| 23 |
exit(1); |
| 24 |
if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1) |
| 25 |
exit(1); |
| 26 |
|
| 27 |
while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf)) |
| 28 |
; |
| 29 |
|
| 30 |
if ((kq = kqueue()) == -1) |
| 31 |
exit(1); |
| 32 |
|
| 33 |
memset(&ev, 0, sizeof(ev)); |
| 34 |
ev.ident = fd[1]; |
| 35 |
ev.filter = EVFILT_WRITE; |
| 36 |
ev.flags = EV_ADD | EV_ENABLE; |
| 37 |
n = kevent(kq, &ev, 1, NULL, 0, NULL); |
| 38 |
if (n == -1) |
| 39 |
exit(1); |
| 40 |
|
| 41 |
read(fd[0], buf, sizeof(buf)); |
| 42 |
|
| 43 |
ts.tv_sec = 0; |
| 44 |
ts.tv_nsec = 0; |
| 45 |
n = kevent(kq, NULL, 0, &ev, 1, &ts); |
| 46 |
if (n == -1 || n == 0) |
| 47 |
exit(1); |
| 48 |
|
| 49 |
exit(0); |
| 50 |
} |
| 51 |
|
| 52 |
" EVENT__HAVE_WORKING_KQUEUE) |