From owner-freebsd-arm@FreeBSD.ORG Tue Apr 28 14:45:00 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 0E753106566C; Tue, 28 Apr 2009 14:45:00 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 8FAE08FC08; Tue, 28 Apr 2009 14:44:59 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id n3SEg7j2067382; Tue, 28 Apr 2009 08:42:07 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 28 Apr 2009 08:42:07 -0600 (MDT) Message-Id: <20090428.084207.-1597329356.imp@bsdimp.com> To: gavin@freebsd.org From: "M. Warner Losh" In-Reply-To: <1240918262.85945.1.camel@buffy.york.ac.uk> References: <515c64960904280252sc9fe2afy24e8db8ab13b13e4@mail.gmail.com> <1240918262.85945.1.camel@buffy.york.ac.uk> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: channa.kad@gmail.com, 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 14:45:00 -0000 In message: <1240918262.85945.1.camel@buffy.york.ac.uk> Gavin Atkinson writes: : : This probably belongs on the -arm list, which I'm CCing. : : 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) This is the same as strncnp("a", "b", UMAXINT) because the len argument is "size_t" which is unsigned. : > 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.? This is a bug in your code not in strncmp. Warner : > Thanks & Regards, : > Channagoud : > _______________________________________________ : > freebsd-current@freebsd.org mailing list : > http://lists.freebsd.org/mailman/listinfo/freebsd-current : > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" : _______________________________________________ : freebsd-arm@freebsd.org mailing list : http://lists.freebsd.org/mailman/listinfo/freebsd-arm : To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" : :