From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 31144 invoked from network); 29 Oct 1999 10:31:39 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 29 Oct 1999 10:31:39 -0000 Received: from voicenet.com (mail12.voicenet.com [207.103.0.6]) by mail.redhat.com (8.8.7/8.8.7) with SMTP id GAA11402 for ; Fri, 29 Oct 1999 06:31:39 -0400 Received: (qmail 19821 invoked from network); 29 Oct 1999 10:31:37 -0000 Received: from dialpool0222-pri.voicenet.com (HELO voicenet.com) (209.71.85.87) by mail12.voicenet.com with SMTP; 29 Oct 1999 10:31:37 -0000 Sender: gat@mail.redhat.com Message-ID: <381976CA.EF859700@voicenet.com> Date: Fri, 29 Oct 1999 06:28:26 -0400 From: Uncle George Organization: Big-Endian X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i686) MIME-Version: 1.0 To: axp-list@redhat.com CC: Dan Morrill , Richard Henderson Subject: Re: Function parameter weirdness References: <38142EA1.E15C284@voicenet.com> <19991028163857.C27836@twiddle.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ok, "sign extend all 32bit integers" ( I dont think this is in k&r ) . what of Sign extening "short"s? "char"s ? by the caller. But all this is related to the fact the the 'C" compiler really doesn't know what the function parameters are at time of compile/link binding. they are only known at runtime ( this is true for java/JNI, but not for postgreSQL ) There is just one ( JNI ) interface to all of the subroutines. And apparently it, as well as the guy who writes the JNI interface needs to know the 'tricks' of this machine's trade. SOoooo By ur example: unsigned short a = 0xffff; call foo( a ); .............. foo( short a ) if ( a == -1 ) printf("Got a neg one"); else printf("Got bogus value"); In the land of the i386 i'd guess u'd "got a neg one", according to u u would get a 65536 ( or was that 65535 ) value Even though the # & pattern of bits are =, the alpha will do a 64 bit compare, whereas ( i suspect ) the i386 will do a (expected) 16bit ( signed ) compare. Richard Henderson wrote: > On Mon, Oct 25, 1999 at 06:19:13AM -0400, Uncle George wrote: > > yup, but it sppears that the 'sender' of the parameter has to know what > > type it is to get this picture correct. > > Kindof. The caller is supposed to sign-extend all 32-bit integers. > Note that this is without respect to whether the variable is declared > as `unsigned int' in the source. > > Values smaller than `int' are promoted by K&R rules to `int', so eg > `unsigned short' winds up zero extended since bit 31 is never set. >