kqueue: modernize Struct usage for Ruby 2.5.0dev
[sleepy_penguin.git] / ext / sleepy_penguin / missing_epoll.h
blobaa55d3a291639bf2c6365f3573988b3f2c2b96da
1 #ifndef EPOLL_CLOEXEC
2 # define EPOLL_CLOEXEC (int)(02000000)
3 #endif
5 #ifndef HAVE_EPOLL_CREATE1
6 /*
7 * fake epoll_create1() since some systems don't have it.
8 * Don't worry about thread-safety since current Ruby 1.9 won't
9 * call this without GVL.
11 static int my_epoll_create1(int flags)
13 int fd = epoll_create(1024); /* size ignored since 2.6.8 */
15 if (fd < 0 || flags == 0)
16 return fd;
18 if ((flags & EPOLL_CLOEXEC) && (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0))
19 goto err;
20 return fd;
21 err:
23 int saved_errno = errno;
24 close(fd);
25 errno = saved_errno;
26 return -1;
29 # define epoll_create1 my_epoll_create1
30 #endif