Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Implement XDR routines for 64-bit integer data types:
details: https://anonhg.NetBSD.org/src/rev/e7a92d791028
branches: trunk
changeset: 479010:e7a92d791028
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Dec 01 18:34:21 1999 +0000
description:
Implement XDR routines for 64-bit integer data types:
- xdr_int64_t(), xdr_u_int64_t(), per NetBSD convention.
- xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), xdr_u_longlong_t(), a'la
Solaris, implemented in terms of the above.
diffstat:
include/rpc/xdr.h | 8 +-
lib/libc/include/namespace.h | 8 +-
lib/libc/rpc/xdr.c | 151 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 163 insertions(+), 4 deletions(-)
diffs (255 lines):
diff -r 6eeb10a79c44 -r e7a92d791028 include/rpc/xdr.h
--- a/include/rpc/xdr.h Wed Dec 01 18:27:08 1999 +0000
+++ b/include/rpc/xdr.h Wed Dec 01 18:34:21 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xdr.h,v 1.15 1998/11/16 12:07:43 christos Exp $ */
+/* $NetBSD: xdr.h,v 1.16 1999/12/01 18:34:21 thorpej Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -246,6 +246,8 @@
extern bool_t xdr_u_int16_t __P((XDR *, u_int16_t *));
extern bool_t xdr_int32_t __P((XDR *, int32_t *));
extern bool_t xdr_u_int32_t __P((XDR *, u_int32_t *));
+extern bool_t xdr_int64_t __P((XDR *, int64_t *));
+extern bool_t xdr_u_int64_t __P((XDR *, u_int64_t *));
extern bool_t xdr_bool __P((XDR *, bool_t *));
extern bool_t xdr_enum __P((XDR *, enum_t *));
extern bool_t xdr_array __P((XDR *, char **, u_int *, u_int, u_int, xdrproc_t));
@@ -262,6 +264,10 @@
extern bool_t xdr_pointer __P((XDR *, char **, u_int, xdrproc_t));
extern bool_t xdr_wrapstring __P((XDR *, char **));
extern void xdr_free __P((xdrproc_t, char *));
+extern bool_t xdr_hyper __P((XDR *, longlong_t *));
+extern bool_t xdr_u_hyper __P((XDR *, u_longlong_t *));
+extern bool_t xdr_longlong_t __P((XDR *, longlong_t *));
+extern bool_t xdr_u_longlong_t __P((XDR *, u_longlong_t *));
__END_DECLS
/*
diff -r 6eeb10a79c44 -r e7a92d791028 lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Wed Dec 01 18:27:08 1999 +0000
+++ b/lib/libc/include/namespace.h Wed Dec 01 18:34:21 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.41 1999/11/25 16:54:15 wennmach Exp $ */
+/* $NetBSD: namespace.h,v 1.42 1999/12/01 18:34:22 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -422,10 +422,13 @@
#define xdr_enum _xdr_enum
#define xdr_float _xdr_float
#define xdr_free _xdr_free
+#define xdr_hyper _xdr_hyper
#define xdr_int _xdr_int
#define xdr_int16_t _xdr_int16_t
#define xdr_int32_t _xdr_int32_t
+#define xdr_int64_t _xdr_int64_t
#define xdr_long _xdr_long
+#define xdr_longlong_t _xdr_longlong_t
#define xdr_mapname _xdr_mapname
#define xdr_netobj _xdr_netobj
#define xdr_opaque _xdr_opaque
@@ -442,10 +445,13 @@
#define xdr_short _xdr_short
#define xdr_string _xdr_string
#define xdr_u_char _xdr_u_char
+#define xdr_u_hyper _xdr_u_hyper
#define xdr_u_int _xdr_u_int
#define xdr_u_int16_t _xdr_u_int16_t
#define xdr_u_int32_t _xdr_u_int32_t
+#define xdr_u_int64_t _xdr_u_int64_t
#define xdr_u_long _xdr_u_long
+#define xdr_u_longlong_t _xdr_u_longlong_t
#define xdr_u_short _xdr_u_short
#define xdr_union _xdr_union
#define xdr_vector _xdr_vector
diff -r 6eeb10a79c44 -r e7a92d791028 lib/libc/rpc/xdr.c
--- a/lib/libc/rpc/xdr.c Wed Dec 01 18:27:08 1999 +0000
+++ b/lib/libc/rpc/xdr.c Wed Dec 01 18:34:21 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xdr.c,v 1.18 1998/11/15 17:32:46 christos Exp $ */
+/* $NetBSD: xdr.c,v 1.19 1999/12/01 18:34:23 thorpej Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
static char *sccsid = "@(#)xdr.c 1.35 87/08/12";
static char *sccsid = "@(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: xdr.c,v 1.18 1998/11/15 17:32:46 christos Exp $");
+__RCSID("$NetBSD: xdr.c,v 1.19 1999/12/01 18:34:23 thorpej Exp $");
#endif
#endif
@@ -65,19 +65,25 @@
__weak_alias(xdr_char,_xdr_char);
__weak_alias(xdr_enum,_xdr_enum);
__weak_alias(xdr_free,_xdr_free);
+__weak_alias(xdr_hyper,_xdr_hyper);
__weak_alias(xdr_int,_xdr_int);
__weak_alias(xdr_int16_t,_xdr_int16_t);
__weak_alias(xdr_int32_t,_xdr_int32_t);
+__weak_alias(xdr_int64_t,_xdr_int64_t);
__weak_alias(xdr_long,_xdr_long);
+__weak_alias(xdr_longlong_t,_xdr_longlong_t);
__weak_alias(xdr_netobj,_xdr_netobj);
__weak_alias(xdr_opaque,_xdr_opaque);
__weak_alias(xdr_short,_xdr_short);
__weak_alias(xdr_string,_xdr_string);
__weak_alias(xdr_u_char,_xdr_u_char);
+__weak_alias(xdr_u_hyper,_xdr_u_hyper);
__weak_alias(xdr_u_int,_xdr_u_int);
__weak_alias(xdr_u_int16_t,_xdr_u_int16_t);
__weak_alias(xdr_u_int32_t,_xdr_u_int32_t);
+__weak_alias(xdr_u_int64_t,_xdr_u_int64_t);
__weak_alias(xdr_u_long,_xdr_u_long);
+__weak_alias(xdr_u_longlong_t,_xdr_u_longlong_t);
__weak_alias(xdr_u_short,_xdr_u_short);
__weak_alias(xdr_union,_xdr_union);
__weak_alias(xdr_void,_xdr_void);
@@ -759,3 +765,144 @@
{
return xdr_string(xdrs, cpp, LASTUNSIGNED);
}
+
+/*
+ * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t()
+ * are in the "non-portable" section because they require that a `long long'
+ * be a 64-bit type.
+ *
+ * --thorpej%netbsd.org@localhost, November 30, 1999
+ */
+
+/*
+ * XDR 64-bit integers
+ */
+bool_t
+xdr_int64_t(xdrs, llp)
+ XDR *xdrs;
+ int64_t *llp;
+{
+ u_long ul[2];
+
+ switch (xdrs->x_op) {
+ case XDR_ENCODE:
+ ul[0] = (*llp >> 32) & 0xffffffff;
+ ul[1] = *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);
+}
+
+
+/*
+ * XDR unsigned 64-bit integers
+ */
+bool_t
+xdr_u_int64_t(xdrs, ullp)
+ XDR *xdrs;
+ u_int64_t *ullp;
+{
+ u_long ul[2];
+
+ switch (xdrs->x_op) {
+ case XDR_ENCODE:
+ ul[0] = (*ullp >> 32) & 0xffffffff;
+ ul[1] = *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);
+}
+
+
+/*
+ * XDR hypers
+ */
+bool_t
+xdr_hyper(xdrs, llp)
+ XDR *xdrs;
+ longlong_t *llp;
+{
+
+ /*
+ * Don't bother open-coding this; it's a fair amount of code. Just
+ * call xdr_int64_t().
+ */
+ return (xdr_int64_t(xdrs, (int64_t *)llp));
+}
+
+
+/*
+ * XDR unsigned hypers
+ */
+bool_t
+xdr_u_hyper(xdrs, ullp)
+ XDR *xdrs;
+ u_longlong_t *ullp;
+{
+
+ /*
+ * Don't bother open-coding this; it's a fair amount of code. Just
+ * call xdr_u_int64_t().
+ */
+ return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
+}
+
+
+/*
+ * XDR longlong_t's
+ */
+bool_t
+xdr_longlong_t(xdrs, llp)
+ XDR *xdrs;
+ longlong_t *llp;
+{
+
+ /*
+ * Don't bother open-coding this; it's a fair amount of code. Just
+ * call xdr_int64_t().
+ */
+ return (xdr_int64_t(xdrs, (int64_t *)llp));
+}
+
+
+/*
+ * XDR u_longlong_t's
+ */
+bool_t
+xdr_u_longlong_t(xdrs, ullp)
+ XDR *xdrs;
+ u_longlong_t *ullp;
+{
+
+ /*
+ * Don't bother open-coding this; it's a fair amount of code. Just
+ * call xdr_u_int64_t().
+ */
+ return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp));
+}
Home |
Main Index |
Thread Index |
Old Index