summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsheldonh <sheldonh@FreeBSD.org>2000-04-12 08:41:16 +0000
committersheldonh <sheldonh@FreeBSD.org>2000-04-12 08:41:16 +0000
commita365f1d25ae787ba1aca5aceb5aa846ab9c3f290 (patch)
treef657ab62d1bdcea92076cfb992ff7f6b492b841c
parentfea3e0ecac004c02502dcdcbf96af20a3a4bc864 (diff)
downloadFreeBSD-src-a365f1d25ae787ba1aca5aceb5aa846ab9c3f290.zip
FreeBSD-src-a365f1d25ae787ba1aca5aceb5aa846ab9c3f290.tar.gz
Do proper byte swapping in 64bit routines.
PR: 17681 Submitted by: "David E. Cross" <crossd@cs.rpi.edu> Obtained from: NetBSD
-rw-r--r--lib/libc/xdr/xdr.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/lib/libc/xdr/xdr.c b/lib/libc/xdr/xdr.c
index 956e2ff..50b68fb 100644
--- a/lib/libc/xdr/xdr.c
+++ b/lib/libc/xdr/xdr.c
@@ -259,20 +259,24 @@ xdr_int64_t(xdrs, int64_p)
register XDR *xdrs;
int64_t *int64_p;
{
- int64_t x;
+ u_long ul[2];
switch (xdrs->x_op) {
case XDR_ENCODE:
- return (xdr_opaque(xdrs, (caddr_t)int64_p, sizeof(int64_t)));
-
+ ul[0] = (u_long)((u_int64_t)*int64_p >> 32) & 0xffffffff;
+ ul[1] = (u_long)((u_int64_t)*int64_p) & 0xffffffff;
+ if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
+ return (FALSE);
+ return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
case XDR_DECODE:
- if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) {
+ if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
return (FALSE);
- }
- *int64_p = x;
+ if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
+ return (FALSE);
+ *int64_p = (int64_t)
+ (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
return (TRUE);
-
case XDR_FREE:
return (TRUE);
}
@@ -287,20 +291,25 @@ xdr_u_int64_t(xdrs, uint64_p)
register XDR *xdrs;
u_int64_t *uint64_p;
{
- u_int64_t x;
+ u_long ul[2];
switch (xdrs->x_op) {
case XDR_ENCODE:
- return (xdr_opaque(xdrs, (caddr_t)uint64_p, sizeof(u_int64_t)));
+ ul[0] = (u_long)(*uint64_p >> 32) & 0xffffffff;
+ ul[1] = (u_long)(*uint64_p) & 0xffffffff;
+ if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE)
+ return (FALSE);
+ return (XDR_PUTLONG(xdrs, (long *)&ul[1]));
- case XDR_DECODE:
- if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) {
+ case XDR_DECODE:
+ if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE)
return (FALSE);
- }
- *uint64_p = x;
+ if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE)
+ return (FALSE);
+ *uint64_p = (u_int64_t)
+ (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1]));
return (TRUE);
-
case XDR_FREE:
return (TRUE);
}
OpenPOWER on IntegriCloud