Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Nov 2014 16:33:34 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r274243 - in user/dchagin/lemul/sys: amd64/linux amd64/linux32 compat/linux i386/linux
Message-ID:  <201411071633.sA7GXYXH025427@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Fri Nov  7 16:33:33 2014
New Revision: 274243
URL: https://svnweb.freebsd.org/changeset/base/274243

Log:
  Implement ppoll() system call.
  
  (need more test, ltp passed)

Modified:
  user/dchagin/lemul/sys/amd64/linux/linux_dummy.c
  user/dchagin/lemul/sys/amd64/linux/syscalls.master
  user/dchagin/lemul/sys/amd64/linux32/linux32_dummy.c
  user/dchagin/lemul/sys/amd64/linux32/syscalls.master
  user/dchagin/lemul/sys/compat/linux/linux_misc.c
  user/dchagin/lemul/sys/i386/linux/linux_dummy.c
  user/dchagin/lemul/sys/i386/linux/syscalls.master

Modified: user/dchagin/lemul/sys/amd64/linux/linux_dummy.c
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux/linux_dummy.c	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/amd64/linux/linux_dummy.c	Fri Nov  7 16:33:33 2014	(r274243)
@@ -92,7 +92,6 @@ DUMMY(inotify_init);
 DUMMY(inotify_add_watch);
 DUMMY(inotify_rm_watch);
 DUMMY(migrate_pages);
-DUMMY(ppoll);
 DUMMY(unshare);
 DUMMY(splice);
 DUMMY(tee);

Modified: user/dchagin/lemul/sys/amd64/linux/syscalls.master
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux/syscalls.master	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/amd64/linux/syscalls.master	Fri Nov  7 16:33:33 2014	(r274243)
@@ -456,7 +456,8 @@
 		    			    l_fd_set *readfds, l_fd_set *writefds,	\
 					    l_fd_set *exceptfds,			\
 					    struct l_timespec *tsp, l_uintptr_t *sig); }
-271	AUE_NULL	STD	{ int linux_ppoll(void); }
+271	AUE_POLL	STD	{ int linux_ppoll(struct pollfd* fds, uint32_t nfds,	\
+				    struct l_timespec *tsp, l_sigset_t *sset, l_size_t ssize); }
 272	AUE_NULL	STD	{ int linux_unshare(void); }
 273	AUE_NULL	STD	{ int linux_set_robust_list(struct linux_robust_list_head *head, \
 				    l_size_t len); }

Modified: user/dchagin/lemul/sys/amd64/linux32/linux32_dummy.c
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux32/linux32_dummy.c	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/amd64/linux32/linux32_dummy.c	Fri Nov  7 16:33:33 2014	(r274243)
@@ -92,7 +92,6 @@ DUMMY(inotify_add_watch);
 DUMMY(inotify_rm_watch);
 /* linux 2.6.16: */
 DUMMY(migrate_pages);
-DUMMY(ppoll);
 DUMMY(unshare);
 /* linux 2.6.17: */
 DUMMY(splice);

Modified: user/dchagin/lemul/sys/amd64/linux32/syscalls.master
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux32/syscalls.master	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/amd64/linux32/syscalls.master	Fri Nov  7 16:33:33 2014	(r274243)
@@ -513,7 +513,8 @@
 				    l_fd_set *readfds, l_fd_set *writefds,	\
 				    l_fd_set *exceptfds,			\
 				    struct l_timespec *tsp, l_uintptr_t *sig); }
