Module Name:    src
Committed By:   snj
Date:           Mon Apr 17 05:19:09 UTC 2017

Modified Files:
        src/sys/compat/linux/arch/alpha [netbsd-7]: syscalls.master
        src/sys/compat/linux/arch/amd64 [netbsd-7]: syscalls.master
        src/sys/compat/linux/arch/arm [netbsd-7]: syscalls.master
        src/sys/compat/linux/arch/i386 [netbsd-7]: syscalls.master
        src/sys/compat/linux/arch/m68k [netbsd-7]: syscalls.master
        src/sys/compat/linux/arch/mips [netbsd-7]: syscalls.master
        src/sys/compat/linux/arch/powerpc [netbsd-7]: syscalls.master
        src/sys/compat/linux/common [netbsd-7]: linux_misc.c linux_signal.h

Log Message:
Pull up following revision(s) (requested by manu in ticket #1354):
        sys/compat/linux/arch/alpha/syscalls.master: revision 1.92 via patch
        sys/compat/linux/arch/amd64/syscalls.master: revision 1.58 via patch
        sys/compat/linux/arch/arm/syscalls.master: revision 1.65 via patch
        sys/compat/linux/arch/i386/syscalls.master: revision 1.122 via patch
        sys/compat/linux/arch/m68k/syscalls.master: revision 1.91 via patch
        sys/compat/linux/arch/mips/syscalls.master: revision 1.61 via patch
        sys/compat/linux/arch/powerpc/syscalls.master: revision 1.70 via patch
        sys/compat/linux/common/linux_misc.c: revision 1.234
        sys/compat/linux/common/linux_signal.h: revision 1.31
Add pselect6 Linux system call.
This lets Matlab R2016A run on NetBSD/amd64


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.88.2.1 \
    src/sys/compat/linux/arch/alpha/syscalls.master
cvs rdiff -u -r1.52 -r1.52.2.1 \
    src/sys/compat/linux/arch/amd64/syscalls.master
cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/compat/linux/arch/arm/syscalls.master
cvs rdiff -u -r1.118 -r1.118.2.1 \
    src/sys/compat/linux/arch/i386/syscalls.master
cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/compat/linux/arch/m68k/syscalls.master
cvs rdiff -u -r1.56 -r1.56.2.1 src/sys/compat/linux/arch/mips/syscalls.master
cvs rdiff -u -r1.65 -r1.65.2.1 \
    src/sys/compat/linux/arch/powerpc/syscalls.master
cvs rdiff -u -r1.229 -r1.229.2.1 src/sys/compat/linux/common/linux_misc.c
cvs rdiff -u -r1.30 -r1.30.38.1 src/sys/compat/linux/common/linux_signal.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/arch/alpha/syscalls.master
diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.88 src/sys/compat/linux/arch/alpha/syscalls.master:1.88.2.1
--- src/sys/compat/linux/arch/alpha/syscalls.master:1.88	Thu May 29 10:35:26 2014
+++ src/sys/compat/linux/arch/alpha/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.88 2014/05/29 10:35:26 njoly Exp $
+	$NetBSD: syscalls.master,v 1.88.2.1 2017/04/17 05:19:09 snj Exp $
 ;
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -728,7 +728,10 @@
 			    linux_umode_t mode); }
 462	STD		{ int|linux_sys||faccessat(int fd, const char *path, \
 			    int amode); }
-463	UNIMPL		pselect6
+463	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 464	STD		{ int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/arch/amd64/syscalls.master
diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.52 src/sys/compat/linux/arch/amd64/syscalls.master:1.52.2.1
--- src/sys/compat/linux/arch/amd64/syscalls.master:1.52	Sat May 31 08:51:19 2014
+++ src/sys/compat/linux/arch/amd64/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.52 2014/05/31 08:51:19 njoly Exp $
+	$NetBSD: syscalls.master,v 1.52.2.1 2017/04/17 05:19:09 snj Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -489,7 +489,10 @@
 			    linux_umode_t mode); }
 269	STD		{ int|linux_sys||faccessat(int fd, const char *path, \
 			    int amode); }
