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