fd_util: support eventfd()
This commit is contained in:
parent
a93caf3cfe
commit
3be57dc4a3
|
@ -133,7 +133,7 @@ AC_SEARCH_LIBS([syslog], [bsd socket inet],
|
|||
AC_SEARCH_LIBS([socket], [socket])
|
||||
AC_SEARCH_LIBS([gethostbyname], [nsl])
|
||||
|
||||
AC_CHECK_FUNCS(pipe2 accept4)
|
||||
AC_CHECK_FUNCS(pipe2 accept4 eventfd)
|
||||
|
||||
AC_SEARCH_LIBS([exp], [m],,
|
||||
[AC_MSG_ERROR([exp() not found])])
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
#include <sys/inotify.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EVENTFD
|
||||
#include <sys/eventfd.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
static int
|
||||
|
@ -328,6 +332,16 @@ inotify_init_cloexec(void)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EVENTFD
|
||||
|
||||
int
|
||||
eventfd_cloexec_nonblock(unsigned initval, int flags)
|
||||
{
|
||||
return eventfd(initval, flags | EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
close_socket(int fd)
|
||||
{
|
||||
|
|
|
@ -144,6 +144,17 @@ inotify_init_cloexec(void);
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EVENTFD
|
||||
|
||||
/**
|
||||
* Wrapper for eventfd() which sets the flags CLOEXEC and NONBLOCK
|
||||
* flag (atomically if supported by the OS).
|
||||
*/
|
||||
int
|
||||
eventfd_cloexec_nonblock(unsigned initval, int flags);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Portable wrapper for close(); use closesocket() on WIN32/WinSock.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue