This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / lib / librpc / rpc / xdr_float.c
index 4b5b697..71dc311 100644 (file)
@@ -1,4 +1,3 @@
-/* @(#)xdr_float.c     2.1 88/07/29 4.0 RPCSRC */
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
+
+#if defined(LIBC_SCCS) && !defined(lint)
+/*static char *sccsid = "from: @(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";*/
+/*static char *sccsid = "from: @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC";*/
+static char *rcsid = "$Id: xdr_float.c,v 1.6 1993/08/26 00:53:49 jtc Exp $";
 #endif
 
 /*
 #endif
 
 /*
@@ -42,15 +44,20 @@ static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
-
+#include <sys/types.h>
+#include <sys/param.h>
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 
 /*
  * NB: Not portable.
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 
 /*
  * NB: Not portable.
- * This routine works on Suns (Sky / 68000's) and Vaxen.
+ * This routine works on Suns (Sky / 68000's), i386's, MIPS, NS32k and Vaxen.
  */
 
  */
 
+#if defined(mc68000)||defined(sparc)||defined(i386)||defined(mips)||defined(ns32000)
+#define IEEEFP
+#endif
+
 #ifdef vax
 
 /* What IEEE single precision floating point looks like on a Vax */
 #ifdef vax
 
 /* What IEEE single precision floating point looks like on a Vax */
@@ -87,7 +94,7 @@ xdr_float(xdrs, fp)
        register XDR *xdrs;
        register float *fp;
 {
        register XDR *xdrs;
        register float *fp;
 {
-#if !defined(mc68000) && !defined(sparc)
+#ifndef IEEEFP
        struct ieee_single is;
        struct vax_single vs, *vsp;
        struct sgl_limits *lim;
        struct ieee_single is;
        struct vax_single vs, *vsp;
        struct sgl_limits *lim;
@@ -96,7 +103,7 @@ xdr_float(xdrs, fp)
        switch (xdrs->x_op) {
 
        case XDR_ENCODE:
        switch (xdrs->x_op) {
 
        case XDR_ENCODE:
-#if defined(mc68000) || defined(sparc)
+#ifdef IEEEFP 
                return (XDR_PUTLONG(xdrs, (long *)fp));
 #else
                vs = *((struct vax_single *)fp);
                return (XDR_PUTLONG(xdrs, (long *)fp));
 #else
                vs = *((struct vax_single *)fp);
@@ -118,7 +125,7 @@ xdr_float(xdrs, fp)
 #endif
 
        case XDR_DECODE:
 #endif
 
        case XDR_DECODE:
-#if defined(mc68000) || defined(sparc)
+#ifdef IEEEFP
                return (XDR_GETLONG(xdrs, (long *)fp));
 #else
                vsp = (struct vax_single *)fp;
                return (XDR_GETLONG(xdrs, (long *)fp));
 #else
                vsp = (struct vax_single *)fp;
@@ -148,7 +155,7 @@ xdr_float(xdrs, fp)
 }
 
 /*
 }
 
 /*
- * This routine works on Suns (Sky / 68000's) and Vaxen.
+ * This routine works on Suns (Sky / 68000's), i386's, MIPS and Vaxen.
  */
 
 #ifdef vax
  */
 
 #ifdef vax
@@ -193,7 +200,7 @@ xdr_double(xdrs, dp)
        double *dp;
 {
        register long *lp;
        double *dp;
 {
        register long *lp;
-#if !defined(mc68000) && !defined(sparc)
+#ifndef IEEEFP
        struct  ieee_double id;
        struct  vax_double vd;
        register struct dbl_limits *lim;
        struct  ieee_double id;
        struct  vax_double vd;
        register struct dbl_limits *lim;
@@ -203,8 +210,13 @@ xdr_double(xdrs, dp)
        switch (xdrs->x_op) {
 
        case XDR_ENCODE:
        switch (xdrs->x_op) {
 
        case XDR_ENCODE:
-#if defined(mc68000) || defined(sparc)
+#ifdef IEEEFP
                lp = (long *)dp;
                lp = (long *)dp;
+#if BYTE_ORDER == BIG_ENDIAN
+               return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
+#else
+               return (XDR_PUTLONG(xdrs, lp+1) && XDR_PUTLONG(xdrs, lp));
+#endif
 #else
                vd = *((struct vax_double *)dp);
                for (i = 0, lim = dbl_limits;
 #else
                vd = *((struct vax_double *)dp);
                for (i = 0, lim = dbl_limits;
@@ -227,13 +239,17 @@ xdr_double(xdrs, dp)
        shipit:
                id.sign = vd.sign;
                lp = (long *)&id;
        shipit:
                id.sign = vd.sign;
                lp = (long *)&id;
-#endif
                return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
                return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
+#endif
 
        case XDR_DECODE:
 
        case XDR_DECODE:
-#if defined(mc68000) || defined(sparc)
+#ifdef IEEEFP
                lp = (long *)dp;
                lp = (long *)dp;
+#if BYTE_ORDER == BIG_ENDIAN
                return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp));
                return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp));
+#else
+               return (XDR_GETLONG(xdrs, lp+1) && XDR_GETLONG(xdrs, lp));
+#endif
 #else
                lp = (long *)&id;
                if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp))
 #else
                lp = (long *)&id;
                if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp))