summaryrefslogtreecommitdiffstats
path: root/src/socket_wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket_wrapper.c')
-rw-r--r--src/socket_wrapper.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 941f660..0d74321 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -56,6 +56,9 @@
#ifdef HAVE_SYS_EVENTFD_H
#include <sys/eventfd.h>
#endif
+#ifdef HAVE_SYS_TIMERFD_H
+#include <sys/timerfd.h>
+#endif
#include <sys/uio.h>
#include <errno.h>
#include <sys/un.h>
@@ -335,6 +338,9 @@ struct swrap_libc_fns {
#endif
int (*libc_socket)(int domain, int type, int protocol);
int (*libc_socketpair)(int domain, int type, int protocol, int sv[2]);
+#ifdef HAVE_TIMERFD_CREATE
+ int (*libc_timerfd_create)(int clockid, int flags);
+#endif
ssize_t (*libc_writev)(int fd, const struct iovec *iov, int iovcnt);
};
@@ -701,6 +707,15 @@ static int libc_socketpair(int domain, int type, int protocol, int sv[2])
return swrap.fns.libc_socketpair(domain, type, protocol, sv);
}
+#ifdef HAVE_TIMERFD_CREATE
+static int libc_timerfd_create(int clockid, int flags)
+{
+ swrap_load_lib_function(SWRAP_LIBC, timerfd_create);
+
+ return swrap.fns.libc_timerfd_create(clockid, flags);
+}
+#endif
+
static ssize_t libc_writev(int fd, const struct iovec *iov, int iovcnt)
{
swrap_load_lib_function(SWRAP_LIBSOCKET, writev);
@@ -2159,6 +2174,29 @@ int socketpair(int family, int type, int protocol, int sv[2])
}
/****************************************************************************
+ * SOCKETPAIR
+ ***************************************************************************/
+
+#ifdef HAVE_TIMERFD_CREATE
+static int swrap_timerfd_create(int clockid, int flags)
+{
+ int fd;
+
+ fd = libc_timerfd_create(clockid, flags);
+ if (fd != -1) {
+ swrap_remove_stale(fd);
+ }
+
+ return fd;
+}
+
+int timerfd_create(int clockid, int flags)
+{
+ return swrap_timerfd_create(clockid, flags);
+}
+#endif
+
+/****************************************************************************
* PIPE
***************************************************************************/