summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorfvdl <fvdl@NetBSD.org>2000-07-14 08:39:31 +0000
committerfvdl <fvdl@NetBSD.org>2000-07-14 08:39:31 +0000
commit02a1d5ef1411d9c8d99e6a7bdfaff0892faa7d63 (patch)
tree1b3e33673cdc43acf803b2cdd4bc5ff76b6832ba /include
parent2d699aa6ce13a8d0cab6b08f478e984e3124003d (diff)
Add explicit int32 get/put macros (and 2 inline functions), as in Solaris.
Needed to get things right on 64bit big-endian systems.
Diffstat (limited to 'include')
-rw-r--r--include/rpc/xdr.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h
index 769ee0150d3..adbc1812f8e 100644
--- a/include/rpc/xdr.h
+++ b/include/rpc/xdr.h
@@ -1,4 +1,4 @@
-/* $NetBSD: xdr.h,v 1.17 2000/06/02 22:57:57 fvdl Exp $ */
+/* $NetBSD: xdr.h,v 1.18 2000/07/14 08:39:31 fvdl Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -154,6 +154,29 @@ typedef bool_t (*xdrproc_t) __P((/* XDR *, void *, u_int */));
#define xdr_putlong(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
+static __inline
+xdr_getint32(XDR *xdrs, int32_t *ip)
+{
+ long l;
+
+ if (!xdr_getlong(xdrs, &l))
+ return (FALSE);
+ *ip = (int32_t)l;
+ return (TRUE);
+}
+
+static __inline
+xdr_putint32(XDR *xdrs, int32_t *ip)
+{
+ long l;
+
+ l = (long)*ip;
+ return xdr_putlong(xdrs, &l);
+}
+
+#define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p)
+#define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p)
+
#define XDR_GETBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define xdr_getbytes(xdrs, addr, len) \
@@ -232,6 +255,11 @@ struct xdr_discrim {
* N.B. and frozen for all time: each data type here uses 4 bytes
* of external representation.
*/
+#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++))
+#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v))
+#define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf))
+#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v)))
+
#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++))
#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v))