From patchwork Mon Jan 12 15:11:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco X-Patchwork-Id: 427773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9A05F1401DA for ; Tue, 13 Jan 2015 02:12:07 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=QBV vqRDyiC/RiIQoI0kQTsy/x1Qyl6Qty/vzCI48fVODatF0PgwBppKToCNaUMnlOag 1VYux282I9qi/dDG7RZyWG+7DYSFkHjs/X7nGEIVCl9UMo0Ez0WV8F+SYxqdMKT2 Hnv3Wr1O7V2i8DWJi5lrgMvCtGaaLFQTjEufJmqA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=KzVPMlUB4 2P2bD6Wj3WnxEbd4tE=; b=KZkstYi+YdhM3EiXvqmaxwyxvijpWEYq1eYvX0kL1 Ro89jgTAUIGLMxQK7MCx8pqQKQ2xPp8uV9IOHEz8Sjq2OvDlS7DyvSiLJh9I4oYX lkGYrw7kTQ60QlCHzKbeaeF7stoJwI5L6Hwaw9dB05Ig7Jl9R1iqFtSUJmcJWDiE ns= Received: (qmail 22148 invoked by alias); 12 Jan 2015 15:11:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 21941 invoked by uid 89); 12 Jan 2015 15:11:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com From: "Wilco Dijkstra" To: Subject: [PATCH] Improve bzero performance Date: Mon, 12 Jan 2015 15:11:47 -0000 Message-ID: <001c01d02e7a$15e03f50$41a0bdf0$@com> MIME-Version: 1.0 X-MC-Unique: 115011215115207401 Rather than using a C implementation of memset, directly call memset, which typically has a much faster optimized implementation. ChangeLog: 2015-01-12 Wilco Dijkstra wdijkstr@arm.com * string/bzero.c (__bzero): Call memset for performance. --- string/bzero.c | 58 +++------------------------------------------------------- 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/string/bzero.c b/string/bzero.c index 9c220b9..f1a0584 100644 --- a/string/bzero.c +++ b/string/bzero.c @@ -16,67 +16,15 @@ License along with the GNU C Library; if not, see . */ +#include #include -#include #undef __bzero /* Set N bytes of S to 0. */ void -__bzero (s, len) - void *s; - size_t len; +__bzero (void *s, size_t len) { - long int dstp = (long int) s; - const op_t zero = 0; - - if (len >= 8) - { - size_t xlen; - - /* There are at least some bytes to zero. No need to test - for LEN == 0 in this alignment loop. */ - while (dstp % OPSIZ != 0) - { - ((byte *) dstp)[0] = 0; - dstp += 1; - len -= 1; - } - - /* Write 8 op_t per iteration until less than 8 op_t remain. */ - xlen = len / (OPSIZ * 8); - while (xlen != 0) - { - ((op_t *) dstp)[0] = zero; - ((op_t *) dstp)[1] = zero; - ((op_t *) dstp)[2] = zero; - ((op_t *) dstp)[3] = zero; - ((op_t *) dstp)[4] = zero; - ((op_t *) dstp)[5] = zero; - ((op_t *) dstp)[6] = zero; - ((op_t *) dstp)[7] = zero; - dstp += 8 * OPSIZ; - xlen -= 1; - } - len %= OPSIZ * 8; - - /* Write 1 op_t per iteration until less than op_t remain. */ - xlen = len / OPSIZ; - while (xlen != 0) - { - ((op_t *) dstp)[0] = zero; - dstp += OPSIZ; - xlen -= 1; - } - len %= OPSIZ; - } - - /* Write the last few bytes. */ - while (len != 0) - { - ((byte *) dstp)[0] = 0; - dstp += 1; - len -= 1; - } + memset (s, '\0', len); } weak_alias (__bzero, bzero)