From patchwork Wed Dec 16 00:59:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 41432 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB446385041E; Wed, 16 Dec 2020 00:59:53 +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 1D95F386102D for ; Wed, 16 Dec 2020 00:59:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1D95F386102D 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 2DF931543; Wed, 16 Dec 2020 01:59:50 +0100 (CET) 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 MEM6TwWYZmjl; Wed, 16 Dec 2020 01:59:49 +0100 (CET) Received: from function.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 9A602156A; Wed, 16 Dec 2020 01:59:46 +0100 (CET) Received: from samy by function.youpi.perso.aquilenet.fr with local (Exim 4.94) (envelope-from ) id 1kpLAP-00CyMK-1d; Wed, 16 Dec 2020 01:59:45 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited 3/7] hurd: Add __lll_abstimed_wait_intr Date: Wed, 16 Dec 2020 01:59:40 +0100 Message-Id: <20201216005944.3091900-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201216005944.3091900-1-samuel.thibault@ens-lyon.org> References: <20201216005944.3091900-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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" For semaphores, we need an interruptible version of low-level locks. --- hurd/Makefile | 1 + hurd/RPC_gsync_wait_intr.c | 4 ++++ hurd/Versions | 2 +- hurd/hurdlock.c | 11 +++++++++++ hurd/hurdlock.h | 16 ++++++++++++++++ mach/lowlevellock.h | 18 ++++++++++++++++++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 hurd/RPC_gsync_wait_intr.c diff --git a/hurd/Makefile b/hurd/Makefile index 861bbf7842..02b2456aa0 100644 --- a/hurd/Makefile +++ b/hurd/Makefile @@ -93,6 +93,7 @@ CFLAGS-RPC_exec_startup_get_info.o = $(no-stack-protector) # Make generated headers compatible with all support standards migheaderpipe := | sed -e 's/\/__ino64_t/' -e 's/\/__loff_t/' include ../mach/Machrules +libhurduser-routines += RPC_gsync_wait_intr include ../Rules # intr-rpc.defs defines the INTR_INTERFACE macro to make the generated RPC diff --git a/hurd/RPC_gsync_wait_intr.c b/hurd/RPC_gsync_wait_intr.c new file mode 100644 index 0000000000..51b63217d6 --- /dev/null +++ b/hurd/RPC_gsync_wait_intr.c @@ -0,0 +1,4 @@ +#include "intr-rpc.h" +#define gsync_wait gsync_wait_intr +#define __gsync_wait __gsync_wait_intr +#include "RPC_gsync_wait.c" diff --git a/hurd/Versions b/hurd/Versions index f37e359ac8..1aad27d91f 100644 --- a/hurd/Versions +++ b/hurd/Versions @@ -149,7 +149,7 @@ libc { GLIBC_PRIVATE { # Used by other libs. - __lll_abstimed_wait; __lll_abstimed_xwait; + __lll_abstimed_wait; __lll_abstimed_wait_intr; __lll_abstimed_xwait; __lll_abstimed_lock; __lll_robust_lock; __lll_robust_abstimed_lock; __lll_robust_trylock; __lll_robust_unlock; diff --git a/hurd/hurdlock.c b/hurd/hurdlock.c index 3b9974bee5..e2a5312036 100644 --- a/hurd/hurdlock.c +++ b/hurd/hurdlock.c @@ -54,6 +54,17 @@ __lll_abstimed_wait (void *ptr, int val, return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_wait (ptr, val, mlsec, flags); } +int +__lll_abstimed_wait_intr (void *ptr, int val, + const struct timespec *tsp, int flags, int clk) +{ + if (clk != CLOCK_REALTIME) + return EINVAL; + + int mlsec = compute_reltime (tsp, clk); + return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_wait_intr (ptr, val, mlsec, flags); +} + int __lll_abstimed_xwait (void *ptr, int lo, int hi, const struct timespec *tsp, int flags, int clk) diff --git a/hurd/hurdlock.h b/hurd/hurdlock.h index c1df42bea4..0a7f6eaf90 100644 --- a/hurd/hurdlock.h +++ b/hurd/hurdlock.h @@ -40,6 +40,11 @@ struct timespec; __gsync_wait (__mach_task_self (), \ (vm_offset_t)ptr, val, 0, mlsec, flags | GSYNC_TIMED) +/* Interruptible version. */ +#define __lll_timed_wait_intr(ptr, val, mlsec, flags) \ + __gsync_wait_intr (__mach_task_self (), \ + (vm_offset_t)ptr, val, 0, mlsec, flags | GSYNC_TIMED) + /* Same as '__lll_xwait', but only block for MLSEC milliseconds. */ #define __lll_timed_xwait(ptr, lo, hi, mlsec, flags) \ __gsync_wait (__mach_task_self (), (vm_offset_t)ptr, \ @@ -50,6 +55,10 @@ struct timespec; extern int __lll_abstimed_wait (void *__ptr, int __val, const struct timespec *__tsp, int __flags, int __clk); +/* Interruptible version. */ +extern int __lll_abstimed_wait_intr (void *__ptr, int __val, + const struct timespec *__tsp, int __flags, int __clk); + /* Same as 'lll_xwait', but only block until TSP elapses, using clock CLK. */ extern int __lll_abstimed_xwait (void *__ptr, int __lo, int __hi, @@ -106,6 +115,13 @@ extern void __lll_robust_unlock (void *__ptr, int __flags); __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]); \ }) +#define lll_abstimed_wait_intr(var, val, tsp, flags, ...) \ + ({ \ + const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ }; \ + __lll_abstimed_wait_intr (&(var), (val), (tsp), (flags), \ + __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]); \ + }) + #define lll_abstimed_xwait(var, lo, hi, tsp, flags, ...) \ ({ \ const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ }; \ diff --git a/mach/lowlevellock.h b/mach/lowlevellock.h index 0a22a030b4..b872d0fe1e 100644 --- a/mach/lowlevellock.h +++ b/mach/lowlevellock.h @@ -34,6 +34,17 @@ /* Static initializer for low-level locks. */ #define LLL_LOCK_INITIALIZER 0 +/* Interruptible version of __gsync_wait. */ +extern kern_return_t __gsync_wait_intr +( + mach_port_t task, + vm_offset_t addr, + unsigned val1, + unsigned val2, + natural_t msec, + int flags +); + /* Wait on address PTR, without blocking if its contents * are different from VAL. */ #define __lll_wait(ptr, val, flags) \ @@ -42,6 +53,13 @@ #define lll_wait(var, val, flags) \ __lll_wait (&(var), val, flags) +/* Interruptible version. */ +#define __lll_wait_intr(ptr, val, flags) \ + __gsync_wait_intr (__mach_task_self (), \ + (vm_offset_t)(ptr), (val), 0, 0, (flags)) +#define lll_wait_intr(var, val, flags) \ + __lll_wait_intr ((&var), val, flags) + /* Wake one or more threads waiting on address PTR. */ #define __lll_wake(ptr, flags) \ __gsync_wake (__mach_task_self (), (vm_offset_t)(ptr), 0, (flags))