xref: /freebsd/lib/libc/powerpc64/_fpmath.h (revision d915a14ef094c8dfc1a5aee70e135abfec01d0f1)
1840b91ccSNathan Whitehorn /*-
2*d915a14eSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*d915a14eSPedro 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  * $FreeBSD$
29840b91ccSNathan Whitehorn  */
30840b91ccSNathan Whitehorn 
31840b91ccSNathan Whitehorn union IEEEl2bits {
32840b91ccSNathan Whitehorn 	long double	e;
33840b91ccSNathan Whitehorn 	struct {
3497a5390eSNathan Whitehorn #if _BYTE_ORDER == _LITTLE_ENDIAN
3597a5390eSNathan Whitehorn 		unsigned int	manl	:32;
3697a5390eSNathan Whitehorn 		unsigned int	manh	:20;
3797a5390eSNathan Whitehorn 		unsigned int	exp	:11;
3897a5390eSNathan Whitehorn 		unsigned int	sign	:1;
3997a5390eSNathan Whitehorn #else	/* _BYTE_ORDER == _LITTLE_ENDIAN */
40840b91ccSNathan Whitehorn 		unsigned int		sign	:1;
41840b91ccSNathan Whitehorn 		unsigned int		exp	:11;
42840b91ccSNathan Whitehorn 		unsigned int		manh	:20;
43840b91ccSNathan Whitehorn 		unsigned int		manl	:32;
4497a5390eSNathan Whitehorn #endif
45840b91ccSNathan Whitehorn 	} bits;
46840b91ccSNathan Whitehorn };
47840b91ccSNathan Whitehorn 
48840b91ccSNathan Whitehorn #define	mask_nbit_l(u)	((void)0)
49840b91ccSNathan Whitehorn #define	LDBL_IMPLICIT_NBIT
50840b91ccSNathan Whitehorn #define	LDBL_NBIT	0
51840b91ccSNathan Whitehorn 
52840b91ccSNathan Whitehorn #define	LDBL_MANH_SIZE	20
53840b91ccSNathan Whitehorn #define	LDBL_MANL_SIZE	32
54840b91ccSNathan Whitehorn 
55840b91ccSNathan Whitehorn #define	LDBL_TO_ARRAY32(u, a) do {			\
56840b91ccSNathan Whitehorn 	(a)[0] = (uint32_t)(u).bits.manl;		\
57840b91ccSNathan Whitehorn 	(a)[1] = (uint32_t)(u).bits.manh;		\
58840b91ccSNathan Whitehorn } while(0)
59