[binutils-gdb] Specialize std::hash for ptid_t
Tom Tromey
tromey@sourceware.org
Mon Sep 11 17:44:05 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9a343d2bb57c4555dedad9b43907aeeda7b51dae
commit 9a343d2bb57c4555dedad9b43907aeeda7b51dae
Author: Tom Tromey <tromey@adacore.com>
Date: Mon Sep 11 08:45:37 2023 -0600
Specialize std::hash for ptid_t
This changes hash_ptid to instead be a specialization of std::hash.
This makes it a little easier to use with standard containers.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diff:
---
gdb/inferior.h | 2 +-
gdb/regcache.c | 2 +-
gdbsupport/ptid.h | 5 ++---
3 files changed, 4 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 @@ public:
/* 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_t, thread_info *, hash_ptid> ptid_thread_map;
+ std::unordered_map<ptid_t, thread_info *> 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<ptid_t, regcache_up, hash_ptid>;
+ = std::unordered_multimap<ptid_t, regcache_up>;
/* Type holding regcaches for a given pid. */
diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h
index aa296b83181..f8644d47633 100644
--- a/gdbsupport/ptid.h
+++ b/gdbsupport/ptid.h
@@ -157,9 +157,8 @@ private:
tid_type m_tid;
};
-/* Functor to hash a ptid. */
-
-struct hash_ptid
+template<>
+struct std::hash<ptid_t>
{
size_t operator() (const ptid_t &ptid) const
{
More information about the Gdb-cvs
mailing list