X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Flinux%2Feventfd.c;h=68e489c83647e71f947ba616a154d9f11f44a85e;hb=4554f155dd23a65fcdfd39f1d5af8af55ba37694;hp=cb39a7bab7b4d8e871c08c6871c8105b2af59209;hpb=15b77d52c950c375514d2e8152e7112fd018e20e;p=musl diff --git a/src/linux/eventfd.c b/src/linux/eventfd.c index cb39a7ba..68e489c8 100644 --- a/src/linux/eventfd.c +++ b/src/linux/eventfd.c @@ -1,7 +1,23 @@ #include +#include +#include #include "syscall.h" int eventfd(unsigned int count, int flags) { - return syscall(flags ? SYS_eventfd2 : SYS_eventfd, count, 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; }