From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GSckH3Qt/mpZ6h0AWB0awg (envelope-from ) for ; Wed, 18 Nov 2026 17:57:56 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=UMYsMg7x; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7B7101E0BC; Wed, 18 Nov 2026 17:57:56 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id EDB4E1E023 for ; Wed, 18 Nov 2026 17:57:55 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 128094BA23E0 for ; Wed, 18 Nov 2026 22:57:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 128094BA23E0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=UMYsMg7x Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by sourceware.org (Postfix) with ESMTPS id DCC544BA23DA for ; Wed, 18 Nov 2026 22:56:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCC544BA23DA Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DCC544BA23DA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795042582; cv=none; b=j2Y7xOVTCBeHa6Ki2wSWtYlowvbIkpwGIvx22VBWWtLVQXvK4aIZMYgwNOnp1vg8BOi5DG6zmxjwVkuuj7FNul4RGoSKUxqjKMTi0EJTPJPreqELIoIv1NDvUIHf3rA662N2OiFu5kqi1Kuavx4lZPMLfnjWKLlfWk6LgZDTU5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795042582; c=relaxed/simple; bh=eGWzfFdjKkDQISIBRvn0nmJh2ZZmj4vyjCl6QNgM0qM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JaYHGIL8LZlpxOQB01e3HiYVpiO4XsCdTwIE9h8qAVstmYpUuhl4njMntR5nbMq40wJb/B6slm4FGWLptyjGnWQp6IK1HwvZfvxeuGZPROf9JvGGA5aoEphsWrRC2epXLycGkOFzISR2PCOoLt6gtmFLm5TJBQgqd+6gLwK3E+Q= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=UMYsMg7x DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCC544BA23DA Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-702dedeb70dso1021157eaf.1 for ; Wed, 18 Nov 2026 14:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1795042581; x=1795647381; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L7+OszEZ6DrUrJQ8bnR6gww9/LpCB5bAShjdH3XJgLM=; b=UMYsMg7xWrmyQEPw96QqsJ4G3uubWmzr+Jr8WgZeyMnTRhchylTRk9+Qb1k8uqs/Jh lZa/hzyW+EOR0/06AUNZnCH/YRxo3PCpfwCRBMsqf4fkEl20E/rv3qRuBz4BZ4B/Vqw6 MQ8fUTqQUoGHcjwpiuY+DjgmR2bpYVn+XvF7Uc/7z97QpH7XV/RS2HsiWwmjLLbyhC9C v/z+xCCLsM/isC5XHucYNg7N7rwIjSzfuLT60qYhbldOHMVkLqxNS6BE7CsiR+DNFYSD KGcDQyFNT3dfdUJ5YqNznrQ02p1o4D7BlvoCrowSiAWLbY/LGbII58EXLroqraPtTGpc 2wDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795042581; x=1795647381; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=L7+OszEZ6DrUrJQ8bnR6gww9/LpCB5bAShjdH3XJgLM=; b=huEBbTmPcEun5FD2qgLPIq3MvpEEXL+RYkW5SBsIBcDod2kMXEv6Obr3popro1skNx Wj6IWzz4W7V0v4eNIR6FCM0of6z0IWuICoDTwK3mAPPyVCWOF2incmJUMVNfOOmIZ8Mo rGLpj2oyWreKOhMFIbxzWN+mdc72GKvz4NhzJAGsVAj5PeMzfvCnpABuaoMuNbAiNE4R ZMFg8xCHjHMD/UeFPS0d5RlVT7J/wm4Mao5SGimrS8v11xoBs9wUjYFWL2fSQv55HAUG DlH0UD+5YaKurQei79e6PsKP+J3fEBTWj6LkrQ4gzrNp9dUxOU5nD+cJWYs8KbuIHleb IT7A== X-Gm-Message-State: APuU4Z9G0ppVCQuuY+SU9sJKgsvIbwi8WgyihNIEKtykgpPq1mx2Zfka TiUtqmNZE7maNbhIuClgm61qs05TUNwSx2TLo0zN5d0vnW+vPSEEsVZXkNHnyZeNtRTH+F47kdd zEBPgjw== X-Gm-Gg: AYBFou1iebJxKqvYbU62aXziUBDlpOe3NRG+xVqR0oXUR/lAvnpq04honhQuvz2Dxit 13rC6P59yZfXJT8s8LbNUdFv8WBG90nSWkQMhpDWD/WQ3jB5hSof0eOpNq2GRWkIFGA6rDXv6Ox Ekq2/lB3KNGlgpq/PDJQM1FhhqASpxkGprKRTI2AKyWannzWkYH+Z0OgyI8MbiuWovihTK198AG SOW31tfdue2F7zOghwHg9i6qsjXr7v8hFHP9uKp240scL4XHhPiF7o8ohNj++mgt03cbihRy0XD Cm3uQY11ja2/9AubRkRRj6+fVMiO/R2ubMEcwgKCdkxp1sxgNIjC0I9zdDv0DRJpl5vzBhWKVmT ohLzipT+EQcOmeUuSFXnh4+cOvQNGHZ7kMNku0DpBUsNnYECJa/JQZj/zNyIlAf7GvWr1bD9Arp 3xNDyyHJixyKErdM9Lz5hYRZu/iTggUB3vXxq1UnfRKiLLHc2QCmaalSx/ZNNWU+idqJ4eakn/3 L+EMmix6XFGM2tvEW3HthKzOkuL1LNX5oXNU9vRyVGD9D8aakKI5VEBNmCsHTjYRbu2B4eSEXsz cqQTMhYW67e7reuwWML/nF9okjZNE0zdsHdWbGRW3ZdATYAexhaXC9sW6dHkZHBNTyu7BIOdI1O MdmagLHo= X-Received: by 2002:a05:6820:5718:10b0:71a:facc:5a3b with SMTP id 006d021491bc7-71b1864e6admr2244572eaf.83.1795042581260; Wed, 18 Nov 2026 14:56:21 -0800 (PST) Received: from [192.168.0.26] (97-122-110-129.hlrn.qwest.net. [97.122.110.129]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-862f01d4764sm2986263a34.5.2026.11.18.14.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 14:56:21 -0800 (PST) From: Tom Tromey Date: Wed, 18 Nov 2026 15:56:17 -0700 Subject: [PATCH v4 16/16] Move gdb::ranges::equal to gdbsupport/ranges.h MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261118-span-part-1-v4-16-5ecf901e570b@adacore.com> References: <20261118-span-part-1-v4-0-5ecf901e570b@adacore.com> In-Reply-To: <20261118-span-part-1-v4-0-5ecf901e570b@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey , Simon Marchi X-Mailer: b4 0.16.0 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This moves the gdb::ranges::equal function to gdbsupport/ranges.h. When moving to C++20, this entire header can be removed. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32660 Approved-By: Simon Marchi --- gdb/dwarf2/read-debug-names.c | 1 + gdb/value.c | 1 + gdbsupport/ranges.h | 27 +++++++++++++++++++++++++++ gdbsupport/span.h | 37 ------------------------------------- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index ca3b46fc9b1..ee35f06dde9 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -29,6 +29,7 @@ #include "read.h" #include "stringify.h" #include "extract-store-integer.h" +#include "gdbsupport/ranges.h" #include "gdbsupport/thread-pool.h" #include "cli/cli-style.h" diff --git a/gdb/value.c b/gdb/value.c index 536eef3e00c..195f4bb5185 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -45,6 +45,7 @@ #include #include "completer.h" #include "gdbsupport/cleanups.h" +#include "gdbsupport/ranges.h" #include "gdbsupport/selftest.h" #include "gdbsupport/span.h" #include "cli/cli-style.h" diff --git a/gdbsupport/ranges.h b/gdbsupport/ranges.h index c89506da86d..e19bbb8224f 100644 --- a/gdbsupport/ranges.h +++ b/gdbsupport/ranges.h @@ -20,9 +20,36 @@ #include +/* The 'equal' wrapper here only works on spans, so include this. + When moving to C++20, this will be removed -- in fact this entire + file should be removed. */ +#include "gdbsupport/span.h" + namespace gdb { namespace ranges { +/* Compare LHS and RHS for (deep) equality. That is, whether LHS and + RHS have the same sizes, and whether each pair of elements of LHS + and RHS at the same position compares equal. */ + +template +bool +equal (const gdb::span &lhs, const gdb::span &rhs) +{ +#if __cplusplus >= 202002L + return std::ranges::equal (lhs, rhs); +#else + if (lhs.size () != rhs.size ()) + return false; + + for (size_t i = 0; i < lhs.size (); i++) + if (!(lhs[i] == rhs[i])) + return false; + + return true; +#endif +} + /* Replace all occurrences of a value in the provided range. Note: this helper is a reimplementation of std::ranges::replace, only diff --git a/gdbsupport/span.h b/gdbsupport/span.h index 54ae6eb0640..1d14e8da5bb 100644 --- a/gdbsupport/span.h +++ b/gdbsupport/span.h @@ -69,20 +69,6 @@ namespace gdb { /* gdb::span. */ template using span = std::span; -namespace ranges -{ - -/* gdb::ranges::equal. */ - -template -constexpr bool -equal (R1 &&r1, R2 &&r2) -{ - return std::ranges::equal (r1, r2); -} - -} /* namespace ranges */ - } /* namespace gdb */ #else /* __cplusplus < 202002L */ @@ -224,29 +210,6 @@ class span size_type m_size; }; -namespace ranges -{ - -/* Compare LHS and RHS for (deep) equality. That is, whether LHS and - RHS have the same sizes, and whether each pair of elements of LHS - and RHS at the same position compares equal. */ - -template -bool -equal (const gdb::span &lhs, const gdb::span &rhs) -{ - if (lhs.size () != rhs.size ()) - return false; - - for (size_t i = 0; i < lhs.size (); i++) - if (!(lhs[i] == rhs[i])) - return false; - - return true; -} - -} /* namespace ranges */ - } /* namespace gdb */ #endif /* __cplusplus < 202002L */ -- 2.56.0