18cf5ed51SMike Barcroft /*- 28cf5ed51SMike Barcroft * Copyright (c) 2003 David Schultz <dschultz@uclink.Berkeley.EDU> 38cf5ed51SMike Barcroft * All rights reserved. 48cf5ed51SMike Barcroft * 58cf5ed51SMike Barcroft * Redistribution and use in source and binary forms, with or without 68cf5ed51SMike Barcroft * modification, are permitted provided that the following conditions 78cf5ed51SMike Barcroft * are met: 88cf5ed51SMike Barcroft * 1. Redistributions of source code must retain the above copyright 98cf5ed51SMike Barcroft * notice, this list of conditions and the following disclaimer. 108cf5ed51SMike Barcroft * 2. Redistributions in binary form must reproduce the above copyright 118cf5ed51SMike Barcroft * notice, this list of conditions and the following disclaimer in the 128cf5ed51SMike Barcroft * documentation and/or other materials provided with the distribution. 138cf5ed51SMike Barcroft * 148cf5ed51SMike Barcroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158cf5ed51SMike Barcroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168cf5ed51SMike Barcroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178cf5ed51SMike Barcroft * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188cf5ed51SMike Barcroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198cf5ed51SMike Barcroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208cf5ed51SMike Barcroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218cf5ed51SMike Barcroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228cf5ed51SMike Barcroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238cf5ed51SMike Barcroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248cf5ed51SMike Barcroft * SUCH DAMAGE. 258cf5ed51SMike Barcroft * 268cf5ed51SMike Barcroft * $FreeBSD$ 278cf5ed51SMike Barcroft */ 288cf5ed51SMike Barcroft 298cf5ed51SMike Barcroft union IEEEl2bits { 308cf5ed51SMike Barcroft long double e; 318cf5ed51SMike Barcroft struct { 328cf5ed51SMike Barcroft unsigned int sign :1; 338cf5ed51SMike Barcroft unsigned int exp :15; 348cf5ed51SMike Barcroft unsigned long manh :48; 358cf5ed51SMike Barcroft unsigned long manl :64; 368cf5ed51SMike Barcroft } bits; 378cf5ed51SMike Barcroft }; 388cf5ed51SMike Barcroft 398cf5ed51SMike Barcroft /* XXX does powerpc have a normalization bit? */ 408cf5ed51SMike Barcroft #define mask_nbit_l(u) ((void)0) 4192b93b37SDavid Schultz #define LDBL_IMPLICIT_NBIT 4292b93b37SDavid Schultz 4392b93b37SDavid Schultz #define LDBL_TO_ARRAY32(u, a) do { \ 4492b93b37SDavid Schultz (a)[0] = (uint32_t)(u).bits.manl; \ 4592b93b37SDavid Schultz (a)[1] = (uint32_t)((u).bits.manl >> 32); \ 4692b93b37SDavid Schultz (a)[2] = (uint32_t)(u).bits.manh; \ 4792b93b37SDavid Schultz (a)[3] = (uint32_t)((u).bits.manh >> 32); \ 4892b93b37SDavid Schultz } while(0) 49