rx: always use/protect the xdr routines in the kernel
[openafs.git] / src / rx / xdr.h
index 8809d22..04236b1 100644 (file)
@@ -5,23 +5,23 @@
  * may copy or modify Sun RPC without charge, but are not authorized
  * to license or distribute it to anyone else except as part of a product or
  * program developed by the user.
- * 
+ *
  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
+ *
  * Sun RPC is provided with no support and without any obligation on the
  * part of Sun Microsystems, Inc. to assist in its use, correction,
  * modification or enhancement.
- * 
+ *
  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
 #endif /* !TRUE */
 #define __dontcare__   -1
 
+#if defined(AFS_NBSD50_ENV)
+# if !defined(DEF_CADDR_T)
+typedef char * caddr_t;
+#define DEF_CADDR_T
+# endif
+#endif
+
 #ifndef mem_alloc
 #define mem_alloc(bsize)       malloc(bsize)
 #endif
@@ -63,7 +70,7 @@
 #define mem_free(ptr, bsize)   free(ptr)
 #endif
 
-#if defined(AFS_AMD64_LINUX24_ENV) || defined(AFS_DARWIN_ENV) || (defined(KERNEL) && !defined(UKERNEL))
+#if !defined(AFS_NT40_ENV)
 #define xdr_alloc afs_xdr_alloc
 #define xdr_free afs_xdr_free
 #define xdr_void afs_xdr_void
@@ -91,6 +98,7 @@
 #define xdr_int64 afs_xdr_int64
 #define xdr_uint64 afs_xdr_uint64
 #define xdr_pointer afs_xdr_pointer
+#define xdrmem_create afs_xdrmem_create
 #endif
 
 #ifdef KERNEL
 /* keep here for now, 64 bit issues */
 #ifndef AFS_OBSD44_ENV
 extern void *afs_osi_Alloc(size_t x);
-#ifndef afs_osi_Alloc_NoSleep
-extern void *afs_osi_Alloc_NoSleep(size_t x);
-#endif
 extern void afs_osi_Free(void *x, size_t asize);
 #endif
 
