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