Add the eventfd system calls to COMPAT_LINUX and COMPAT_LINUX32.

This commit is contained in:
thorpej 2021-09-20 00:09:01 +00:00
parent 302264731f
commit 4d055d8a83
10 changed files with 118 additions and 28 deletions

View File

@ -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 ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -764,7 +764,7 @@
struct linux_timespec *times, int flag); } struct linux_timespec *times, int flag); }
476 UNIMPL signalfd 476 UNIMPL signalfd
477 UNIMPL timerfd 477 UNIMPL timerfd
478 UNIMPL eventfd 478 STD { int|linux_sys||eventfd(unsigned int initval); }
479 STD { int|linux_sys||recvmmsg(int s, \ 479 STD { int|linux_sys||recvmmsg(int s, \
struct linux_mmsghdr *msgvec, unsigned int vlen, \ struct linux_mmsghdr *msgvec, unsigned int vlen, \
unsigned int flags, struct timespec *timeout); } unsigned int flags, struct timespec *timeout); }
@ -778,7 +778,8 @@
483 STD { int|linux_sys||timerfd_gettime(int fd, \ 483 STD { int|linux_sys||timerfd_gettime(int fd, \
struct linux_itimerspec *tim); } struct linux_itimerspec *tim); }
484 UNIMPL signalfd4 484 UNIMPL signalfd4
485 UNIMPL eventfd2 485 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
486 UNIMPL epoll_create1 486 UNIMPL epoll_create1
487 STD { int|linux_sys||dup3(int from, int to, int flags); } 487 STD { int|linux_sys||dup3(int from, int to, int flags); }
488 STD { int|linux_sys||pipe2(int *pfds, int flags); } 488 STD { int|linux_sys||pipe2(int *pfds, int flags); }

View File

