From patchwork Tue Jun 28 15:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 55501 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B36E38B8D78 for ; Tue, 28 Jun 2022 15:28:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B36E38B8D78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656430109; bh=KwC+hxK+Oeg32yFk4ZO+mp1treGnEGzHX7ZCufY4u9E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=EDO+++fBpLEtIFC2J1FH/cEwgeuK49/LYQBDTWGuazYuVZzTtquh1LM/nq6A0+bRt we93USM8sJye1JBDowhfqg8oQAUCAWVShxLapaMyMu3TEZVYkeuw1HF/Ou8YvyibcS 1C0+Qotd5MvnihUDCxHooLCKg6tERjou/zOuzHJ0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 2AF59389988D for ; Tue, 28 Jun 2022 15:27:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AF59389988D Received: by mail-pg1-x52e.google.com with SMTP id 23so12524541pgc.8 for ; Tue, 28 Jun 2022 08:27:21 -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=KwC+hxK+Oeg32yFk4ZO+mp1treGnEGzHX7ZCufY4u9E=; b=XYXkAL6uuANSF5gDP5Mxs8Ag0GGD1lB8N89ca0xBcugrSu2OvfVjiwmdTH+8N4WV8v HEein7/GrWizQfIKWqQg4w4pGLf3HKH+wPR0j2steZSxjM1EqvQCGO7sqRYMvfnQ2+j3 K+9wFMJ9FI/6AOP252gt70EoZUHF2d/8wqgqBezqLsGOzPQWgjVxSib5Z8jlKhUk2V2i 27OabwhToT+chdmXy6KyCZWEq6Bzj2l9WvRGp+AFrXwRxsFoN+O/RkKnEaXUWXCXy6AZ tcSkHIQgnjaphyVALVwhdU1kCxMv0e9U/otnJi+NzYUWnvXwos0JJVGJaKGPeMTbXOo/ rMtQ== X-Gm-Message-State: AJIora9277ZVLjwIS7Ad2zg2Yk86XA1G818N2eRq3w+Tux39vChfHY86 8oWkBvhhttrlheFNJlSMP6SwbxCYOcc= X-Google-Smtp-Source: AGRyM1uHxwd2qtxnJJE0IlTra0GNoBBP0bshX3SMsM+gjRpPFCZBly2qELPa97ImZvKvr20l93Iw7A== X-Received: by 2002:a63:78ce:0:b0:40c:3c04:e3d8 with SMTP id t197-20020a6378ce000000b0040c3c04e3d8mr18066148pgc.202.1656430040011; Tue, 28 Jun 2022 08:27:20 -0700 (PDT) Received: from noah-tgl.. ([192.55.60.43]) by smtp.gmail.com with ESMTPSA id u3-20020a170903108300b0016a613012a0sm9425256pld.210.2022.06.28.08.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 08:27:19 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v1 1/2] x86: Add comment explaining no Slow_SSE4_2 check in ifunc-sse4_2 Date: Tue, 28 Jun 2022 08:27:16 -0700 Message-Id: <20220628152717.17838-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 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+patchwork=sourceware.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, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h index ee36525bcf..204c4b5406 100644 --- a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h +++ b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h @@ -27,7 +27,11 @@ IFUNC_SELECTOR (void) { const struct cpu_features* cpu_features = __get_cpu_features (); - if (CPU_FEATURE_USABLE_P (cpu_features, SSE4_2)) + /* This function uses slow sse4.2 instructions (pcmpstri) but since + there is no other optimized implementation keep using. If an + optimized fallback is added add a X86_ISA_CPU_FEATURE_USABLE_P + (cpu_features, SSE4_2) check. */ + if (ISA_CPU_FEATURE_USABLE_P (cpu_features, SSE4_2)) return OPTIMIZE (sse42); return OPTIMIZE (generic); From patchwork Tue Jun 28 15:27:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 55499 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49150380F1B8 for ; Tue, 28 Jun 2022 15:27:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49150380F1B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656430066; bh=xdm6BGAp5elQu3NsiqdFUpC3OnqHUaiZNKVj6VIXxns=; 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=NnUoPEyRb/3WOBBe9MOsbOLTdVtF24EGPasLzYKE0OxJg66hsA0bhOspPEuw8K7bj WpIro9MJ88CDWq1zPiS2SVLairD18JsqvpkeBWuTJ8n/De/sC3gmczIRI312LtBUZl pxAv2Aik4mxRYOgl9D2Zmx2SpwMwtEVlmhFVuUrU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id C348B3810BE7 for ; Tue, 28 Jun 2022 15:27:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C348B3810BE7 Received: by mail-pj1-x102d.google.com with SMTP id g20-20020a17090a579400b001ed52939d72so7583367pji.4 for ; Tue, 28 Jun 2022 08:27:22 -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=xdm6BGAp5elQu3NsiqdFUpC3OnqHUaiZNKVj6VIXxns=; b=5FsEWsqJFD4MR1gByFprtmkFGNs+0WD0xE/RyAxNoku9HGSfKo57+l4HRGWcON4bJ/ iP8c94/Bib03N924m3YOeQsxgYNgZIcR8r+2ZoScEdoFceNjOMDfQHO/mjf3nFYIGDdu SawxB1RD0WvoB30OkV7aIsUzXQ1o71hNsNPq8XSZUqv4qmGOJzC/pHBuhNhmYPLEdt4m Af9n+4+zKNA3dBaRL/a5WFoGMWEk6IUQa+u75rHnQJTVIkl7V7wSqoaTIL+wyFC5xJ0u +yov/xXG3HulAxWn5abin5fMK22DZSKidraeQ73uDp889QMtsi5HpezbbuxVdf1t7fBJ zK4g== X-Gm-Message-State: AJIora+QrSpxKcSXdlogLJgm8S9IwRRiWa2x0nhkP9+sWTIei79MDKNB QLfSoesVhTnibVgmQ+KOgvp8Ll/bJFM= X-Google-Smtp-Source: AGRyM1u+AZ+yQrFY42KD2sAockJX7hSN7wk6+pHUQTgM8f4pH/KcCg1r3+2eXIuRxJWyfPauteAm+A== X-Received: by 2002:a17:90b:3a8d:b0:1ef:7d4:6a5f with SMTP id om13-20020a17090b3a8d00b001ef07d46a5fmr142896pjb.139.1656430041330; Tue, 28 Jun 2022 08:27:21 -0700 (PDT) Received: from noah-tgl.. ([192.55.60.43]) by smtp.gmail.com with ESMTPSA id u3-20020a170903108300b0016a613012a0sm9425256pld.210.2022.06.28.08.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 08:27:21 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v1 2/2] x86: Add support for building str{c|p}{brk|spn} with explicit ISA level Date: Tue, 28 Jun 2022 08:27:17 -0700 Message-Id: <20220628152717.17838-2-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=-12.0 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+patchwork=sourceware.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 >= 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 | 9 +++++++- sysdeps/x86_64/multiarch/ifunc-sse4_2.h | 2 +- sysdeps/x86_64/multiarch/rtld-strcspn.c | 18 +++++++++++++++ sysdeps/x86_64/multiarch/strcspn-generic.c | 11 +++++---- sysdeps/x86_64/multiarch/strcspn-sse4.c | 6 +++-- sysdeps/x86_64/multiarch/strpbrk-generic.c | 9 +++++--- sysdeps/x86_64/multiarch/strpbrk-sse4.c | 6 ++++- sysdeps/x86_64/multiarch/strspn-generic.c | 8 ++++--- sysdeps/x86_64/multiarch/strspn-sse4.c | 6 ++++- sysdeps/x86_64/strcspn-generic.c | 22 ++++++++++++++++++ sysdeps/x86_64/strcspn.c | 27 ++++++++++++++++++++++ sysdeps/x86_64/strpbrk-generic.c | 22 ++++++++++++++++++ sysdeps/x86_64/strpbrk.c | 27 ++++++++++++++++++++++ sysdeps/x86_64/strspn-generic.c | 23 ++++++++++++++++++ sysdeps/x86_64/strspn.c | 27 ++++++++++++++++++++++ sysdeps/x86_64/varshift.c | 23 ++++++++++++++++++ 17 files changed, 238 insertions(+), 17 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..c130d56342 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 772b4ace6c..251b0022d9 100644 --- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c +++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c @@ -540,6 +540,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)) @@ -616,6 +618,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)) @@ -623,13 +627,16 @@ __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)) /* Support sysdeps/x86_64/multiarch/strstr.c. */ IFUNC_IMPL (i, name, strstr, - /* All implementations of strstr are built at all ISA levels. */ + /* All implementations of strstr are built at all ISA + levels. */ IFUNC_IMPL_ADD (array, i, strstr, (CPU_FEATURE_USABLE (AVX512VL) && CPU_FEATURE_USABLE (AVX512BW) diff --git a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h index 204c4b5406..d642f54fac 100644 --- a/sysdeps/x86_64/multiarch/ifunc-sse4_2.h +++ b/sysdeps/x86_64/multiarch/ifunc-sse4_2.h @@ -31,7 +31,7 @@ IFUNC_SELECTOR (void) there is no other optimized implementation keep using. If an optimized fallback is added add a X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, SSE4_2) check. */ - if (ISA_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..64e90a26bb 100644 --- a/sysdeps/x86_64/multiarch/strcspn-generic.c +++ b/sysdeps/x86_64/multiarch/strcspn-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 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 # undef libc_hidden_builtin_def # define libc_hidden_builtin_def(STRCSPN) -#endif -#include +# include + +#endif diff --git a/sysdeps/x86_64/multiarch/strcspn-sse4.c b/sysdeps/x86_64/multiarch/strcspn-sse4.c index 59f64f9fe8..becdaf05f3 100644 --- a/sysdeps/x86_64/multiarch/strcspn-sse4.c +++ b/sysdeps/x86_64/multiarch/strcspn-sse4.c @@ -52,9 +52,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 @@ -78,7 +80,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..7f3ea86e91 100644 --- a/sysdeps/x86_64/multiarch/strpbrk-generic.c +++ b/sysdeps/x86_64/multiarch/strpbrk-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 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 # undef libc_hidden_builtin_def # define libc_hidden_builtin_def(STRPBRK) -#endif -#include +# include +#endif 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..f5632ad3b2 100644 --- a/sysdeps/x86_64/multiarch/strspn-generic.c +++ b/sysdeps/x86_64/multiarch/strspn-generic.c @@ -16,13 +16,15 @@ 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 +#endif diff --git a/sysdeps/x86_64/multiarch/strspn-sse4.c b/sysdeps/x86_64/multiarch/strspn-sse4.c index d044916688..6263669b54 100644 --- a/sysdeps/x86_64/multiarch/strspn-sse4.c +++ b/sysdeps/x86_64/multiarch/strspn-sse4.c @@ -51,12 +51,16 @@ We exit from the loop for case 1. */ + 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/strcspn-generic.c b/sysdeps/x86_64/strcspn-generic.c new file mode 100644 index 0000000000..082324e793 --- /dev/null +++ b/sysdeps/x86_64/strcspn-generic.c @@ -0,0 +1,22 @@ +/* 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 !defined USE_MULTIARCH && 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..6bdbb2d164 --- /dev/null +++ b/sysdeps/x86_64/strpbrk-generic.c @@ -0,0 +1,22 @@ +/* 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 !defined USE_MULTIARCH && 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..0730972bbd --- /dev/null +++ b/sysdeps/x86_64/strspn-generic.c @@ -0,0 +1,23 @@ +/* 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 !defined USE_MULTIARCH && 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..ab3c506378 --- /dev/null +++ b/sysdeps/x86_64/varshift.c @@ -0,0 +1,23 @@ +/* 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 !defined USE_MULTIARCH && MINIMUM_X86_ISA_LEVEL >= 2 +# include "multiarch/varshift.c" +#endif