Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp698239rdb; Sun, 3 Sep 2023 06:43:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFdjxOSSrsyaktXr8pPaXDAXppmuIgq/VqKNVgIWBmu8pls2VzC6AVEg3TkVxCiWfqOoZZ X-Received: by 2002:a05:6402:1607:b0:523:1ce9:1f49 with SMTP id f7-20020a056402160700b005231ce91f49mr4774939edv.42.1693748589645; Sun, 03 Sep 2023 06:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693748589; cv=none; d=google.com; s=arc-20160816; b=y1K/tB/rVUjPxJUtr2Y2dUpPua3Q6YGc2CHtAPnDnfxJt5stPl72uJNB3CY8zzTINr k/X+csGFc7JN1XYrtCtdb+rpHUgK6hUMdzoelKAsEyCKQHX2LePPZGk8y7PE6SN59JDN MGcAgrvLlxcd1015/dMQ73i2Z9FWPkiV/xtWU8eJTPGKKLbiY6+dXQWsy0Ee+B3Je7Kp JlFZhx8/TZB+Q0b7i6xqrSKULIgPf4pSXcJDtftNS8u/UcH6mqIcNCJFUGxQzToOXRIw hooFQuJgng9TiTFz6Fu8vazHFnU1wQvyRzGvYplWXyheTrhvSqyB1wV18FYrkVg7Bqi9 0JMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hD5kBCU3gdprCu64uYrBeMAfLHBjNz97NsnNYH1Mtx8=; fh=uB+M+oKdvki1yyK2yvJzCFfZDgyJpU60CoVCPdrmo/I=; b=WzqGejFDYQEUm/I8DB0b06igE49SCie1SxdviA6Fhk/nIpfV3NUVpjyyj1ydrgatjV o7FyjUboqHXtJthI9aK8NzTGTODux6sktFXkl8jX8nRXFTZP2ueRhNFuvgefKdMakH0w 4FQjxsZN3dNFsrqsPO1nawi2vQ869P9jSytQpYylTqkIYIzjDLZFUOgfBw8/+Gzo08Kv ts9eMOTYUol0JhlhbjE+ncXgknficExhYMFUuWIDVm+reIFYtTF6iqxgzBmLtJV/TaF0 S88LV6nT4izJkCZOcWwU442kFPHpD4dBLDhWhHHPuP/2b20lgGPIDrDY/GHzEfjlGh/e OzoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b="fAbK/+f5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020aa7d1d0000000b00529f5d8ee3fsi4944205edp.574.2023.09.03.06.42.43; Sun, 03 Sep 2023 06:43:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b="fAbK/+f5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233282AbjIBNfo (ORCPT + 99 others); Sat, 2 Sep 2023 09:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233120AbjIBNfo (ORCPT ); Sat, 2 Sep 2023 09:35:44 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DC131738 for ; Sat, 2 Sep 2023 06:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693661733; bh=adKYv+UWCAtL6RnGzj9nIBJ/HQrhFBvKNcQpOXq1TGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fAbK/+f59o0nFsY7PmslyoS5pHnhg8H4k2Rp7HYy9XAeYFWockUwzwwYlFU+VM7iJ dStQbPfzEbfklMzNAV6CQphMOlwmNPgfCWTV2yMBvFnaUkmbekN0E5SrAg+pZxelcG FjcTf83uHhIY21i0fUb/XKo7155W9N87t9d/xjtXk8/GnjOC85b+Ifhq48kGkGoOcI eAIdmXAbq6W+gJfPmr1L10oq/Dxv+twRAbvliE0Ij+BcoeT8DI+8/kCAAYd7WFKLOd /01Nzb0HC63R90yc02TkGmg8ccA4a1Itzr0tiOFUVo5lXRuuoi5dnoB6BYWIttkSjJ Xw9iIO4Vwd6xA== Received: from localhost.localdomain (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id 6CAC424B3E2; Sat, 2 Sep 2023 20:35:29 +0700 (WIB) From: Ammar Faizi To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Cc: Ammar Faizi , David Laight , Nicholas Rosenberg , Alviro Iskandar Setiawan , Michael William Jonathan , GNU/Weeb Mailing List , Linux Kernel Mailing List Subject: [RFC PATCH v3 4/4] tools/nolibc: string: Remove the `_nolibc_memcpy_up()` function Date: Sat, 2 Sep 2023 20:35:05 +0700 Message-Id: <20230902133505.2176434-5-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230902133505.2176434-1-ammarfaizi2@gnuweeb.org> References: <20230902133505.2176434-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function is only called by memcpy(), there is no real reason to have this wrapper. Delete this function and move the code to memcpy() directly. Signed-off-by: Ammar Faizi --- tools/include/nolibc/string.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index 22dcb3f566baeefe..a01c69dd495f550c 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -10,84 +10,78 @@ #include "std.h" static void *malloc(size_t len); /* * As much as possible, please keep functions alphabetically sorted. */ static __attribute__((unused)) int memcmp(const void *s1, const void *s2, size_t n) { size_t ofs = 0; int c1 = 0; while (ofs < n && !(c1 = ((unsigned char *)s1)[ofs] - ((unsigned char *)s2)[ofs])) { ofs++; } return c1; } -static __attribute__((unused)) -void *_nolibc_memcpy_up(void *dst, const void *src, size_t len) -{ - size_t pos = 0; - - while (pos < len) { - ((char *)dst)[pos] = ((const char *)src)[pos]; - pos++; - } - return dst; -} - #ifndef NOLIBC_ARCH_HAS_MEMMOVE /* might be ignored by the compiler without -ffreestanding, then found as * missing. */ __attribute__((weak,unused,section(".text.nolibc_memmove"))) void *memmove(void *dst, const void *src, size_t len) { size_t dir, pos; pos = len; dir = -1; if (dst < src) { pos = -1; dir = 1; } while (len) { pos += dir; ((char *)dst)[pos] = ((const char *)src)[pos]; len--; } return dst; } #endif /* #ifndef NOLIBC_ARCH_HAS_MEMMOVE */ #ifndef NOLIBC_ARCH_HAS_MEMCPY /* must be exported, as it's used by libgcc on ARM */ __attribute__((weak,unused,section(".text.nolibc_memcpy"))) void *memcpy(void *dst, const void *src, size_t len) { - return _nolibc_memcpy_up(dst, src, len); + size_t pos = 0; + + while (pos < len) { + ((char *)dst)[pos] = ((const char *)src)[pos]; + pos++; + } + return dst; } #endif /* #ifndef NOLIBC_ARCH_HAS_MEMCPY */ #ifndef NOLIBC_ARCH_HAS_MEMSET /* might be ignored by the compiler without -ffreestanding, then found as * missing. */ __attribute__((weak,unused,section(".text.nolibc_memset"))) void *memset(void *dst, int b, size_t len) { char *p = dst; while (len--) { /* prevent gcc from recognizing memset() here */ __asm__ volatile(""); *(p++) = b; } return dst; } #endif /* #ifndef NOLIBC_ARCH_HAS_MEMSET */ -- Ammar Faizi