From patchwork Fri Aug 14 18:36:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 141437 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DCEF4BA79A2 for ; Fri, 14 Aug 2026 18:37:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DCEF4BA79A2 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=VMf77YuZ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by sourceware.org (Postfix) with ESMTPS id C97514BA2E09 for ; Fri, 14 Aug 2026 18:36:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C97514BA2E09 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=igalia.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C97514BA2E09 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786732612; cv=none; b=Tx7R4DdKEcGhq9fvRsEbSvAa3Mqhk5svxboouT934sdQjZt8wPv1yMaY7hWH2dkQYaSehnas4xc5aHjRLYvS0mU4PpvvzGHqJinyMFvYc5rg88tG9HDJmpSwMt1IBnAEf70LWMHzIAhZwhe1JzdNuDaqewJAcYFZTedQp8avxlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786732612; c=relaxed/simple; bh=Omrw66q/CwUJ0FE3dDot2jYVBVl5pwie0VNyihf0kRU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jPknO1qc5vlGy1/++9phmvyokf7n40EN6srnTHaMLNfs8k9n/12k1mD3xHRuiXfMUUnDy+U52Si7ROOf828MBHiXBIYCaSv541lFtnoCk94nHyyO7fY9LF+kdbmvu0t494br/6kFEsKTOqYqYWw8C/l00ORs3EdUw4aew5w7dt0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=VMf77YuZ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C97514BA2E09 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:From:Reply-To; bh=8/053y49ukQZomjt+gIbsnSrX2NNLfEdhI9UZlxEzyw=; b=VMf77YuZmYnfqgRrNfkPauWecV svIYET4OU/JXZoLhKkNzTgCXPV2IvZiC4z19xMDW022i2EhhAgERMc0Ht4O7bEGhFnApQ3nxpy2FT 5SJDsfOUTRLo68tGF9V+xS7w9Ollr1/3f8I0hUTdnZWnBNpRUo3w+KWX1yD8XjneEfhpdPDCtB8or tLdQ+IDMgIK5zC76ppi/EZgTk+ml764rDf/lnszAM9zM+7eCeZ8kxcD8h3mwCgE8WJf9KZ9Aj+m2g hoiFz+Txp2zPhcU5CrcN2BM9YGCaWm8CQOcAqvWT6fIw90T+3lq5yoS/psMHmqWDS+j/DVIeWAxlY /JC2ckYw==; Received: from [177.139.22.20] (helo=computador) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wuwlu-001xOF-5G; Fri, 14 Aug 2026 20:36:50 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: libc-alpha@sourceware.org, carlos@redhat.com, adhemerval.zanella@linaro.org Cc: =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH 1/2] Linux: Add futex_waitv Date: Fri, 14 Aug 2026 15:36:11 -0300 Message-ID: <20260814183612.1780736-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260814183612.1780736-1-andrealmeid@igalia.com> References: <20260814183612.1780736-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org This syscall can wait on multiple futexes at the same time, and wake up on any. Signed-off-by: André Almeida --- include/sys/futex.h | 4 ++++ sysdeps/unix/sysv/linux/Makefile | 2 ++ sysdeps/unix/sysv/linux/futex_waitv.c | 32 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/sys/futex.h | 24 ++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 include/sys/futex.h create mode 100644 sysdeps/unix/sysv/linux/futex_waitv.c create mode 100644 sysdeps/unix/sysv/linux/sys/futex.h diff --git a/include/sys/futex.h b/include/sys/futex.h new file mode 100644 index 0000000000..8f0f56c58c --- /dev/null +++ b/include/sys/futex.h @@ -0,0 +1,4 @@ +#ifndef _SYS_FUTEX_H +#include_next + +#endif diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 14a56d5cc3..d3ccb57b59 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -74,6 +74,7 @@ sysdep_routines += \ eventfd_read \ eventfd_write \ fanotify_mark \ + futex_waitv \ fxstat \ fxstat64 \ fxstatat \ @@ -169,6 +170,7 @@ sysdep_headers += \ sys/eventfd.h \ sys/fanotify.h \ sys/fsuid.h \ + sys/futex.h \ sys/inotify.h \ sys/kd.h \ sys/klog.h \ diff --git a/sysdeps/unix/sysv/linux/futex_waitv.c b/sysdeps/unix/sysv/linux/futex_waitv.c new file mode 100644 index 0000000000..b77df2f2cd --- /dev/null +++ b/sysdeps/unix/sysv/linux/futex_waitv.c @@ -0,0 +1,32 @@ +/* futex_waitv -- Wait on multiple futexes. Linux version. + Copyright (C) 2020-2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +int +futex_waitv (struct futex_waitv *waiters, unsigned int nr_waiters, + unsigned int flags, const struct __timespec64 *timeout, + clockid_t clockid) +{ + return SYSCALL_CANCEL (futex_waitv, waiters, nr_waiters, flags, &timeout, clockid); +} diff --git a/sysdeps/unix/sysv/linux/sys/futex.h b/sysdeps/unix/sysv/linux/sys/futex.h new file mode 100644 index 0000000000..89780e9e5a --- /dev/null +++ b/sysdeps/unix/sysv/linux/sys/futex.h @@ -0,0 +1,24 @@ +#ifndef _SYS_FUTEX_H +#define _SYS_FUTEX_H 1 + +#include +#include +#include + +#define FUTEX2_SIZE_U8 0x00 +#define FUTEX2_SIZE_U16 0x01 +#define FUTEX2_SIZE_U32 0x02 +#define FUTEX2_SIZE_U64 0x03 + +struct futex_waitv { + uint64_t val; + uint64_t uaddr; + uint32_t flags; + uint32_t __reserved; +}; + +extern int +futex_waitv (struct futex_waitv *waiters, unsigned int nr_waiters, + unsigned int flags, const struct __timespec64 *timeout, + clockid_t clockid); +#endif