From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id B3165385840D for ; Tue, 7 Feb 2023 00:16:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3165385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-wm1-x329.google.com with SMTP id q8so9902923wmo.5 for ; Mon, 06 Feb 2023 16:16:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RBHAK002AzI3hQ/WoDDMDNndvRPVevPn2VOyQuf0EHU=; b=WnR4CWXRdyYX8udraWfIrSIR1cTGN60Nn4WqAJYv9yZkCG0URoMkFIEgUJB/Q3/PIi ns+V4HDGpAaSVbhPdjqKHT1LyS0ydqhekgcyMbGez4dqUdLa+EIPMj5swxdSRPFVJOZJ 6FI2CArPFbuT4B39cZS85PolJaOY3Z/ypYJ0S8J0NdKBYmTqCFXJd0vqamkfZoZTiSvT sB3+JI+3gnP/3nOGjZW/DkYpc36zwzSSlOPU/gLyxE0Dn9PBxqm17WmoW1fUcYdVNau8 7FpWoRlINbsx5dot6RJDDb/EGwdekrE4Y9TzYogmWR65OejQAWwp8ur+88GKWoHkThmP 6rHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RBHAK002AzI3hQ/WoDDMDNndvRPVevPn2VOyQuf0EHU=; b=gnpCX5KseBi+UtP6AlY0qoZdlLitHcTUJsdpJioB7dC8GzgPSq7vYK+1XZgJffPryv EgRm24HwFIxWrRiUc+SwviuqILc3Rulym8Z2DM9kG4wx1qxug9eotHiO+aAQ+1hmeUNs HlCL1TOOie8xTaS7evhp4K1s7ZHzjG/lDpJuGF6aeS6uRJwW1kyHy9j4fwTwlEo7Tl3L k8GslPeIY8RaUxYh4t5VomMelybi0nxwI4oKwcZfUxv1RSw9ycw5rq7IsnK58L7KoKn0 OHcKS8KpaIVx8Oj88jKXn0NmCzre/c16OybXqsDoIyniKQDOGS51TNsMH6oybNfB8s1m BeaQ== X-Gm-Message-State: AO0yUKWmMrAraGmO791Q5eaL3mwKyc328PZ/XAWm7WJh/SOUAwc1V0Sd Rf09CgOfdVsuoqMuoXRQ7D19jp/mMasZ45Ux X-Google-Smtp-Source: AK7set81fktnwAnnvt1kNavcwnOjyQgDmwd1uOSPoouWl4Jh8URirZGzKBtUVyLSCee30NQ4Z9JWgw== X-Received: by 2002:a05:600c:4a97:b0:3dc:5342:4132 with SMTP id b23-20020a05600c4a9700b003dc53424132mr1336343wmp.4.1675729012168; Mon, 06 Feb 2023 16:16:52 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id f1-20020a1cc901000000b003df14531724sm16862050wmb.21.2023.02.06.16.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 16:16:51 -0800 (PST) From: Christoph Muellner To: libc-alpha@sourceware.org, Palmer Dabbelt , Darius Rad , Andrew Waterman , DJ Delorie , Vineet Gupta , Kito Cheng , Jeff Law , Philipp Tomsich , Heiko Stuebner Cc: =?UTF-8?q?Christoph=20M=C3=BCllner?= Subject: [RFC PATCH 15/19] riscv: Add ifunc support for strcmp Date: Tue, 7 Feb 2023 01:16:14 +0100 Message-Id: <20230207001618.458947-16-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207001618.458947-1-christoph.muellner@vrull.eu> References: <20230207001618.458947-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_MANYTO,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: From: Christoph Müllner This patch adds ifunc support for calls to strcmp to the RISC-V code. No optimized code is added as part of this patch. Signed-off-by: Christoph Müllner --- sysdeps/riscv/multiarch/Makefile | 4 ++- sysdeps/riscv/multiarch/ifunc-impl-list.c | 2 ++ sysdeps/riscv/multiarch/strcmp.c | 40 +++++++++++++++++++++++ sysdeps/riscv/multiarch/strcmp_generic.c | 32 ++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 sysdeps/riscv/multiarch/strcmp.c create mode 100644 sysdeps/riscv/multiarch/strcmp_generic.c diff --git a/sysdeps/riscv/multiarch/Makefile b/sysdeps/riscv/multiarch/Makefile index b2247b7326..3017bde75a 100644 --- a/sysdeps/riscv/multiarch/Makefile +++ b/sysdeps/riscv/multiarch/Makefile @@ -9,5 +9,7 @@ sysdep_routines += \ memset_rv64_unaligned_cboz64 \ \ strlen_generic \ - strlen_zbb + strlen_zbb \ + \ + strcmp_generic endif diff --git a/sysdeps/riscv/multiarch/ifunc-impl-list.c b/sysdeps/riscv/multiarch/ifunc-impl-list.c index 2b4d2e1c17..64331a4c7f 100644 --- a/sysdeps/riscv/multiarch/ifunc-impl-list.c +++ b/sysdeps/riscv/multiarch/ifunc-impl-list.c @@ -58,6 +58,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_zbb) IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_generic)) + IFUNC_IMPL (i, name, strcmp, + IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcmp_generic)) return i; } diff --git a/sysdeps/riscv/multiarch/strcmp.c b/sysdeps/riscv/multiarch/strcmp.c new file mode 100644 index 0000000000..8c21a90afd --- /dev/null +++ b/sysdeps/riscv/multiarch/strcmp.c @@ -0,0 +1,40 @@ +/* Multiple versions of strcmp. RISC-V version. + 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 + . */ + +/* Define multiple versions only for the definition in libc. */ + +#if IS_IN (libc) +/* Redefine strcmp so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef strcmp +# define strcmp __redirect_strcmp +# include +# include +# include +# include + +extern __typeof (__redirect_strcmp) __libc_strcmp; +extern __typeof (__redirect_strcmp) __strcmp_generic attribute_hidden; + +libc_ifunc (__libc_strcmp, __strcmp_generic); + +# undef strcmp +strong_alias (__libc_strcmp, strcmp); +#else +# include +#endif diff --git a/sysdeps/riscv/multiarch/strcmp_generic.c b/sysdeps/riscv/multiarch/strcmp_generic.c new file mode 100644 index 0000000000..d85cf3940f --- /dev/null +++ b/sysdeps/riscv/multiarch/strcmp_generic.c @@ -0,0 +1,32 @@ +/* strcmp for RISC-V, default version for internal use. + 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 + +#define STRCMP __strcmp_generic + +#ifdef SHARED +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1(__strcmp_generic, __GI_strcmp, __strcmp_generic); +#endif + +extern int __strcmp_generic(const char *s1, const char *s2); + +#include -- 2.39.1