Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: werme@alingo.zk3.dec.com (Eric Werme)
Subject: Re: RPC from 32 bit to 64 bit
Date: 1996/10/18	[thread overview]
Message-ID: <werme.845639106@alingo.zk3.dec.com> (raw)
In-Reply-To: 3261CFBB.65@dial.pipex.com


Brian Bowman <brian.bowman@dial.pipex.com> 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   <>
  <>  <werme@zk3.dec.com>  <>     visit http://www.HarryBrowne96.org/      <>



      reply	other threads:[~1996-10-18  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-13  4:00 RPC from 32 bit to 64 bit Brian Bowman
1996-10-18  4:00 ` Eric Werme [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox