From owner-svn-src-all@FreeBSD.ORG Sun May 24 16:59:28 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A07FCFC3; Sun, 24 May 2015 16:59:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80ACB183C; Sun, 24 May 2015 16:59:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4OGxSRx003616; Sun, 24 May 2015 16:59:28 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4OGxQoe003607; Sun, 24 May 2015 16:59:26 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201505241659.t4OGxQoe003607@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 24 May 2015 16:59:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283451 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2015 16:59:28 -0000 Author: dchagin Date: Sun May 24 16:59:25 2015 New Revision: 283451 URL: https://svnweb.freebsd.org/changeset/base/283451 Log: Implement ppoll() system call. Differential Revision: https://reviews.freebsd.org/D1105 Reviewed by: trasz Modified: head/sys/amd64/linux/linux_dummy.c head/sys/amd64/linux/syscalls.master head/sys/amd64/linux32/linux32_dummy.c head/sys/amd64/linux32/syscalls.master head/sys/compat/linux/linux_misc.c head/sys/i386/linux/linux_dummy.c head/sys/i386/linux/syscalls.master Modified: head/sys/amd64/linux/linux_dummy.c ============================================================================== --- head/sys/amd64/linux/linux_dummy.c Sun May 24 16:56:32 2015 (r283450) +++ head/sys/amd64/linux/linux_dummy.c Sun May 24 16:59:25 2015 (r283451) @@ -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: head/sys/amd64/linux/syscalls.master ============================================================================== --- head/sys/amd64/linux/syscalls.master Sun May 24 16:56:32 2015 (r283450) +++ head/sys/amd64/linux/syscalls.master Sun May 24 16:59:25 2015 (r283451) @@ -456,7 +456,8 @@ 270 AUE_SELECT STD { int linux_pselect6(l_int nfds, \ 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: head/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- head/sys/amd64/linux32/linux32_dummy.c Sun May 24 16:56:32 2015 (r283450) +++ head/sys/amd64/linux32/linux32_dummy.c Sun May 24 16:59:25 2015 (r283451) @@ -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: head/sys/amd64/linux32/syscalls.master ============================================================================== --- head/sys/amd64/linux32/syscalls.master Sun May 24 16:56:32 2015 (r283450) +++ head/sys/amd64/linux32/syscalls.master Sun May 24 16:59:25 2015 (r283451) @@ -514,7 +514,8 @@ 308 AUE_SELECT STD { int linux_pselect6(l_int nfds, 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: head/sys/compat/linux/linux_misc.c ============================================================================== --- head/sys/compat/linux/linux_misc.c Sun May 24 16:56:32 2015 (r283450) +++ head/sys/compat/linux/linux_misc.c Sun May 24 16:59:25 2015 (r283451) @@ -2209,6 +2209,59 @@ 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 != NULL) { + 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); + ssp = &ss; + } else + ssp = NULL; + if (args->tsp != NULL) { + error = copyin(args->tsp, <s, 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_poll(td, args->fds, args->nfds, tsp, ssp); + + if (error == 0 && args->tsp != NULL) { + 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(<s, args->tsp, sizeof(lts)); + } + + return (error); +} + #if defined(DEBUG) || defined(KTR) /* XXX: can be removed when every ldebug(...) and KTR stuff are removed. */ Modified: head/sys/i386/linux/linux_dummy.c ============================================================================== --- head/sys/i386/linux/linux_dummy.c Sun May 24 16:56:32 2015 (r283450) +++ head/sys/i386/linux/linux_dummy.c Sun May 24 16:59:25 2015 (r283451) @@ -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: head/sys/i386/linux/syscalls.master ============================================================================== --- head/sys/i386/linux/syscalls.master Sun May 24 16:56:32 2015 (r283450) +++ head/sys/i386/linux/syscalls.master Sun May 24 16:59:25 2015 (r283451) @@ -522,7 +522,8 @@ 308 AUE_SELECT STD { int linux_pselect6(l_int nfds, 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, \