@@ -174,16 +179,17 @@ enum xdr_op {
  * allocate dynamic storage of the appropriate size and return it.
  * bool_t      (*xdrproc_t)(XDR *, caddr_t *);
  */
-#if 0
-typedef bool_t(*xdrproc_t) ();
-#else
-#ifdef AFS_I386_LINUX26_ENV
-typedef bool_t(*xdrproc_t) (void *, caddr_t *, u_int);
+
+/* We need a different prototype for i386 Linux kernel code, because it
+ * uses a register (rather than stack) based calling convention. The
+ * normal va_args prototype results in the arguments being placed on the
+ * stack, where they aren't accessible to the 'real' function.
+ */
+#if defined(AFS_I386_LINUX26_ENV) && defined(KERNEL) && !defined(UKERNEL)
+typedef bool_t(*xdrproc_t) (void *, caddr_t, u_int);
 #else
 typedef bool_t(*xdrproc_t) (void *, ...);
 #endif
-#endif
-
 
 /*
  * The XDR handle.
@@ -191,31 +197,36 @@ typedef bool_t(*xdrproc_t) (void *, ...);
  * an operations vector for the paticular implementation (e.g. see xdr_mem.c),
  * and two private fields for the use of the particular impelementation.
  */
-typedef struct {
-    enum xdr_op x_op;          /* operation; fast additional param */
-    struct xdr_ops {
+
 #if defined(KERNEL) && ((defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV))
 /* NOTE: SGI 6.1 adds two routines to the xdr_ops if the size of a long is
  * 64 bits. I've only done this for the kernel, since other changes may
  * be necessary if we make a 64 bit user version of AFS.
  */
-       bool_t(*x_getint64) (void *xdrs, afs_int64 * lp);       /* get 32 bits into a long */
-       bool_t(*x_putint64) (void *xdrs, afs_int64 * lp);       /* send 32 bits of a long */
-#endif                         /* defined(KERNEL) && ((defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)) */
+#define AFS_XDR_64BITOPS 1
+#endif
+
+typedef struct __afs_xdr {
+    enum xdr_op x_op;          /* operation; fast additional param */
+    struct xdr_ops {
+#ifdef AFS_XDR_64BITOPS
+       bool_t(*x_getint64) (struct __afs_xdr *xdrs, afs_int64 * lp);   /* get 32 bits into a long */
+       bool_t(*x_putint64) (struct __afs_xdr *xdrs, afs_int64 * lp);   /* send 32 bits of a long */
+#endif
 #if !(defined(KERNEL) && defined(AFS_SUN57_ENV))
-       bool_t(*x_getint32) (void *xdrs, afs_int32 * lp);       /* get an afs_int32 from underlying stream */
-       bool_t(*x_putint32) (void *xdrs, afs_int32 * lp);       /* put an afs_int32 to " */
+       bool_t(*x_getint32) (struct __afs_xdr *xdrs, afs_int32 * lp);   /* get an afs_int32 from underlying stream */
+       bool_t(*x_putint32) (struct __afs_xdr *xdrs, afs_int32 * lp);   /* put an afs_int32 to " */
 #endif
-       bool_t(*x_getbytes) (void *xdrs, caddr_t addr, u_int len);      /* get some bytes from " */
-       bool_t(*x_putbytes) (void *xdrs, caddr_t addr, u_int len);      /* put some bytes to " */
-       u_int(*x_getpostn) (void *xdrs);        /* returns bytes off from beginning */
-       bool_t(*x_setpostn) (void *xdrs, u_int pos);    /* lets you reposition the stream */
-       afs_int32 *(*x_inline) (void *xdrs, u_int len); /* buf quick ptr to buffered data */
-       void (*x_destroy) (void *xdrs); /* free privates of this xdr_stream */
+       bool_t(*x_getbytes) (struct __afs_xdr *xdrs, caddr_t addr, u_int len);  /* get some bytes from " */
+       bool_t(*x_putbytes) (struct __afs_xdr *xdrs, caddr_t addr, u_int len);  /* put some bytes to " */
+       u_int(*x_getpostn) (struct __afs_xdr *xdrs);    /* returns bytes off from beginning */
+       bool_t(*x_setpostn) (struct __afs_xdr *xdrs, u_int pos);        /* lets you reposition the stream */
+       afs_int32 *(*x_inline) (struct __afs_xdr *xdrs, u_int len);     /* buf quick ptr to buffered data */
+       void (*x_destroy) (struct __afs_xdr *xdrs);     /* free privates of this xdr_stream */
 #if defined(KERNEL) && defined(AFS_SUN57_ENV)
-         bool_t(*x_control) (void *xdrs);
-         bool_t(*x_getint32) (void *xdrs, afs_int32 * lp);
-         bool_t(*x_putint32) (void *xdrs, afs_int32 * lp);
+         bool_t(*x_control) (struct __afs_xdr *xdrs);
+         bool_t(*x_getint32) (struct __afs_xdr *xdrs, afs_int32 * lp);
+         bool_t(*x_putint32) (struct __afs_xdr *xdrs, afs_int32 * lp);
 #endif
     } *x_ops;
     caddr_t x_public;          /* users' data */
@@ -233,7 +244,7 @@ typedef struct {
  * u_int        len;
  * u_int        pos;
  */
-#if defined(AFS_SGI61_ENV) && defined(KERNEL) && (_MIPS_SZLONG != _MIPS_SZINT) || defined(AFS_HPUX_64BIT_ENV)
+#ifdef AFS_XDR_64BITOPS
 #define XDR_GETINT64(xdrs, int64p)                     \
        (*(xdrs)->x_ops->x_getint64)(xdrs, int64p)
 #define xdr_getint64(xdrs, int64p)                     \
@@ -243,7 +254,7 @@ typedef struct {
        (*(xdrs)->x_ops->x_putint64)(xdrs, int64p)
 #define xdr_putint64(xdrs, int64p)                     \
        (*(xdrs)->x_ops->x_putint64)(xdrs, int64p)
-#endif /* defined(KERNEL) && ((defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)) */
+#endif /* AFS_XDR_64BITOPS */
 
 #define XDR_GETINT32(xdrs, int32p)                     \
        (*(xdrs)->x_ops->x_getint32)(xdrs, int32p)