Source-Changes-HG archive

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

[src/thorpej-futex]: src/sys/compat/linux32/common Add sigevent mapping for L...



details:   https://anonhg.NetBSD.org/src/rev/dc36fe06179b
branches:  thorpej-futex
changeset: 982893:dc36fe06179b
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Dec 17 03:00:28 2020 +0000

description:
Add sigevent mapping for Linux-32 compat.

diffstat:

 sys/compat/linux32/arch/amd64/linux32_siginfo.h |   7 +-
 sys/compat/linux32/common/linux32_sigevent.h    |  64 +++++++++++++++++++++++++
 sys/compat/linux32/common/linux32_siginfo.h     |   4 +-
 sys/compat/linux32/common/linux32_signal.c      |  59 ++++++++++++++++++++++-
 4 files changed, 126 insertions(+), 8 deletions(-)

diffs (194 lines):

diff -r 1244b314cd8e -r dc36fe06179b sys/compat/linux32/arch/amd64/linux32_siginfo.h
--- a/sys/compat/linux32/arch/amd64/linux32_siginfo.h   Thu Dec 17 02:52:40 2020 +0000
+++ b/sys/compat/linux32/arch/amd64/linux32_siginfo.h   Thu Dec 17 03:00:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_siginfo.h,v 1.1 2011/11/18 04:08:56 christos Exp $     */
+/*     $NetBSD: linux32_siginfo.h,v 1.1.66.1 2020/12/17 03:00:28 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -32,10 +32,7 @@
 #ifndef _AMD64_LINUX32_SIGINFO_H
 #define _AMD64_LINUX32_SIGINFO_H
 
-typedef union linux32_sigval {
-       int     sival_int;
-       netbsd32_voidp  sival_ptr;
-} linux32_sigval_t;
+#include <compat/linux32/common/linux32_sigevent.h>
 
 #define SI_MAX_SIZE    128
 #define SI_PAD_SIZE    ((SI_MAX_SIZE/sizeof(int)) - 3)
diff -r 1244b314cd8e -r dc36fe06179b sys/compat/linux32/common/linux32_sigevent.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/linux32/common/linux32_sigevent.h      Thu Dec 17 03:00:28 2020 +0000
@@ -0,0 +1,64 @@
+/*     $NetBSD: linux32_sigevent.h,v 1.1.2.1 2020/12/17 03:00:28 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LINUX32_SIGEVENT_H
+#define _LINUX32_SIGEVENT_H
+
+typedef union linux32_sigval {
+       int             sival_int;
+       netbsd32_voidp  sival_ptr;
+} linux32_sigval_t;
+
+#define LINUX32_SIGEV_MAX  64
+#ifndef LINUX32_SIGEV_PAD
+#define LINUX32_SIGEV_PAD  (LINUX32_SIGEV_MAX -                                \
+                           (sizeof(linux32_sigval_t) + (sizeof(int) * 2)))
+#endif
+
+typedef struct linux32_sigevent {
+       linux32_sigval_t sigev_value;
+       int sigev_signo;
+       int sigev_notify;
+       union {
+               int pad[LINUX32_SIGEV_PAD];
+               int tid;
+               struct {
+                       void (*func)(linux32_sigval_t);
+                       void *attr;
+               } _sigev_thread;
+       } _sigev_un;
+} linux32_sigevent_t;
+
+int    linux32_to_native_sigevent(struct sigevent *,
+           const struct linux32_sigevent *);
+int    linux32_sigevent_copyin(const void *, void *, size_t);
+
+#endif /* _LINUX32_SIGEVENT_H */
diff -r 1244b314cd8e -r dc36fe06179b sys/compat/linux32/common/linux32_siginfo.h
--- a/sys/compat/linux32/common/linux32_siginfo.h       Thu Dec 17 02:52:40 2020 +0000
+++ b/sys/compat/linux32/common/linux32_siginfo.h       Thu Dec 17 03:00:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_siginfo.h,v 1.1 2011/11/18 04:08:56 christos Exp $     */
+/*     $NetBSD: linux32_siginfo.h,v 1.1.66.1 2020/12/17 03:00:28 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -32,6 +32,8 @@
 #ifndef _LINUX32_SIGINFO_H
 #define _LINUX32_SIGINFO_H
 
+#include <compat/linux32/common/linux32_sigevent.h>
+
 #if defined(__amd64__)
 #include <compat/linux32/arch/amd64/linux32_siginfo.h>
 #endif
diff -r 1244b314cd8e -r dc36fe06179b sys/compat/linux32/common/linux32_signal.c
--- a/sys/compat/linux32/common/linux32_signal.c        Thu Dec 17 02:52:40 2020 +0000
+++ b/sys/compat/linux32/common/linux32_signal.c        Thu Dec 17 03:00:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_signal.c,v 1.20 2019/08/23 08:31:11 maxv Exp $ */
+/*     $NetBSD: linux32_signal.c,v 1.20.8.1 2020/12/17 03:00:28 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.20 2019/08/23 08:31:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.20.8.1 2020/12/17 03:00:28 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/ucred.h>
@@ -46,9 +46,11 @@
 
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_sigevent.h>
 
 #include <compat/linux32/common/linux32_types.h>
 #include <compat/linux32/common/linux32_signal.h>
+#include <compat/linux32/common/linux32_sigevent.h>
 #include <compat/linux32/common/linux32_siginfo.h>
 #include <compat/linux32/linux32_syscallargs.h>
 #include <compat/linux32/common/linux32_errno.h>
@@ -652,3 +654,56 @@
 
        return sts;
 }
+
+int
+linux32_to_native_sigevent(struct sigevent *nsep,
+    const struct linux32_sigevent *lsep)
+{
+       memset(nsep, 0, sizeof(*nsep));
+
+       switch (lsep->sigev_notify) {
+       case LINUX_SIGEV_SIGNAL:
+               nsep->sigev_notify = SIGEV_SIGNAL;
+               break;
+
+       case LINUX_SIGEV_NONE:
+               nsep->sigev_notify = SIGEV_NONE;
+               break;
+
+       case LINUX_SIGEV_THREAD:
+       case LINUX_SIGEV_THREAD_ID:
+       default:
+               return ENOTSUP;
+       }
+
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+       nsep->sigev_value.sival_ptr =
+           NETBSD32PTR64(lsep->sigev_value.sival_ptr);
+#else
+#error This is probably broken on big-endian platforms.
+#endif
+
+       if (lsep->sigev_signo < 0 || lsep->sigev_signo >= LINUX32__NSIG) {
+               return EINVAL;
+       }
+       nsep->sigev_signo = linux32_to_native_signo[lsep->sigev_signo];
+
+       return 0;
+}
+
+int
+linux32_sigevent_copyin(const void *src, void *dst, size_t size)
+{
+       struct linux32_sigevent lse;
+       struct sigevent *sep = dst;
+       int error;
+
+       KASSERT(size == sizeof(*sep));
+
+       error = copyin(src, &lse, sizeof(lse));
+       if (error) {
+               return error;
+       }
+
+       return linux32_to_native_sigevent(sep, &lse);
+}



Home | Main Index | Thread Index | Old Index