From patchwork Mon Jun 29 00:32:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1318693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49w7jw3BRJz9sRk for ; Mon, 29 Jun 2020 10:32:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 25EEC388A80E; Mon, 29 Jun 2020 00:32:31 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id 0DF0A3840C0F for ; Mon, 29 Jun 2020 00:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0DF0A3840C0F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 52F3119AC; Mon, 29 Jun 2020 02:32:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bBwU-XqrgxMB; Mon, 29 Jun 2020 02:32:26 +0200 (CEST) Received: from function (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id E4B6119A5; Mon, 29 Jun 2020 02:32:25 +0200 (CEST) Received: from samy by function with local (Exim 4.94) (envelope-from ) id 1jphid-003KjZ-0p; Mon, 29 Jun 2020 02:32:19 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited 1/3] hurd: fix usleep(ULONG_MAX) Date: Mon, 29 Jun 2020 02:32:16 +0200 Message-Id: <20200629003218.794639-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629003218.794639-1-samuel.thibault@ens-lyon.org> References: <20200629003218.794639-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * sysdeps/mach/usleep.c (usleep): Clamp timeout when rouding up. --- sysdeps/mach/usleep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/mach/usleep.c b/sysdeps/mach/usleep.c index 530336ba0b..d53eb04a51 100644 --- a/sysdeps/mach/usleep.c +++ b/sysdeps/mach/usleep.c @@ -25,11 +25,15 @@ int usleep (useconds_t useconds) { mach_port_t recv; + useconds_t useconds_up = useconds + 999; + + if (useconds_up < useconds) + useconds_up = UINT32_MAX; recv = __mach_reply_port (); (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, - 0, 0, recv, (useconds + 999) / 1000, MACH_PORT_NULL); + 0, 0, recv, useconds_up / 1000, MACH_PORT_NULL); __mach_port_destroy (mach_task_self (), recv); return 0; From patchwork Mon Jun 29 00:32:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1318696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49w7k86ln5z9sQx for ; Mon, 29 Jun 2020 10:32:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42872388E82D; Mon, 29 Jun 2020 00:32:34 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by sourceware.org (Postfix) with ESMTPS id CA8733840C0F for ; Mon, 29 Jun 2020 00:32:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CA8733840C0F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id BC87F199E; Mon, 29 Jun 2020 02:32:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jz0O6uK5JsgW; Mon, 29 Jun 2020 02:32:28 +0200 (CEST) Received: from function (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 37A8219A6; Mon, 29 Jun 2020 02:32:26 +0200 (CEST) Received: from samy by function with local (Exim 4.94) (envelope-from ) id 1jphid-003Kjb-43; Mon, 29 Jun 2020 02:32:19 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited 2/3] hurd: Add remaining cancelation points Date: Mon, 29 Jun 2020 02:32:17 +0200 Message-Id: <20200629003218.794639-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629003218.794639-1-samuel.thibault@ens-lyon.org> References: <20200629003218.794639-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * hurd/hurdselect.c: Include . (_hurd_select): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/hurd/accept4.c: Include . (__libc_accept4): Surround call to __socket_accept with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/connect.c: Include . (__connect): Surround call to __file_name_lookup and __socket_connect with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/fdatasync.c: Include . (fdatasync): Surround call to __file_sync with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/fsync.c: Include . (fsync): Surround call to __file_sync with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/ioctl.c: Include . (__ioctl): When request is TIOCDRAIN, surround call to send_rpc with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/msync.c: Include . (msync): Surround call to __vm_object_sync with enabling async cancel. * sysdeps/mach/hurd/sigsuspend.c: Include . (__sigsuspend): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/hurd/sigwait.c: Include . (__sigwait): Surround wait code with enabling async cancel. * sysdeps/mach/msync.c: Include . (msync): Surround call to __vm_msync with enabling async cancel. * sysdeps/mach/sleep.c: Include . (__sleep): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/usleep.c: Include . (usleep): Surround call to __vm_msync with enabling async cancel. --- hurd/hurdselect.c | 5 +++++ sysdeps/mach/hurd/accept4.c | 7 ++++++- sysdeps/mach/hurd/connect.c | 11 +++++++++-- sysdeps/mach/hurd/fdatasync.c | 8 +++++++- sysdeps/mach/hurd/fsync.c | 8 +++++++- sysdeps/mach/hurd/ioctl.c | 11 ++++++++++- sysdeps/mach/hurd/msync.c | 4 ++++ sysdeps/mach/hurd/sigsuspend.c | 5 +++++ sysdeps/mach/hurd/sigwait.c | 4 ++++ sysdeps/mach/msync.c | 9 +++++++-- sysdeps/mach/sleep.c | 4 ++++ sysdeps/mach/usleep.c | 4 ++++ 12 files changed, 72 insertions(+), 8 deletions(-) diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c index 69a415c02c..8da0ccf282 100644 --- a/hurd/hurdselect.c +++ b/hurd/hurdselect.c @@ -28,6 +28,7 @@ #include #include #include +#include /* All user select types. */ #define SELECT_ALL (SELECT_READ | SELECT_WRITE | SELECT_URG) @@ -432,11 +433,14 @@ _hurd_select (int nfds, to = MACH_MSG_TIMEOUT_NONE; } + int cancel_oldtype = LIBC_CANCEL_ASYNC(); while ((msgerr = __mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_INTERRUPT | options, 0, sizeof msg, portset, to, MACH_PORT_NULL)) == MACH_MSG_SUCCESS) { + LIBC_CANCEL_RESET (cancel_oldtype); + /* We got a message. Decode it. */ #ifdef MACH_MSG_TYPE_BIT const union typeword inttype = @@ -527,6 +531,7 @@ _hurd_select (int nfds, options |= MACH_RCV_TIMEOUT; } } + LIBC_CANCEL_RESET (cancel_oldtype); if (msgerr == MACH_RCV_INTERRUPTED) /* Interruption on our side (e.g. signal reception). */ diff --git a/sysdeps/mach/hurd/accept4.c b/sysdeps/mach/hurd/accept4.c index 639f159951..2da7a8b032 100644 --- a/sysdeps/mach/hurd/accept4.c +++ b/sysdeps/mach/hurd/accept4.c @@ -24,6 +24,7 @@ #include #include #include +#include /* Await a connection on socket FD. When a connection arrives, open a new socket to communicate with it, @@ -41,13 +42,17 @@ __libc_accept4 (int fd, __SOCKADDR_ARG addrarg, socklen_t *addr_len, int flags) char *buf = (char *) addr; mach_msg_type_number_t buflen; int type; + int cancel_oldtype; flags = sock_to_o_flags (flags); if (flags & ~(O_CLOEXEC | O_NONBLOCK)) return __hurd_fail (EINVAL); - if (err = HURD_DPORT_USE (fd, __socket_accept (port, &new, &aport))) + cancel_oldtype = LIBC_CANCEL_ASYNC(); + err = HURD_DPORT_USE_CANCEL (fd, __socket_accept (port, &new, &aport)); + LIBC_CANCEL_RESET (cancel_oldtype); + if (err) return __hurd_dfail (fd, err); if (addr != NULL) diff --git a/sysdeps/mach/hurd/connect.c b/sysdeps/mach/hurd/connect.c index b9b9fddf8b..2b03b879aa 100644 --- a/sysdeps/mach/hurd/connect.c +++ b/sysdeps/mach/hurd/connect.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "hurd/hurdsocket.h" /* Open a connection on socket FD to peer at ADDR (which LEN bytes long). @@ -34,13 +35,17 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len) error_t err; addr_port_t aport; const struct sockaddr_un *addr = addrarg.__sockaddr_un__; + int cancel_oldtype; if (addr->sun_family == AF_LOCAL) { char *name = _hurd_sun_path_dupa (addr, len); /* For the local domain, we must look up the name as a file and talk to it with the ifsock protocol. */ - file_t file = __file_name_lookup (name, 0, 0); + file_t file; + cancel_oldtype = LIBC_CANCEL_ASYNC(); + file = __file_name_lookup (name, 0, 0); + LIBC_CANCEL_RESET (cancel_oldtype); if (file == MACH_PORT_NULL) return -1; err = __ifsock_getsockaddr (file, &aport); @@ -54,7 +59,7 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len) else err = EIEIO; - err = HURD_DPORT_USE (fd, + err = HURD_DPORT_USE_CANCEL (fd, ({ if (err) err = __socket_create_address (port, @@ -63,7 +68,9 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len) &aport); if (! err) { + cancel_oldtype = LIBC_CANCEL_ASYNC(); err = __socket_connect (port, aport); + LIBC_CANCEL_RESET (cancel_oldtype); __mach_port_deallocate (__mach_task_self (), aport); } diff --git a/sysdeps/mach/hurd/fdatasync.c b/sysdeps/mach/hurd/fdatasync.c index 797fcf6a88..8ccda0a0b3 100644 --- a/sysdeps/mach/hurd/fdatasync.c +++ b/sysdeps/mach/hurd/fdatasync.c @@ -19,12 +19,18 @@ #include #include #include +#include /* Make all changes done to FD's file data actually appear on disk. */ int fdatasync (int fd) { - error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 1)); + error_t err; + int cancel_oldtype; + + cancel_oldtype = LIBC_CANCEL_ASYNC(); + err = HURD_DPORT_USE_CANCEL (fd, __file_sync (port, 1, 1)); + LIBC_CANCEL_RESET (cancel_oldtype); if (err) { if (err == EOPNOTSUPP) diff --git a/sysdeps/mach/hurd/fsync.c b/sysdeps/mach/hurd/fsync.c index 85aa992db2..0b2a09dcf8 100644 --- a/sysdeps/mach/hurd/fsync.c +++ b/sysdeps/mach/hurd/fsync.c @@ -19,12 +19,18 @@ #include #include #include +#include /* Make all changes done to FD actually appear on disk. */ int fsync (int fd) { - error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 0)); + error_t err; + int cancel_oldtype; + + cancel_oldtype = LIBC_CANCEL_ASYNC(); + err = HURD_DPORT_USE_CANCEL (fd, __file_sync (port, 1, 0)); + LIBC_CANCEL_RESET (cancel_oldtype); if (err) { if (err == EOPNOTSUPP) diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c index a9a148f1e3..4c0e54b038 100644 --- a/sysdeps/mach/hurd/ioctl.c +++ b/sysdeps/mach/hurd/ioctl.c @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -269,7 +270,15 @@ __ioctl (int fd, unsigned long int request, ...) /* Marshal the arguments into the request message and make the RPC. This wrapper function handles EBACKGROUND returns, turning them into either SIGTTOU or EIO. */ - err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc)); + if (request == TIOCDRAIN) + { + /* This is a cancellation point. */ + int cancel_oldtype = LIBC_CANCEL_ASYNC(); + err = HURD_DPORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty, send_rpc)); + LIBC_CANCEL_RESET (cancel_oldtype); + } + else + err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc)); #ifdef MACH_MSG_TYPE_BIT t = (mach_msg_type_t *) msg.data; diff --git a/sysdeps/mach/hurd/msync.c b/sysdeps/mach/hurd/msync.c index cec467eb7f..1820190dbe 100644 --- a/sysdeps/mach/hurd/msync.c +++ b/sysdeps/mach/hurd/msync.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -44,6 +45,7 @@ msync (void *addr, size_t length, int flags) vm_offset_t offset; kern_return_t err; + int cancel_oldtype; if (flags & (MS_SYNC | MS_ASYNC) == (MS_SYNC | MS_ASYNC)) return __hurd_fail (EINVAL); @@ -77,8 +79,10 @@ msync (void *addr, size_t length, int flags) else sync_len = len; + cancel_oldtype = LIBC_CANCEL_ASYNC(); err = __vm_object_sync (obj, cur - begin + offset, sync_len, should_flush, 1, should_iosync); + LIBC_CANCEL_RESET (cancel_oldtype); __mach_port_deallocate (__mach_task_self (), obj); if (err) diff --git a/sysdeps/mach/hurd/sigsuspend.c b/sysdeps/mach/hurd/sigsuspend.c index 38f095ef09..ed98104dce 100644 --- a/sysdeps/mach/hurd/sigsuspend.c +++ b/sysdeps/mach/hurd/sigsuspend.c @@ -20,6 +20,7 @@ #include #include #include +#include /* Change the set of blocked signals to SET, wait until a signal arrives, and restore the set of blocked signals. */ @@ -30,6 +31,7 @@ __sigsuspend (const sigset_t *set) sigset_t newmask, oldmask, pending; mach_port_t wait; mach_msg_header_t msg; + int cancel_oldtype; if (set != NULL) /* Crash before locking. */ @@ -59,8 +61,11 @@ __sigsuspend (const sigset_t *set) __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); /* Wait for the signal thread's message. */ + + cancel_oldtype = LIBC_CANCEL_ASYNC(); __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + LIBC_CANCEL_RESET (cancel_oldtype); __mach_port_destroy (__mach_task_self (), wait); /* Restore the old mask and check for pending signals again. */ diff --git a/sysdeps/mach/hurd/sigwait.c b/sysdeps/mach/hurd/sigwait.c index 53d2110983..48ccaf05fe 100644 --- a/sysdeps/mach/hurd/sigwait.c +++ b/sysdeps/mach/hurd/sigwait.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Select any of pending signals from SET or wait for any to arrive. */ int @@ -33,6 +34,7 @@ __sigwait (const sigset_t *set, int *sig) jmp_buf buf; mach_port_t wait; mach_msg_header_t msg; + int cancel_oldtype; sighandler_t preempt_fun (struct hurd_signal_preemptor *pe, @@ -71,6 +73,7 @@ __sigwait (const sigset_t *set, int *sig) __sigemptyset (&mask); ss = _hurd_self_sigstate (); + cancel_oldtype = LIBC_CANCEL_ASYNC(); _hurd_sigstate_lock (ss); /* See if one of these signals is currently pending. */ @@ -128,6 +131,7 @@ __sigwait (const sigset_t *set, int *sig) all_done: _hurd_sigstate_unlock (ss); + LIBC_CANCEL_RESET (cancel_oldtype); __mach_port_destroy (__mach_task_self (), wait); *sig = signo; diff --git a/sysdeps/mach/msync.c b/sysdeps/mach/msync.c index e36a564ef4..f72222b57b 100644 --- a/sysdeps/mach/msync.c +++ b/sysdeps/mach/msync.c @@ -20,6 +20,7 @@ #include #include #include +#include /* Some Mach variants have vm_msync and some don't. Those that have it define the VM_SYNC_* bits when we include . */ @@ -37,6 +38,7 @@ msync (void *addr, size_t len, int flags) { vm_sync_t sync_flags = 0; kern_return_t err; + int cancel_oldtype; if (flags & MS_SYNC) sync_flags |= VM_SYNC_SYNCHRONOUS; @@ -45,8 +47,11 @@ msync (void *addr, size_t len, int flags) if (flags & MS_INVALIDATE) sync_flags |= VM_SYNC_INVALIDATE; - if (err = __vm_msync (__mach_task_self (), - (vm_address_t) addr, (vm_size_t) len, sync_flags)) + cancel_oldtype = LIBC_CANCEL_ASYNC(); + err = __vm_msync (__mach_task_self (), + (vm_address_t) addr, (vm_size_t) len, sync_flags); + LIBC_CANCEL_RESET (cancel_oldtype); + if (err) { errno = err; return -1; diff --git a/sysdeps/mach/sleep.c b/sysdeps/mach/sleep.c index de58bd18c4..9de9de1ae9 100644 --- a/sysdeps/mach/sleep.c +++ b/sysdeps/mach/sleep.c @@ -19,6 +19,7 @@ #include #include #include +#include /* Make the process sleep for SECONDS seconds, or until a signal arrives and is not ignored. The function returns the number of seconds less @@ -30,12 +31,15 @@ __sleep (unsigned int seconds) { time_t before, after; mach_port_t recv; + int cancel_oldtype; recv = __mach_reply_port (); before = time_now (); + cancel_oldtype = LIBC_CANCEL_ASYNC(); (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, 0, 0, recv, seconds * 1000, MACH_PORT_NULL); + LIBC_CANCEL_RESET (cancel_oldtype); after = time_now (); __mach_port_destroy (__mach_task_self (), recv); diff --git a/sysdeps/mach/usleep.c b/sysdeps/mach/usleep.c index d53eb04a51..75514b2e35 100644 --- a/sysdeps/mach/usleep.c +++ b/sysdeps/mach/usleep.c @@ -19,12 +19,14 @@ #include #include #include +#include /* Sleep USECONDS microseconds, or until a previously set timer goes off. */ int usleep (useconds_t useconds) { mach_port_t recv; + int cancel_oldtype; useconds_t useconds_up = useconds + 999; if (useconds_up < useconds) @@ -32,8 +34,10 @@ usleep (useconds_t useconds) recv = __mach_reply_port (); + cancel_oldtype = LIBC_CANCEL_ASYNC(); (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, 0, 0, recv, useconds_up / 1000, MACH_PORT_NULL); + LIBC_CANCEL_RESET (cancel_oldtype); __mach_port_destroy (mach_task_self (), recv); return 0; From patchwork Mon Jun 29 00:32:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1318695 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49w7k6111lz9sRk for ; Mon, 29 Jun 2020 10:32:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD3E9388E81C; Mon, 29 Jun 2020 00:32:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by sourceware.org (Postfix) with ESMTPS id 6C6BE388A80E for ; Mon, 29 Jun 2020 00:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6C6BE388A80E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 4C80719A5; Mon, 29 Jun 2020 02:32:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CzIMrZBmPQOe; Mon, 29 Jun 2020 02:32:27 +0200 (CEST) Received: from function (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 3B24119A9; Mon, 29 Jun 2020 02:32:26 +0200 (CEST) Received: from samy by function with local (Exim 4.94) (envelope-from ) id 1jphid-003Kjd-8J; Mon, 29 Jun 2020 02:32:19 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited 3/3] htl: Enable cancel*16 an cancel*20 tests Date: Mon, 29 Jun 2020 02:32:18 +0200 Message-Id: <20200629003218.794639-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629003218.794639-1-samuel.thibault@ens-lyon.org> References: <20200629003218.794639-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * nptl/tst-cancel16.c, tst-cancel20.c, tst-cancelx16.c, tst-cancelx20.c: Move to... * sysdeps/pthread: ... here. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here. * sysdeps/mach/hurd/i386/Makefile: Xfail tst-cancel*16 for now: missing barrier pshared support, but test should be working otherwise. --- nptl/Makefile | 9 ++------- sysdeps/mach/hurd/i386/Makefile | 2 ++ sysdeps/pthread/Makefile | 11 +++++++---- {nptl => sysdeps/pthread}/tst-cancel16.c | 0 {nptl => sysdeps/pthread}/tst-cancel20.c | 0 {nptl => sysdeps/pthread}/tst-cancelx16.c | 0 {nptl => sysdeps/pthread}/tst-cancelx20.c | 0 7 files changed, 11 insertions(+), 11 deletions(-) rename {nptl => sysdeps/pthread}/tst-cancel16.c (100%) rename {nptl => sysdeps/pthread}/tst-cancel20.c (100%) rename {nptl => sysdeps/pthread}/tst-cancelx16.c (100%) rename {nptl => sysdeps/pthread}/tst-cancelx20.c (100%) diff --git a/nptl/Makefile b/nptl/Makefile index 4602824bf1..5e62c77853 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -278,8 +278,7 @@ tests = tst-attr2 tst-attr3 tst-default-attr \ tst-sem17 \ tst-tsd3 tst-tsd4 \ tst-cancel4 tst-cancel4_1 tst-cancel4_2 tst-cancel5 \ - tst-cancel7 \ - tst-cancel16 tst-cancel17 tst-cancel20 tst-cancel24 \ + tst-cancel7 tst-cancel17 tst-cancel24 \ tst-cleanup4 \ tst-signal3 \ tst-exec4 tst-exec5 \ @@ -357,9 +356,7 @@ endif LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst -tests += tst-cancelx4 tst-cancelx5 tst-cancelx7 \ - tst-cancelx16 tst-cancelx17 tst-cancelx20 \ - tst-cleanupx4 +tests += tst-cancelx4 tst-cancelx5 tst-cancelx7 tst-cancelx17 tst-cleanupx4 ifeq ($(build-shared),yes) tests += tst-compat-forwarder tst-audit-threads @@ -476,9 +473,7 @@ CFLAGS-tst-cancelx5.c += -Wno-error CFLAGS-tst-cancelx4.c += -fexceptions CFLAGS-tst-cancelx5.c += -fexceptions CFLAGS-tst-cancelx7.c += -fexceptions -CFLAGS-tst-cancelx16.c += -fexceptions CFLAGS-tst-cancelx17.c += -fexceptions -CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-tst-cleanupx4.c += -fexceptions CFLAGS-tst-cleanupx4aux.c += -fexceptions CFLAGS-tst-initializers1.c += -W -Wall -Werror diff --git a/sysdeps/mach/hurd/i386/Makefile b/sysdeps/mach/hurd/i386/Makefile index a67fe5d393..daeb85ba4f 100644 --- a/sysdeps/mach/hurd/i386/Makefile +++ b/sysdeps/mach/hurd/i386/Makefile @@ -107,6 +107,8 @@ ifeq ($(subdir),htl) # For bug 25521 # (setpshared support) test-xfail-tst-mutex4 = yes +test-xfail-tst-cancel16 = yes +test-xfail-tst-cancelx16 = yes test-xfail-tst-cond4 = yes test-xfail-tst-cond6 = yes test-xfail-tst-cond12 = yes diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index ed31ae8f4f..920d875420 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -55,8 +55,8 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \ tst-cancel-self-canceltype tst-cancel-self-testcancel \ tst-cancel1 tst-cancel2 tst-cancel3 \ tst-cancel6 tst-cancel8 tst-cancel9 tst-cancel10 tst-cancel11 \ - tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 tst-cancel18 \ - tst-cancel19 tst-cancel21 \ + tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 tst-cancel16 \ + tst-cancel18 tst-cancel19 tst-cancel20 tst-cancel21 \ tst-cancel22 tst-cancel23 tst-cancel26 tst-cancel27 tst-cancel28 \ tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \ tst-clock1 \ @@ -118,7 +118,7 @@ CFLAGS-tst-cleanupx2.c += -fno-builtin tests += tst-cancelx2 tst-cancelx3 tst-cancelx6 tst-cancelx8 tst-cancelx9 \ tst-cancelx10 tst-cancelx11 tst-cancelx12 tst-cancelx13 tst-cancelx14 \ - tst-cancelx15 tst-cancelx18 tst-cancelx21 \ + tst-cancelx15 tst-cancelx16 tst-cancelx18 tst-cancelx20 tst-cancelx21 \ tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 ifeq ($(build-shared),yes) @@ -137,7 +137,8 @@ ifeq ($(build-shared),yes) tests: $(test-modules) endif -tests-static += tst-locale1 tst-locale2 tst-cancel21-static \ + +tests-static += tst-locale1 tst-locale2 tst-cancel21-static tests += tst-cancel21-static tst-cond11-static @@ -163,7 +164,9 @@ CFLAGS-tst-cancelx12.c += -fexceptions CFLAGS-tst-cancelx13.c += -fexceptions CFLAGS-tst-cancelx14.c += -fexceptions CFLAGS-tst-cancelx15.c += -fexceptions +CFLAGS-tst-cancelx16.c += -fexceptions CFLAGS-tst-cancelx18.c += -fexceptions +CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-tst-cancelx21.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-tst-cleanupx0.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-tst-cleanupx1.c += -fexceptions -fasynchronous-unwind-tables diff --git a/nptl/tst-cancel16.c b/sysdeps/pthread/tst-cancel16.c similarity index 100% rename from nptl/tst-cancel16.c rename to sysdeps/pthread/tst-cancel16.c diff --git a/nptl/tst-cancel20.c b/sysdeps/pthread/tst-cancel20.c similarity index 100% rename from nptl/tst-cancel20.c rename to sysdeps/pthread/tst-cancel20.c diff --git a/nptl/tst-cancelx16.c b/sysdeps/pthread/tst-cancelx16.c similarity index 100% rename from nptl/tst-cancelx16.c rename to sysdeps/pthread/tst-cancelx16.c diff --git a/nptl/tst-cancelx20.c b/sysdeps/pthread/tst-cancelx20.c similarity index 100% rename from nptl/tst-cancelx20.c rename to sysdeps/pthread/tst-cancelx20.c