From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id B05FA3858D38 for ; Mon, 11 Sep 2023 14:47:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B05FA3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-34f2d7c1bc8so14399815ab.1 for ; Mon, 11 Sep 2023 07:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1694443646; x=1695048446; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=urklEdK+jDIRWZ29so3LYP8g+aan9I+YOr+wpTr5bTo=; b=kcIkj2ldFCKjiZbLvVsv2yLVVOTYWMIy5zlp454RAwGd9G8nrZ2wwqKGL6ipkt6KHc tT1QWIwyvgpHDUKnidWCsuz3dGTH4VoP1o7zh3hsrhTEaJqRgekdTpF4lmuoQFzCFWnG tXBUmONJJcgETbXoUTIAXDE0nz5HS+eEmYmsna9CfKWPCAGDrtzWq2zXZ5JRNRnmSqZt Za2XsD4GDcT9BKtoqqrHJpE1YdjetNrVvPPbbRN4ITqx7AbMXx0/ZYHtEAzsNWzo21jp qTDCYOSgKfa4jJsszkqRU5OCyJ8g+Nu2g9EcFo6gttnGXGrLB5+8y0qmobKlcD6Uk9+m oAAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694443646; x=1695048446; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=urklEdK+jDIRWZ29so3LYP8g+aan9I+YOr+wpTr5bTo=; b=QxFPhiHe5QOa2TQIbrrv5Tbi8PxEtlBSsW8hGxiuxHt5Fnu3JouMe8kGPujydq9XJo s2B8UiJ/4eV4dvWOsHjCTSmkan94qRKy18yxX1iwwJdSvtPxDdDJKk+Tgv0dx3hqFvkm FOGvj9gPGSgoR5lyHTYwbsY3SCcKZzJPVT1/OpOVXYaY5P/sZuANaHRzZAwiDiHcrtYW rdYhwbaMkZxE1NOMXrZwzM/6Na6pp9rYKXDYK3wJ6j3GI76mTJbrlRxBEOJS7cnAuObp 2EEk2if8ZLHZD+kFmBSUAvQJZDHWazspvB6xtoudtU1fSuVB3nSb7liy2cmlRfowiVo/ V5sg== X-Gm-Message-State: AOJu0Yy7+oL/ORIc/wgiBLHaZoxKP8qafGnsMGVQKBqpZCCNKG/6IgZ7 2eTW5IeuL0Sr7D+eTKjeHTwt2xygQODHfuw+yMCIsA== X-Google-Smtp-Source: AGHT+IFqSxC1id6buEW21kCoHyZno2qKCp++gzrbEXQR8Ac78fGhLZyAXbaGw9K3NOIWa2MxyhwjRA== X-Received: by 2002:a05:6e02:1caf:b0:349:3808:e387 with SMTP id x15-20020a056e021caf00b003493808e387mr13492648ill.11.1694443645992; Mon, 11 Sep 2023 07:47:25 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id a8-20020a056e02120800b0034f7c597bf4sm573440ilq.88.2023.09.11.07.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 07:47:25 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Specialize std::hash for ptid_t Date: Mon, 11 Sep 2023 08:47:18 -0600 Message-Id: <20230911144718.3425981-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This changes hash_ptid to instead be a specialization of std::hash. This makes it a little easier to use with standard containers. --- gdb/inferior.h | 2 +- gdb/regcache.c | 2 +- gdbsupport/ptid.h | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gdb/inferior.h b/gdb/inferior.h index 04672582984..29c90d15efa 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -462,7 +462,7 @@ class inferior : public refcounted_object, /* A map of ptid_t to thread_info*, for average O(1) ptid_t lookup. Exited threads do not appear in the map. */ - std::unordered_map ptid_thread_map; + std::unordered_map ptid_thread_map; /* Returns a range adapter covering the inferior's threads, including exited threads. Used like this: diff --git a/gdb/regcache.c b/gdb/regcache.c index 9b71931bb0b..91b20b7a2a2 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -329,7 +329,7 @@ reg_buffer::assert_regnum (int regnum) const regcaches, associated to different gdbarches). */ using ptid_regcache_map - = std::unordered_multimap; + = std::unordered_multimap; /* Type holding regcaches for a given pid. */ diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h index aa296b83181..96c7d9c8bfd 100644 --- a/gdbsupport/ptid.h +++ b/gdbsupport/ptid.h @@ -157,9 +157,10 @@ class ptid_t tid_type m_tid; }; -/* Functor to hash a ptid. */ - -struct hash_ptid +namespace std +{ +template<> +struct hash { size_t operator() (const ptid_t &ptid) const { @@ -170,6 +171,7 @@ struct hash_ptid + long_hash (ptid.tid ())); } }; +} /* The null or zero ptid, often used to indicate no process. */ -- 2.40.1