home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sun.admin:6214 comp.sys.sun.misc:4143
- Newsgroups: comp.sys.sun.admin,comp.sys.sun.misc
- Path: sparky!uunet!mcsun!sun4nl!fwi.uva.nl!casper
- From: casper@fwi.uva.nl (Casper H.S. Dik)
- Subject: Re: SunOS 4.1.2 XDR alignment requirements?
- Message-ID: <1992Sep9.075506.9919@fwi.uva.nl>
- Keywords: SunOS XDR alignment
- Sender: news@fwi.uva.nl
- Nntp-Posting-Host: adam.fwi.uva.nl
- Organization: FWI, University of Amsterdam
- References: <1992Sep8.135138@ead.dsa.com>
- Date: Wed, 9 Sep 1992 07:55:06 GMT
- Lines: 55
-
- schorr@ead.dsa.com (Andrew J. Schorr) writes:
-
- >It appears (although this is undocumented) that the
- >buffer supplied in a call to xdrmem_create must be
- >aligned on a 4-byte boundary. On a SparcStation 1
- >running SunOS 4.1.2, consider the following session script:
-
- > schorr@dead: cat xdr.c
- > #include <rpc/rpc.h>
-
- > main()
- > {
- > int x;
- > char buf[100];
- > XDR xdr;
-
- > #define OFFSET 1
-
- > xdrmem_create(&xdr,&buf[OFFSET],sizeof(buf)-OFFSET,XDR_ENCODE);
- > printf("%d\n",xdr_int(&xdr,&x));
- > }
-
- The xdrmem_create manual states (sunOS 4.1.2):
-
- void xdrmem_create(xdrs, addr, size, op)
- XDR *xdrs;
- char *addr;
- u_int size;
- enum xdr_op op;
-
- This routine initializes the XDR stream object pointed
- to by xdrs. The stream's data is written to, or read
- from, a chunk of memory at location addr whose length
- is no more than size bytes long. size should be a mul-
- tiple of 4. The op determines the direction of the XDR
- stream (either XDR_ENCODE, XDR_DECODE, or XDR_FREE).
-
- This means that sizeof(buf) - OFFSET is not allowed as size
- argument to xdrmem_create. The source code reveals that
- xdrmem_*() routines do require a 4 byte alignment:
-
-
- sunrpc4.0/xdr_mem.c:xdrmem_putlong()
-
- *(long *)xdrs->x_private = (long)htonl((u_long)(*lp));
-
- xdrs->x_private is the pointer you supplied.
-
- Is 4 bytes alignment a big problem for you?
-
- Casper
-
- --
- | Casper H.S. Dik
- | casper@fwi.uva.nl
-