xdr_float.c (294227) | xdr_float.c (298120) |
---|---|
1/* $NetBSD: xdr_float.c,v 1.23 2000/07/17 04:59:51 matt Exp $ */ 2 3/*- 4 * Copyright (c) 2010, Oracle America, Inc. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: --- 22 unchanged lines hidden (view full) --- 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char *sccsid2 = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; 36static char *sccsid = "@(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC"; 37#endif 38#include <sys/cdefs.h> | 1/* $NetBSD: xdr_float.c,v 1.23 2000/07/17 04:59:51 matt Exp $ */ 2 3/*- 4 * Copyright (c) 2010, Oracle America, Inc. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: --- 22 unchanged lines hidden (view full) --- 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char *sccsid2 = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; 36static char *sccsid = "@(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC"; 37#endif 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/lib/libc/xdr/xdr_float.c 294227 2016-01-17 15:21:23Z br $"); | 39__FBSDID("$FreeBSD: head/lib/libc/xdr/xdr_float.c 298120 2016-04-16 17:52:00Z pfg $"); |
40 41/* 42 * xdr_float.c, Generic XDR routines implementation. 43 * 44 * These are the "floating point" xdr routines used to (de)serialize 45 * most common data items. See xdr.h for more info on the interface to 46 * xdr. 47 */ --- 58 unchanged lines hidden (view full) --- 106#endif 107 switch (xdrs->x_op) { 108 109 case XDR_ENCODE: 110#ifdef IEEEFP 111 return (XDR_PUTINT32(xdrs, (int32_t *)fp)); 112#else 113 vs = *((struct vax_single *)fp); | 40 41/* 42 * xdr_float.c, Generic XDR routines implementation. 43 * 44 * These are the "floating point" xdr routines used to (de)serialize 45 * most common data items. See xdr.h for more info on the interface to 46 * xdr. 47 */ --- 58 unchanged lines hidden (view full) --- 106#endif 107 switch (xdrs->x_op) { 108 109 case XDR_ENCODE: 110#ifdef IEEEFP 111 return (XDR_PUTINT32(xdrs, (int32_t *)fp)); 112#else 113 vs = *((struct vax_single *)fp); |
114 for (i = 0, lim = sgl_limits; 115 i < sizeof(sgl_limits)/sizeof(struct sgl_limits); 116 i++, lim++) { | 114 for (i = 0, lim = sgl_limits; i < nitems(sgl_limits); 115 i++, lim++) { |
117 if ((vs.mantissa2 == lim->s.mantissa2) && 118 (vs.exp == lim->s.exp) && 119 (vs.mantissa1 == lim->s.mantissa1)) { 120 is = lim->ieee; 121 goto shipit; 122 } 123 } 124 is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; --- 5 unchanged lines hidden (view full) --- 130 131 case XDR_DECODE: 132#ifdef IEEEFP 133 return (XDR_GETINT32(xdrs, (int32_t *)fp)); 134#else 135 vsp = (struct vax_single *)fp; 136 if (!XDR_GETINT32(xdrs, (int32_t *)&is)) 137 return (FALSE); | 116 if ((vs.mantissa2 == lim->s.mantissa2) && 117 (vs.exp == lim->s.exp) && 118 (vs.mantissa1 == lim->s.mantissa1)) { 119 is = lim->ieee; 120 goto shipit; 121 } 122 } 123 is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; --- 5 unchanged lines hidden (view full) --- 129 130 case XDR_DECODE: 131#ifdef IEEEFP 132 return (XDR_GETINT32(xdrs, (int32_t *)fp)); 133#else 134 vsp = (struct vax_single *)fp; 135 if (!XDR_GETINT32(xdrs, (int32_t *)&is)) 136 return (FALSE); |
138 for (i = 0, lim = sgl_limits; 139 i < sizeof(sgl_limits)/sizeof(struct sgl_limits); 140 i++, lim++) { | 137 for (i = 0, lim = sgl_limits; i < nitems(sgl_limits); 138 i++, lim++) { |
141 if ((is.exp == lim->ieee.exp) && 142 (is.mantissa == lim->ieee.mantissa)) { 143 *vsp = lim->s; 144 goto doneit; 145 } 146 } 147 vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; 148 vsp->mantissa2 = is.mantissa; --- 74 unchanged lines hidden (view full) --- 223 rv = XDR_PUTINT32(xdrs, i32p+1); 224 if (!rv) 225 return (rv); 226 rv = XDR_PUTINT32(xdrs, i32p); 227#endif 228 return (rv); 229#else 230 vd = *((struct vax_double *)dp); | 139 if ((is.exp == lim->ieee.exp) && 140 (is.mantissa == lim->ieee.mantissa)) { 141 *vsp = lim->s; 142 goto doneit; 143 } 144 } 145 vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; 146 vsp->mantissa2 = is.mantissa; --- 74 unchanged lines hidden (view full) --- 221 rv = XDR_PUTINT32(xdrs, i32p+1); 222 if (!rv) 223 return (rv); 224 rv = XDR_PUTINT32(xdrs, i32p); 225#endif 226 return (rv); 227#else 228 vd = *((struct vax_double *)dp); |
231 for (i = 0, lim = dbl_limits; 232 i < sizeof(dbl_limits)/sizeof(struct dbl_limits); 233 i++, lim++) { | 229 for (i = 0, lim = dbl_limits; i < nitems(dbl_limits); 230 i++, lim++) { |
234 if ((vd.mantissa4 == lim->d.mantissa4) && 235 (vd.mantissa3 == lim->d.mantissa3) && 236 (vd.mantissa2 == lim->d.mantissa2) && 237 (vd.mantissa1 == lim->d.mantissa1) && 238 (vd.exp == lim->d.exp)) { 239 id = lim->ieee; 240 goto shipit; 241 } --- 23 unchanged lines hidden (view full) --- 265 return (rv); 266 rv = XDR_GETINT32(xdrs, i32p); 267#endif 268 return (rv); 269#else 270 lp = (int32_t *)&id; 271 if (!XDR_GETINT32(xdrs, lp++) || !XDR_GETINT32(xdrs, lp)) 272 return (FALSE); | 231 if ((vd.mantissa4 == lim->d.mantissa4) && 232 (vd.mantissa3 == lim->d.mantissa3) && 233 (vd.mantissa2 == lim->d.mantissa2) && 234 (vd.mantissa1 == lim->d.mantissa1) && 235 (vd.exp == lim->d.exp)) { 236 id = lim->ieee; 237 goto shipit; 238 } --- 23 unchanged lines hidden (view full) --- 262 return (rv); 263 rv = XDR_GETINT32(xdrs, i32p); 264#endif 265 return (rv); 266#else 267 lp = (int32_t *)&id; 268 if (!XDR_GETINT32(xdrs, lp++) || !XDR_GETINT32(xdrs, lp)) 269 return (FALSE); |
273 for (i = 0, lim = dbl_limits; 274 i < sizeof(dbl_limits)/sizeof(struct dbl_limits); 275 i++, lim++) { | 270 for (i = 0, lim = dbl_limits; i < nitems(dbl_limits); 271 i++, lim++) { |
276 if ((id.mantissa2 == lim->ieee.mantissa2) && 277 (id.mantissa1 == lim->ieee.mantissa1) && 278 (id.exp == lim->ieee.exp)) { 279 vd = lim->d; 280 goto doneit; 281 } 282 } 283 vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; --- 17 unchanged lines hidden --- | 272 if ((id.mantissa2 == lim->ieee.mantissa2) && 273 (id.mantissa1 == lim->ieee.mantissa1) && 274 (id.exp == lim->ieee.exp)) { 275 vd = lim->d; 276 goto doneit; 277 } 278 } 279 vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; --- 17 unchanged lines hidden --- |