Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 COMPAT_NETBSD32: Catch up with sys___kev...
details: https://anonhg.NetBSD.org/src/rev/9ae63361f875
branches: trunk
changeset: 378312:9ae63361f875
user: rin <rin%NetBSD.org@localhost>
date: Sat Jul 29 12:38:25 2023 +0000
description:
COMPAT_NETBSD32: Catch up with sys___kevent100() addition.
XXX
Add epoll_* and memfd_create.
diffstat:
sys/compat/netbsd32/netbsd32.h | 15 +++-
sys/compat/netbsd32/netbsd32_compat_100.c | 122 +++++++++++++++++++++++++++++-
sys/compat/netbsd32/netbsd32_compat_50.c | 71 +++-------------
sys/compat/netbsd32/netbsd32_conv.h | 4 +-
sys/compat/netbsd32/netbsd32_event.c | 53 +++++++-----
sys/compat/netbsd32/netbsd32_event.h | 45 +++++++++++
sys/compat/netbsd32/syscalls.master | 23 ++++-
7 files changed, 242 insertions(+), 91 deletions(-)
diffs (truncated from 515 to 300 lines):
diff -r 95295424b02d -r 9ae63361f875 sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h Sat Jul 29 12:16:34 2023 +0000
+++ b/sys/compat/netbsd32/netbsd32.h Sat Jul 29 12:38:25 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32.h,v 1.141 2023/02/12 16:28:32 andvar Exp $ */
+/* $NetBSD: netbsd32.h,v 1.142 2023/07/29 12:38:25 rin Exp $ */
/*
* Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -1024,6 +1024,19 @@ struct netbsd32_kevent {
uint32_t fflags;
netbsd32_int64 data;
netbsd32_pointer_t udata;
+ netbsd32_uint64 ext[4];
+};
+
+/* from <compat/sys/event.h> */
+typedef netbsd32_pointer_t netbsd32_kevent100p_t;
+
+struct netbsd32_kevent100 {
+ netbsd32_uintptr_t ident;
+ uint32_t filter;
+ uint32_t flags;
+ uint32_t fflags;
+ netbsd32_int64 data;
+ netbsd32_pointer_t udata;
};
/* from <sys/sched.h> */
diff -r 95295424b02d -r 9ae63361f875 sys/compat/netbsd32/netbsd32_compat_100.c
--- a/sys/compat/netbsd32/netbsd32_compat_100.c Sat Jul 29 12:16:34 2023 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_100.c Sat Jul 29 12:38:25 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_100.c,v 1.1 2022/12/19 23:19:51 pgoyette Exp $ */
+/* $NetBSD: netbsd32_compat_100.c,v 1.2 2023/07/29 12:38:25 rin Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,14 +30,126 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_100.c,v 1.1 2022/12/19 23:19:51 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_100.c,v 1.2 2023/07/29 12:38:25 rin Exp $");
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/eventvar.h>
#include <sys/module.h>
+#include <sys/syscallvar.h>
+#include <sys/syscallargs.h>
+#include <sys/systm.h>
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_syscall.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
#include <compat/netbsd32/netbsd32_conv.h>
+#include <compat/netbsd32/netbsd32_event.h>
+
+static int
+compat_100_netbsd32_kevent_fetch_timeout(const void *src, void *dest,
+ size_t length)
+{
+ struct netbsd32_timespec ts32;
+ int error;
+
+ KASSERT(length == sizeof(struct timespec));
+
+ error = copyin(src, &ts32, sizeof(ts32));
+ if (error)
+ return error;
+ netbsd32_to_timespec(&ts32, (struct timespec *)dest);
+ return 0;
+}
+
+static void
+compat_100_netbsd32_to_kevent(const struct netbsd32_kevent100 *ke32,
+ struct kevent *ke)
+{
+
+ memset(ke, 0, sizeof(*ke));
+ ke->ident = ke32->ident;
+ ke->filter = ke32->filter;
+ ke->flags = ke32->flags;
+ ke->fflags = ke32->fflags;
+ ke->data = ke32->data;
+ ke->udata = NETBSD32PTR64(ke32->udata);
+}
+
+static void
+compat_100_netbsd32_from_kevent(const struct kevent *ke,
+ struct netbsd32_kevent100 *ke32)
+{
+
+ memset(ke32, 0, sizeof(*ke32));
+ ke32->ident = ke->ident;
+ ke32->filter = ke->filter;
+ ke32->flags = ke->flags;
+ ke32->fflags = ke->fflags;
+ ke32->data = ke->data;
+ NETBSD32PTR32(ke32->udata, ke->udata);
+}
+
+int
+compat_100_netbsd32_kevent_fetch_changes(void *ctx,
+ const struct kevent *changelist, struct kevent *changes, size_t index,
+ int n)
+{
+ const struct netbsd32_kevent100 *src =
+ (const struct netbsd32_kevent100 *)changelist;
+ struct netbsd32_kevent100 *ke32, *changes32 = ctx;
+ int error, i;
+
+ error = copyin(src + index, changes32, n * sizeof(*changes32));
+ if (error)
+ return error;
+ for (i = 0, ke32 = changes32; i < n; i++, ke32++, changes++)
+ compat_100_netbsd32_to_kevent(ke32, changes);
+ return 0;
+}
+
+int
+compat_100_netbsd32_kevent_put_events(void *ctx, struct kevent *events,
+ struct kevent *eventlist, size_t index, int n)
+{
+ struct netbsd32_kevent100 *ke32, *events32 = ctx;
+ int i;
+
+ for (i = 0, ke32 = events32; i < n; i++, ke32++, events++)
+ compat_100_netbsd32_from_kevent(events, ke32);
+ ke32 = ((struct netbsd32_kevent100 *)eventlist) + index;
+ return copyout(events32, ke32, n * sizeof(*events32));
+}
+
+int
+compat_100_netbsd32___kevent50(struct lwp *l,
+ const struct compat_100_netbsd32___kevent50_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(const netbsd32_kevent100p_t) changelist;
+ syscallarg(netbsd32_size_t) nchanges;
+ syscallarg(netbsd32_kevent100p_t) eventlist;
+ syscallarg(netbsd32_size_t) nevents;
+ syscallarg(netbsd32_timespecp_t) timeout;
+ } */
+ struct kevent_ops netbsd32_kevent_ops = {
+ .keo_fetch_timeout = compat_100_netbsd32_kevent_fetch_timeout,
+ .keo_fetch_changes = compat_100_netbsd32_kevent_fetch_changes,
+ .keo_put_events = compat_100_netbsd32_kevent_put_events,
+ };
+
+ return netbsd32_kevent1(retval, SCARG(uap, fd),
+ (netbsd32_keventp_t)SCARG(uap, changelist), SCARG(uap, nchanges),
+ (netbsd32_keventp_t)SCARG(uap, eventlist), SCARG(uap, nevents),
+ SCARG(uap, timeout), &netbsd32_kevent_ops);
+}
+
+static struct syscall_package compat_netbsd32_100_syscalls[] = {
+ { NETBSD32_SYS_compat_100_netbsd32___kevent50, 0,
+ (sy_call_t *)compat_100_netbsd32___kevent50 },
+ { 0, 0, NULL },
+};
MODULE(MODULE_CLASS_EXEC, compat_netbsd32_100, "compat_netbsd32,compat_100");
@@ -47,10 +159,12 @@ compat_netbsd32_100_modcmd(modcmd_t cmd,
switch (cmd) {
case MODULE_CMD_INIT:
- return 0;
+ return syscall_establish(&emul_netbsd32,
+ compat_netbsd32_100_syscalls);
case MODULE_CMD_FINI:
- return 0;
+ return syscall_disestablish(&emul_netbsd32,
+ compat_netbsd32_100_syscalls);
default:
return ENOTTY;
diff -r 95295424b02d -r 9ae63361f875 sys/compat/netbsd32/netbsd32_compat_50.c
--- a/sys/compat/netbsd32/netbsd32_compat_50.c Sat Jul 29 12:16:34 2023 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_50.c Sat Jul 29 12:38:25 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_50.c,v 1.53 2022/10/26 23:23:52 riastradh Exp $ */
+/* $NetBSD: netbsd32_compat_50.c,v 1.54 2023/07/29 12:38:25 rin Exp $ */
/*-
* Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.53 2022/10/26 23:23:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.54 2023/07/29 12:38:25 rin Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -71,6 +71,7 @@
#include <compat/netbsd32/netbsd32_syscall.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
#include <compat/netbsd32/netbsd32_conv.h>
+#include <compat/netbsd32/netbsd32_event.h>
#include <compat/sys/mount.h>
#include <compat/sys/time.h>
#include <compat/sys/rnd.h>
@@ -577,7 +578,8 @@ compat_50_netbsd32__lwp_park(struct lwp
}
static int
-netbsd32_kevent_fetch_timeout(const void *src, void *dest, size_t length)
+compat_50_netbsd32_kevent_fetch_timeout(const void *src, void *dest,
+ size_t length)
{
struct netbsd32_timespec50 ts32;
int error;
@@ -591,71 +593,28 @@ netbsd32_kevent_fetch_timeout(const void
return 0;
}
-static int
-netbsd32_kevent_fetch_changes(void *ctx, const struct kevent *changelist,
- struct kevent *changes, size_t index, int n)
-{
- const struct netbsd32_kevent *src =
- (const struct netbsd32_kevent *)changelist;
- struct netbsd32_kevent *kev32, *changes32 = ctx;
- int error, i;
-
- error = copyin(src + index, changes32, n * sizeof(*changes32));
- if (error)
- return error;
- for (i = 0, kev32 = changes32; i < n; i++, kev32++, changes++)
- netbsd32_to_kevent(kev32, changes);
- return 0;
-}
-
-static int
-netbsd32_kevent_put_events(void *ctx, struct kevent *events,
- struct kevent *eventlist, size_t index, int n)
-{
- struct netbsd32_kevent *kev32, *events32 = ctx;
- int i;
-
- for (i = 0, kev32 = events32; i < n; i++, kev32++, events++)
- netbsd32_from_kevent(events, kev32);
- kev32 = (struct netbsd32_kevent *)eventlist;
- return copyout(events32, kev32, n * sizeof(*events32));
-}
-
int
compat_50_netbsd32_kevent(struct lwp *l,
const struct compat_50_netbsd32_kevent_args *uap, register_t *retval)
{
/* {
syscallarg(int) fd;
- syscallarg(netbsd32_keventp_t) changelist;
+ syscallarg(netbsd32_kevent100p_t) changelist;
syscallarg(netbsd32_size_t) nchanges;
- syscallarg(netbsd32_keventp_t) eventlist;
+ syscallarg(netbsd32_kevent100p_t) eventlist;
syscallarg(netbsd32_size_t) nevents;
syscallarg(netbsd32_timespec50p_t) timeout;
} */
- int error;
- size_t maxalloc, nchanges, nevents;
- struct kevent_ops netbsd32_kevent_ops = {
- .keo_fetch_timeout = netbsd32_kevent_fetch_timeout,
- .keo_fetch_changes = netbsd32_kevent_fetch_changes,
- .keo_put_events = netbsd32_kevent_put_events,
+ struct kevent_ops kops = {
+ .keo_fetch_timeout = compat_50_netbsd32_kevent_fetch_timeout,
+ .keo_fetch_changes = compat_100_netbsd32_kevent_fetch_changes,
+ .keo_put_events = compat_100_netbsd32_kevent_put_events,
};
- nchanges = SCARG(uap, nchanges);
- nevents = SCARG(uap, nevents);
- maxalloc = KQ_NEVENTS;
-
- netbsd32_kevent_ops.keo_private =
- kmem_alloc(maxalloc * sizeof(struct netbsd32_kevent), KM_SLEEP);
-
- error = kevent1(retval, SCARG(uap, fd),
- NETBSD32PTR64(SCARG(uap, changelist)), nchanges,
- NETBSD32PTR64(SCARG(uap, eventlist)), nevents,
- NETBSD32PTR64(SCARG(uap, timeout)), &netbsd32_kevent_ops);
-
- kmem_free(netbsd32_kevent_ops.keo_private,
- maxalloc * sizeof(struct netbsd32_kevent));
- return error;
+ return netbsd32_kevent1(retval, SCARG(uap, fd),
+ (netbsd32_keventp_t)SCARG(uap, changelist), SCARG(uap, nchanges),
+ (netbsd32_keventp_t)SCARG(uap, eventlist), SCARG(uap, nevents),
+ (netbsd32_timespecp_t)SCARG(uap, timeout), &kops);
}
int
diff -r 95295424b02d -r 9ae63361f875 sys/compat/netbsd32/netbsd32_conv.h
Home |
Main Index |
Thread Index |
Old Index