cheung@titan.sw.mcc.com (Po Cheung) (09/25/90)
Has anyone built Sun RPC 4.0 on a Pyramid ? Specifically, I'd like to know if I can simply assume the floating point representation of the Pyramid to resemble that of the Sun, rather than the Vax, as in xdr_float.c ? Thanks, Po Cheung MCC cheung@mcc.com ------------------------------------------------------------------------------ /* * xdr_float.c, Generic XDR routines impelmentation. * * Copyright (C) 1984, Sun Microsystems, Inc. * * These are the "floating point" xdr routines used to (de)serialize * most common data items. See xdr.h for more info on the interface to * xdr. */ #include <stdio.h> #include <rpc/types.h> #include <rpc/xdr.h> /* * NB: Not portable. * This routine works on Suns (Sky / 68000's) and Vaxen. */ #ifdef vax /* What IEEE single precision floating point looks like on a Vax */ struct ieee_single { unsigned int mantissa: 23; unsigned int exp : 8; unsigned int sign : 1; }; /* Vax single precision floating point */ struct vax_single { unsigned int mantissa1 : 7; unsigned int exp : 8; unsigned int sign : 1; unsigned int mantissa2 : 16; }; #define VAX_SNG_BIAS 0x81 #define IEEE_SNG_BIAS 0x7f static struct sgl_limits { struct vax_single s; struct ieee_single ieee; } sgl_limits[2] = { {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ { 0x0, 0xff, 0x0 }}, /* Max IEEE */ {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ { 0x0, 0x0, 0x0 }} /* Min IEEE */ }; #endif /* vax */ bool_t xdr_float(xdrs, fp) register XDR *xdrs; register float *fp; { #if !defined(mc68000) && !defined(sparc) && !defined(pyr) struct ieee_single is; struct vax_single vs, *vsp; struct sgl_limits *lim; int i; #endif switch (xdrs->x_op) { case XDR_ENCODE: #if defined(mc68000) || defined(sparc) || defined(pyr) return (XDR_PUTLONG(xdrs, (long *)fp)); #else vs = *((struct vax_single *)fp); for (i = 0, lim = sgl_limits; i < sizeof(sgl_limits)/sizeof(struct sgl_limits); i++, lim++) { if ((vs.mantissa2 == lim->s.mantissa2) && (vs.exp == lim->s.exp) && (vs.mantissa1 == lim->s.mantissa1)) { is = lim->ieee; goto shipit; } } is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; shipit: is.sign = vs.sign; return (XDR_PUTLONG(xdrs, (long *)&is)); #endif