1129202Scognet/*- 2141379Sdas * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG> 3129202Scognet * All rights reserved. 4129202Scognet * 5129202Scognet * Redistribution and use in source and binary forms, with or without 6129202Scognet * modification, are permitted provided that the following conditions 7129202Scognet * are met: 8129202Scognet * 1. Redistributions of source code must retain the above copyright 9129202Scognet * notice, this list of conditions and the following disclaimer. 10129202Scognet * 2. Redistributions in binary form must reproduce the above copyright 11129202Scognet * notice, this list of conditions and the following disclaimer in the 12129202Scognet * documentation and/or other materials provided with the distribution. 13129202Scognet * 14129202Scognet * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15129202Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16129202Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17129202Scognet * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18129202Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19129202Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20129202Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21129202Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22129202Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23129202Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24129202Scognet * SUCH DAMAGE. 25129202Scognet * 26129202Scognet * $FreeBSD$ 27129202Scognet */ 28129202Scognet 29255361Sandrew#if defined(__VFP_FP__) || defined(__ARM_EABI__) 30186461Smarcel#define _IEEE_WORD_ORDER _BYTE_ORDER 31186461Smarcel#else 32186461Smarcel#define _IEEE_WORD_ORDER _BIG_ENDIAN 33186461Smarcel#endif 34186461Smarcel 35129202Scognetunion IEEEl2bits { 36129202Scognet long double e; 37129202Scognet struct { 38186461Smarcel#if _BYTE_ORDER == _LITTLE_ENDIAN 39186461Smarcel#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN 40129202Scognet unsigned int manl :32; 41186461Smarcel#endif 42143858Scognet unsigned int manh :20; 43143858Scognet unsigned int exp :11; 44129202Scognet unsigned int sign :1; 45186461Smarcel#if _IEEE_WORD_ORDER == _BIG_ENDIAN 46186461Smarcel unsigned int manl :32; 47186461Smarcel#endif 48186461Smarcel#else /* _BYTE_ORDER == _LITTLE_ENDIAN */ 49143858Scognet unsigned int sign :1; 50143858Scognet unsigned int exp :11; 51143858Scognet unsigned int manh :20; 52143858Scognet unsigned int manl :32; 53143858Scognet#endif 54129202Scognet } bits; 55129202Scognet}; 56129202Scognet 57143858Scognet#define LDBL_NBIT 0 58230188Sdas#define LDBL_IMPLICIT_NBIT 59143858Scognet#define mask_nbit_l(u) ((void)0) 60129202Scognet 61230188Sdas#define LDBL_MANH_SIZE 20 62129202Scognet#define LDBL_MANL_SIZE 32 63129202Scognet 64129202Scognet#define LDBL_TO_ARRAY32(u, a) do { \ 65129202Scognet (a)[0] = (uint32_t)(u).bits.manl; \ 66129202Scognet (a)[1] = (uint32_t)(u).bits.manh; \ 67129202Scognet} while(0) 68