From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from de01egw02.freescale.net (de01egw02.freescale.net [192.88.165.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "de01egw02.freescale.net", Issuer "Thawte Premium Server CA" (verified OK)) by ozlabs.org (Postfix) with ESMTP id 13248DDF4C for ; Thu, 6 Sep 2007 05:21:26 +1000 (EST) Date: Wed, 5 Sep 2007 14:21:14 -0500 From: Scott Wood To: galak@kernel.crashing.org Subject: [PATCH 06/10] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h. Message-ID: <20070905192114.GF32113@ld0162-tx32.am.freescale.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20070905192001.GA32049@ld0162-tx32.am.freescale.net> Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , It will be needed for PlanetCore firmware support. Signed-off-by: Scott Wood --- arch/powerpc/boot/flatdevtree_env.h | 14 +------------- arch/powerpc/boot/string.S | 13 +++++++++++++ arch/powerpc/boot/string.h | 1 + 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/boot/flatdevtree_env.h b/arch/powerpc/boot/flatdevtree_env.h index 83bc1c7..643bf7f 100644 --- a/arch/powerpc/boot/flatdevtree_env.h +++ b/arch/powerpc/boot/flatdevtree_env.h @@ -2,7 +2,7 @@ * This file adds the header file glue so that the shared files * flatdevicetree.[ch] can compile and work in the powerpc bootwrapper. * - * strncmp & strchr copied from + * strchr copied from * Copyright (C) 1991, 1992 Linus Torvalds * * Maintained by: Mark A. Greer @@ -24,18 +24,6 @@ #define be64_to_cpu(x) (x) #define cpu_to_be64(x) (x) -static inline int strncmp(const char *cs, const char *ct, size_t count) -{ - signed char __res = 0; - - while (count) { - if ((__res = *cs - *ct++) != 0 || !*cs++) - break; - count--; - } - return __res; -} - static inline char *strchr(const char *s, int c) { for (; *s != (char)c; ++s) diff --git a/arch/powerpc/boot/string.S b/arch/powerpc/boot/string.S index ac3d43b..ce68c58 100644 --- a/arch/powerpc/boot/string.S +++ b/arch/powerpc/boot/string.S @@ -61,6 +61,19 @@ strcmp: beq 1b blr + .globl strncmp +strncmp: + mtctr r5 + addi r5,r3,-1 + addi r4,r4,-1 +1: lbzu r3,1(r5) + cmpwi 1,r3,0 + lbzu r0,1(r4) + subf. r3,r0,r3 + beqlr 1 + bdnzt 2, 1b + blr + .globl strlen strlen: addi r4,r3,-1 diff --git a/arch/powerpc/boot/string.h b/arch/powerpc/boot/string.h index 9fdff1c..db401b7 100644 --- a/arch/powerpc/boot/string.h +++ b/arch/powerpc/boot/string.h @@ -6,6 +6,7 @@ extern char *strcpy(char *dest, const char *src); extern char *strncpy(char *dest, const char *src, size_t n); extern char *strcat(char *dest, const char *src); extern int strcmp(const char *s1, const char *s2); +extern int strncmp(const char *s1, const char *s2, size_t n); extern size_t strlen(const char *s); extern size_t strnlen(const char *s, size_t count); -- 1.5.3