From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4ACCD3842339 for ; Tue, 6 Dec 2022 17:19:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4ACCD3842339 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670347185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Gb4jtGUmuvnQ79TPFArO/VND57uRiOInuORZhMCy3r0=; b=aJyHHGzwwtSotSQV0D7UObRzX1H6J6W6rXJqpHcvxblGt9w8jq4/MWdgcIqtvqA6D4lbhq AivGUC5oUhI32yrobYc4KoOlwCFKlb2LNo8i8HGx864+k/EPAk6ljuPF+EgSWTMsGIEjFi UMs2kOLx73iAoJAB0OR1CzFZofvFYv4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-604-WpY9lkrXO6Gz2AS2qzYeIQ-1; Tue, 06 Dec 2022 12:19:43 -0500 X-MC-Unique: WpY9lkrXO6Gz2AS2qzYeIQ-1 Received: by mail-wr1-f70.google.com with SMTP id v14-20020adf8b4e000000b0024174021277so3443820wra.13 for ; Tue, 06 Dec 2022 09:19:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gb4jtGUmuvnQ79TPFArO/VND57uRiOInuORZhMCy3r0=; b=a9WZ9r5563oSkg1n3soOS0E2OyzQ7WvM+uFuwDbHgcfsIbbdvj3sHoaw9/aaZA2RmC whj9LbXYGpCE7ErdNP+1NJaFOOa5Iat+TE7tWFpJl+S8ijOxyFfLEjYo+hx1chuhCPA+ 0rpXX4LfGaHkyd44t6CBVWXkHS8Tu00cPScNCjI4ddhdHbtiAK+VsdQmX1jctf37cbBr 27prfcjE/rWfFU4hnUs8Dzz+hmlfNZEc+F1I9bP32MwnPlDNUaZ/fIvce/7LC9SiJYoA IQbIo6wmzskY2e7Isa7RfUX8JdgTuj5f0UDzYDtkmRg+cuHT8IL0bwu1Je+yTXqmlgWA 3XIw== X-Gm-Message-State: ANoB5pkgBjJZsN+FAZISTjPpM+UfhzVzms/LROEiUMGERm7ZCxxY3b/E PszE7F0eEMuk3cnthcSZomYrIfFeLbNYkEjEnyL910gxcG+XegIMWb0je9fZNw4s+PKOwX9bImX FOjU3ay59p5G5MU06eeYuBT1ShmP84ocLQnxC07DKEHUUlMYFaRB7MFMHe55cfKkGoCMtBCrQeA == X-Received: by 2002:a5d:5a92:0:b0:242:6c24:af21 with SMTP id bp18-20020a5d5a92000000b002426c24af21mr4667078wrb.588.1670347182406; Tue, 06 Dec 2022 09:19:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf4We1g+jj7YmbxQ/K72VYdr3bOQMb0v4GVQjyhpwXyBnfE6j5CuYckGUWoK0iqvfsPwbb/yNA== X-Received: by 2002:a5d:5a92:0:b0:242:6c24:af21 with SMTP id bp18-20020a5d5a92000000b002426c24af21mr4667066wrb.588.1670347182110; Tue, 06 Dec 2022 09:19:42 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id t67-20020a1c4646000000b003cfa622a18asm24700892wma.3.2022.12.06.09.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 09:19:41 -0800 (PST) From: Andrew Burgess To: Simon Marchi via Gdb-patches , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 08/12] gdbsupport: move fast_hash to gdbsupport/common-utils.h In-Reply-To: <20221206135729.3937767-9-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> <20221206135729.3937767-9-simon.marchi@efficios.com> Date: Tue, 06 Dec 2022 17:19:40 +0000 Message-ID: <87k03430wj.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: Simon Marchi via Gdb-patches 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 > > -#ifdef HAVE_LIBXXHASH > -#include > -#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 > +#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