3 * Copyright (c) 2009, Sun Microsystems, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * - Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * - Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * - Neither the name of Sun Microsystems, Inc. nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
31 * xdr_float.c, Generic XDR routines implementation.
33 * Copyright (C) 1984, Sun Microsystems, Inc.
35 * These are the "floating point" xdr routines used to (de)serialize
36 * most common data items. See xdr.h for more info on the interface to
40 #include <sys/types.h>
41 #include <rpc/types.h>
44 #include "xdr_private.h"
48 * This routine works on machines with IEEE754 FP and Vaxen.
49 * Assume that xdr_private.h arranges things so that one of
50 * 1) __IEEE_LITTLE_ENDIAN
51 * 2) __IEEE_BIG_ENDIAN
53 * is #defined. Otherwise, expect errors.
59 #if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BIG_ENDIAN)
62 xdr_float (XDR
* xdrs
,
69 return (XDR_PUTINT32 (xdrs
, (int32_t *) fp
));
72 return (XDR_GETINT32 (xdrs
, (int32_t *) fp
));
80 #if !defined(_DOUBLE_IS_32BITS)
82 xdr_double (XDR
* xdrs
,
92 i32p
= (int32_t *) (void *) dp
;
93 #if defined(__IEEE_BIG_ENDIAN)
94 rv
= XDR_PUTINT32 (xdrs
, i32p
);
97 rv
= XDR_PUTINT32 (xdrs
, i32p
+ 1);
98 #else /* must be __IEEE_LITTLE_ENDIAN */
99 rv
= XDR_PUTINT32 (xdrs
, i32p
+ 1);
102 rv
= XDR_PUTINT32 (xdrs
, i32p
);
103 #endif /* __IEEE_LITTLE_ENDIAN */
107 i32p
= (int32_t *) (void *) dp
;
108 #if defined(__IEEE_BIG_ENDIAN)
109 rv
= XDR_GETINT32 (xdrs
, i32p
);
112 rv
= XDR_GETINT32 (xdrs
, i32p
+ 1);
113 #else /* must be __IEEE_LITTLE_ENDIAN */
114 rv
= XDR_GETINT32 (xdrs
, i32p
+ 1);
117 rv
= XDR_GETINT32 (xdrs
, i32p
);
118 #endif /* __IEEE_LITTLE_ENDIAN */
126 #endif /* !_DOUBLE_IS_32BITS */
128 #elif defined(__vax__)
129 #include "xdr_float_vax.c"