_fpmath.h revision 124653
166703Sarchie/*- 266703Sarchie * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> 366703Sarchie * Copyright (c) 2002, 2003 David Schultz <dschultz@uclink.Berkeley.EDU> 466703Sarchie * All rights reserved. 566703Sarchie * 666703Sarchie * Redistribution and use in source and binary forms, with or without 766703Sarchie * modification, are permitted provided that the following conditions 866703Sarchie * are met: 966703Sarchie * 1. Redistributions of source code must retain the above copyright 1066703Sarchie * notice, this list of conditions and the following disclaimer. 1166703Sarchie * 2. Redistributions in binary form must reproduce the above copyright 1266703Sarchie * notice, this list of conditions and the following disclaimer in the 1366703Sarchie * documentation and/or other materials provided with the distribution. 1466703Sarchie * 1566703Sarchie * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1666703Sarchie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1766703Sarchie * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1866703Sarchie * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1966703Sarchie * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2066703Sarchie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2166703Sarchie * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2266703Sarchie * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2366703Sarchie * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2466703Sarchie * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2566703Sarchie * SUCH DAMAGE. 2666703Sarchie * 2766703Sarchie * $FreeBSD: head/lib/libc/ia64/_fpmath.h 124653 2004-01-18 07:57:02Z das $ 2866703Sarchie */ 2966703Sarchie 3066703Sarchie#include <sys/endian.h> 3166703Sarchie 3266703Sarchieunion IEEEl2bits { 3366703Sarchie long double e; 3466703Sarchie struct { 3566703Sarchie#if _BYTE_ORDER == _LITTLE_ENDIAN 3666703Sarchie unsigned int manl :32; 3766703Sarchie unsigned int manh :32; 3866703Sarchie unsigned int exp :15; 3966703Sarchie unsigned int sign :1; 4066703Sarchie unsigned long junk :48; 4166703Sarchie#else /* _BIG_ENDIAN */ 4266703Sarchie unsigned long junk :48; 4366703Sarchie unsigned int sign :1; 4466703Sarchie unsigned int exp :15; 4566703Sarchie unsigned int manh :32; 4666703Sarchie unsigned int manl :32; 4766703Sarchie#endif 4866703Sarchie } bits; 4966703Sarchie}; 5066703Sarchie 5169734Sarchie#if _BYTE_ORDER == _LITTLE_ENDIAN 5266703Sarchie#define mask_nbit_l(u) ((u).bits.manh &= 0x7fffffff) 5366703Sarchie#else /* _BIG_ENDIAN */ 5466703Sarchie#define mask_nbit_l(u) ((u).bits.manh &= 0xffffff7f) 5566703Sarchie#endif 5666703Sarchie 5766703Sarchie#define LDBL_MANH_SIZE 32 5866703Sarchie#define LDBL_MANL_SIZE 32 5966703Sarchie 6066703Sarchie#define LDBL_TO_ARRAY32(u, a) do { \ 6166703Sarchie (a)[0] = (uint32_t)(u).bits.manl; \ 6266703Sarchie (a)[1] = (uint32_t)(u).bits.manh; \ 6366703Sarchie} while(0) 6466703Sarchie