From owner-cvs-all Thu Jan 11 13:10:25 2001 Delivered-To: cvs-all@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id CAC0C37B401; Thu, 11 Jan 2001 13:09:54 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id IAA00182; Fri, 12 Jan 2001 08:09:09 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01JYT9TWF928EMXNEJ@cim.alcatel.com.au>; Fri, 12 Jan 2001 08:09:18 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.0/8.11.0) id f0BL97R86662; Fri, 12 Jan 2001 08:09:07 +1100 (EST envelope-from jeremyp) Content-return: prohibited Date: Fri, 12 Jan 2001 08:09:07 +1100 From: Peter Jeremy Subject: Re: cvs commit: src/sys/alpha/include bus.h In-reply-to: ; from mjacob@feral.com on Wed, Jan 10, 2001 at 10:24:26PM -0800 To: Matthew Jacob Cc: Warner Losh , Matt Jacob , cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Mail-followup-to: Matthew Jacob , Warner Losh , Matt Jacob , cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Message-id: <20010112080906.I91029@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i References: <20010111163029.B91242@gsmx07.alcatel.com.au> Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2001-Jan-10 22:24:26 -0800, Matthew Jacob wrote: >On Thu, 11 Jan 2001, Peter Jeremy wrote: > >> On 2001-Jan-09 22:04:03 -0800, Matthew Jacob wrote: >> > >> > >> >> In message <200101091817.f09IHng10622@freefall.freebsd.org> Matt Jacob writes: >> >> : me that BUS_SPACE_UNRESTRICTED should b ~0UL, not ~0. >> >> >> >> Would this impact the 10E6 uses of ~0 in the bus_alloc_resource calls >> >> we have? >> > >> >int foo() >> >{ >> > bar(~0); >> >} >> >int zoo() >> >{ >> > bar1(~0UL); >> >} >> ... >> >Sorta looks the same to me.... >> >> I don't think that's a valid test. A more reasonable test would be >> something like >Why isn't it a valid test? This is exactly the test case that Warner was >worrying about? There are no prototypes (visibly) in scope for either bar() or bar1(). This means that the only possible promotions are char or short to int - ie, bar() is passed a signed int and bar1() is passed an unsigned long. In the case of the Alpha, (the first few) parameters are passed to functions in registers and registers are always 64-bits, hence there was a promotion to 64 bits. A signed promotion is done presumably because that is the easiest. Note that the following is also passed as 0xffffffffffffffff, though ANSI-C (at least) promotion would result in 0x00000000ffffffff (having experimented, it seems the callee will explicitly clear the top 32 bits if an argument is being used in an unsigned context). void abc() { def(~0u); } This implicit "promotion to long" is an implementation detail on the Alpha and another 32/64-bit architecture may not behave the same (especially if function arguments are passed on the stack). Note that the following code is in error (in the absence of a prototype for bar() preceeding foo()) because foo() will pass an int, not a long to bar(): void foo() { bar(~0); } void bar(long x) { ... } >> unsigned long foo, bar; >> >> fun() >> { >> foo = bar & ~0; >> } >> >> Unfortunately, I don't have a functional FreeBSD/Alpha box right now, >> but both Compaq CC and gcc-2.8.1 generate "foo = bar". I'm not sure >> that this behaviour makes sense. Having thought about it on my way home yesterday (and carefully studied K&R2 - since I don't have the actual standards), I agree with the statements that Warner and Garrett made - the behaviour does make sense. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message