From d9498988903da18a822d8d019e3469bec8dce994 Mon Sep 17 00:00:00 2001 From: Vitaly Baranov Date: Sat, 14 Nov 2020 07:04:03 +0300 Subject: [PATCH] glibc-compatibility: Add eventfd(), eventfd_read(), eventfd_write() from musl 1.2.1. --- base/glibc-compatibility/musl/eventfd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 base/glibc-compatibility/musl/eventfd.c diff --git a/base/glibc-compatibility/musl/eventfd.c b/base/glibc-compatibility/musl/eventfd.c new file mode 100644 index 00000000000..68e489c8364 --- /dev/null +++ b/base/glibc-compatibility/musl/eventfd.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include "syscall.h" + +int eventfd(unsigned int count, int flags) +{ + int r = __syscall(SYS_eventfd2, count, flags); +#ifdef SYS_eventfd + if (r==-ENOSYS && !flags) r = __syscall(SYS_eventfd, count); +#endif + return __syscall_ret(r); +} + +int eventfd_read(int fd, eventfd_t *value) +{ + return (sizeof(*value) == read(fd, value, sizeof(*value))) ? 0 : -1; +} + +int eventfd_write(int fd, eventfd_t value) +{ + return (sizeof(value) == write(fd, &value, sizeof(value))) ? 0 : -1; +}