From owner-freebsd-arch@FreeBSD.ORG Sat Feb 7 07:09:50 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B1A134DB for ; Sat, 7 Feb 2015 07:09:50 +0000 (UTC) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 7342DB3 for ; Sat, 7 Feb 2015 07:09:50 +0000 (UTC) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 280B5D61438; Sat, 7 Feb 2015 18:09:48 +1100 (AEDT) Date: Sat, 7 Feb 2015 18:09:47 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: "Simon J. Gerraty" Subject: Re: Buggy sbspace() on 64bit builds? In-Reply-To: <5977.1423271024@chaos> Message-ID: <20150207180005.F1334@besplex.bde.org> References: <20150206183036.S1246@besplex.bde.org> <5977.1423271024@chaos> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=baJSDo/B c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=OUXY8nFuAAAA:8 a=bdFpWTK2ga1vbW0cgXkA:9 a=CjuIK1q_8ugA:10 Cc: Anuranjan Shukla , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Feb 2015 07:09:50 -0000 On Fri, 6 Feb 2015, Simon J. Gerraty wrote: > Anuranjan Shukla wrote: >> this, along with return value being 'int' acceptable as a final >> determination? > > It is ok for the function to return long, > so long as an int is used internally. > Casting the int to long - implicit on return does no harm. > > #include > #include > #include > > int > main(int argc, char *argv[]) > { > uint a, b; > long r1; > int r2; > > a = 1; > b = 2; > > r1 = a - b; > r2 = a - b; > > printf("r1=%ld\nr2=%d\nr3=%ld\n", r1, r2, (long)r2); > exit(0); > } > > r1=4294967295 > r2=-1 > r3=-1 > > so I think just using 'int' internally should work for now, > perhaps with a comment saying the object size should match > those being subtracted etc. Yes, that is simplest. Bruce