From patchwork Tue Feb 7 00:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 64389 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 3D1A73884526 for ; Tue, 7 Feb 2023 00:18:44 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 0FD1F385840A for ; Tue, 7 Feb 2023 00:16:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FD1F385840A 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-x330.google.com with SMTP id o36so9916622wms.1 for ; Mon, 06 Feb 2023 16:16:45 -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=f8F8/LKA8ApCKbih+IBLa4IoTM1LoL3MkN+4weX429k=; b=TCUSYMkLGviuqNi8d839d8FwaeAZ1RMzpWdvLuTWHU7VytTMdRWuQo9ntulej7YeXm 8gw6MeyMKEkIiERdVfsXuVOyI9GQK/8g77Dw4lBhH4HMYEPviMCDZa7APJkxegRTVful p451GPZNFpEAoSZnT5YFZFtwBwqkhx44L2+bsqvBfTobq98G1t2xHJXSIuUufiwOy6Zq b1vvT3SDhKDFXaMvGUaaJxdi9MQbmKolcNort5HDPw8AixaMPP0Gia6UVXQ4H0v7xIun Gc+yX7LfW1hY8irYfsjujPWfqSRKW4naBBtOrmf0MaT+HsopAQ/JDiWZG1c5egwi0aci ykOw== 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=f8F8/LKA8ApCKbih+IBLa4IoTM1LoL3MkN+4weX429k=; b=BtCNP7OlqUHeXyUb/4qL1U2NV91nObJaPqSlC0qNe/klqkfbNuuvUAJB/EstXt2EUp 2aApNwjn8Op5Lropf1JWZKNUnfAMwDo7v+A9N2XmmcfbZ1P9H+e5XX6pb2v9yeC9wnuf V08XeEJ/SsjWtRxPIpwXWQWqgxovH6wDkWqWh/iQaxn88YbSjV11lUlPXgjhUYuKPcWN 2HHBfkSSaTmO634kdpKostKD5EnQR/LILagrA7uIjFXrKb4StEePQIBSoglLRs5gvm8z sATgn4GeEIF4RLseKVBvZ99NGUgQLGJce7PCcgX1yG+LSEcjDjwrjNDaiJfGoynaebMA HyMA== X-Gm-Message-State: AO0yUKWqB4tx+pNdFPFLwbgK9aC931iHt5l5r8hQCQYfCK9caO+xcQgC OeZ/gopx5qDZMCXhodl02l8R6W3OJlB05mEH X-Google-Smtp-Source: AK7set8Dojc18bonySy7RnjVsdTsV2BQrKsPazOcsubpFDj/Z0hxzoxZKExAuX5b7gMzJL0zPJEAjg== X-Received: by 2002:a05:600c:4aa0:b0:3d9:69fd:7707 with SMTP id b32-20020a05600c4aa000b003d969fd7707mr817023wmp.2.1675729003285; Mon, 06 Feb 2023 16:16:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 16:16:42 -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_M=C3=BCllner?= Subject: [RFC PATCH 09/19] riscv: Add ifunc support for memset Date: Tue, 7 Feb 2023 01:16:08 +0100 Message-Id: <20230207001618.458947-10-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 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 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: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" From: Christoph Müllner This patch adds ifunc support for calls to memset 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 | 2 +- sysdeps/riscv/multiarch/ifunc-impl-list.c | 3 ++ sysdeps/riscv/multiarch/memset.c | 40 +++++++++++++++++++++++ sysdeps/riscv/multiarch/memset_generic.c | 32 ++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 sysdeps/riscv/multiarch/memset.c create mode 100644 sysdeps/riscv/multiarch/memset_generic.c diff --git a/sysdeps/riscv/multiarch/Makefile b/sysdeps/riscv/multiarch/Makefile index 68d3f5192f..453f0f4e4c 100644 --- a/sysdeps/riscv/multiarch/Makefile +++ b/sysdeps/riscv/multiarch/Makefile @@ -1,4 +1,4 @@ ifeq ($(subdir),string) sysdep_routines += \ - + memset_generic endif diff --git a/sysdeps/riscv/multiarch/ifunc-impl-list.c b/sysdeps/riscv/multiarch/ifunc-impl-list.c index c0cdca45fd..fd1752bc46 100644 --- a/sysdeps/riscv/multiarch/ifunc-impl-list.c +++ b/sysdeps/riscv/multiarch/ifunc-impl-list.c @@ -35,5 +35,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t i = 0; + IFUNC_IMPL (i, name, memset, + IFUNC_IMPL_ADD (array, i, memset, 1, __memset_generic)) + return i; } diff --git a/sysdeps/riscv/multiarch/memset.c b/sysdeps/riscv/multiarch/memset.c new file mode 100644 index 0000000000..ae4289ab03 --- /dev/null +++ b/sysdeps/riscv/multiarch/memset.c @@ -0,0 +1,40 @@ +/* Multiple versions of memset. 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 memset so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef memset +# define memset __redirect_memset +# include +# include +# include +# include + +extern __typeof (__redirect_memset) __libc_memset; +extern __typeof (__redirect_memset) __memset_generic attribute_hidden; + +libc_ifunc (__libc_memset, __memset_generic); + +# undef memset +strong_alias (__libc_memset, memset); +#else +# include +#endif diff --git a/sysdeps/riscv/multiarch/memset_generic.c b/sysdeps/riscv/multiarch/memset_generic.c new file mode 100644 index 0000000000..37acb398d4 --- /dev/null +++ b/sysdeps/riscv/multiarch/memset_generic.c @@ -0,0 +1,32 @@ +/* Memset 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 MEMSET __memset_generic + +#ifdef SHARED +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1(__memset_generic, __GI_memset, __memset_generic); +#endif + +extern void *__memset_generic(void *s, int c, size_t n); + +#include