Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add ppoll() a compatibility wrapper around pollts(2)
details: https://anonhg.NetBSD.org/src/rev/356b6153396f
branches: trunk
changeset: 936061:356b6153396f
user: kamil <kamil%NetBSD.org@localhost>
date: Fri Jul 17 15:34:16 2020 +0000
description:
Add ppoll() a compatibility wrapper around pollts(2)
Submitted by Apurva Nandan.
diffstat:
distrib/sets/lists/comp/mi | 5 +-
distrib/sets/lists/debug/mi | 4 +-
distrib/sets/lists/tests/mi | 4 +-
lib/libc/sys/Makefile.inc | 8 +-
lib/libc/sys/poll.2 | 34 +++++-
lib/libc/sys/ppoll.c | 46 +++++++++
sys/sys/poll.h | 4 +-
tests/lib/libc/sys/Makefile | 4 +-
tests/lib/libc/sys/t_poll.c | 174 ++---------------------------------
tests/lib/libc/sys/t_pollts.c | 201 ++++++++++++++++++++++++++++++++++++++++++
tests/lib/libc/sys/t_ppoll.c | 33 ++++++
11 files changed, 341 insertions(+), 176 deletions(-)
diffs (truncated from 753 to 300 lines):
diff -r 46be9b80a8f7 -r 356b6153396f distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Fri Jul 17 15:24:03 2020 +0000
+++ b/distrib/sets/lists/comp/mi Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2339 2020/07/10 02:27:13 thorpej Exp $
+# $NetBSD: mi,v 1.2340 2020/07/17 15:34:17 kamil Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -4529,6 +4529,7 @@
./usr/share/man/cat2/posix_fadvise.0 comp-c-catman .cat
./usr/share/man/cat2/posix_fallocate.0 comp-c-catman .cat
./usr/share/man/cat2/posix_madvise.0 comp-c-catman .cat
+./usr/share/man/cat2/ppoll.0 comp-c-catman .cat
./usr/share/man/cat2/pread.0 comp-c-catman .cat
./usr/share/man/cat2/preadv.0 comp-c-catman .cat
./usr/share/man/cat2/profil.0 comp-c-catman .cat
@@ -12822,6 +12823,7 @@
./usr/share/man/html2/posix_fadvise.html comp-c-htmlman html
./usr/share/man/html2/posix_fallocate.html comp-c-htmlman html
./usr/share/man/html2/posix_madvise.html comp-c-htmlman html
+./usr/share/man/html2/ppoll.html comp-c-htmlman html
./usr/share/man/html2/pread.html comp-c-htmlman html
./usr/share/man/html2/preadv.html comp-c-htmlman html
./usr/share/man/html2/profil.html comp-c-htmlman html
@@ -20943,6 +20945,7 @@
./usr/share/man/man2/posix_fadvise.2 comp-c-man .man
./usr/share/man/man2/posix_fallocate.2 comp-c-man .man
./usr/share/man/man2/posix_madvise.2 comp-c-man .man
+./usr/share/man/man2/ppoll.2 comp-c-man .man
./usr/share/man/man2/pread.2 comp-c-man .man
./usr/share/man/man2/preadv.2 comp-c-man .man
./usr/share/man/man2/profil.2 comp-c-man .man
diff -r 46be9b80a8f7 -r 356b6153396f distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Fri Jul 17 15:24:03 2020 +0000
+++ b/distrib/sets/lists/debug/mi Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.324 2020/07/06 18:47:02 christos Exp $
+# $NetBSD: mi,v 1.325 2020/07/17 15:34:17 kamil Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile
@@ -2169,8 +2169,10 @@
./usr/libdata/debug/usr/tests/lib/libc/sys/t_pipe.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/sys/t_pipe2.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/sys/t_poll.debug tests-lib-debug debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_pollts.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/sys/t_posix_fadvise.debug tests-lib-debug debug,atf,rump
./usr/libdata/debug/usr/tests/lib/libc/sys/t_posix_fallocate.debug tests-lib-debug debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_ppoll.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/sys/t_ptrace.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/sys/t_ptrace_sigchld.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/sys/t_ptrace_wait.debug tests-lib-debug debug,atf,compattestfile
diff -r 46be9b80a8f7 -r 356b6153396f distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Jul 17 15:24:03 2020 +0000
+++ b/distrib/sets/lists/tests/mi Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.873 2020/07/06 18:47:02 christos Exp $
+# $NetBSD: mi,v 1.874 2020/07/17 15:34:17 kamil Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -3169,8 +3169,10 @@
./usr/tests/lib/libc/sys/t_pipe tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/sys/t_pipe2 tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/sys/t_poll tests-lib-tests compattestfile,atf
+./usr/tests/lib/libc/sys/t_pollts tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/sys/t_posix_fadvise tests-lib-tests atf,rump
./usr/tests/lib/libc/sys/t_posix_fallocate tests-lib-tests compattestfile,atf
+./usr/tests/lib/libc/sys/t_ppoll tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/sys/t_ptrace tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/sys/t_ptrace_sigchld tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/sys/t_ptrace_wait tests-lib-tests compattestfile,atf
diff -r 46be9b80a8f7 -r 356b6153396f lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc Fri Jul 17 15:24:03 2020 +0000
+++ b/lib/libc/sys/Makefile.inc Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.243 2020/05/16 18:31:47 christos Exp $
+# $NetBSD: Makefile.inc,v 1.244 2020/07/17 15:34:17 kamil Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
# sys sources
@@ -8,8 +8,8 @@
SRCS+= cpuset.c
# glue to offer userland wrappers for some syscalls
SRCS+= accept4.c clock_getcpuclockid.c posix_fadvise.c posix_madvise.c \
- sched.c sigqueue.c sigtimedwait.c sigwait.c sigwaitinfo.c statvfs.c \
- swapon.c semctl.c vadvise.c
+ ppoll.c sched.c sigqueue.c sigtimedwait.c sigwait.c sigwaitinfo.c \
+ statvfs.c swapon.c semctl.c vadvise.c
.if ${RUMPRUN} != "yes"
# modules with non-default implementations on at least one architecture:
@@ -359,7 +359,7 @@
MLINKS+=open.2 openat.2
MLINKS+=ntp_adjtime.2 ntp_gettime.2
MLINKS+=pathconf.2 fpathconf.2
-MLINKS+=poll.2 pollts.2
+MLINKS+=poll.2 pollts.2 poll.2 ppoll.2
MLINKS+=read.2 readv.2 read.2 pread.2 read.2 preadv.2
MLINKS+=readlink.2 readlinkat.2
MLINKS+=recv.2 recvfrom.2 recv.2 recvmsg.2 recv.2 recvmmsg.2
diff -r 46be9b80a8f7 -r 356b6153396f lib/libc/sys/poll.2
--- a/lib/libc/sys/poll.2 Fri Jul 17 15:24:03 2020 +0000
+++ b/lib/libc/sys/poll.2 Fri Jul 17 15:34:16 2020 +0000
@@ -1,6 +1,6 @@
-.\" $NetBSD: poll.2,v 1.30 2019/05/06 06:56:36 wiz Exp $
+.\" $NetBSD: poll.2,v 1.31 2020/07/17 15:34:17 kamil Exp $
.\"
-.\" Copyright (c) 1998, 2005 The NetBSD Foundation, Inc.
+.\" Copyright (c) 1998, 2005, 2020 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,11 +27,11 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 5, 2019
+.Dd May 25, 2020
.Dt POLL 2
.Os
.Sh NAME
-.Nm poll, pollts
+.Nm poll, pollts, ppoll
.Nd synchronous I/O multiplexing
.Sh LIBRARY
.Lb libc
@@ -44,10 +44,16 @@
.In time.h
.Ft int
.Fn pollts "struct pollfd * restrict fds" "nfds_t nfds" "const struct timespec * restrict ts" "const sigset_t * restrict sigmask"
+.In poll.h
+.In signal.h
+.In time.h
+.Ft int
+.Fn ppoll "struct pollfd * restrict fds" "nfds_t nfds" "const struct timespec * restrict ts" "const sigset_t * restrict sigmask"
.Sh DESCRIPTION
-.Fn poll
+.Fn poll ,
+.Fn pollts
and
-.Fn pollts
+.Fn ppoll
examine a set of file descriptors to see if some of them are ready for
I/O.
The
@@ -161,17 +167,23 @@
.Fa ts
is a null pointer,
.Fn pollts
+and
+.Fn ppoll
blocks indefinitely.
If
.Fa ts
is a non-null pointer, referencing a zero-valued timespec structure, then
.Fn pollts
+and
+.Fn ppoll
will return without blocking.
.Pp
If
.Fa sigmask
is a non-null pointer, then the
.Fn pollts
+and
+.Fn ppoll
function shall replace the signal mask of the caller by the set of
signals pointed to by
.Fa sigmask
@@ -206,6 +218,12 @@
bitmask.
Attempting to perform I/O on this descriptor will then return an error.
This behaviour is believed to be more useful.
+.Pp
+The
+.Fn ppoll
+function is an wrapper for
+.Fn pollts
+to provide compatiblity with the Linux implementation.
.Sh ERRORS
An error return from
.Fn poll
@@ -239,6 +257,10 @@
.Fn pollts
function first appeared in
.Nx 3.0 .
+The
+.Fn ppoll
+function first appeared in
+.Nx 10.0 .
.Sh BUGS
The distinction between some of the fields in the
.Fa events
diff -r 46be9b80a8f7 -r 356b6153396f lib/libc/sys/ppoll.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/sys/ppoll.c Fri Jul 17 15:34:16 2020 +0000
@@ -0,0 +1,46 @@
+/* $NetBSD: ppoll.c,v 1.1 2020/07/17 15:34:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Apurva Nandan.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: ppoll.c,v 1.1 2020/07/17 15:34:17 kamil Exp $");
+
+#include "namespace.h"
+#include <sys/poll.h>
+#include <sys/time.h>
+
+int
+ppoll(struct pollfd * restrict fds, nfds_t nfds,
+ const struct timespec * restrict timeout_ts,
+ const sigset_t * restrict sigmask)
+{
+
+ return pollts(fds, nfds, timeout_ts, sigmask);
+}
diff -r 46be9b80a8f7 -r 356b6153396f sys/sys/poll.h
--- a/sys/sys/poll.h Fri Jul 17 15:24:03 2020 +0000
+++ b/sys/sys/poll.h Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: poll.h,v 1.15 2009/11/11 09:48:51 rmind Exp $ */
+/* $NetBSD: poll.h,v 1.16 2020/07/17 15:34:16 kamil Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -92,6 +92,8 @@
int pollts(struct pollfd * __restrict, nfds_t,
const struct timespec * __restrict, const sigset_t * __restrict)
__RENAME(__pollts50);
+int ppoll(struct pollfd * __restrict, nfds_t,
+ const struct timespec * __restrict, const sigset_t * __restrict);
#endif /* __LIBC12_SOURCE__ */
__END_DECLS
#endif /* _NETBSD_SOURCE */
diff -r 46be9b80a8f7 -r 356b6153396f tests/lib/libc/sys/Makefile
--- a/tests/lib/libc/sys/Makefile Fri Jul 17 15:24:03 2020 +0000
+++ b/tests/lib/libc/sys/Makefile Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.65 2020/06/17 22:07:21 rin Exp $
+# $NetBSD: Makefile,v 1.66 2020/07/17 15:34:16 kamil Exp $
MKMAN= no
@@ -53,7 +53,9 @@
TESTS_C+= t_pipe
TESTS_C+= t_pipe2
TESTS_C+= t_poll
+TESTS_C+= t_pollts
TESTS_C+= t_posix_fallocate
+TESTS_C+= t_ppoll
TESTS_C+= t_ptrace
TESTS_C+= t_ptrace_sigchld
TESTS_C+= t_ptrace_wait
diff -r 46be9b80a8f7 -r 356b6153396f tests/lib/libc/sys/t_poll.c
--- a/tests/lib/libc/sys/t_poll.c Fri Jul 17 15:24:03 2020 +0000
+++ b/tests/lib/libc/sys/t_poll.c Fri Jul 17 15:34:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_poll.c,v 1.3 2012/03/18 07:00:52 jruoho Exp $ */
+/* $NetBSD: t_poll.c,v 1.4 2020/07/17 15:34:16 kamil Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -82,8 +82,8 @@
(void)printf("child3 exit\n");
}
-ATF_TC(poll_3way);
-ATF_TC_HEAD(poll_3way, tc)
+ATF_TC(3way);
+ATF_TC_HEAD(3way, tc)
{
Home |
Main Index |
Thread Index |
Old Index