18cf5ed51SMike Barcroft /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3d915a14eSPedro F. Giffuni * 4f154b03bSDavid Schultz * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG> 58cf5ed51SMike Barcroft * All rights reserved. 68cf5ed51SMike Barcroft * 78cf5ed51SMike Barcroft * Redistribution and use in source and binary forms, with or without 88cf5ed51SMike Barcroft * modification, are permitted provided that the following conditions 98cf5ed51SMike Barcroft * are met: 108cf5ed51SMike Barcroft * 1. Redistributions of source code must retain the above copyright 118cf5ed51SMike Barcroft * notice, this list of conditions and the following disclaimer. 128cf5ed51SMike Barcroft * 2. Redistributions in binary form must reproduce the above copyright 138cf5ed51SMike Barcroft * notice, this list of conditions and the following disclaimer in the 148cf5ed51SMike Barcroft * documentation and/or other materials provided with the distribution. 158cf5ed51SMike Barcroft * 168cf5ed51SMike Barcroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 178cf5ed51SMike Barcroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188cf5ed51SMike Barcroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198cf5ed51SMike Barcroft * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 208cf5ed51SMike Barcroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 218cf5ed51SMike Barcroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228cf5ed51SMike Barcroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 238cf5ed51SMike Barcroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 248cf5ed51SMike Barcroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 258cf5ed51SMike Barcroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 268cf5ed51SMike Barcroft * SUCH DAMAGE. 278cf5ed51SMike Barcroft */ 288cf5ed51SMike Barcroft 298cf5ed51SMike Barcroft union IEEEl2bits { 308cf5ed51SMike Barcroft long double e; 318cf5ed51SMike Barcroft struct { 3297a5390eSNathan Whitehorn #if _BYTE_ORDER == _LITTLE_ENDIAN 3397a5390eSNathan Whitehorn unsigned int manl :32; 3497a5390eSNathan Whitehorn unsigned int manh :20; 3597a5390eSNathan Whitehorn unsigned int exp :11; 3697a5390eSNathan Whitehorn unsigned int sign :1; 3797a5390eSNathan Whitehorn #else /* _BYTE_ORDER == _LITTLE_ENDIAN */ 388cf5ed51SMike Barcroft unsigned int sign :1; 39df11547fSAndrew Gallatin unsigned int exp :11; 40df11547fSAndrew Gallatin unsigned int manh :20; 41df11547fSAndrew Gallatin unsigned int manl :32; 4297a5390eSNathan Whitehorn #endif 438cf5ed51SMike Barcroft } bits; 448cf5ed51SMike Barcroft }; 458cf5ed51SMike Barcroft 468cf5ed51SMike Barcroft #define mask_nbit_l(u) ((void)0) 4792b93b37SDavid Schultz #define LDBL_IMPLICIT_NBIT 481dfab5edSDavid Schultz #define LDBL_NBIT 0 4992b93b37SDavid Schultz 50df11547fSAndrew Gallatin #define LDBL_MANH_SIZE 20 51df11547fSAndrew Gallatin #define LDBL_MANL_SIZE 32 52a8cb7ccaSDavid Schultz 5392b93b37SDavid Schultz #define LDBL_TO_ARRAY32(u, a) do { \ 5492b93b37SDavid Schultz (a)[0] = (uint32_t)(u).bits.manl; \ 55df11547fSAndrew Gallatin (a)[1] = (uint32_t)(u).bits.manh; \ 5692b93b37SDavid Schultz } while(0) 57