Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux32/common Add the eventfd system calls to CO...



details:   https://anonhg.NetBSD.org/src/rev/011725978e5e
branches:  trunk
changeset: 1023646:011725978e5e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Sep 20 00:09:01 2021 +0000

description:
Add the eventfd system calls to COMPAT_LINUX and COMPAT_LINUX32.

diffstat:

 sys/compat/linux/arch/alpha/syscalls.master   |   7 +-
 sys/compat/linux/arch/amd64/syscalls.master   |   7 +-
 sys/compat/linux/arch/arm/syscalls.master     |   7 +-
 sys/compat/linux/arch/i386/syscalls.master    |   7 +-
 sys/compat/linux/arch/m68k/syscalls.master    |   7 +-
 sys/compat/linux/arch/mips/syscalls.master    |   7 +-
 sys/compat/linux/arch/powerpc/syscalls.master |   7 +-
 sys/compat/linux/common/linux_misc.c          |  56 ++++++++++++++++++++++++++-
 sys/compat/linux32/arch/amd64/syscalls.master |   7 +-
 sys/compat/linux32/common/linux32_misc.c      |  34 +++++++++++++++-
 10 files changed, 118 insertions(+), 28 deletions(-)

diffs (truncated from 356 to 300 lines):

diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/alpha/syscalls.master
--- a/sys/compat/linux/arch/alpha/syscalls.master       Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/alpha/syscalls.master       Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.99 2021/09/19 23:51:36 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.100 2021/09/20 00:09:01 thorpej Exp $
 ;
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -764,7 +764,7 @@
                            struct linux_timespec *times, int flag); }
 476    UNIMPL          signalfd
 477    UNIMPL          timerfd
-478    UNIMPL          eventfd
+478    STD             { int|linux_sys||eventfd(unsigned int initval); }
 479    STD             { int|linux_sys||recvmmsg(int s, \
                            struct linux_mmsghdr *msgvec, unsigned int vlen, \
                            unsigned int flags, struct timespec *timeout); }
@@ -778,7 +778,8 @@
 483    STD             { int|linux_sys||timerfd_gettime(int fd, \
                            struct linux_itimerspec *tim); }
 484    UNIMPL          signalfd4
