From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 17 06:33:02 2021 Received: (at submit) by debbugs.gnu.org; 17 Aug 2021 10:33:02 +0000 Received: from localhost ([127.0.0.1]:51886 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mFwOz-0004Yj-RN for submit@debbugs.gnu.org; Tue, 17 Aug 2021 06:33:02 -0400 Received: from lists.gnu.org ([209.51.188.17]:52410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mFwOx-0004YX-Nm for submit@debbugs.gnu.org; Tue, 17 Aug 2021 06:33:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mFwOx-0008IU-AP for bug-grep@gnu.org; Tue, 17 Aug 2021 06:32:59 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:36820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mFwOu-0004nr-CH for bug-grep@gnu.org; Tue, 17 Aug 2021 06:32:57 -0400 Received: by mail-wm1-f42.google.com with SMTP id 79-20020a1c0452000000b002e6cf79e572so1531318wme.1 for ; Tue, 17 Aug 2021 03:32:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=3YKtTO9vP1l83haaNLC3VaTA0AaDPTf86s5NyC3XJm0=; b=AtMkmoAM50yitp/hiA+k/ChlEsx5rZTy6ia1TRB84MaAp1jU8rqohkeVfMrbRME7Xc 9DgNwL4S1biIfUb8O4a+wgmbj0ZrwijM6DXVJwQIowlo2yLZpskuzoNEX2aQSLIvucle +Iy1Ubw+1kASCUmMY53MpZ6Zll3DD+DartcBgoMDgvV4O0Lcf1N6S73Sq+kwTDuji1dV b5OfLm034YfFfo/XW6O74GWGM7yKyr+DlMj4Bd6PBUGPqpp1/Rn5jNtrhfQJ7UkY0u5u Z3N6ZaCUb1TDucm4pgIPITf99ecY0nQGyUnDc0bBzCpcFZUsrO1RAn7kA+Q1AI9a6RUk eg5w== X-Gm-Message-State: AOAM532ItgBgY3ZVC9hyJ9VappKTMhzDhNZDQDaw1XHoPNOP2QlJjupZ TFXvdhSfOJt1XtCCJMmSTR8GPcys/4x1stXpDaNlXXO9JJiWFaAi X-Google-Smtp-Source: ABdhPJwXVqFX/hRjc8169/b0ukrSj9ipByATHUyehIBrqR4bGwLOxRiyGXr8qORZz7ftKaCsUBnoZ+j/dgisXEwiKT4= X-Received: by 2002:a05:600c:b51:: with SMTP id k17mr2579907wmr.149.1629196373177; Tue, 17 Aug 2021 03:32:53 -0700 (PDT) MIME-Version: 1.0 From: Jim Meyering Date: Tue, 17 Aug 2021 12:32:39 +0200 Message-ID: Subject: djb2 correction To: bug-grep@gnu.org, Alex Murray Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=209.85.128.42; envelope-from=meyering@gmail.com; helo=mail-wm1-f42.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) Alex Murray noticed that my djb2 implementation mistakenly initialized to 0, rather than to 5381. Corrected with this: >>From 54590ca833dba62041af045e7bc7c09b90b54b71 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Tue, 17 Aug 2021 03:24:37 -0700 Subject: [PATCH] grep: correct DJB2 initialization * src/grep.c (hash_pattern): DJB2 starts with 5381, not 0. --- src/grep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grep.c b/src/grep.c index 271b6b9..8fed550 100644 --- a/src/grep.c +++ b/src/grep.c @@ -126,7 +126,7 @@ static Hash_table *pattern_table; static size_t _GL_ATTRIBUTE_PURE hash_pattern (void const *pat, size_t n_buckets) { - size_t h = 0; + size_t h = 5381; intptr_t pat_offset = (intptr_t) pat - 1; unsigned char const *s = (unsigned char const *) pattern_array + pat_offset; for ( ; *s != '\n'; s++) -- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 17 17:04:42 2021 Received: (at 50093) by debbugs.gnu.org; 17 Aug 2021 21:04:42 +0000 Received: from localhost ([127.0.0.1]:54250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mG6GH-0002Iv-OY for submit@debbugs.gnu.org; Tue, 17 Aug 2021 17:04:42 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mG6GE-0002If-5V for 50093@debbugs.gnu.org; Tue, 17 Aug 2021 17:04:39 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 10C9C1600CC; Tue, 17 Aug 2021 14:04:32 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id NgU5zuksp1Pd; Tue, 17 Aug 2021 14:04:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1C634160083; Tue, 17 Aug 2021 14:04:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id acVBDga7eKVc; Tue, 17 Aug 2021 14:04:27 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E08591600D3; Tue, 17 Aug 2021 14:04:26 -0700 (PDT) To: Jim Meyering References: From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#50093: djb2 correction Message-ID: <306ecbad-6fed-4a8c-26d2-e89c1ab12420@cs.ucla.edu> Date: Tue, 17 Aug 2021 14:04:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------01F3638945BFD1D3BBB6DB4F" Content-Language: en-US X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 50093 Cc: alex.murray@canonical.com, 50093@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) This is a multi-part message in MIME format. --------------01F3638945BFD1D3BBB6DB4F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 8/17/21 3:32 AM, Jim Meyering wrote: > - size_t h =3D 0; > + size_t h =3D 5381; I expect DJB chose that number because of the primeth recurrence=20 sequence : 2 is 1st prime. 3 is 2nd prime. 5 is 3rd prime. 11 is 5th prime. 31 is 11th prime. 127 is 31st prime. 709 is 127th prime. 5381 is 709th prime. 52711 is 5381st prime. ... Although 5381 is the largest number in this sequence that can fit into=20 'int' in a portable C program, and that's probably why DJB chose 5381,=20 we're not limited to such small values here. How about the attached patch instead? --------------01F3638945BFD1D3BBB6DB4F Content-Type: text/x-patch; charset=UTF-8; name="0001-grep-djb2-correction.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-grep-djb2-correction.patch" =46rom da3bd0041a8c8623e80df8ac7999b84341020de2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 17 Aug 2021 13:58:13 -0700 Subject: [PATCH] grep: djb2 correction Problem reported by Alex Murray (bug#50093). * src/grep.c (hash_pattern): Use a nonzero initial value. --- src/grep.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/grep.c b/src/grep.c index 271b6b9..1a6d9f6 100644 --- a/src/grep.c +++ b/src/grep.c @@ -126,7 +126,16 @@ static Hash_table *pattern_table; static size_t _GL_ATTRIBUTE_PURE hash_pattern (void const *pat, size_t n_buckets) { - size_t h =3D 0; + /* This uses the djb2 algorithm, except starting with a larger prime + in place of djb2's 5381, if size_t is wide enough. The primes + are taken from the primeth recurrence sequence + . h15, h32 and h64 are the largest + sequence members that fit into 15, 32 and 64 bits, respectively. + Since any H will do, hashing works correctly on oddball machines + where size_t has some other width. */ + unsigned long long int + h15 =3D 5381, h32 =3D 3657500101, h64 =3D 4123221751654370051; + size_t h =3D h64 <=3D SIZE_MAX ? h64 : h32 <=3D SIZE_MAX ? h32 : h15; intptr_t pat_offset =3D (intptr_t) pat - 1; unsigned char const *s =3D (unsigned char const *) pattern_array + pat= _offset; for ( ; *s !=3D '\n'; s++) --=20 2.30.2 --------------01F3638945BFD1D3BBB6DB4F-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 17 22:52:22 2021 Received: (at 50093) by debbugs.gnu.org; 18 Aug 2021 02:52:22 +0000 Received: from localhost ([127.0.0.1]:54490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGBgf-0004cB-U5 for submit@debbugs.gnu.org; Tue, 17 Aug 2021 22:52:22 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:55088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGBgZ-0004bs-V2 for 50093@debbugs.gnu.org; Tue, 17 Aug 2021 22:52:16 -0400 Received: from graphene (1.general.amurray.uk.vpn [10.172.193.220]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id EAA003F07D; Wed, 18 Aug 2021 02:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1629255124; bh=0es5lhNDft8G23e8EfwfVy3ncsW5T8U6LYWQXGttDaE=; h=References:From:To:Cc:Subject:Date:Reply-To:In-reply-to: Message-ID:MIME-Version:Content-Type; b=iqKoZZb6VTbNRcUTJ9Mqsyy+Lp8GnDIiatKE0sAfX6QCocA3APilt37VmlYXOWpD1 1e79LPN/uJLAPW6xZ25ZuArIOxKaBjZpzkULGqFf/zX8s4SKXAWviPcZXuie6jinfv Fi3r/koqRvXI5y+bOct5GbrIc5PJmjX/cuUFeai4n13Vj/ddEXAN4tVkZAA6g9p/T1 ZisLtKIeOe6B+ZwBFAVD2cd+CZlRw4ffXv7QbMlHQvmEuRtwDLjuHS3ZVzvO97U1f4 WZ2bBqXdp9+j60aw/dTyompAEcwZwrPLI+LVlJD1C9Lf3AqeqNaLpjauypPtxbSO33 dtJ0vcR2nrgzQ== References: <306ecbad-6fed-4a8c-26d2-e89c1ab12420@cs.ucla.edu> User-agent: mu4e 1.6.3; emacs 28.0.50 From: Alex Murray To: Paul Eggert Subject: Re: bug#50093: djb2 correction Date: Wed, 18 Aug 2021 12:20:26 +0930 In-reply-to: <306ecbad-6fed-4a8c-26d2-e89c1ab12420@cs.ucla.edu> Message-ID: <87wnojmpm8.fsf@canonical.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50093 Cc: Jim Meyering , 50093@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: alex.murray@canonical.com Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On Tue, 2021-08-17 at 14:04:26 -0700, Paul Eggert wrote: > On 8/17/21 3:32 AM, Jim Meyering wrote: >> - size_t h = 0; >> + size_t h = 5381; > > I expect DJB chose that number because of the primeth recurrence sequence > : > > 2 is 1st prime. > 3 is 2nd prime. > 5 is 3rd prime. > 11 is 5th prime. > 31 is 11th prime. > 127 is 31st prime. > 709 is 127th prime. > 5381 is 709th prime. > 52711 is 5381st prime. > ... > > Although 5381 is the largest number in this sequence that can fit into > 'int' in a portable C program, and that's probably why DJB chose 5381, > we're not limited to such small values here. > > How about the attached patch instead? > How about letting the compiler choose which prime to use? - something like the following: #define H15_PRIME (unsigned long long)5381 #define H32_PRIME (unsigned long long)3657500101 #define H64_PRIME (unsigned long long)4123221751654370051 size_t h = H64_PRIME <= SIZE_MAX ? H64_PRIME : H32_PRIME <= SIZE_MAX ? H32_PRIME : H15_PRIME; From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 18 10:18:57 2021 Received: (at 50093) by debbugs.gnu.org; 18 Aug 2021 14:18:57 +0000 Received: from localhost ([127.0.0.1]:57172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGMPB-00028X-BP for submit@debbugs.gnu.org; Wed, 18 Aug 2021 10:18:57 -0400 Received: from mail-wm1-f45.google.com ([209.85.128.45]:45610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGMP7-00028J-QS for 50093@debbugs.gnu.org; Wed, 18 Aug 2021 10:18:55 -0400 Received: by mail-wm1-f45.google.com with SMTP id j12-20020a05600c1c0c00b002e6d80c902dso1882259wms.4 for <50093@debbugs.gnu.org>; Wed, 18 Aug 2021 07:18:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3+MdmbN9PeQl09KrHUzUT5/jeFaSn7fCAlhTY0cGLx8=; b=k4iis1+FMNTh5csiIbrFgv4bh/bXHDXAl9iAEGcq9atdEFQ1Xa/71qs4F+I3B/sUsT Nz26/VWEsQVGJdibewPWiaebWTdIFHFWHbiA+XvtMl/uWKy8Eiss2voy+ZEYuDEAePzP GrzOlPggGUjp6eFOesPxteSmXSZMnlV4AO7LgoWNotP0YdNTC/HPTMXJt3zaO0ZS79QJ MH+5HAdMmTRqd1G/B2Mys04atvmKNBsBx/q760ttREuUUCTTXofUxBmhNaxLQT7vPB1w P4CZ+X+r1NhXTaxfYuklLyS+EoL3rxQjvWO+Yjdt7Ra7h/qrTvINTiPqxwYcIgBGf7e2 kgcA== X-Gm-Message-State: AOAM533Rq9KbEEEJJwF+2o352j2QkfsPITuhUwVlWTS4Hj9+eKSWtmF1 H4QZVhehvrIS4YkPpzIwDmSoM2xHwH1pTl1tO4U= X-Google-Smtp-Source: ABdhPJz2Q94cEYfnXJEFHTQF4WxrCsOWc1iSbe83VG2Z26SpMkAu4LpPXUCt7dM9pCz3Ajl3AZ4ObP+GgnfeCXyWQ+g= X-Received: by 2002:a7b:c7c3:: with SMTP id z3mr8742088wmk.96.1629296328050; Wed, 18 Aug 2021 07:18:48 -0700 (PDT) MIME-Version: 1.0 References: <306ecbad-6fed-4a8c-26d2-e89c1ab12420@cs.ucla.edu> In-Reply-To: <306ecbad-6fed-4a8c-26d2-e89c1ab12420@cs.ucla.edu> From: Jim Meyering Date: Wed, 18 Aug 2021 16:18:33 +0200 Message-ID: Subject: Re: bug#50093: djb2 correction To: Paul Eggert Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 50093 Cc: Alex Murray , 50093@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On Tue, Aug 17, 2021 at 11:04 PM Paul Eggert wrote: > On 8/17/21 3:32 AM, Jim Meyering wrote: > > - size_t h = 0; > > + size_t h = 5381; > > I expect DJB chose that number because of the primeth recurrence > sequence : > > 2 is 1st prime. > 3 is 2nd prime. > 5 is 3rd prime. > 11 is 5th prime. > 31 is 11th prime. > 127 is 31st prime. > 709 is 127th prime. > 5381 is 709th prime. > 52711 is 5381st prime. > ... > > Although 5381 is the largest number in this sequence that can fit into > 'int' in a portable C program, and that's probably why DJB chose 5381, > we're not limited to such small values here. > > How about the attached patch instead? I prefer that, indeed. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 18 10:48:21 2021 Received: (at 50093-done) by debbugs.gnu.org; 18 Aug 2021 14:48:21 +0000 Received: from localhost ([127.0.0.1]:57213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGMrd-00053L-3S for submit@debbugs.gnu.org; Wed, 18 Aug 2021 10:48:21 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mGMrZ-000531-5p for 50093-done@debbugs.gnu.org; Wed, 18 Aug 2021 10:48:19 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A0F4C1600D3; Wed, 18 Aug 2021 07:48:10 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id FzCMieexReao; Wed, 18 Aug 2021 07:48:09 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C747A1600ED; Wed, 18 Aug 2021 07:48:09 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5d6pZs7w92xk; Wed, 18 Aug 2021 07:48:09 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9EEFD1600D3; Wed, 18 Aug 2021 07:48:09 -0700 (PDT) To: alex.murray@canonical.com References: <306ecbad-6fed-4a8c-26d2-e89c1ab12420@cs.ucla.edu> <87wnojmpm8.fsf@canonical.com> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#50093: djb2 correction Message-ID: <91534c5b-8bef-0a7d-b510-178b4441fcba@cs.ucla.edu> Date: Wed, 18 Aug 2021 07:48:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87wnojmpm8.fsf@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 50093-done Cc: Jim Meyering , 50093-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 8/17/21 7:50 PM, Alex Murray wrote: > How about letting the compiler choose which prime to use? - something l= ike the following: >=20 > #define H15_PRIME (unsigned long long)5381 > #define H32_PRIME (unsigned long long)3657500101 > #define H64_PRIME (unsigned long long)4123221751654370051 > size_t h =3D H64_PRIME <=3D SIZE_MAX ? H64_PRIME : H32_PRIME <=3D SIZE_= MAX ? H32_PRIME : H15_PRIME; That's equivalent to the patch I suggested; on my platform it even=20 generates the same machine code. It's better to avoid macros when that's=20 easy, as is the case here. I installed the patch, except with uint_fast64_t instead of unsigned=20 long long int as that's a better type for the 64-bit constants in=20 question. (In case you're wondering what that "_fast" is doing there,=20 POSIX and the C standard guarantee the existence of uint_fast64_t but=20 not of uint64_t, as a concession to Unisys mainframes where long long is=20 72 bits.) From unknown Mon Jun 23 16:48:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 16 Sep 2021 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator