public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdbsupport: move fast_hash to gdbsupport/common-utils.h
@ 2023-01-05 19:40 Simon Marchi
0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2023-01-05 19:40 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=72127b193c970a61a36c940bf167c596ddc32eae
commit 72127b193c970a61a36c940bf167c596ddc32eae
Author: Simon Marchi <simon.marchi@efficios.com>
Date: Thu Oct 20 12:48:27 2022 -0400
gdbsupport: move fast_hash to gdbsupport/common-utils.h
The following patch adds a hash type for gdb::string_view in gdbsupport,
which will use the fast_hash function. Move the latter to gdbsupport.
Change-Id: Id74510e17801e775bd5ffa5f443713d79adf14ad
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diff:
---
gdb/utils.h | 19 -------------------
gdbsupport/common-utils.h | 21 +++++++++++++++++++++
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/gdb/utils.h b/gdb/utils.h
index 59cab931ec9..7865812998e 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -26,10 +26,6 @@
#include "gdbsupport/scoped_restore.h"
#include <chrono>
-#ifdef HAVE_LIBXXHASH
-#include <xxhash.h>
-#endif
-
struct completion_match_for_lcd;
class compiled_regex;
@@ -348,19 +344,4 @@ extern void copy_bitwise (gdb_byte *dest, ULONGEST dest_offset,
const gdb_byte *source, ULONGEST source_offset,
ULONGEST nbits, int bits_big_endian);
-/* A fast hashing function. This can be used to hash data in a fast way
- when the length is known. If no fast hashing library is available, falls
- back to iterative_hash from libiberty. START_VALUE can be set to
- continue hashing from a previous value. */
-
-static inline unsigned int
-fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
-{
-#ifdef HAVE_LIBXXHASH
- return XXH64 (ptr, len, start_value);
-#else
- return iterative_hash (ptr, len, start_value);
-#endif
-}
-
#endif /* UTILS_H */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 530817fff10..31ab1a6cec8 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -27,6 +27,12 @@
#include "poison.h"
#include "gdb_string_view.h"
+#if defined HAVE_LIBXXHASH
+# include <xxhash.h>
+#else
+# include "hashtab.h"
+#endif
+
/* xmalloc(), xrealloc() and xcalloc() have already been declared in
"libiberty.h". */
@@ -188,4 +194,19 @@ extern int hex2bin (const char *hex, gdb_byte *bin, int count);
/* Like the above, but return a gdb::byte_vector. */
gdb::byte_vector hex2bin (const char *hex);
+/* A fast hashing function. This can be used to hash data in a fast way
+ when the length is known. If no fast hashing library is available, falls
+ back to iterative_hash from libiberty. START_VALUE can be set to
+ continue hashing from a previous value. */
+
+static inline unsigned int
+fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
+{
+#if defined HAVE_LIBXXHASH
+ return XXH64 (ptr, len, start_value);
+#else
+ return iterative_hash (ptr, len, start_value);
+#endif
+}
+
#endif /* COMMON_COMMON_UTILS_H */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-05 19:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 19:40 [binutils-gdb] gdbsupport: move fast_hash to gdbsupport/common-utils.h Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).