From fa033c6beae5a8c912ea440385e1b7d16c1443d3 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 30 Jan 2010 21:56:57 +0000 Subject: [PATCH] Add xdr_mem to the Unix build A number of forthcoming attractions require xdrmem, which is currently not part of the Unix build. Fix it so that it builds without warnings, and add it to the standard RX build. Change-Id: I5a21b2c7cd837c317f16dc35bf12cdac69d10167 Reviewed-on: http://gerrit.openafs.org/1220 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/rx/Makefile.in | 2 +- src/rx/xdr.h | 30 +++++++++++++++++++++++++++ src/rx/xdr_mem.c | 59 ++++++++++++++++++++++++++++++++++-------------------- 3 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/rx/Makefile.in b/src/rx/Makefile.in index f76a868..bbfca7f 100644 --- a/src/rx/Makefile.in +++ b/src/rx/Makefile.in @@ -18,7 +18,7 @@ CFLAGS=${COMMON_CFLAGS} ${XCFLAGS} ${ARCHFLAGS} ${RXDEBUG} # Generic xdr objects (or, at least, xdr stuff that's not newly defined for rx). # Really the xdr stuff should be in its own directory. # -XDROBJS_common = xdr.o xdr_array.o xdr_rx.o xdr_afsuuid.o +XDROBJS_common = xdr.o xdr_array.o xdr_rx.o xdr_mem.o xdr_afsuuid.o XDROBJS = xdr_arrayn.o ${XDROBJS_common} diff --git a/src/rx/xdr.h b/src/rx/xdr.h index 2936e29..655e684 100644 --- a/src/rx/xdr.h +++ b/src/rx/xdr.h @@ -55,6 +55,35 @@ #endif /* !TRUE */ #define __dontcare__ -1 +#if defined(KERNEL) +/* + * kernel version needs to agree with + * except on Linux which does XDR differently from everyone else + */ +# if defined(AFS_LINUX20_ENV) && !defined(UKERNEL) +# define AFS_XDRS_T void * +# else +# define AFS_XDRS_T XDR * +# endif +# if defined(AFS_SUN57_ENV) +# define AFS_RPC_INLINE_T rpc_inline_t +# elif defined(AFS_DUX40_ENV) +# define AFS_RPC_INLINE_T int +# elif defined(AFS_LINUX20_ENV) && !defined(UKERNEL) +# define AFS_RPC_INLINE_T afs_int32 +# elif defined(AFS_LINUX20_ENV) +# define AFS_RPC_INLINE_T int32_t * +# else +# define AFS_RPC_INLINE_T long +# endif +#else /* KERNEL */ +/* + * user version needs to agree with "xdr.h", i.e. + */ +# define AFS_XDRS_T void * +# define AFS_RPC_INLINE_T afs_int32 +#endif /* KERNEL */ + #ifndef mem_alloc #define mem_alloc(bsize) malloc(bsize) #endif @@ -91,6 +120,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 diff --git a/src/rx/xdr_mem.c b/src/rx/xdr_mem.c index 44c2aa1..2608b2a 100644 --- a/src/rx/xdr_mem.c +++ b/src/rx/xdr_mem.c @@ -43,21 +43,22 @@ * */ -#include "xdr.h" -#ifndef AFS_NT40_ENV -#include -#else +#include #include +#ifndef AFS_NT40_ENV +# include #endif -static bool_t xdrmem_getint32(); -static bool_t xdrmem_putint32(); -static bool_t xdrmem_getbytes(); -static bool_t xdrmem_putbytes(); -static u_int xdrmem_getpos(); -static bool_t xdrmem_setpos(); -static afs_int32 *xdrmem_inline(); -static void xdrmem_destroy(); +#include "xdr.h" + +static bool_t xdrmem_getint32(AFS_XDRS_T, afs_int32 *); +static bool_t xdrmem_putint32(AFS_XDRS_T, afs_int32 *); +static bool_t xdrmem_getbytes(AFS_XDRS_T, caddr_t, u_int); +static bool_t xdrmem_putbytes(AFS_XDRS_T, caddr_t, u_int); +static u_int xdrmem_getpos(AFS_XDRS_T); +static bool_t xdrmem_setpos(AFS_XDRS_T, u_int); +static afs_int32 *xdrmem_inline(AFS_XDRS_T, u_int); +static void xdrmem_destroy(AFS_XDRS_T); static struct xdr_ops xdrmem_ops = { #ifdef AFS_NT40_ENV @@ -75,8 +76,8 @@ static struct xdr_ops xdrmem_ops = { .x_putint32 = xdrmem_putint32, .x_getbytes = xdrmem_getbytes, .x_putbytes = xdrmem_putbytes, - .x_getpos = xdrmem_getpos, - .x_setpos = xdrmem_setpos, + .x_getpostn = xdrmem_getpos, + .x_setpostn = xdrmem_setpos, .x_inline = xdrmem_inline, .x_destroy = xdrmem_destroy #endif @@ -96,13 +97,15 @@ xdrmem_create(XDR * xdrs, caddr_t addr, u_int size, enum xdr_op op) } static void -xdrmem_destroy(void) +xdrmem_destroy(AFS_XDRS_T axdrs) { } static bool_t -xdrmem_getint32(XDR * xdrs, afs_int32 * lp) +xdrmem_getint32(AFS_XDRS_T axdrs, afs_int32 * lp) { + XDR * xdrs = (XDR *)axdrs; + if (xdrs->x_handy < sizeof(afs_int32)) return (FALSE); else @@ -113,8 +116,10 @@ xdrmem_getint32(XDR * xdrs, afs_int32 * lp) } static bool_t -xdrmem_putint32(XDR * xdrs, afs_int32 * lp) +xdrmem_putint32(AFS_XDRS_T axdrs, afs_int32 * lp) { + XDR * xdrs = (XDR *)axdrs; + if (xdrs->x_handy < sizeof(afs_int32)) return (FALSE); else @@ -125,8 +130,10 @@ xdrmem_putint32(XDR * xdrs, afs_int32 * lp) } static bool_t -xdrmem_getbytes(XDR * xdrs, caddr_t addr, u_int len) +xdrmem_getbytes(AFS_XDRS_T axdrs, caddr_t addr, u_int len) { + XDR * xdrs = (XDR *)axdrs; + if (xdrs->x_handy < len) return (FALSE); else @@ -137,8 +144,10 @@ xdrmem_getbytes(XDR * xdrs, caddr_t addr, u_int len) } static bool_t -xdrmem_putbytes(XDR * xdrs, caddr_t addr, u_int len) +xdrmem_putbytes(AFS_XDRS_T axdrs, caddr_t addr, u_int len) { + XDR * xdrs = (XDR *)axdrs; + if (xdrs->x_handy < len) return (FALSE); else @@ -149,14 +158,18 @@ xdrmem_putbytes(XDR * xdrs, caddr_t addr, u_int len) } static u_int -xdrmem_getpos(XDR * xdrs) +xdrmem_getpos(AFS_XDRS_T axdrs) { + XDR * xdrs = (XDR *)axdrs; + return ((u_int)(xdrs->x_private - xdrs->x_base)); } static bool_t -xdrmem_setpos(XDR * xdrs, u_int pos) +xdrmem_setpos(AFS_XDRS_T axdrs, u_int pos) { + XDR * xdrs = (XDR *)axdrs; + caddr_t newaddr = xdrs->x_base + pos; caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; @@ -168,8 +181,10 @@ xdrmem_setpos(XDR * xdrs, u_int pos) } static afs_int32 * -xdrmem_inline(XDR * xdrs, int len) +xdrmem_inline(AFS_XDRS_T axdrs, u_int len) { + XDR * xdrs = (XDR *)axdrs; + afs_int32 *buf = 0; if (len >= 0 && xdrs->x_handy >= len) { -- 1.9.4