From owner-freebsd-arm@FreeBSD.ORG Tue Apr 28 11:46:18 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 A9342106567E; Tue, 28 Apr 2009 11:46:18 +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 986B98FC13; Tue, 28 Apr 2009 11:46:17 +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 n3SBtCkI098762; Tue, 28 Apr 2009 13:55:12 +0200 (CEST) (envelope-from mlfbsd@dong.ci0.org) Received: (from mlfbsd@localhost) by dong.ci0.org (8.14.3/8.14.3/Submit) id n3SBtBVC098761; Tue, 28 Apr 2009 13:55:11 +0200 (CEST) (envelope-from mlfbsd) Date: Tue, 28 Apr 2009 13:55:10 +0200 From: Olivier Houchard To: Gavin Atkinson Message-ID: <20090428115510.GA98699@ci0.org> References: <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> <1240918262.85945.1.camel@buffy.york.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1240918262.85945.1.camel@buffy.york.ac.uk> User-Agent: Mutt/1.4.1i Cc: Channa , freebsd-arm@freebsd.org 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 11:46:21 -0000 > 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