12357939bSOlivier Houchard /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3d915a14eSPedro F. Giffuni * 4f154b03bSDavid Schultz * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG> 52357939bSOlivier Houchard * All rights reserved. 62357939bSOlivier Houchard * 72357939bSOlivier Houchard * Redistribution and use in source and binary forms, with or without 82357939bSOlivier Houchard * modification, are permitted provided that the following conditions 92357939bSOlivier Houchard * are met: 102357939bSOlivier Houchard * 1. Redistributions of source code must retain the above copyright 112357939bSOlivier Houchard * notice, this list of conditions and the following disclaimer. 122357939bSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright 132357939bSOlivier Houchard * notice, this list of conditions and the following disclaimer in the 142357939bSOlivier Houchard * documentation and/or other materials provided with the distribution. 152357939bSOlivier Houchard * 162357939bSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172357939bSOlivier Houchard * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182357939bSOlivier Houchard * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192357939bSOlivier Houchard * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202357939bSOlivier Houchard * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 212357939bSOlivier Houchard * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222357939bSOlivier Houchard * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232357939bSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242357939bSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252357939bSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262357939bSOlivier Houchard * SUCH DAMAGE. 272357939bSOlivier Houchard */ 282357939bSOlivier Houchard 290a10f22aSAndrew Turner #if defined(__VFP_FP__) || defined(__ARM_EABI__) 3074aed985SMarcel Moolenaar #define _IEEE_WORD_ORDER _BYTE_ORDER 3174aed985SMarcel Moolenaar #else 3274aed985SMarcel Moolenaar #define _IEEE_WORD_ORDER _BIG_ENDIAN 3374aed985SMarcel Moolenaar #endif 3474aed985SMarcel Moolenaar 352357939bSOlivier Houchard union IEEEl2bits { 362357939bSOlivier Houchard long double e; 372357939bSOlivier Houchard struct { 3874aed985SMarcel Moolenaar #if _BYTE_ORDER == _LITTLE_ENDIAN 3974aed985SMarcel Moolenaar #if _IEEE_WORD_ORDER == _LITTLE_ENDIAN 402357939bSOlivier Houchard unsigned int manl :32; 4174aed985SMarcel Moolenaar #endif 422b271493SOlivier Houchard unsigned int manh :20; 432b271493SOlivier Houchard unsigned int exp :11; 442357939bSOlivier Houchard unsigned int sign :1; 4574aed985SMarcel Moolenaar #if _IEEE_WORD_ORDER == _BIG_ENDIAN 4674aed985SMarcel Moolenaar unsigned int manl :32; 4774aed985SMarcel Moolenaar #endif 4874aed985SMarcel Moolenaar #else /* _BYTE_ORDER == _LITTLE_ENDIAN */ 492b271493SOlivier Houchard unsigned int sign :1; 502b271493SOlivier Houchard unsigned int exp :11; 512b271493SOlivier Houchard unsigned int manh :20; 522b271493SOlivier Houchard unsigned int manl :32; 532b271493SOlivier Houchard #endif 542357939bSOlivier Houchard } bits; 552357939bSOlivier Houchard }; 562357939bSOlivier Houchard 572b271493SOlivier Houchard #define LDBL_NBIT 0 58c6c72ab9SDavid Schultz #define LDBL_IMPLICIT_NBIT 592b271493SOlivier Houchard #define mask_nbit_l(u) ((void)0) 602357939bSOlivier Houchard 61c6c72ab9SDavid Schultz #define LDBL_MANH_SIZE 20 622357939bSOlivier Houchard #define LDBL_MANL_SIZE 32 632357939bSOlivier Houchard 642357939bSOlivier Houchard #define LDBL_TO_ARRAY32(u, a) do { \ 652357939bSOlivier Houchard (a)[0] = (uint32_t)(u).bits.manl; \ 662357939bSOlivier Houchard (a)[1] = (uint32_t)(u).bits.manh; \ 672357939bSOlivier Houchard } while(0) 68