summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikolay Sturm <sturm@cvs.openbsd.org>2008-06-13 21:12:12 +0000
committerNikolay Sturm <sturm@cvs.openbsd.org>2008-06-13 21:12:12 +0000
commitba65de2ed207d73f6640130f2afd026c6889f953 (patch)
tree65f0773e4dda4985b70b4bc421c3e760062c68f1 /lib
parent67f713638f317f78924d1b5f4adf791cc4b27819 (diff)
implement xdr_int64_t, xdr_u_int64_t
from NetBSD
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/rpc/xdr.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/lib/libc/rpc/xdr.c b/lib/libc/rpc/xdr.c
index e2569bbf66f..daad18ef938 100644
--- a/lib/libc/rpc/xdr.c
+++ b/lib/libc/rpc/xdr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xdr.c,v 1.9 2005/08/08 08:05:35 espie Exp $ */
+/* $OpenBSD: xdr.c,v 1.10 2008/06/13 21:12:11 sturm Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -667,3 +667,57 @@ xdr_wrapstring(XDR *xdrs, char **cpp)
{
return xdr_string(xdrs, cpp, LASTUNSIGNED);
}
+
+bool_t
+xdr_int64_t(XDR *xdrs, int64_t *llp)
+{
+ u_long ul[2];
+
+ switch (xdrs->x_op) {
+ case XDR_ENCODE:
+ ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff;
+ ul[1] = (u_long)((u_int64_t)*llp) & 0xffffffff;
+ if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
+ return (FALSE);
+ return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
+ case XDR_DECODE:
+ if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
+ return (FALSE);
+ if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
+ return (FALSE);
+ *llp = (int64_t)
+ (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
+ return (TRUE);
+ case XDR_FREE:
+ return (TRUE);
+ }
+ /* NOTREACHED */
+ return (FALSE);
+}
+
+bool_t
+xdr_u_int64_t(XDR *xdrs, u_int64_t *ullp)
+{
+ u_long ul[2];
+
+ switch (xdrs->x_op) {
+ case XDR_ENCODE:
+ ul[0] = (u_long)(*ullp >> 32) & 0xffffffff;
+ ul[1] = (u_long)(*ullp) & 0xffffffff;
+ if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
+ return (FALSE);
+ return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
+ case XDR_DECODE:
+ if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
+ return (FALSE);
+ if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
+ return (FALSE);
+ *ullp = (u_int64_t)
+ (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
+ return (TRUE);
+ case XDR_FREE:
+ return (TRUE);
+ }
+ /* NOTREACHED */
+ return (FALSE);
+}