-309	AUE_NULL	STD	{ int linux_ppoll(void); }
+309	AUE_POLL	STD	{ int linux_ppoll(struct pollfd* fds, uint32_t nfds,	\
+				    struct l_timespec *tsp, l_sigset_t *sset, l_size_t ssize); }
 310	AUE_NULL	STD	{ int linux_unshare(void); }
 ; linux 2.6.17:
 311	AUE_NULL	STD	{ int linux_set_robust_list(struct linux_robust_list_head *head, \

Modified: user/dchagin/lemul/sys/compat/linux/linux_misc.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linux/linux_misc.c	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/compat/linux/linux_misc.c	Fri Nov  7 16:33:33 2014	(r274243)
@@ -2170,6 +2170,61 @@ linux_pselect6(struct thread *td, struct
 	return (error);
 }
 
+int
+linux_ppoll(struct thread *td, struct linux_ppoll_args *args)
+{
+	struct timespec ts0, ts1;
+	struct l_timespec lts;
+	struct timespec uts, *tsp;
+	l_sigset_t l_ss;
+	sigset_t *ssp;
+	sigset_t ss;
+	int error;
+
+	if (args->sset) {
+		if (args->ssize != sizeof(l_ss))
+			return (EINVAL);
+		error = copyin(args->sset, &l_ss, sizeof(l_ss));
+		if (error)
+			return (error);
+		linux_to_bsd_sigset(&l_ss, &ss);
+		SIGDELSET(ss, SIGKILL);
+		SIGDELSET(ss, SIGSTOP);
+		ssp = &ss;
+	} else
+		ssp = NULL;
+	if (args->tsp) {
+		error = copyin(args->tsp, &lts, sizeof(lts));
+		if (error)
+			return (error);
+		uts.tv_sec = lts.tv_sec;
+		uts.tv_nsec = lts.tv_nsec;
+
+		nanotime(&ts0);
+		tsp = &uts;
+	} else
+		tsp = NULL;
+
+	error = kern_ppoll(td, args->fds, args->nfds, tsp, ssp);
+
+	if (error == 0 && args->tsp) {
+		if (td->td_retval[0]) {
+			nanotime(&ts1);
+			timespecsub(&ts1, &ts0);
+			timespecsub(&uts, &ts1);
+			if (uts.tv_sec < 0)
+				timespecclear(&uts);
+		} else
+			timespecclear(&uts);
+
+		lts.tv_sec = uts.tv_sec;
+		lts.tv_nsec = uts.tv_nsec;
+		error = copyout(&lts, args->tsp, sizeof(lts));
+	}
+
+	return (error);
+}
+
 #if defined(DEBUG) || defined(KTR)
 /* XXX: can be removed when every ldebug(...) and KTR stuff are removed. */
 

Modified: user/dchagin/lemul/sys/i386/linux/linux_dummy.c
==============================================================================
--- user/dchagin/lemul/sys/i386/linux/linux_dummy.c	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/i386/linux/linux_dummy.c	Fri Nov  7 16:33:33 2014	(r274243)
@@ -88,7 +88,6 @@ DUMMY(inotify_add_watch);
 DUMMY(inotify_rm_watch);
 /* linux 2.6.16: */
 DUMMY(migrate_pages);
-DUMMY(ppoll);
 DUMMY(unshare);
 /* linux 2.6.17: */
 DUMMY(splice);

Modified: user/dchagin/lemul/sys/i386/linux/syscalls.master
==============================================================================
--- user/dchagin/lemul/sys/i386/linux/syscalls.master	Fri Nov  7 16:25:07 2014	(r274242)
+++ user/dchagin/lemul/sys/i386/linux/syscalls.master	Fri Nov  7 16:33:33 2014	(r274243)
@@ -521,7 +521,8 @@
 		    			    l_fd_set *readfds, l_fd_set *writefds,	\
 					    l_fd_set *exceptfds,			\
 					    struct l_timespec *tsp, l_uintptr_t *sig); }
-309	AUE_NULL	STD	{ int linux_ppoll(void); }
+309	AUE_POLL	STD	{ int linux_ppoll(struct pollfd* fds, uint32_t nfds,	\
+				    struct l_timespec *tsp, l_sigset_t *sset, l_size_t ssize); }
 310	AUE_NULL	STD	{ int linux_unshare(void); }
 ; linux 2.6.17:
 311	AUE_NULL	STD	{ int linux_set_robust_list(struct linux_robust_list_head *head, \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411071633.sA7GXYXH025427>