-270	UNIMPL		pselect6
+270	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 271	STD		{ int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/arch/arm/syscalls.master
diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.61 src/sys/compat/linux/arch/arm/syscalls.master:1.61.2.1
--- src/sys/compat/linux/arch/arm/syscalls.master:1.61	Sat May 31 08:51:19 2014
+++ src/sys/compat/linux/arch/arm/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.61 2014/05/31 08:51:19 njoly Exp $
+	$NetBSD: syscalls.master,v 1.61.2.1 2017/04/17 05:19:09 snj Exp $
 
 ; Derived from sys/compat/linux/arch/*/syscalls.master
 ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -530,7 +530,10 @@
 			    linux_umode_t mode); }
 334	STD		{ int|linux_sys||faccessat(int fd, const char *path, \
 			    int amode); }
-335	UNIMPL		pselect6
+335	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 336	STD		{ int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/arch/i386/syscalls.master
diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.118 src/sys/compat/linux/arch/i386/syscalls.master:1.118.2.1
--- src/sys/compat/linux/arch/i386/syscalls.master:1.118	Sat May 31 08:51:19 2014
+++ src/sys/compat/linux/arch/i386/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.118 2014/05/31 08:51:19 njoly Exp $
+	$NetBSD: syscalls.master,v 1.118.2.1 2017/04/17 05:19:09 snj Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -503,7 +503,10 @@
 			    linux_umode_t mode); }
 307	STD		{ int|linux_sys||faccessat(int fd, const char *path, \
 			    int amode); }
-308	UNIMPL		pselect6
+308	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 309	STD		{ int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/arch/m68k/syscalls.master
diff -u src/sys/compat/linux/arch/m68k/syscalls.master:1.88 src/sys/compat/linux/arch/m68k/syscalls.master:1.88.2.1
--- src/sys/compat/linux/arch/m68k/syscalls.master:1.88	Sat May 31 08:51:19 2014
+++ src/sys/compat/linux/arch/m68k/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.88 2014/05/31 08:51:19 njoly Exp $
+	$NetBSD: syscalls.master,v 1.88.2.1 2017/04/17 05:19:09 snj Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -511,7 +511,10 @@
 			    linux_umode_t mode); }
 300	STD		{ int|linux_sys||faccessat(int fd, const char *path, \
 			    int amode); }
-301	UNIMPL		pselect6
+301	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 302	STD             { int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/arch/mips/syscalls.master
diff -u src/sys/compat/linux/arch/mips/syscalls.master:1.56 src/sys/compat/linux/arch/mips/syscalls.master:1.56.2.1
--- src/sys/compat/linux/arch/mips/syscalls.master:1.56	Sat May 31 08:51:19 2014
+++ src/sys/compat/linux/arch/mips/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.56 2014/05/31 08:51:19 njoly Exp $  
+	$NetBSD: syscalls.master,v 1.56.2.1 2017/04/17 05:19:09 snj Exp $  
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -500,7 +500,10 @@
 			    linux_umode_t mode); }
 300	STD		{ int|linux_sys||faccessat(int fd, const char *path, \
 			    int amode); }
-301	UNIMPL		pselect6
+301	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 302	STD		{ int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/arch/powerpc/syscalls.master
diff -u src/sys/compat/linux/arch/powerpc/syscalls.master:1.65 src/sys/compat/linux/arch/powerpc/syscalls.master:1.65.2.1
--- src/sys/compat/linux/arch/powerpc/syscalls.master:1.65	Sat May 31 08:51:19 2014
+++ src/sys/compat/linux/arch/powerpc/syscalls.master	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.65 2014/05/31 08:51:19 njoly Exp $  
+	$NetBSD: syscalls.master,v 1.65.2.1 2017/04/17 05:19:09 snj Exp $  
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -477,7 +477,10 @@
 277	UNIMPL		inotify_rm_watch
 278	UNIMPL		spu_run
 279	UNIMPL		spu_create
-280	UNIMPL		pselect6
+280	STD		{ int|linux_sys||pselect6(int nfds, fd_set *readfds, \
+			    fd_set *writefds, fd_set *exceptfds, \
+			    struct linux_timespec *timeout, \
+			    linux_sized_sigset_t *ss); }
 281	STD		{ int|linux_sys||ppoll(struct pollfd *fds, int nfds, \
 			    struct linux_timespec *timeout, \
 			    linux_sigset_t *sigset); }

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.229 src/sys/compat/linux/common/linux_misc.c:1.229.2.1
--- src/sys/compat/linux/common/linux_misc.c:1.229	Thu May 29 10:35:27 2014
+++ src/sys/compat/linux/common/linux_misc.c	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.229 2014/05/29 10:35:27 njoly Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.229.2.1 2017/04/17 05:19:09 snj Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.229 2014/05/29 10:35:27 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.229.2.1 2017/04/17 05:19:09 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -922,6 +922,87 @@ linux_select1(struct lwp *l, register_t 
 	return 0;
 }
 
+/*
+ * Derived from FreeBSD's sys/compat/linux/linux_misc.c:linux_pselect6()
+ * which was contributed by Dmitry Chagin
+ * https://svnweb.freebsd.org/base?view=revision&revision=283403
+ */
+int
+linux_sys_pselect6(struct lwp *l,
+	const struct linux_sys_pselect6_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(int) nfds;
+		syscallarg(fd_set *) readfds;
+		syscallarg(fd_set *) writefds;
+		syscallarg(fd_set *) exceptfds;
+		syscallarg(struct timespec *) timeout;
+		syscallarg(linux_sized_sigset_t *) ss;
+	} */
+	struct timespec uts, ts0, ts1, *tsp;
+	linux_sized_sigset_t lsss;
+	struct linux_timespec lts;
+	linux_sigset_t lss;
+	sigset_t *ssp;
+	sigset_t ss;
+	int error;
+
+	ssp = NULL;
+	if (SCARG(uap, ss) != NULL) {
+		if ((error = copyin(SCARG(uap, ss), &lsss, sizeof(lsss))) != 0)
+			return (error);
+		if (lsss.ss_len != sizeof(lss))
+			return (EINVAL);
+		if (lsss.ss != NULL) {
+			if ((error = copyin(lsss.ss, &lss, sizeof(lss))) != 0)
+				return (error);
+			linux_to_native_sigset(&ss, &lss);
+			ssp = &ss;
+		}
+	}
+
+	if (SCARG(uap, timeout) != NULL) {
+		error = copyin(SCARG(uap, timeout), &lts, sizeof(lts));
+		if (error != 0)
+			return (error);
+		linux_to_native_timespec(&uts, &lts);
+
+		if (itimespecfix(&uts))
+			return (EINVAL);
+
+		nanotime(&ts0);
+		tsp = &uts;
+	} else {
+		tsp = NULL;
+	}
+
+	error = selcommon(retval, SCARG(uap, nfds), SCARG(uap, readfds),
+	    SCARG(uap, writefds), SCARG(uap, exceptfds), tsp, ssp);
+
+	if (error == 0 && tsp != NULL) {
+		if (retval != 0) {
+			/*
+			 * Compute how much time was left of the timeout,
+			 * by subtracting the current time and the time
+			 * before we started the call, and subtracting
+			 * that result from the user-supplied value.
+			 */
+			nanotime(&ts1);
+			timespecsub(&ts1, &ts0, &ts1);
+			timespecsub(&uts, &ts1, &uts);
+			if (uts.tv_sec < 0)
+				timespecclear(&uts);
+		} else {
+			timespecclear(&uts);
+		}
+
+		native_to_linux_timespec(&lts, &uts);
+		error = copyout(&lts, SCARG(uap, timeout), sizeof(lts));
+	}
+
+	return (error);
+}
+
 int
 linux_sys_ppoll(struct lwp *l,
 	const struct linux_sys_ppoll_args *uap, register_t *retval)

Index: src/sys/compat/linux/common/linux_signal.h
diff -u src/sys/compat/linux/common/linux_signal.h:1.30 src/sys/compat/linux/common/linux_signal.h:1.30.38.1
--- src/sys/compat/linux/common/linux_signal.h:1.30	Fri May 29 14:19:13 2009
+++ src/sys/compat/linux/common/linux_signal.h	Mon Apr 17 05:19:09 2017
@@ -1,4 +1,4 @@
-/* 	$NetBSD: linux_signal.h,v 1.30 2009/05/29 14:19:13 njoly Exp $	*/
+/* 	$NetBSD: linux_signal.h,v 1.30.38.1 2017/04/17 05:19:09 snj Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -48,6 +48,11 @@
 #include <compat/linux/arch/amd64/linux_signal.h>
 #endif
 
+typedef struct {
+	linux_sigset_t *ss;
+	size_t ss_len;
+} linux_sized_sigset_t;
+
 #ifdef _KERNEL
 extern const int native_to_linux_signo[];
 extern const int linux_to_native_signo[];

Reply via email to