From owner-freebsd-arm@FreeBSD.ORG Tue Apr 28 12:03:58 2009 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76A23106591D; Tue, 28 Apr 2009 12:03:58 +0000 (UTC) (envelope-from mlfbsd@dong.ci0.org) Received: from dong.ci0.org (dong.ci0.org [IPv6:2001:7a8:2066:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 912A88FC08; Tue, 28 Apr 2009 12:03:57 +0000 (UTC) (envelope-from mlfbsd@dong.ci0.org) Received: from dong.ci0.org (localhost.ci0.org [127.0.0.1]) by dong.ci0.org (8.14.3/8.14.3) with ESMTP id n3SCCuVp099083; Tue, 28 Apr 2009 14:12:56 +0200 (CEST) (envelope-from mlfbsd@dong.ci0.org) Received: (from mlfbsd@localhost) by dong.ci0.org (8.14.3/8.14.3/Submit) id n3SCCu4O099082; Tue, 28 Apr 2009 14:12:56 +0200 (CEST) (envelope-from mlfbsd) Date: Tue, 28 Apr 2009 14:12:55 +0200 From: Olivier Houchard To: Channa Message-ID: <20090428121255.GA99020@ci0.org> References: <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> <1240918262.85945.1.camel@buffy.york.ac.uk> <20090428115510.GA98699@ci0.org> <515c64960904280459p3c2ef8bdu3600157eb0c47bcc@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <515c64960904280459p3c2ef8bdu3600157eb0c47bcc@mail.gmail.com> User-Agent: Mutt/1.4.1i Cc: freebsd-arm@freebsd.org, Gavin Atkinson Subject: Re: strncmp issue X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2009 12:04:01 -0000 On Tue, Apr 28, 2009 at 05:29:28PM +0530, Channa wrote: > 2009/4/28 Olivier Houchard : > >> On Tue, 2009-04-28 at 15:22 +0530, Channa wrote: > >> > Hi, > >> > > >> > I am using the freebsd implementation of strncmp for ARM which is an > >> > assembly implementation. > >> > I have a small doubt, when i tested the strncmp by passing the third argument: > >> > 'n' as -1 the return values is ?'0' instead it should '-1'. > >> > When the third argument ?to strncmp is as below: > >> > > >> > ret = strncmp("a","b",-1) > >> > > >> > I think the assembly implementation in > >> > src/lib/libc/arm/string/strncmp.S file needs > >> > to be modified to take care of the above condition. > >> > > >> > In the current implementation > >> > /* if ((len - 1) < 0) return 0 */ > >> > ? ? ? ? subs ? ?r2, r2, #1 > >> > ? ? ? ? movmi ? r0, #0 > >> > ? ? ? ? RETc(mi) > >> > > >> > This should be changed to check as below > >> > > >> > /* if ((len ) < 0) return 0 */ > >> > /* Assembly code here */ > >> > > >> > Could anyone help in solving the above issue.? > >> > > > > > Hi, > > > > This shouldn't be an issue, as the second argument of strncmp is unsigned, > > -1 is not a valid value. > > > > Regards, > > > > Olivier > > > Hi, > Thanks for the reply. > True the third argument of strncmp is unsigned but the return value in > the below call to strncmp > > ret = strncmp("a","b",-1) > > is '0' but it should be -1 i suppose. > > Please let me know if anything is wrong. > True, sorry. I'll fix this later today, thanks a lot for reporting ! Regards, Olivier