xref: /freebsd/lib/libc/powerpc64/_fpmath.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1840b91ccSNathan Whitehorn /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3d915a14eSPedro F. Giffuni  *
4840b91ccSNathan Whitehorn  * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
5840b91ccSNathan Whitehorn  * All rights reserved.
6840b91ccSNathan Whitehorn  *
7840b91ccSNathan Whitehorn  * Redistribution and use in source and binary forms, with or without
8840b91ccSNathan Whitehorn  * modification, are permitted provided that the following conditions
9840b91ccSNathan Whitehorn  * are met:
10840b91ccSNathan Whitehorn  * 1. Redistributions of source code must retain the above copyright
11840b91ccSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer.
12840b91ccSNathan Whitehorn  * 2. Redistributions in binary form must reproduce the above copyright
13840b91ccSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer in the
14840b91ccSNathan Whitehorn  *    documentation and/or other materials provided with the distribution.
15840b91ccSNathan Whitehorn  *
16840b91ccSNathan Whitehorn  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17840b91ccSNathan Whitehorn  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18840b91ccSNathan Whitehorn  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19840b91ccSNathan Whitehorn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20840b91ccSNathan Whitehorn  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21840b91ccSNathan Whitehorn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22840b91ccSNathan Whitehorn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23840b91ccSNathan Whitehorn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24840b91ccSNathan Whitehorn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25840b91ccSNathan Whitehorn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26840b91ccSNathan Whitehorn  * SUCH DAMAGE.
27840b91ccSNathan Whitehorn  */
28840b91ccSNathan Whitehorn 
29840b91ccSNathan Whitehorn union IEEEl2bits {
30840b91ccSNathan Whitehorn 	long double	e;
31840b91ccSNathan Whitehorn 	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 */
38840b91ccSNathan Whitehorn 		unsigned int		sign	:1;
39840b91ccSNathan Whitehorn 		unsigned int		exp	:11;
40840b91ccSNathan Whitehorn 		unsigned int		manh	:20;
41840b91ccSNathan Whitehorn 		unsigned int		manl	:32;
4297a5390eSNathan Whitehorn #endif
43840b91ccSNathan Whitehorn 	} bits;
44840b91ccSNathan Whitehorn };
45840b91ccSNathan Whitehorn 
46840b91ccSNathan Whitehorn #define	mask_nbit_l(u)	((void)0)
47840b91ccSNathan Whitehorn #define	LDBL_IMPLICIT_NBIT
48840b91ccSNathan Whitehorn #define	LDBL_NBIT	0
49840b91ccSNathan Whitehorn 
50840b91ccSNathan Whitehorn #define	LDBL_MANH_SIZE	20
51840b91ccSNathan Whitehorn #define	LDBL_MANL_SIZE	32
52840b91ccSNathan Whitehorn 
53840b91ccSNathan Whitehorn #define	LDBL_TO_ARRAY32(u, a) do {			\
54840b91ccSNathan Whitehorn 	(a)[0] = (uint32_t)(u).bits.manl;		\
55840b91ccSNathan Whitehorn 	(a)[1] = (uint32_t)(u).bits.manh;		\
56840b91ccSNathan Whitehorn } while(0)
57