From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,1671a2362b01a7e X-Google-Attributes: gidfee84,public From: werme@alingo.zk3.dec.com (Eric Werme) Subject: Re: RPC from 32 bit to 64 bit Date: 1996/10/18 Message-ID: #1/1 X-Deja-AN: 190290611 references: <3261CFBB.65@dial.pipex.com> organization: Digital Equipment Corporation reply-to: werme@zk3.dec.com newsgroups: comp.unix.osf.osf1 Brian Bowman writes: >I'm having problems porting some RPC code to an ALPHA running OSF1. I >keep getting an error 1734 which is error in array bounds. The problem >occurrs when calling a function with an argument which is a pointer to a >structure. Any suggestions or clues very much appreciated. I've been on >this problem for a week and its driving me nuts ! Error 1734? What language are you using? What libraries are you using? What follows pertains solely to the RPC routines in libc.a. I can't tell if this applies to your problem. >From a HTML-ized Digital UNIX FAW at http://www.eecis.udel.edu/~carver/digital_unix_faq.html What's wrong with xdr_long in the Digital UNIX XDR routines? xdr_long is used for sending signed 32-bit values and cannot send 0xFFFFFFFF. xdr_ulong should be used instead. For 64-bit integer values, use xdr_hyper. See the manual pages for more details. [Curtis Keller, curtis@kinesix.com] This is slightly misleading. xdr_long() can send -1, which in 32 bits is 0xffffffff. xdr_long() does range checking, insuring that the top 33 bits of its 64-bit argument are all ones or all zeroes. If this is not the case, then the signed long integer is beyond the range of representation within a signed 32-bit value, and xdr_long() rightly fails. xdr_u_long() [note typo above!] insures that the top 32 bits of its 64-bit argument are all zero. If this is not the case, then the unsigned long integer is beyond ... blah blah. So, the upshot is: If you're using signed values, use xdr_long(), and DON'T use unsigned constants like 0xffffffff to set variables. If you're using unsigned values, use xdr_u_long(). In both cases, make sure you're within range for 32-bits, if you want to interoperate with 32-bit machines using native data types. [John Kohl,jtk@atria.com] >From "man xdr_long": Differences Between xdr_long and xdr_hyper Routines On Digital UNIX platforms, the C programming language and the XDR routines apply different conventions to the definitions of the long data type. On Digital UNIX platforms, the C programming language applies the following conventions for int and long data types: __________________________ Data Type bits bytes __________________________ int 32 4 bytes long 64 8 bytes __________________________ The XDR routines apply the following conventions: __________________________ Data Type bits bytes __________________________ int 32 4 bytes long 32 4 bytes hyper 64 8 bytes __________________________ The xdr_long() and xdr_u_long() interfaces serialize 4 bytes of data. The xdr_hyper() and xdr_u_hyper() serialize 8 bytes of data. On Digital UNIX systems, the second argument to both xdr_long and xdr_hyper must be either a pointer or of the C language type long (8 bytes). When xdr_hyper is called with a parameter that points to a long all 8-bytes are serialized. In contrast, when xdr_long is called with a parameter that points to a long only the low order 4-bytes are serialized. When calling xdr_long on the DECODE operation, the upper 4-bytes of the long are sign extended in accordance with the high order bit of the lower 4-byte quantity. This is necessary to maintain the XDR convention of xdr_long serializing 4-bytes. If you want all 8-bytes to be serialized, use the xdr_hyper interface. The xdr_longlong_t and the xdr_u_longlong_t perform the same function as the xdr_hyper and the xdr_u_hyper interfaces respectively. -- <> Eric (Ric) Werme <> Why Government Doesn't Work! For details <> <> <> visit http://www.HarryBrowne96.org/ <>