*BSD News Article 12323


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!apple!kaleida.com!conklin
From: conklin@kaleida.com (J.T. Conklin)
Newsgroups: comp.os.386bsd.development
Subject: Re: Anyone converted xdr_float.c for 386BSD?
Date: 4 Mar 93 10:46:04
Organization: Kaleida Labs, Inc., Mountain View, CA
Lines: 227
Message-ID: <CONKLIN.93Mar4104604@ngai.kaleida.com>
References: <C38405.2tyz@austin.ibm.com>
Reply-To: conklin@kaleida.com
NNTP-Posting-Host: ngai.kaleida.com
In-reply-to: fredriks@austin.ibm.com's message of Mon, 1 Mar 1993 18:43:16 GMT

Lars> I got the sunrpc package from ref.tfs.com, but when I tried
Lars> to compile the rpc library, xdr_float.c bombed out. I was under the
Lars> impression that the software was ported already, but there were no
Lars> diffs that I could find. 

The sunrpc code on ref is based on rpc 3.9, while the version in
/usr/src/lib is based on rpc 4.0.  I made my diffs against the 
version in /usr/src/lib.

This was submitted for the patchkit long ago:

The xdr_float() and xdr_double routines from the xdr/rpc library were not
ported to the '386 (xdr_float.c was excluded in the makefile).  Since the
'386, like the 68k and sparc, uses IEEE floating point, all that was needed
was to take word ordering into account for xdr_double().

I rearranged the code slightly: rather than testing mc68000, sparc, i386, 
etc. several times throughout the code, I test once and define the IEEEFP
and BIGENDIAN macros accordingly.  This will make things easier for anyone 
who ports 386BSD to another architecture.

The following diff updates Makefile and xdr_float.c in /usr/src/lib/librpc/rpc.

*** 1.1	1993/01/21 19:41:14
--- Makefile	1993/01/22 03:41:46
***************
*** 8,17 ****
  	pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \
  	pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \
  	svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \
! 	svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_mem.c \
  	xdr_rec.c xdr_reference.c xdr_stdio.c
- 
- UNSUPPORTED=	xdr_float.c 
  
  HDRS=	auth.h auth_unix.h clnt.h pmap_clnt.h \
  	pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h svc.h svc_auth.h types.h xdr.h
--- 8,15 ----
  	pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \
  	pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \
  	svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \
! 	svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_float.c xdr_mem.c \
  	xdr_rec.c xdr_reference.c xdr_stdio.c
  
  HDRS=	auth.h auth_unix.h clnt.h pmap_clnt.h \
  	pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h svc.h svc_auth.h types.h xdr.h
*** 1.1	1993/01/21 19:39:19
--- xdr_float.c	1993/01/22 05:36:18
***************
*** 48,56 ****
  
  /*
   * 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 */
--- 48,66 ----
  
  /*
   * NB: Not portable.
!  * This routine works on Suns (Sky / 68000's), i386's and Vaxen.
   */
  
+ #if defined(mc68000) || defined(sparc)
+ #define IEEEFP
+ #define BIGENDIAN 1
+ #endif
+ 
+ #if defined(i386)
+ #define IEEEFP
+ #define BIGENDIAN 0
+ #endif
+ 
  #ifdef vax
  
  /* What IEEE single precision floating point looks like on a Vax */
***************
*** 87,93 ****
  	register XDR *xdrs;
  	register float *fp;
  {
! #if !defined(mc68000) && !defined(sparc)
  	struct ieee_single is;
  	struct vax_single vs, *vsp;
  	struct sgl_limits *lim;
--- 97,103 ----
  	register XDR *xdrs;
  	register float *fp;
  {
! #ifndef IEEEFP
  	struct ieee_single is;
  	struct vax_single vs, *vsp;
  	struct sgl_limits *lim;
***************
*** 96,102 ****
  	switch (xdrs->x_op) {
  
  	case XDR_ENCODE:
! #if defined(mc68000) || defined(sparc)
  		return (XDR_PUTLONG(xdrs, (long *)fp));
  #else
  		vs = *((struct vax_single *)fp);
--- 106,112 ----
  	switch (xdrs->x_op) {
  
  	case XDR_ENCODE:
! #ifdef IEEEFP 
  		return (XDR_PUTLONG(xdrs, (long *)fp));
  #else
  		vs = *((struct vax_single *)fp);
***************
*** 118,124 ****
  #endif
  
  	case XDR_DECODE:
! #if defined(mc68000) || defined(sparc)
  		return (XDR_GETLONG(xdrs, (long *)fp));
  #else
  		vsp = (struct vax_single *)fp;
--- 128,134 ----
  #endif
  
  	case XDR_DECODE:
! #ifdef IEEEFP
  		return (XDR_GETLONG(xdrs, (long *)fp));
  #else
  		vsp = (struct vax_single *)fp;
***************
*** 148,154 ****
  }
  
  /*
!  * This routine works on Suns (Sky / 68000's) and Vaxen.
   */
  
  #ifdef vax
--- 158,164 ----
  }
  
  /*
!  * This routine works on Suns (Sky / 68000's), i386's and Vaxen.
   */
  
  #ifdef vax
***************
*** 193,199 ****
  	double *dp;
  {
  	register long *lp;
! #if !defined(mc68000) && !defined(sparc)
  	struct	ieee_double id;
  	struct	vax_double vd;
  	register struct dbl_limits *lim;
--- 203,209 ----
  	double *dp;
  {
  	register long *lp;
! #ifndef IEEEFP
  	struct	ieee_double id;
  	struct	vax_double vd;
  	register struct dbl_limits *lim;
***************
*** 203,210 ****
  	switch (xdrs->x_op) {
  
  	case XDR_ENCODE:
! #if defined(mc68000) || defined(sparc)
  		lp = (long *)dp;
  #else
  		vd = *((struct vax_double *)dp);
  		for (i = 0, lim = dbl_limits;
--- 213,225 ----
  	switch (xdrs->x_op) {
  
  	case XDR_ENCODE:
! #ifdef IEEEFP
  		lp = (long *)dp;
+ #if BIGENDIAN
+ 		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;
***************
*** 227,239 ****
  	shipit:
  		id.sign = vd.sign;
  		lp = (long *)&id;
- #endif
  		return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
  
  	case XDR_DECODE:
! #if defined(mc68000) || defined(sparc)
  		lp = (long *)dp;
  		return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp));
  #else
  		lp = (long *)&id;
  		if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp))
--- 242,258 ----
  	shipit:
  		id.sign = vd.sign;
  		lp = (long *)&id;
  		return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
+ #endif
  
  	case XDR_DECODE:
! #ifdef IEEEFP
  		lp = (long *)dp;
+ #if BIGENDIAN
  		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))
--
J.T. Conklin <jtc@wimsey.com>    | Your source for floppy distributions
    Winning Strategies, Inc.     |    of the 386BSD OS and binaries
    61 Crestwood Drive #18       | Send e-mail for complete product list
    Daly City, CA 94015          +---------------------------------------