From patchwork Thu Apr 14 04:12:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1617027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=oKTDtZyr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kf5fK3MQkz9sFx for ; Thu, 14 Apr 2022 14:12:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55C0A385780C for ; Thu, 14 Apr 2022 04:12:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55C0A385780C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1649909574; bh=TvP1wMqM9A6UwmlxuuTkre8bdPZHmmxJRY7Yn9d97IE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oKTDtZyr6JM09+KQv1dSG2eudvjlacDHHMHcuyZbh7GYr5s6U147fg1LgEj1Dv/Mf 1oHHx1siH4tqgT7jmt/PU6MFB/9ubCIHfF7/b9mnEMXkI7Gfuo74ui/xmfDgS3mUVa BdJ5L6V/EwIufSkCz4kVQ9SjqLBAuImYGb/G7Ddw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 8BA4E3858C53 for ; Thu, 14 Apr 2022 04:12:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8BA4E3858C53 Received: by mail-il1-x131.google.com with SMTP id x9so2402206ilc.3 for ; Wed, 13 Apr 2022 21:12:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TvP1wMqM9A6UwmlxuuTkre8bdPZHmmxJRY7Yn9d97IE=; b=Y4ekXm36uvhJw39SeiMY+0nN9AFKpklAfkv95SN9A1IhkhDdJFwg4APRF/8BYKWTQG BkcbkuFvMp7LWg6bWJs6nxsXLaUi8x25di1vZC9+n5WJ0v+gs9kwvDPyyDkeVO+Y13yC Ss4e2RmdcGT0uQ9HwNIbprtDpU18einFpbaNrmkMxSdSM1094j+085sG2SbYcxyVZtj/ bc+NYfzZySN0bbRECmiACTokYFhV1eCrPNMDQVaYCZ/Wr6cueqxtI5XKCP3MKEgldKrs 3Ynb5EtSlfr2Llm/6HUW7PL7bOwb06OO3aIWrRAmkb3d3V8N8lWIjlKVELsaqbdDFDFR KPrQ== X-Gm-Message-State: AOAM532L9/mX9mtRsMQK1UCkbsM5cU66MQruZwoMMexnAHzSUWtb3fYq wYmRMZSWqCTQ1syZuGzpjyToVqEvIDQ= X-Google-Smtp-Source: ABdhPJzkwpA11Hw/S0dIndw1F6AtkjJfZTGJIzJMywMxUAcfbtHfnKmTF5VuBLO6+zKWaiGHVC6UqA== X-Received: by 2002:a92:d7d0:0:b0:2ca:33ba:8bde with SMTP id g16-20020a92d7d0000000b002ca33ba8bdemr378343ilq.121.1649909557642; Wed, 13 Apr 2022 21:12:37 -0700 (PDT) Received: from localhost.localdomain (node-17-161.flex.volo.net. [76.191.17.161]) by smtp.googlemail.com with ESMTPSA id t18-20020a056e02011200b002cbe6ce18e5sm113120ilm.40.2022.04.13.21.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 21:12:37 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v1 1/6] elf: Refactor dl_new_hash so it can be tested / benchmarked Date: Wed, 13 Apr 2022 23:12:26 -0500 Message-Id: <20220414041231.926415-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" No change to the code other than moving it to sysdeps/generic/dl-hash.h. Changed name so its now in the reserved namespace. --- sysdeps/generic/dl-hash.h | 13 +++++++++++++ sysdeps/i386/i686/dl-hash.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/sysdeps/generic/dl-hash.h b/sysdeps/generic/dl-hash.h index 9bc7e3bd67..c041074352 100644 --- a/sysdeps/generic/dl-hash.h +++ b/sysdeps/generic/dl-hash.h @@ -19,7 +19,9 @@ #ifndef _DL_HASH_H #define _DL_HASH_H 1 +#include +#ifndef __HAS_DL_ELF_HASH /* This is the hashing function specified by the ELF ABI. In the first five operations no overflow is possible so we optimized it a bit. */ @@ -71,5 +73,16 @@ _dl_elf_hash (const char *name_arg) } return hash; } +#endif /* !__HAS_DL_ELF_HASH */ + +static uint32_t +__dl_new_hash (const char *s) +{ + uint32_t h = 5381; + for (unsigned char c = *s; c != '\0'; c = *++s) + h = h * 33 + c; + return h; +} + #endif /* dl-hash.h */ diff --git a/sysdeps/i386/i686/dl-hash.h b/sysdeps/i386/i686/dl-hash.h index c124480e77..d18370350d 100644 --- a/sysdeps/i386/i686/dl-hash.h +++ b/sysdeps/i386/i686/dl-hash.h @@ -75,4 +75,7 @@ _dl_elf_hash (const char *name) return result; } +#define __HAS_DL_ELF_HASH 1 +#include + #endif /* dl-hash.h */