home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sun / admin / 6214 < prev    next >
Encoding:
Text File  |  1992-09-09  |  2.0 KB  |  70 lines

  1. Xref: sparky comp.sys.sun.admin:6214 comp.sys.sun.misc:4143
  2. Newsgroups: comp.sys.sun.admin,comp.sys.sun.misc
  3. Path: sparky!uunet!mcsun!sun4nl!fwi.uva.nl!casper
  4. From: casper@fwi.uva.nl (Casper H.S. Dik)
  5. Subject: Re: SunOS 4.1.2 XDR alignment requirements?
  6. Message-ID: <1992Sep9.075506.9919@fwi.uva.nl>
  7. Keywords: SunOS XDR alignment
  8. Sender: news@fwi.uva.nl
  9. Nntp-Posting-Host: adam.fwi.uva.nl
  10. Organization: FWI, University of Amsterdam
  11. References: <1992Sep8.135138@ead.dsa.com>
  12. Date: Wed, 9 Sep 1992 07:55:06 GMT
  13. Lines: 55
  14.  
  15. schorr@ead.dsa.com (Andrew J. Schorr) writes:
  16.  
  17. >It appears (although this is undocumented) that the
  18. >buffer supplied in a call to xdrmem_create must be
  19. >aligned on a 4-byte boundary.  On a SparcStation 1
  20. >running SunOS 4.1.2, consider the following session script:
  21.  
  22. >   schorr@dead: cat xdr.c
  23. >   #include <rpc/rpc.h>
  24.  
  25. >   main()
  26. >   {
  27. >      int x;
  28. >      char buf[100];
  29. >      XDR xdr;
  30.  
  31. >   #define OFFSET 1
  32.  
  33. >      xdrmem_create(&xdr,&buf[OFFSET],sizeof(buf)-OFFSET,XDR_ENCODE);
  34. >      printf("%d\n",xdr_int(&xdr,&x));
  35. >   }
  36.  
  37. The xdrmem_create manual states (sunOS 4.1.2):
  38.  
  39. void xdrmem_create(xdrs, addr, size, op)
  40.      XDR *xdrs;
  41.      char *addr;
  42.      u_int size;
  43.      enum xdr_op op;
  44.  
  45.           This routine initializes the XDR stream object  pointed
  46.           to  by  xdrs.  The stream's data is written to, or read
  47.           from, a chunk of memory at location addr  whose  length
  48.           is no more than size bytes long.  size should be a mul-
  49.           tiple of 4.  The op determines the direction of the XDR
  50.           stream (either XDR_ENCODE, XDR_DECODE, or XDR_FREE).
  51.  
  52. This means that sizeof(buf) - OFFSET is not allowed as size
  53. argument to xdrmem_create. The source code reveals that
  54. xdrmem_*() routines do require a 4 byte alignment:
  55.  
  56.  
  57. sunrpc4.0/xdr_mem.c:xdrmem_putlong()
  58.  
  59.         *(long *)xdrs->x_private = (long)htonl((u_long)(*lp));
  60.  
  61. xdrs->x_private is the pointer you supplied.
  62.  
  63. Is 4 bytes alignment a big problem for you?
  64.  
  65. Casper
  66.  
  67. -- 
  68.                         |    Casper H.S. Dik
  69.                         |    casper@fwi.uva.nl
  70.