From: Andrew Burgess <aburgess@redhat.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>,
gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 08/12] gdbsupport: move fast_hash to gdbsupport/common-utils.h
Date: Tue, 06 Dec 2022 17:19:40 +0000 [thread overview]
Message-ID: <87k03430wj.fsf@redhat.com> (raw)
In-Reply-To: <20221206135729.3937767-9-simon.marchi@efficios.com>
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 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.
LGTM.
Thanks,
Andrew
>
> Change-Id: Id74510e17801e775bd5ffa5f443713d79adf14ad
> ---
> 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 d2acf899ba2..65080a9b9ce 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;
>
> @@ -365,19 +361,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 8a9448a638b..fae77640666 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". */
>
> @@ -172,4 +178,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 */
> --
> 2.38.1
next prev parent reply other threads:[~2022-12-06 17:19 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 13:57 [PATCH 00/12] Initial support for ROCm platform (AMDGPU) debugging Simon Marchi
2022-12-06 13:57 ` [PATCH 01/12] gdb: add supports_arch_info callback to gdbarch_register Simon Marchi
2022-12-06 16:45 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 02/12] gdb: make install_breakpoint return a non-owning reference Simon Marchi
2022-12-06 16:46 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 03/12] gdbsupport: add type definitions for pid, lwp and tid Simon Marchi
2022-12-06 16:36 ` Andrew Burgess
2022-12-07 2:55 ` Simon Marchi
2022-12-06 13:57 ` [PATCH 04/12] gdb: add inferior_pre_detach observable Simon Marchi
2022-12-06 16:39 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 05/12] gdb: make gdbarch_alloc take ownership of the tdep Simon Marchi
2022-12-06 17:06 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 06/12] gdb: add gdbarch_up Simon Marchi
2022-12-06 17:07 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 07/12] gdbsupport: move libxxhash configure check to gdbsupport Simon Marchi
2022-12-06 17:19 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 08/12] gdbsupport: move fast_hash to gdbsupport/common-utils.h Simon Marchi
2022-12-06 17:19 ` Andrew Burgess [this message]
2022-12-06 13:57 ` [PATCH 09/12] gdbsupport: add gdb::string_view_hash Simon Marchi
2022-12-06 17:19 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 10/12] gdb/solib-svr4: don't disable probes interface if probe not found Simon Marchi
2022-12-06 13:57 ` [PATCH 11/12] gdb: make gdb_printing_disassembler::stream public Simon Marchi
2022-12-06 17:38 ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 12/12] gdb: initial support for ROCm platform (AMDGPU) debugging Simon Marchi
2022-12-06 15:00 ` Eli Zaretskii
2022-12-06 15:10 ` Simon Marchi
2022-12-06 15:42 ` Eli Zaretskii
2022-12-07 2:17 ` Simon Marchi
2022-12-07 13:29 ` Eli Zaretskii
2022-12-16 17:37 ` Simon Marchi
2023-01-05 19:41 ` [PATCH 00/12] Initial " Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k03430wj.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).