1*604f6bf0SLi-Wen Hsu /*- 2*604f6bf0SLi-Wen Hsu * SPDX-License-Identifier: BSD-2-Clause 3*604f6bf0SLi-Wen Hsu * 4*604f6bf0SLi-Wen Hsu * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG> 5*604f6bf0SLi-Wen Hsu * All rights reserved. 6*604f6bf0SLi-Wen Hsu * 7*604f6bf0SLi-Wen Hsu * Redistribution and use in source and binary forms, with or without 8*604f6bf0SLi-Wen Hsu * modification, are permitted provided that the following conditions 9*604f6bf0SLi-Wen Hsu * are met: 10*604f6bf0SLi-Wen Hsu * 1. Redistributions of source code must retain the above copyright 11*604f6bf0SLi-Wen Hsu * notice, this list of conditions and the following disclaimer. 12*604f6bf0SLi-Wen Hsu * 2. Redistributions in binary form must reproduce the above copyright 13*604f6bf0SLi-Wen Hsu * notice, this list of conditions and the following disclaimer in the 14*604f6bf0SLi-Wen Hsu * documentation and/or other materials provided with the distribution. 15*604f6bf0SLi-Wen Hsu * 16*604f6bf0SLi-Wen Hsu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*604f6bf0SLi-Wen Hsu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*604f6bf0SLi-Wen Hsu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*604f6bf0SLi-Wen Hsu * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*604f6bf0SLi-Wen Hsu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*604f6bf0SLi-Wen Hsu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*604f6bf0SLi-Wen Hsu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*604f6bf0SLi-Wen Hsu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*604f6bf0SLi-Wen Hsu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*604f6bf0SLi-Wen Hsu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*604f6bf0SLi-Wen Hsu * SUCH DAMAGE. 27*604f6bf0SLi-Wen Hsu */ 28*604f6bf0SLi-Wen Hsu 29*604f6bf0SLi-Wen Hsu union IEEEl2bits { 30*604f6bf0SLi-Wen Hsu long double e; 31*604f6bf0SLi-Wen Hsu struct { 32*604f6bf0SLi-Wen Hsu #if _BYTE_ORDER == _LITTLE_ENDIAN 33*604f6bf0SLi-Wen Hsu unsigned int manl :32; 34*604f6bf0SLi-Wen Hsu unsigned int manh :20; 35*604f6bf0SLi-Wen Hsu unsigned int exp :11; 36*604f6bf0SLi-Wen Hsu unsigned int sign :1; 37*604f6bf0SLi-Wen Hsu #else /* _BYTE_ORDER == _LITTLE_ENDIAN */ 38*604f6bf0SLi-Wen Hsu unsigned int sign :1; 39*604f6bf0SLi-Wen Hsu unsigned int exp :11; 40*604f6bf0SLi-Wen Hsu unsigned int manh :20; 41*604f6bf0SLi-Wen Hsu unsigned int manl :32; 42*604f6bf0SLi-Wen Hsu #endif 43*604f6bf0SLi-Wen Hsu } bits; 44*604f6bf0SLi-Wen Hsu }; 45*604f6bf0SLi-Wen Hsu 46*604f6bf0SLi-Wen Hsu #define mask_nbit_l(u) ((void)0) 47*604f6bf0SLi-Wen Hsu #define LDBL_IMPLICIT_NBIT 48*604f6bf0SLi-Wen Hsu #define LDBL_NBIT 0 49*604f6bf0SLi-Wen Hsu 50*604f6bf0SLi-Wen Hsu #define LDBL_MANH_SIZE 20 51*604f6bf0SLi-Wen Hsu #define LDBL_MANL_SIZE 32 52*604f6bf0SLi-Wen Hsu 53*604f6bf0SLi-Wen Hsu #define LDBL_TO_ARRAY32(u, a) do { \ 54*604f6bf0SLi-Wen Hsu (a)[0] = (uint32_t)(u).bits.manl; \ 55*604f6bf0SLi-Wen Hsu (a)[1] = (uint32_t)(u).bits.manh; \ 56*604f6bf0SLi-Wen Hsu } while(0) 57