diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-03-02 12:05:18 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-03-02 12:05:18 +0000 |
commit | 3d7c4998ac37629eae7ad07a48844cf2ce8ec750 (patch) | |
tree | fe8879ab36704886d63ddc3814e9d42debeabd46 /newlib/libc/xdr/xdr_float.c | |
parent | cf1569458601355da7b427a24a1e08517f2a0deb (diff) | |
download | cygnal-3d7c4998ac37629eae7ad07a48844cf2ce8ec750.tar.gz cygnal-3d7c4998ac37629eae7ad07a48844cf2ce8ec750.tar.bz2 cygnal-3d7c4998ac37629eae7ad07a48844cf2ce8ec750.zip |
Add eXtensible Data Record (XDR) support
* configure.host: Build libc/xdr only on cygwin.
* Makefile.am: Install xdr headers.
* libc/configure.in: Support new libc/xdr subdirectory.
* libc/Makefile.am: Support new libc/xdr subdirectory.
* libc/include/rpc/types.h: New.
* libc/include/rpc/xdr.h: New.
* libc/xdr/README: New.
* libc/xdr/Makefile.am: New.
* libc/xdr/dummy.c: New.
* libc/xdr/xdr.c: New.
* libc/xdr/xdr_array.c: New.
* libc/xdr/xdr_float.c: New.
* libc/xdr/xdr_float_vax.c: New.
* libc/xdr/xdr_mem.c: New.
* libc/xdr/xdr_private.c: New.
* libc/xdr/xdr_private.h: New.
* libc/xdr/xdr_rec.c: New.
* libc/xdr/xdr_reference.c: New.
* libc/xdr/xdr_sizeof.c: New.
* libc/xdr/xdr_stdio.c: New.
Regenerate using ac-2.63 and am-1.11.1
* libc/xdr/Makefile.in: New.
* Makefile.in: Regenerate.
* libc/configure: Regenerate.
* libc/Makefile.in: Regenerate.
* libc/argz/Makefile.in: Regenerate.
* libc/ctype/Makefile.in: Regenerate.
* libc/errno/Makefile.in: Regenerate.
* libc/iconv/ccs/binary/Makefile.in: Regenerate.
* libc/iconv/ccs/Makefile.in: Regenerate.
* libc/iconv/ces/Makefile.in: Regenerate.
* libc/iconv/lib/Makefile.in: Regenerate.
* libc/iconv/Makefile.in: Regenerate.
* libc/locale/Makefile.in: Regenerate.
* libc/misc/Makefile.in: Regenerate.
* libc/posix/Makefile.in: Regenerate.
* libc/reent/Makefile.in: Regenerate.
* libc/search/Makefile.in: Regenerate.
* libc/signal/Makefile.in: Regenerate.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio64/Makefile.in: Regenerate.
* libc/stdlib/Makefile.in: Regenerate.
* libc/string/Makefile.in: Regenerate.
* libc/syscalls/Makefile.in: Regenerate.
* libc/time/Makefile.in: Regenerate.
* libc/unix/Makefile.in: Regenerate.
Diffstat (limited to 'newlib/libc/xdr/xdr_float.c')
-rw-r--r-- | newlib/libc/xdr/xdr_float.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/newlib/libc/xdr/xdr_float.c b/newlib/libc/xdr/xdr_float.c new file mode 100644 index 000000000..00726bb43 --- /dev/null +++ b/newlib/libc/xdr/xdr_float.c @@ -0,0 +1,133 @@ + +/* + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * xdr_float.c, Generic XDR routines implementation. + * + * 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 <sys/types.h> +#include <rpc/types.h> +#include <rpc/xdr.h> + +#include "xdr_private.h" + +/* + * NB: Not portable. + * This routine works on machines with IEEE754 FP and Vaxen. + * Assume that xdr_private.h arranges things so that one of + * 1) __IEEE_LITTLE_ENDIAN + * 2) __IEEE_BIG_ENDIAN + * 3) __vax__ + * is #defined. Otherwise, expect errors. + */ +#ifndef XDR_FLOAT_C +#define XDR_FLOAT_C +#endif + +#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BIG_ENDIAN) + +bool_t +_DEFUN (xdr_float, (xdrs, fp), + XDR * xdrs _AND + float *fp) +{ + switch (xdrs->x_op) + { + + case XDR_ENCODE: + return (XDR_PUTINT32 (xdrs, (int32_t *) fp)); + + case XDR_DECODE: + return (XDR_GETINT32 (xdrs, (int32_t *) fp)); + + case XDR_FREE: + return TRUE; + } + return FALSE; +} + +#if !defined(_DOUBLE_IS_32BITS) +bool_t +_DEFUN (xdr_double, (xdrs, dp), + XDR * xdrs _AND + double *dp) +{ + int32_t *i32p; + bool_t rv; + + switch (xdrs->x_op) + { + + case XDR_ENCODE: + i32p = (int32_t *) (void *) dp; +#if defined(__IEEE_BIG_ENDIAN) + rv = XDR_PUTINT32 (xdrs, i32p); + if (!rv) + return (rv); + rv = XDR_PUTINT32 (xdrs, i32p + 1); +#else /* must be __IEEE_LITTLE_ENDIAN */ + rv = XDR_PUTINT32 (xdrs, i32p + 1); + if (!rv) + return (rv); + rv = XDR_PUTINT32 (xdrs, i32p); +#endif /* __IEEE_LITTLE_ENDIAN */ + return (rv); + + case XDR_DECODE: + i32p = (int32_t *) (void *) dp; +#if defined(__IEEE_BIG_ENDIAN) + rv = XDR_GETINT32 (xdrs, i32p); + if (!rv) + return (rv); + rv = XDR_GETINT32 (xdrs, i32p + 1); +#else /* must be __IEEE_LITTLE_ENDIAN */ + rv = XDR_GETINT32 (xdrs, i32p + 1); + if (!rv) + return (rv); + rv = XDR_GETINT32 (xdrs, i32p); +#endif /* __IEEE_LITTLE_ENDIAN */ + return (rv); + + case XDR_FREE: + return TRUE; + } + return FALSE; +} +#endif /* !_DOUBLE_IS_32BITS */ + +#elif defined(__vax__) +#include "xdr_float_vax.c" +#endif + |