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