@ -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 ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -521,7 +521,7 @@
282 UNIMPL signalfd 282 UNIMPL signalfd
283 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ 283 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \
int flags); } int flags); }
284 UNIMPL eventfd 284 STD { int|linux_sys||eventfd(unsigned int initval); }
285 STD { int|linux_sys||fallocate(int fd, int mode, \ 285 STD { int|linux_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
286 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ 286 STD { int|linux_sys||timerfd_settime(int fd, int flags, \
@ -533,7 +533,8 @@
struct osockaddr *name, \ struct osockaddr *name, \
int *anamelen, int flags); } int *anamelen, int flags); }
289 UNIMPL signalfd4 289 UNIMPL signalfd4
290 UNIMPL eventfd2 290 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
291 UNIMPL epoll_create1 291 UNIMPL epoll_create1
292 STD { int|linux_sys||dup3(int from, int to, int flags); } 292 STD { int|linux_sys||dup3(int from, int to, int flags); }
293 STD { int|linux_sys||pipe2(int *pfds, int flags); } 293 STD { int|linux_sys||pipe2(int *pfds, int flags); }

View File

@ -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 ; Derived from sys/compat/linux/arch/*/syscalls.master
; and from Linux 2.4.12 arch/arm/kernel/calls.S ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@ -564,7 +564,7 @@
349 UNIMPL signalfd 349 UNIMPL signalfd
350 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ 350 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \
int flags); } int flags); }
351 UNIMPL eventfd 351 STD { int|linux_sys||eventfd(unsigned int initval); }
352 STD { int|linux_sys||fallocate(int fd, int mode, \ 352 STD { int|linux_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
353 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ 353 STD { int|linux_sys||timerfd_settime(int fd, int flags, \
@ -573,7 +573,8 @@
354 STD { int|linux_sys||timerfd_gettime(int fd, \ 354 STD { int|linux_sys||timerfd_gettime(int fd, \
struct linux_itimerspec *tim); } struct linux_itimerspec *tim); }
355 UNIMPL signalfd4 355 UNIMPL signalfd4
356 UNIMPL eventfd2 356 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
357 UNIMPL epoll_create1 357 UNIMPL epoll_create1
358 STD { int|linux_sys||dup3(int from, int to, int flags); } 358 STD { int|linux_sys||dup3(int from, int to, int flags); }
359 STD { int|linux_sys||pipe2(int *pfds, int flags); } 359 STD { int|linux_sys||pipe2(int *pfds, int flags); }

View File

@ -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 ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -531,7 +531,7 @@
321 UNIMPL signalfd 321 UNIMPL signalfd
322 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ 322 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \
int flags); } int flags); }
323 UNIMPL eventfd 323 STD { int|linux_sys||eventfd(unsigned int initval); }
324 STD { int|linux_sys||fallocate(int fd, int mode, \ 324 STD { int|linux_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
325 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ 325 STD { int|linux_sys||timerfd_settime(int fd, int flags, \
@ -540,7 +540,8 @@
326 STD { int|linux_sys||timerfd_gettime(int fd, \ 326 STD { int|linux_sys||timerfd_gettime(int fd, \
struct linux_itimerspec *tim); } struct linux_itimerspec *tim); }
327 UNIMPL signalfd4 327 UNIMPL signalfd4
328 UNIMPL eventfd2 328 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
329 UNIMPL epoll_create1 329 UNIMPL epoll_create1
330 STD { int|linux_sys||dup3(int from, int to, int flags); } 330 STD { int|linux_sys||dup3(int from, int to, int flags); }
331 STD { int|linux_sys||pipe2( int *pfds, int flags); } 331 STD { int|linux_sys||pipe2( int *pfds, int flags); }

View File

@ -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 ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -549,7 +549,7 @@
317 UNIMPL signalfd 317 UNIMPL signalfd
318 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ 318 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \
int flags); } int flags); }
319 UNIMPL eventfd 319 STD { int|linux_sys||eventfd(unsigned int initval); }
320 STD { int|linux_sys||fallocate(int fd, int mode, \ 320 STD { int|linux_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
321 STD { int|linux_sys||timerfd_settime(int fd, int flags, \ 321 STD { int|linux_sys||timerfd_settime(int fd, int flags, \
@ -558,7 +558,8 @@
322 STD { int|linux_sys||timerfd_gettime(int fd, \ 322 STD { int|linux_sys||timerfd_gettime(int fd, \
struct linux_itimerspec *tim); } struct linux_itimerspec *tim); }
323 UNIMPL signalfd4 323 UNIMPL signalfd4
324 UNIMPL eventfd2 324 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
325 UNIMPL epoll_create1 325 UNIMPL epoll_create1
326 STD { int|linux_sys||dup3(int from, int to, int flags); } 326 STD { int|linux_sys||dup3(int from, int to, int flags); }
327 STD { int|linux_sys||pipe2(int *pfds, int flags); } 327 STD { int|linux_sys||pipe2(int *pfds, int flags); }

View File

@ -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 ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -536,7 +536,7 @@
struct linux_timespec *times, int flag); } struct linux_timespec *times, int flag); }
317 UNIMPL signalfd 317 UNIMPL signalfd
318 UNIMPL timerfd 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, \ 320 STD { int|linux_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
321 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ 321 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \
@ -547,7 +547,8 @@
const struct linux_itimerspec *tim, \ const struct linux_itimerspec *tim, \
struct linux_itimerspec *otim); } struct linux_itimerspec *otim); }
324 UNIMPL signalfd4 324 UNIMPL signalfd4
325 UNIMPL eventfd2 325 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
326 UNIMPL epoll_create1 326 UNIMPL epoll_create1
327 STD { int|linux_sys||dup3(int from, int to, int flags); } 327 STD { int|linux_sys||dup3(int from, int to, int flags); }
328 STD { int|linux_sys||pipe2(int *pfds, int flags); } 328 STD { int|linux_sys||pipe2(int *pfds, int flags); }

View File

@ -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 ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -535,7 +535,7 @@
305 UNIMPL signalfd 305 UNIMPL signalfd
306 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \ 306 STD { int|linux_sys||timerfd_create(clockid_t clock_id, \
int flags); } int flags); }
307 UNIMPL eventfd 307 STD { int|linux_sys||eventfd(unsigned int initval); }
308 UNIMPL sync_file_range2 308 UNIMPL sync_file_range2
309 STD { int|linux_sys||fallocate(int fd, int mode, \ 309 STD { int|linux_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
@ -546,7 +546,8 @@
312 STD { int|linux_sys||timerfd_gettime(int fd, \ 312 STD { int|linux_sys||timerfd_gettime(int fd, \
struct linux_itimerspec *tim); } struct linux_itimerspec *tim); }
313 UNIMPL signalfd4 313 UNIMPL signalfd4
314 UNIMPL eventfd2 314 STD { int|linux_sys||eventfd2(unsigned int initval, \
int flags); }
315 UNIMPL epoll_create1 315 UNIMPL epoll_create1
316 STD { int|linux_sys||dup3(int from, int to, int flags); } 316 STD { int|linux_sys||dup3(int from, int to, int flags); }
317 STD { int|linux_sys||pipe2(int *pfds, int flags); } 317 STD { int|linux_sys||pipe2(int *pfds, int flags); }

View File

@ -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. * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@ -57,13 +57,14 @@
*/ */
#include <sys/cdefs.h> #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/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/namei.h> #include <sys/namei.h>
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/dirent.h> #include <sys/dirent.h>
#include <sys/eventfd.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/filedesc.h> #include <sys/filedesc.h>
@ -1583,3 +1584,54 @@ linux_do_futex(int *uaddr, int op, int val, struct timespec *timeout,
return do_futex(uaddr, op & ~FUTEX_PRIVATE_FLAG, return do_futex(uaddr, op & ~FUTEX_PRIVATE_FLAG,
val, timeout, uaddr2, val2, val3, retval); 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);
}

View File

@ -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. ; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
; (See syscalls.conf to see what it is processed into.) ; (See syscalls.conf to see what it is processed into.)
@ -552,7 +552,7 @@
321 UNIMPL signalfd 321 UNIMPL signalfd
322 NOARGS { int|linux_sys||timerfd_create(clockid_t clock_id, \ 322 NOARGS { int|linux_sys||timerfd_create(clockid_t clock_id, \
int flags); } int flags); }
323 UNIMPL eventfd 323 STD { int|linux32_sys||eventfd(unsigned int initval); }
324 STD { int|linux32_sys||fallocate(int fd, int mode, \ 324 STD { int|linux32_sys||fallocate(int fd, int mode, \
off_t offset, off_t len); } off_t offset, off_t len); }
325 STD { int|linux32_sys||timerfd_settime(int fd, int flags, \ 325 STD { int|linux32_sys||timerfd_settime(int fd, int flags, \
@ -561,7 +561,8 @@
326 STD { int|linux32_sys||timerfd_gettime(int fd, \ 326 STD { int|linux32_sys||timerfd_gettime(int fd, \
struct linux32_itimerspec *tim); } struct linux32_itimerspec *tim); }
327 UNIMPL signalfd4 327 UNIMPL signalfd4
328 UNIMPL eventfd2 328 STD { int|linux32_sys||eventfd2(unsigned int initval, \
int flags); }
329 UNIMPL epoll_create1 329 UNIMPL epoll_create1
330 STD { int|linux32_sys||dup3(int from, int to, int flags); } 330 STD { int|linux32_sys||dup3(int from, int to, int flags); }
331 STD { int|linux32_sys||pipe2(netbsd32_intp fd, int flags); } 331 STD { int|linux32_sys||pipe2(netbsd32_intp fd, int flags); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_misc.c,v 1.31 2021/09/19 22:32:45 thorpej Exp $ */ /* $NetBSD: linux32_misc.c,v 1.32 2021/09/20 00:09:02 thorpej Exp $ */
/*- /*-
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.31 2021/09/19 22:32:45 thorpej Exp $"); __KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.32 2021/09/20 00:09:02 thorpej Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/proc.h> #include <sys/proc.h>
@ -350,3 +350,33 @@ linux32_sys_ppoll(struct lwp *l, const struct linux32_sys_ppoll_args *uap,
return pollcommon(retval, SCARG_P32(uap, fds), SCARG(uap, nfds), return pollcommon(retval, SCARG_P32(uap, fds), SCARG(uap, nfds),
ts, sigmask); ts, sigmask);
} }
int
linux32_sys_eventfd(struct lwp *l, const struct linux32_sys_eventfd_args *uap,
register_t *retval)
{
/* {
syscallarg(unsigned int) initval;
} */
struct linux_sys_eventfd_args ua;
NETBSD32TO64_UAP(initval);
return linux_sys_eventfd(l, &ua, retval);
}
int
linux32_sys_eventfd2(struct lwp *l, const struct linux32_sys_eventfd2_args *uap,
register_t *retval)
{
/* {
syscallarg(unsigned int) initval;
syscallarg(int) flags;
} */
struct linux_sys_eventfd2_args ua;
NETBSD32TO64_UAP(initval);
NETBSD32TO64_UAP(flags);
return linux_sys_eventfd2(l, &ua, retval);
}