posix: Add npth_poll/npth_ppoll
posix: Add npth_poll/npth_ppoll Signed-off-by: EulerOSWander <314264452@qq.com>
This commit is contained in:
parent
8784a74280
commit
4a30b2e5ed
157
backport-0002-posix-Add-npth_poll-npth_ppoll.patch
Normal file
157
backport-0002-posix-Add-npth_poll-npth_ppoll.patch
Normal file
@ -0,0 +1,157 @@
|
||||
From b5ecd8d2c6fdb988f6139c5157c124ebea293bd7 Mon Sep 17 00:00:00 2001
|
||||
From: NIIBE Yutaka <gniibe@fsij.org>
|
||||
Date: Wed, 22 Dec 2021 09:52:44 +0900
|
||||
Subject: [PATCH 1/2] posix: Add npth_poll/npth_ppoll.
|
||||
|
||||
* configure.ac: Add checks for poll.h and ppoll.
|
||||
|
||||
--
|
||||
|
||||
GnuPG-bug-id: 5748
|
||||
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
|
||||
Signed-off-by: EulerOSWander <314264452@qq.com>
|
||||
---
|
||||
|
||||
configure.ac | 6 ++---
|
||||
src/npth.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
src/npth.h.in | 5 +++++
|
||||
3 files changed, 78 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 3d76661..cf8bb0e 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
-AC_PREREQ([2.67])
|
||||
+AC_PREREQ([2.69])
|
||||
min_automake_version="1.14"
|
||||
|
||||
# To build a release you need to create a tag with the version number
|
||||
@@ -198,7 +198,7 @@ AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
|
||||
#
|
||||
# fixme: For what do we need the sys/socket test?
|
||||
AC_CHECK_HEADERS([sys/socket.h sys/select.h unistd.h sys/time.h time.h \
|
||||
- signal.h])
|
||||
+ signal.h poll.h])
|
||||
INSERT_SYS_SELECT_H=
|
||||
if test x"$ac_cv_header_sys_select_h" = xyes; then
|
||||
INSERT_SYS_SELECT_H="include <sys/select.h>"
|
||||
@@ -277,7 +277,7 @@ if test "$have_w32_system" = no; then
|
||||
fi
|
||||
fi
|
||||
|
||||
-AC_CHECK_FUNCS([select pselect gettimeofday])
|
||||
+AC_CHECK_FUNCS([select pselect gettimeofday ppoll])
|
||||
|
||||
npth_LIBSOCKET
|
||||
config_libs="$config_libs $LIBSOCKET"
|
||||
diff --git a/src/npth.c b/src/npth.c
|
||||
index 45ca7ee..22314a6 100644
|
||||
--- a/src/npth.c
|
||||
+++ b/src/npth.c
|
||||
@@ -71,6 +71,9 @@ sem_wait (sem_t *sem)
|
||||
#ifndef HAVE_PSELECT
|
||||
# include <signal.h>
|
||||
#endif
|
||||
+#ifdef HAVE_POLL_H
|
||||
+#include <poll.h>
|
||||
+#endif
|
||||
|
||||
#include "npth.h"
|
||||
|
||||
@@ -675,6 +678,73 @@ npth_pselect(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
}
|
||||
|
||||
|
||||
+int
|
||||
+npth_poll (struct pollfd *fds, unsigned long nfds, int timeout)
|
||||
+{
|
||||
+ int res;
|
||||
+
|
||||
+ ENTER();
|
||||
+#ifdef HAVE_POLL_H
|
||||
+ res = poll (fds, (nfds_t)nfds, timeout);
|
||||
+#endif
|
||||
+ LEAVE();
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+int
|
||||
+npth_ppoll (struct pollfd *fds, unsigned long nfds,
|
||||
+ const struct timespec *timeout, const sigset_t *sigmask)
|
||||
+{
|
||||
+ int res;
|
||||
+
|
||||
+ ENTER();
|
||||
+#ifdef HAVE_POLL_H
|
||||
+#ifdef HAVE_PPOLL
|
||||
+ res = ppoll (fds, (nfds_t)nfds, timeout, sigmask);
|
||||
+#else /*!HAVE_PPOLL*/
|
||||
+ {
|
||||
+# ifdef __GNUC__
|
||||
+# warning Using a non race free ppoll emulation.
|
||||
+# endif
|
||||
+
|
||||
+ int t;
|
||||
+
|
||||
+ if (!timeout)
|
||||
+ t = -1;
|
||||
+ else if (timeout->tv_nsec >= 0 && timeout->tv_nsec < 1000000000)
|
||||
+ t = timeout->tv_sec * 1000 + (timeout->tv_nsec + 999999) / 1000000;
|
||||
+ else
|
||||
+ {
|
||||
+ errno = EINVAL;
|
||||
+ res = -1;
|
||||
+ goto leave;
|
||||
+ }
|
||||
+
|
||||
+ if (sigmask)
|
||||
+ {
|
||||
+ int save_errno;
|
||||
+ sigset_t savemask;
|
||||
+
|
||||
+ pthread_sigmask (SIG_SETMASK, sigmask, &savemask);
|
||||
+ res = poll (fds, (nfds_t)nfds, timeout);
|
||||
+ save_errno = errno;
|
||||
+ pthread_sigmask (SIG_SETMASK, &savemask, NULL);
|
||||
+ errno = save_errno;
|
||||
+ }
|
||||
+ else
|
||||
+ res = poll (fds, (nfds_t)nfds, timeout);
|
||||
+
|
||||
+ leave:
|
||||
+ ;
|
||||
+ }
|
||||
+#endif
|
||||
+#endif
|
||||
+ LEAVE();
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+
|
||||
ssize_t
|
||||
npth_read(int fd, void *buf, size_t nbytes)
|
||||
{
|
||||
diff --git a/src/npth.h.in b/src/npth.h.in
|
||||
index 39dcf32..db57935 100644
|
||||
--- a/src/npth.h.in
|
||||
+++ b/src/npth.h.in
|
||||
@@ -345,6 +345,11 @@ ssize_t npth_write(int fd, const void *buf, size_t nbytes);
|
||||
int npth_recvmsg (int fd, struct msghdr *msg, int flags);
|
||||
int npth_sendmsg (int fd, const struct msghdr *msg, int flags);
|
||||
|
||||
+struct pollfd;
|
||||
+int npth_poll (struct pollfd *fds, unsigned long nfds, int timeout);
|
||||
+int npth_ppoll (struct pollfd *fds, unsigned long nfds,
|
||||
+ const struct timespec *timeout, const sigset_t *sigmask);
|
||||
+
|
||||
/* For anything not covered here, you can enter/leave manually at your
|
||||
own risk. */
|
||||
void npth_unprotect (void);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: npth
|
||||
Version: 1.6
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: The New GNU Portable Threads library
|
||||
License: LGPLv2+
|
||||
URL: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=npth.git
|
||||
@ -21,7 +21,8 @@ stack, signal mask and errno variable.
|
||||
Summary: Development files for %{name}
|
||||
Patch6000: backport-0001-w32-Use-cast-by-uintptr_t-for-thread-ID.patch
|
||||
Patch6001: add-test-cases.patch
|
||||
|
||||
Patch6002: backport-0002-posix-Add-npth_poll-npth_ppoll.patch
|
||||
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
@ -61,6 +62,9 @@ make check
|
||||
%{_datadir}/aclocal/%{name}.m4
|
||||
|
||||
%changelog
|
||||
* Thu Mar 10 2022 EulerOSWander <314264452@qq.com> - 1.6-5
|
||||
- DESC: posix: Add npth_poll/npth_ppoll
|
||||
|
||||
* Tue Mar 1 2022 yaowenbinHW <yaowenbin@huawei.com> - 1.6-4
|
||||
- DESC: add test cases
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user