Binary Compatability?

Brendan Eich brendan at illyria.SGI.COM
Wed Mar 1 05:38:04 AEST 1989


The bug arose because Sun's xdr_float.c routines are conditionally compiled
to do no conversion #if mc68000, and to do IEEE-to-DEC conversion otherwise.
Alas, when the code was ported to the 3000 (68xxx-based machines as you no
doubt know), mc68000 was assumed to be defined.  It isn't; m68000 is (sigh).

Lack of heterogeneous testing allowed both the 3.5 and 3.6 releases to ship
with xdr_float and xdr_double converting the 3000's native floating point
representations to DEC format on the wire, and back again.  Of course it
doesn't work so well with other vendor's machines.

The fix is to write your own xdr_float and xdr_double:

	bool_t
	xdr_float(xdrs, fp)
		XDR *xdrs;
		float *fp;
	{
		return xdr_long(xdrs, (long *)fp);
	}

	bool_t
	xdr_double(xdrs, dp)
		XDR *xdrs;
		double *dp;
	{
		return xdr_opaque(xdrs, (caddr_t)dp, sizeof *dp);
	}

Put the above functions with the necessary includes in xdr_float.c, compile
to xdr_float.o, and utter

	ar rv /usr/lib/libsun.a xdr_float.o; ranlib /usr/lib/libsun.a

to install the fix.  (These functions could be optimized to use XDR_PUTLONG
and XDR_GETLONG.)

Brendan Eich
Silicon Graphics, Inc.
brendan at sgi.com



More information about the Comp.sys.sgi mailing list