From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QQ40HhCR9GpvUAIAWB0awg (envelope-from ) for ; Wed, 11 Nov 2026 11:00:16 -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=KvkkXrkO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 774F5378003; Wed, 11 Nov 2026 11:00:16 -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 60BA51E04F for ; Wed, 11 Nov 2026 11:00:15 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32AA14B92092 for ; Wed, 11 Nov 2026 16:00:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32AA14B92092 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=KvkkXrkO Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by sourceware.org (Postfix) with ESMTPS id 2BA964B920B8 for ; Wed, 11 Nov 2026 15:59:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2BA964B920B8 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 2BA964B920B8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::30 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794412769; cv=none; b=WTORUBJehkupAGAjPDIoiZT/+okzBSh4/bM0OUPJGxu96Z23UoQ+IH29VeRH6yOg7VG4efUYahgHPvaYJhTe71bUPPOB6zdnK+atrtuvZ/6Of8ZIGUXFBStaPxzGqESJ9/l+kLUmEIEIdLzRPacLAc1VOFWGqI8Jf4+IAvdufnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794412769; c=relaxed/simple; bh=BjbhqRjaqUifXOSj82zanlK9UOk90c3TMf/p9XHtbiM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QVZzRM1KLw8EdUZyeOo+f9NA9NxTdFp6BNwdhou7qOaI7mGpymGAwfqAXgVo5KkC9uALNQf+Y+75dUDx46DzuHmkL+VJbzbYZG9FeqYRNcJwqIc03DhyRfca/cHHvbAImBthV9kThjI5POms8wWfDKcZnsuSpV362WSnZqmbcLE= 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=KvkkXrkO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BA964B920B8 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-4adf4431ca0so895656fac.2 for ; Wed, 11 Nov 2026 07:59:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1794412768; x=1795017568; 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=2oe7JHCUm76YtxeO50+v7JqtGwI6lxjzOpJ/JIsa/aQ=; b=KvkkXrkOWWVZw5kK3/jFvTWabS/DOTLEXMPtUyUanoxOJCS21kKqCm1bT6+o3mZZ0L eh4oN8FZRHxVVT87WrjD+ctnArtcO1CtKjbWxmQxXIaWtEHX+71mSkMXoE6YSx4H5lTr qqa7tkF2j3Gvt/c3cca6tKEaUdwXldJBheNoIEhCGM27vOCopTKaXHqadzlAFUA+6Fxu FznJmCGccm3VBKEEhXnhADSPInJNPaY9EWj55A6phBiMHvxIgjMneo/kYQLjTPpxS7+f CgdSF70lu59fmL4hhAD/64uZk8jNfY8PsTLgnJDcsSW0tVzKdZNA/W0622KmuYDkdkJI Lcnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794412768; x=1795017568; 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=2oe7JHCUm76YtxeO50+v7JqtGwI6lxjzOpJ/JIsa/aQ=; b=q8+nUcVQ+vVTfWQAn+QaxVupDVAFudggsq506w7QAy0HobpC27fjqMrav5QgF/nK/+ AUALwYD1i72GohQAOedvDYgL4R99NFUiZORwT2LA6n9AFdhtc7tRwAM8/OzGrYlceKyq jJUzoB4HriyB6qw4Nraa//5IsbNhGh3csMivxKaaZmsGYTlzyDwHinfb+JOF3VkcJQCN 8yQSLOieeCLPDNTAnyk6eAfNOtQvkXG8/P8KVLG5dzEq/Hr3mNnwGH02XqoKsqVO+UUW 5QRoUa6Hwh0Fl4POq0ohQOiZU68QaS2C47zoeqeKsK5t5IHXjbHdbAlMzHcMpHJOtVVr Hvwg== X-Gm-Message-State: APuU4Z9IontnIUSZYK8nxnhqSyTtpdTo57uozapwUhv4yXa877GLiIns TM7JtRX7vzwizvsIdY5JiF+Uzxwx+0VMhUuy9CSI3w+LLJWwga7OfEv1d2ZfSRRekuclhIQDGOq jCf/N7Q== X-Gm-Gg: AYBFou1usYOygpUqZxZW64VqSriF4aDUy54kexCOCCxWZyH0hU2bICkaPpGO5y4GvhA 4C9rCVjPgMVkDIgZDto1/TIYlZ+D6f8Sd1UzZUEIDRu2o72VyAUwV9c65bhhw/vRET9W7CMM4V+ 4Fg7A49MTZEAPa9Bed7q7W/g6Xfa5t7ux1YUsYRUa2ht1vpu5NUbOVJJIb0Jjc0ep5AqYhj3oaX T9tXgXBtl9J2G6qgpeliirkbEUfBQ8mQZ4vyTNl+Q5uaQhmITwiZSIfKUEJCTmwmte3GuCWxHeo 0IumUUH2Pe+zu9a3oSUzBdvKS70BHc5E7I6ioHj7A8gMCVCa5T8PXzDnZhSRCE/jp4XmswIY+vg VrRhJZWhpBbU8CCCPl0PAUtROjM/9tPyvR/SqhNJ6+pcehDiy2POiKKqPlkxNiiU+VC5w23RLO0 OOunL1VY2qrMerMmZ58wPTHapK8sgbsJ4RMgdAo60zZ64oeCsv+e9GaIaDDuNaA2qY2C7ddP2ZP OU+J+fRYAykjSWQ8czuP/HuV45n+s+RWUExLV/zRlUzOr/tamnMv/bcfN1px9c6FzdBna0D2PNZ WFAWXWFmePlrrZQULT9rS/5h3aYn8yVGa6rlxVcINFLGaxqEiosOhEW6fL6mtA== X-Received: by 2002:a05:6870:1405:b0:48f:e0f6:c460 with SMTP id 586e51a60fabf-4ae46c476cemr2176831fac.46.1794412768413; Wed, 11 Nov 2026 07:59:28 -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 586e51a60fabf-4ae2308e3ccsm3497521fac.15.2026.11.11.07.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2026 07:59:27 -0800 (PST) From: Tom Tromey Date: Wed, 11 Nov 2026 08:59:03 -0700 Subject: [PATCH v2 15/15] 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: <20261111-span-part-1-v2-15-cd4e33a8a723@adacore.com> References: <20261111-span-part-1-v2-0-cd4e33a8a723@adacore.com> In-Reply-To: <20261111-span-part-1-v2-0-cd4e33a8a723@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey 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 --- gdb/dwarf2/read-debug-names.c | 1 + gdb/value.c | 1 + gdbsupport/ranges.h | 27 +++++++++++++++++++++++++++ gdbsupport/span.h | 36 ------------------------------------ 4 files changed, 29 insertions(+), 36 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 69893fffc94..f5a194f4858 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 1acc0414840..52504b9b9e3 100644 --- a/gdbsupport/ranges.h +++ b/gdbsupport/ranges.h @@ -22,9 +22,36 @@ #include #endif +/* 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 3759b05fb34..201d21696df 100644 --- a/gdbsupport/span.h +++ b/gdbsupport/span.h @@ -69,19 +69,6 @@ namespace gdb { /* gdb::span. */ template using span = std::span; -/* gdb::ranges::equal. */ -namespace ranges -{ - -template -constexpr bool -equal (R1 &&r1, R2 &&r2) -{ - return std::ranges::equal (r1, r2); -} - -} /* namespace ranges */ - } /* namespace gdb */ #else /* __cplusplus < 202002L */ @@ -211,29 +198,6 @@ class span size_type m_size; }; -/* 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. */ - -namespace ranges -{ - -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