From patchwork Mon Jul 4 04:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1651730 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=Fln3opzy; 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 (ip-8-43-85-97.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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lbt8r1GY2z9s1l for ; Mon, 4 Jul 2022 14:28:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1572F385BAD9 for ; Mon, 4 Jul 2022 04:28:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1572F385BAD9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656908904; bh=Q202AflrMLxG76iDw0ynOLxvx4W+9NaU3YdjuMV3rgk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Fln3opzy/RES2qGf3T3iSpVwlayHxOWqHVx9AoPgeqbyldCtJK4P4GY6i6jhDnjTP WeEdbA3k3Ldzlzb+j2YB/fmV63E1FbiIpBWolq3DL4AC5evY9oTO0tBeGCRY1lfaV4 nsoS7baOAx2xq6uiVNph5SsqbSZZitGOxhdCPXKc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 0835C385735C for ; Mon, 4 Jul 2022 04:28:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0835C385735C Received: by mail-pj1-x1029.google.com with SMTP id g20-20020a17090a579400b001ed52939d72so8365312pji.4 for ; Sun, 03 Jul 2022 21:28:09 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q202AflrMLxG76iDw0ynOLxvx4W+9NaU3YdjuMV3rgk=; b=Ny+H4wUoMVOc9kWhjoet0dvlt3Y8617MxkWZjbakezLMhHzPd7AHRTCx3bD7GJr7wC HqoSjfAqdaVp9+2m9C0E3Y1r17Cj0HOi+rz254ZCo/XQ0fk3ZBpQr2LKjXF8gW6cwr/y NVgabN2OiwZ+RU/KG67BIrqKjF8QBV71Obx/0pCbk/AyFWOz+i7c+VMEqetwDe4vD5c1 FfawigsS0s+VP/s8XBsmKHnIOMYNY3sz1wag+zDeb43VqQweGRuLJWzacWnJzhqkofW7 BDN+PStSgewPKNW2CkhYGRXHXKmBOiY5eGoMmJ+8Izc6hqOEgnHFAiZAuMTrf+ioiSS0 Bjxg== X-Gm-Message-State: AJIora/XV47E+oh7S77SK/i88Ac5eEzHtKrj8AQJ+2ke5V1escORlBfu +IaLIeKxzaap38xtk8rnjFfHoau84WE= X-Google-Smtp-Source: AGRyM1v0pCxTaczcPcKLXD4lOuWL6SQZfMSu1/aOEaFkF20hPyvZq6KkJUezkCf+bvOZXESiBIUG3Q== X-Received: by 2002:a17:90a:f48a:b0:1ed:5ec:f890 with SMTP id bx10-20020a17090af48a00b001ed05ecf890mr34323026pjb.40.1656908888957; Sun, 03 Jul 2022 21:28:08 -0700 (PDT) Received: from noah-tgl.hsd1.ca.comcast.net ([2601:642:c302:8c00:49fb:7665:e6a4:2078]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b0016a4db13435sm19999327plr.191.2022.07.03.21.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 21:28:08 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v7 1/2] x86: Add comment explaining no Slow_SSE4_2 check in ifunc-sse4_2 Date: Sun, 3 Jul 2022 21:28:06 -0700 Message-Id: <20220704042807.3863553-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628152717.17838-1-goldstein.w.n@gmail.com> References: <20220628152717.17838-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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" Just for clarities sake and so that if a future implementation is added we remember to add the check. --- sysdeps/x86_64/multiarch/ifunc-sse4_2.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h index ee36525bcf..f8b56936ec 100644 --- a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h +++ b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h @@ -27,6 +27,12 @@ IFUNC_SELECTOR (void) { const struct cpu_features* cpu_features = __get_cpu_features (); + /* This function uses the `pcmpstri` sse4.2 instruction which can be + slow on some CPUs. This normally would be guarded by a + Slow_SSE4_2 check, but since there is no other optimized + implementation its best to keep it regardless. If an optimized + fallback is added add a X86_ISA_CPU_FEATURE_ARCH_P (cpu_features, + Slow_SSE4_2) check. */ if (CPU_FEATURE_USABLE_P (cpu_features, SSE4_2)) return OPTIMIZE (sse42); From patchwork Mon Jul 4 04:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1651731 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=jquYkbIE; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lbt8s3Z6Kz9s1l for ; Mon, 4 Jul 2022 14:28:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 10396385BAD7 for ; Mon, 4 Jul 2022 04:28:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10396385BAD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656908907; bh=KN4vKCeOyBTLvdFyIUjiBBRsMzUkOlp++TKRXOQLby0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jquYkbIEvNFxNIkJe6uDzFa2DeMI2sahkmBWs4zm4ekvro2glnUy0yAggt8B/wMoH Tpvzug1ocnmqRxzZIxg5dbuBZb0Gd1ZyiYRiLjnZeoWN9IiokuFK5Sqt2JQcSdCerN QxtW2dQLkm0PxZ4g/KyMRjB60TMKHOJ5ExjMyPyY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 3F04B3857366 for ; Mon, 4 Jul 2022 04:28:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3F04B3857366 Received: by mail-pg1-x531.google.com with SMTP id e132so7877392pgc.5 for ; Sun, 03 Jul 2022 21:28:11 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=KN4vKCeOyBTLvdFyIUjiBBRsMzUkOlp++TKRXOQLby0=; b=2caNqTJpHlDuOVQZrCxSjINWfN12Blt4y/SkO3jwVknrxK0D+iuESwP+VtA823XQtL HZgnPZWcWJFZR0QDiSRwn7FcoawumkICOUBkul/Lw8SoDuo2aWzA8NNFC3iXN+zM4RCT 0m348KNyHrcz6UoiIJVd03VVWdCCIxy6ASPJZPqvvRJMJdQf8a6D71VoPViGEKI1VssC XPZp7OofK1fDLIIva9UElWr3IRJQpnZORD9yoSvyeWszJGnB8VD1DhzlK5m6azpnBCHQ fbDmCb7iPuvvu0QiGnTtZsbYjBTXFs4OPcYKPKcOuxuBS3PXGGNUUbw1xEaf/OGzsxyw gebQ== X-Gm-Message-State: AJIora/41HIW6lfHL57nZkJugrOS8Qpdidire7Os+Peh3lDmCYnSQaQ/ iipGCxj+wmqTQu4MLYJ4mElN+CaU/IA= X-Google-Smtp-Source: AGRyM1sfFcy9iGcJS8YiHo0217ZzNhhEGiAJknXMWGeRVJu1MPPzR7Gg0iYW95cwYZbmMYTXIgOrOQ== X-Received: by 2002:a05:6a00:1a8f:b0:525:a5f1:6f06 with SMTP id e15-20020a056a001a8f00b00525a5f16f06mr33685297pfv.70.1656908889914; Sun, 03 Jul 2022 21:28:09 -0700 (PDT) Received: from noah-tgl.hsd1.ca.comcast.net ([2601:642:c302:8c00:49fb:7665:e6a4:2078]) by smtp.gmail.com with ESMTPSA id i4-20020a17090332c400b0016a4db13435sm19999327plr.191.2022.07.03.21.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 21:28:09 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v7 2/2] x86: Add support for building str{c|p}{brk|spn} with explicit ISA level Date: Sun, 3 Jul 2022 21:28:07 -0700 Message-Id: <20220704042807.3863553-2-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704042807.3863553-1-goldstein.w.n@gmail.com> References: <20220628152717.17838-1-goldstein.w.n@gmail.com> <20220704042807.3863553-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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" The changes for these functions are different than the others because the best implementation (sse4_2) requires the generic implementation as a fallback to be built as well. Changes are: 1. Add non-multiarch functions for str{c|p}{brk|spn}.c to statically select the best implementation based on the configured ISA build level. 2. Add stubs for str{c|p}{brk|spn}-generic and varshift.c to in the sysdeps/x86_64 directory so that the the sse4 implementation will have all of its dependencies for the non-multiarch / rtld build when ISA level >= 2. 3. Add new multiarch/rtld-strcspn.c that just include the non-multiarch strcspn.c which will in turn select the best implementation based on the compiled ISA level. 4. Refactor the ifunc selector and ifunc implementation list to use the ISA level aware wrapper macros that allow functions below the compiled ISA level (with a guranteed replacement) to be skipped. Tested with and without multiarch on x86_64 for ISA levels: {generic, x86-64-v2, x86-64-v3, x86-64-v4} And m32 with and without multiarch. --- sysdeps/x86_64/Makefile | 9 +++++++- sysdeps/x86_64/multiarch/ifunc-impl-list.c | 6 +++++ sysdeps/x86_64/multiarch/ifunc-sse4_2.h | 2 +- sysdeps/x86_64/multiarch/rtld-strcspn.c | 18 +++++++++++++++ sysdeps/x86_64/multiarch/strcspn-generic.c | 6 +++-- sysdeps/x86_64/multiarch/strcspn-sse4.c | 9 +++++--- sysdeps/x86_64/multiarch/strpbrk-generic.c | 5 +++- sysdeps/x86_64/multiarch/strpbrk-sse4.c | 6 ++++- sysdeps/x86_64/multiarch/strspn-generic.c | 7 ++++-- sysdeps/x86_64/multiarch/strspn-sse4.c | 5 +++- sysdeps/x86_64/multiarch/varshift.c | 4 +++- sysdeps/x86_64/strcspn-generic.c | 25 ++++++++++++++++++++ sysdeps/x86_64/strcspn.c | 27 ++++++++++++++++++++++ sysdeps/x86_64/strpbrk-generic.c | 25 ++++++++++++++++++++ sysdeps/x86_64/strpbrk.c | 27 ++++++++++++++++++++++ sysdeps/x86_64/strspn-generic.c | 26 +++++++++++++++++++++ sysdeps/x86_64/strspn.c | 27 ++++++++++++++++++++++ sysdeps/x86_64/varshift.c | 26 +++++++++++++++++++++ 18 files changed, 247 insertions(+), 13 deletions(-) create mode 100644 sysdeps/x86_64/multiarch/rtld-strcspn.c create mode 100644 sysdeps/x86_64/strcspn-generic.c create mode 100644 sysdeps/x86_64/strcspn.c create mode 100644 sysdeps/x86_64/strpbrk-generic.c create mode 100644 sysdeps/x86_64/strpbrk.c create mode 100644 sysdeps/x86_64/strspn-generic.c create mode 100644 sysdeps/x86_64/strspn.c create mode 100644 sysdeps/x86_64/varshift.c diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index 79365aff2a..e597a4855f 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -14,7 +14,14 @@ sysdep_noprof += _mcount endif ifeq ($(subdir),string) -sysdep_routines += strcasecmp_l-nonascii strncase_l-nonascii +sysdep_routines += \ + strcasecmp_l-nonascii \ + strcspn-generic \ + strncase_l-nonascii \ + strpbrk-generic \ + strspn-generic \ + varshift \ +# sysdep_routines gen-as-const-headers += locale-defines.sym tests += \ tst-rsi-strlen diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c index 9e07283f86..b84acfead2 100644 --- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c +++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c @@ -533,6 +533,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/x86_64/multiarch/strcspn.c. */ IFUNC_IMPL (i, name, strcspn, + /* All implementations of strcspn are built at all ISA + levels. */ IFUNC_IMPL_ADD (array, i, strcspn, CPU_FEATURE_USABLE (SSE4_2), __strcspn_sse42) IFUNC_IMPL_ADD (array, i, strcspn, 1, __strcspn_generic)) @@ -609,6 +611,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/x86_64/multiarch/strpbrk.c. */ IFUNC_IMPL (i, name, strpbrk, + /* All implementations of strpbrk are built at all ISA + levels. */ IFUNC_IMPL_ADD (array, i, strpbrk, CPU_FEATURE_USABLE (SSE4_2), __strpbrk_sse42) IFUNC_IMPL_ADD (array, i, strpbrk, 1, __strpbrk_generic)) @@ -616,6 +620,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/x86_64/multiarch/strspn.c. */ IFUNC_IMPL (i, name, strspn, + /* All implementations of strspn are built at all ISA + levels. */ IFUNC_IMPL_ADD (array, i, strspn, CPU_FEATURE_USABLE (SSE4_2), __strspn_sse42) IFUNC_IMPL_ADD (array, i, strspn, 1, __strspn_generic)) diff --git a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h index f8b56936ec..9a819ee1d2 100644 --- a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h +++ b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h @@ -33,7 +33,7 @@ IFUNC_SELECTOR (void) implementation its best to keep it regardless. If an optimized fallback is added add a X86_ISA_CPU_FEATURE_ARCH_P (cpu_features, Slow_SSE4_2) check. */ - if (CPU_FEATURE_USABLE_P (cpu_features, SSE4_2)) + if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, SSE4_2)) return OPTIMIZE (sse42); return OPTIMIZE (generic); diff --git a/sysdeps/x86_64/multiarch/rtld-strcspn.c b/sysdeps/x86_64/multiarch/rtld-strcspn.c new file mode 100644 index 0000000000..99e3c59e00 --- /dev/null +++ b/sysdeps/x86_64/multiarch/rtld-strcspn.c @@ -0,0 +1,18 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "../strcspn.c" diff --git a/sysdeps/x86_64/multiarch/strcspn-generic.c b/sysdeps/x86_64/multiarch/strcspn-generic.c index 423de2e2b2..86cda7b037 100644 --- a/sysdeps/x86_64/multiarch/strcspn-generic.c +++ b/sysdeps/x86_64/multiarch/strcspn-generic.c @@ -16,8 +16,10 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) - +/* We always need to build this implementation as strcspn-sse4 needs + to be able to fallback to it. */ +#include +#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2 # include # define STRCSPN __strcspn_generic diff --git a/sysdeps/x86_64/multiarch/strcspn-sse4.c b/sysdeps/x86_64/multiarch/strcspn-sse4.c index d11e87ab6c..873a416cef 100644 --- a/sysdeps/x86_64/multiarch/strcspn-sse4.c +++ b/sysdeps/x86_64/multiarch/strcspn-sse4.c @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +#include +#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2 # include # include @@ -54,9 +55,11 @@ when either CFlag or ZFlag is 1. If CFlag == 1, ECX has the offset X for case 1. */ +# ifndef STRCSPN +# define STRCSPN __strcspn_sse42 +# endif # ifndef STRCSPN_GENERIC # define STRCSPN_GENERIC __strcspn_generic -# define STRCSPN_SSE42 __strcspn_sse42 # endif # ifdef USE_AS_STRPBRK @@ -80,7 +83,7 @@ char * size_t # endif __attribute__ ((section (".text.sse4.2"))) -STRCSPN_SSE42 (const char *s, const char *a) +STRCSPN (const char *s, const char *a) { if (*a == 0) RETURN (NULL, strlen (s)); diff --git a/sysdeps/x86_64/multiarch/strpbrk-generic.c b/sysdeps/x86_64/multiarch/strpbrk-generic.c index d31acfe495..058f635774 100644 --- a/sysdeps/x86_64/multiarch/strpbrk-generic.c +++ b/sysdeps/x86_64/multiarch/strpbrk-generic.c @@ -16,8 +16,11 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +/* We always need to build this implementation as strpbrk-sse4 needs + to be able to fallback to it. */ +#include +#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2 # include # define STRPBRK __strpbrk_generic diff --git a/sysdeps/x86_64/multiarch/strpbrk-sse4.c b/sysdeps/x86_64/multiarch/strpbrk-sse4.c index bf74d660d5..0adb577955 100644 --- a/sysdeps/x86_64/multiarch/strpbrk-sse4.c +++ b/sysdeps/x86_64/multiarch/strpbrk-sse4.c @@ -16,7 +16,11 @@ License along with the GNU C Library; if not, see . */ +#ifndef STRPBRK +# define STRPBRK __strpbrk_sse42 +#endif + #define USE_AS_STRPBRK #define STRCSPN_GENERIC __strpbrk_generic -#define STRCSPN_SSE42 __strpbrk_sse42 +#define STRCSPN STRPBRK #include "strcspn-sse4.c" diff --git a/sysdeps/x86_64/multiarch/strspn-generic.c b/sysdeps/x86_64/multiarch/strspn-generic.c index 6b50c36432..0f485ab4da 100644 --- a/sysdeps/x86_64/multiarch/strspn-generic.c +++ b/sysdeps/x86_64/multiarch/strspn-generic.c @@ -16,13 +16,16 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) - +/* We always need to build this implementation as strspn-sse4 needs to + be able to fallback to it. */ +#include +#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2 # include # define STRSPN __strspn_generic # undef libc_hidden_builtin_def # define libc_hidden_builtin_def(STRSPN) + #endif #include diff --git a/sysdeps/x86_64/multiarch/strspn-sse4.c b/sysdeps/x86_64/multiarch/strspn-sse4.c index d044916688..4d50507a0d 100644 --- a/sysdeps/x86_64/multiarch/strspn-sse4.c +++ b/sysdeps/x86_64/multiarch/strspn-sse4.c @@ -53,10 +53,13 @@ extern size_t __strspn_generic (const char *, const char *) attribute_hidden; +#ifndef STRSPN +# define STRSPN __strspn_sse42 +#endif size_t __attribute__ ((section (".text.sse4.2"))) -__strspn_sse42 (const char *s, const char *a) +STRSPN (const char *s, const char *a) { if (*a == 0) return 0; diff --git a/sysdeps/x86_64/multiarch/varshift.c b/sysdeps/x86_64/multiarch/varshift.c index 5e2f2bdf51..a98311d749 100644 --- a/sysdeps/x86_64/multiarch/varshift.c +++ b/sysdeps/x86_64/multiarch/varshift.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +#include +#if IS_IN (libc) || MINIMUM_X86_ISA_LEVEL >= 2 + # include const int8_t ___m128i_shift_right[31] attribute_hidden diff --git a/sysdeps/x86_64/strcspn-generic.c b/sysdeps/x86_64/strcspn-generic.c new file mode 100644 index 0000000000..51fd70b63d --- /dev/null +++ b/sysdeps/x86_64/strcspn-generic.c @@ -0,0 +1,25 @@ +/* Hook for build strcspn-generic for non-multiarch build. Needed for + the ISA level >= 2 because strcspn-sse4 has a dependency on + strcspn-generic. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if MINIMUM_X86_ISA_LEVEL >= 2 +# include "multiarch/strcspn-generic.c" +#endif diff --git a/sysdeps/x86_64/strcspn.c b/sysdeps/x86_64/strcspn.c new file mode 100644 index 0000000000..cd54eed869 --- /dev/null +++ b/sysdeps/x86_64/strcspn.c @@ -0,0 +1,27 @@ +/* strcspn hook for non-multiarch and RTLD build. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if MINIMUM_X86_ISA_LEVEL == 1 +#include +#else +#define STRCSPN strcspn +#include "multiarch/strcspn-sse4.c" +libc_hidden_builtin_def (strcspn) +#endif diff --git a/sysdeps/x86_64/strpbrk-generic.c b/sysdeps/x86_64/strpbrk-generic.c new file mode 100644 index 0000000000..a7d8b11216 --- /dev/null +++ b/sysdeps/x86_64/strpbrk-generic.c @@ -0,0 +1,25 @@ +/* Hook for build strpbrk-generic for non-multiarch build. Needed for + the ISA level >= 2 because strpbrk-sse4 has a dependency on + strpbrk-generic. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if MINIMUM_X86_ISA_LEVEL >= 2 +# include "multiarch/strpbrk-generic.c" +#endif diff --git a/sysdeps/x86_64/strpbrk.c b/sysdeps/x86_64/strpbrk.c new file mode 100644 index 0000000000..e7ea1b334a --- /dev/null +++ b/sysdeps/x86_64/strpbrk.c @@ -0,0 +1,27 @@ +/* strpbrk hook for non-multiarch and RTLD build. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if MINIMUM_X86_ISA_LEVEL == 1 +#include +#else +#define STRPBRK strpbrk +#include "multiarch/strpbrk-sse4.c" +libc_hidden_builtin_def (strpbrk) +#endif diff --git a/sysdeps/x86_64/strspn-generic.c b/sysdeps/x86_64/strspn-generic.c new file mode 100644 index 0000000000..1a2a576e49 --- /dev/null +++ b/sysdeps/x86_64/strspn-generic.c @@ -0,0 +1,26 @@ +/* Hook for build strspn-generic for non-multiarch build. Needed for + the ISA level >= 2 because strspn-sse4 has a dependency on + strspn-generic. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + + +#include + +#if MINIMUM_X86_ISA_LEVEL >= 2 +# include "multiarch/strspn-generic.c" +#endif diff --git a/sysdeps/x86_64/strspn.c b/sysdeps/x86_64/strspn.c new file mode 100644 index 0000000000..7b9ede26d9 --- /dev/null +++ b/sysdeps/x86_64/strspn.c @@ -0,0 +1,27 @@ +/* strspn hook for non-multiarch and RTLD build. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if MINIMUM_X86_ISA_LEVEL == 1 +#include +#else +#define STRSPN strspn +#include "multiarch/strspn-sse4.c" +libc_hidden_builtin_def (strspn) +#endif diff --git a/sysdeps/x86_64/varshift.c b/sysdeps/x86_64/varshift.c new file mode 100644 index 0000000000..8f9eb13547 --- /dev/null +++ b/sysdeps/x86_64/varshift.c @@ -0,0 +1,26 @@ +/* Hook for build varshift for non-multiarch build. Needed for the + ISA level >= 2 because strspn-sse4, strcspn-sse4, and strpbrk-sse4 + all have a dependency on varshift.c. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + + +#include + +#if MINIMUM_X86_ISA_LEVEL >= 2 +# include "multiarch/varshift.c" +#endif