-485    UNIMPL          eventfd2
+485    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 486    UNIMPL          epoll_create1
 487    STD             { int|linux_sys||dup3(int from, int to, int flags); }
 488    STD             { int|linux_sys||pipe2(int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/amd64/syscalls.master
--- a/sys/compat/linux/arch/amd64/syscalls.master       Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/amd64/syscalls.master       Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.64 2021/09/19 23:51:36 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.65 2021/09/20 00:09:01 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -521,7 +521,7 @@
 282    UNIMPL          signalfd
 283    STD             { int|linux_sys||timerfd_create(clockid_t clock_id, \
                            int flags); }
-284    UNIMPL          eventfd
+284    STD             { int|linux_sys||eventfd(unsigned int initval); }
 285    STD             { int|linux_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
 286    STD             { int|linux_sys||timerfd_settime(int fd, int flags, \
@@ -533,7 +533,8 @@
                            struct osockaddr *name, \
                            int *anamelen, int flags); }
 289    UNIMPL          signalfd4
-290    UNIMPL          eventfd2
+290    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 291    UNIMPL          epoll_create1
 292    STD             { int|linux_sys||dup3(int from, int to, int flags); }
 293    STD             { int|linux_sys||pipe2(int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/arm/syscalls.master
--- a/sys/compat/linux/arch/arm/syscalls.master Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/arm/syscalls.master Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.71 2021/09/19 23:51:36 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.72 2021/09/20 00:09:01 thorpej Exp $
 
 ; Derived from sys/compat/linux/arch/*/syscalls.master
 ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -564,7 +564,7 @@
 349    UNIMPL          signalfd
 350    STD             { int|linux_sys||timerfd_create(clockid_t clock_id, \
                            int flags); }
-351    UNIMPL          eventfd
+351    STD             { int|linux_sys||eventfd(unsigned int initval); }
 352    STD             { int|linux_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
 353    STD             { int|linux_sys||timerfd_settime(int fd, int flags, \
@@ -573,7 +573,8 @@
 354    STD             { int|linux_sys||timerfd_gettime(int fd, \
                            struct linux_itimerspec *tim); }
 355    UNIMPL          signalfd4
-356    UNIMPL          eventfd2
+356    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 357    UNIMPL          epoll_create1
 358    STD             { int|linux_sys||dup3(int from, int to, int flags); }
 359    STD             { int|linux_sys||pipe2(int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/i386/syscalls.master
--- a/sys/compat/linux/arch/i386/syscalls.master        Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/i386/syscalls.master        Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.126 2021/09/19 23:51:36 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.127 2021/09/20 00:09:01 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -531,7 +531,7 @@
 321    UNIMPL          signalfd
 322    STD             { int|linux_sys||timerfd_create(clockid_t clock_id, \
                            int flags); }
-323    UNIMPL          eventfd
+323    STD             { int|linux_sys||eventfd(unsigned int initval); }
 324    STD             { int|linux_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
 325    STD             { int|linux_sys||timerfd_settime(int fd, int flags, \
@@ -540,7 +540,8 @@
 326    STD             { int|linux_sys||timerfd_gettime(int fd, \
                            struct linux_itimerspec *tim); }
 327    UNIMPL          signalfd4
-328    UNIMPL          eventfd2
+328    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 329    UNIMPL          epoll_create1
 330     STD             { int|linux_sys||dup3(int from, int to, int flags); }
 331     STD             { int|linux_sys||pipe2( int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/m68k/syscalls.master
--- a/sys/compat/linux/arch/m68k/syscalls.master        Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/m68k/syscalls.master        Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.97 2021/09/19 23:51:36 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.98 2021/09/20 00:09:01 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -549,7 +549,7 @@
 317    UNIMPL          signalfd
 318    STD             { int|linux_sys||timerfd_create(clockid_t clock_id, \
                            int flags); }
-319    UNIMPL          eventfd
+319    STD             { int|linux_sys||eventfd(unsigned int initval); }
 320    STD             { int|linux_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
 321    STD             { int|linux_sys||timerfd_settime(int fd, int flags, \
@@ -558,7 +558,8 @@
 322    STD             { int|linux_sys||timerfd_gettime(int fd, \
                            struct linux_itimerspec *tim); }
 323    UNIMPL          signalfd4
-324    UNIMPL          eventfd2
+324    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 325    UNIMPL          epoll_create1
 326    STD             { int|linux_sys||dup3(int from, int to, int flags); }
 327    STD             { int|linux_sys||pipe2(int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/mips/syscalls.master
--- a/sys/compat/linux/arch/mips/syscalls.master        Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/mips/syscalls.master        Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.70 2021/09/19 23:51:37 thorpej Exp $  
+       $NetBSD: syscalls.master,v 1.71 2021/09/20 00:09:01 thorpej Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -536,7 +536,7 @@
                            struct linux_timespec *times, int flag); }
 317    UNIMPL          signalfd
 318    UNIMPL          timerfd
-319    UNIMPL          eventfd
+319    STD             { int|linux_sys||eventfd(unsigned int initval); }
 320    STD             { int|linux_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
 321    STD             { int|linux_sys||timerfd_create(clockid_t clock_id, \
@@ -547,7 +547,8 @@
                            const struct linux_itimerspec *tim, \
                            struct linux_itimerspec *otim); }
 324    UNIMPL          signalfd4
-325    UNIMPL          eventfd2
+325    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 326    UNIMPL          epoll_create1
 327    STD             { int|linux_sys||dup3(int from, int to, int flags); }
 328    STD             { int|linux_sys||pipe2(int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/arch/powerpc/syscalls.master
--- a/sys/compat/linux/arch/powerpc/syscalls.master     Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/arch/powerpc/syscalls.master     Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.76 2021/09/19 23:51:37 thorpej Exp $  
+       $NetBSD: syscalls.master,v 1.77 2021/09/20 00:09:01 thorpej Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -535,7 +535,7 @@
 305    UNIMPL          signalfd
 306    STD             { int|linux_sys||timerfd_create(clockid_t clock_id, \
                            int flags); }
-307    UNIMPL          eventfd
+307    STD             { int|linux_sys||eventfd(unsigned int initval); }
 308    UNIMPL          sync_file_range2
 309    STD             { int|linux_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
@@ -546,7 +546,8 @@
 312    STD             { int|linux_sys||timerfd_gettime(int fd, \
                            struct linux_itimerspec *tim); }
 313    UNIMPL          signalfd4
-314    UNIMPL          eventfd2
+314    STD             { int|linux_sys||eventfd2(unsigned int initval, \
+                           int flags); }
 315    UNIMPL          epoll_create1
 316    STD             { int|linux_sys||dup3(int from, int to, int flags); }
 317    STD             { int|linux_sys||pipe2(int *pfds, int flags); }
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.252 2021/09/07 11:43:04 riastradh Exp $       */
+/*     $NetBSD: linux_misc.c,v 1.253 2021/09/20 00:09:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,13 +57,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.252 2021/09/07 11:43:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.253 2021/09/20 00:09:02 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/namei.h>
 #include <sys/proc.h>
 #include <sys/dirent.h>
+#include <sys/eventfd.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/filedesc.h>
@@ -1583,3 +1584,54 @@
        return do_futex(uaddr, op & ~FUTEX_PRIVATE_FLAG,
                        val, timeout, uaddr2, val2, val3, retval);
 }
+
+#define        LINUX_EFD_SEMAPHORE     0x0001
+#define        LINUX_EFD_CLOEXEC       LINUX_O_CLOEXEC
+#define        LINUX_EFD_NONBLOCK      LINUX_O_NONBLOCK
+
+static int
+linux_do_eventfd2(struct lwp *l, unsigned int initval, int flags,
+    register_t *retval)
+{
+       int nflags = 0;
+
+       if (flags & ~(LINUX_EFD_SEMAPHORE | LINUX_EFD_CLOEXEC |
+                     LINUX_EFD_NONBLOCK)) {
+               return EINVAL;
+       }
+       if (flags & LINUX_EFD_SEMAPHORE) {
+               nflags |= EFD_SEMAPHORE;
+       }
+       if (flags & LINUX_EFD_CLOEXEC) {
+               nflags |= EFD_CLOEXEC;
+       }
+       if (flags & LINUX_EFD_NONBLOCK) {
+               nflags |= EFD_NONBLOCK;
+       }
+
+       return do_eventfd(l, initval, nflags, retval);
+}
+
+int
+linux_sys_eventfd(struct lwp *l, const struct linux_sys_eventfd_args *uap,
+    register_t *retval)
+{
+       /* {
+               syscallarg(unsigned int) initval;
+       } */
+
+       return linux_do_eventfd2(l, SCARG(uap, initval), 0, retval);
+}
+
+int
+linux_sys_eventfd2(struct lwp *l, const struct linux_sys_eventfd2_args *uap,
+    register_t *retval)
+{
+       /* {
+               syscallarg(unsigned int) initval;
+               syscallarg(int) flags;
+       } */
+
+       return linux_do_eventfd2(l, SCARG(uap, initval), SCARG(uap, flags),
+                                retval);
+}
diff -r 5774bb33bf69 -r 011725978e5e sys/compat/linux32/arch/amd64/syscalls.master
--- a/sys/compat/linux32/arch/amd64/syscalls.master     Sun Sep 19 23:52:07 2021 +0000
+++ b/sys/compat/linux32/arch/amd64/syscalls.master     Mon Sep 20 00:09:01 2021 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.73 2021/09/19 23:51:37 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.74 2021/09/20 00:09:02 thorpej Exp $
 
 ; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
 ; (See syscalls.conf to see what it is processed into.)
@@ -552,7 +552,7 @@
 321    UNIMPL  signalfd
 322    NOARGS  { int|linux_sys||timerfd_create(clockid_t clock_id, \
                    int flags); }
-323    UNIMPL  eventfd
+323    STD     { int|linux32_sys||eventfd(unsigned int initval); }
 324    STD     { int|linux32_sys||fallocate(int fd, int mode, \
                            off_t offset, off_t len); }
 325    STD     { int|linux32_sys||timerfd_settime(int fd, int flags, \
@@ -561,7 +561,8 @@
 326    STD     { int|linux32_sys||timerfd_gettime(int fd, \
                    struct linux32_itimerspec *tim); }
 327    UNIMPL  signalfd4
-328    UNIMPL  eventfd2
+328    STD     { int|linux32_sys||eventfd2(unsigned int initval, \



Home | Main Index | Thread Index | Old Index