1294227Sbr/*-
2294227Sbr * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
3294227Sbr * Copyright (c) 2014 The FreeBSD Foundation
4294227Sbr * All rights reserved.
5294227Sbr *
6294227Sbr * Redistribution and use in source and binary forms, with or without
7294227Sbr * modification, are permitted provided that the following conditions
8294227Sbr * are met:
9294227Sbr * 1. Redistributions of source code must retain the above copyright
10294227Sbr *    notice, this list of conditions and the following disclaimer.
11294227Sbr * 2. Redistributions in binary form must reproduce the above copyright
12294227Sbr *    notice, this list of conditions and the following disclaimer in the
13294227Sbr *    documentation and/or other materials provided with the distribution.
14294227Sbr *
15294227Sbr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16294227Sbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17294227Sbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18294227Sbr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19294227Sbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20294227Sbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21294227Sbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22294227Sbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23294227Sbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24294227Sbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25294227Sbr * SUCH DAMAGE.
26294227Sbr *
27294227Sbr * $FreeBSD: releng/11.0/lib/libc/riscv/_fpmath.h 294227 2016-01-17 15:21:23Z br $
28294227Sbr */
29294227Sbr
30294227Sbrunion IEEEl2bits {
31294227Sbr	long double	e;
32294227Sbr	struct {
33294227Sbr		unsigned long	manl	:64;
34294227Sbr		unsigned long	manh	:48;
35294227Sbr		unsigned int	exp	:15;
36294227Sbr		unsigned int	sign	:1;
37294227Sbr	} bits;
38294227Sbr	struct {
39294227Sbr		unsigned long	manl	:64;
40294227Sbr		unsigned long	manh	:48;
41294227Sbr		unsigned int	expsign	:16;
42294227Sbr	} xbits;
43294227Sbr};
44294227Sbr
45294227Sbr#define	LDBL_NBIT	0
46294227Sbr#define	LDBL_IMPLICIT_NBIT
47294227Sbr#define	mask_nbit_l(u)	((void)0)
48294227Sbr
49294227Sbr#define	LDBL_MANH_SIZE	20
50294227Sbr#define	LDBL_MANL_SIZE	32
51294227Sbr
52294227Sbr#define	LDBL_TO_ARRAY32(u, a) do {			\
53294227Sbr	(a)[0] = (uint32_t)(u).bits.manl;		\
54294227Sbr	(a)[1] = (uint32_t)(u).bits.manh;		\
55294227Sbr} while(0)
56294227Sbr
57294227Sbr/*
58294227Sbr * TODO: Due to compiler problem we are temporary using
59294227Sbr * LDBL_PREC == 53. Use code below for LDBL_PREC == 113
60294227Sbr */
61294227Sbr#if 0
62294227Sbr#define	LDBL_MANH_SIZE	48
63294227Sbr#define	LDBL_MANL_SIZE	64
64294227Sbr
65294227Sbr#define	LDBL_TO_ARRAY32(u, a) do {			\
66294227Sbr	(a)[0] = (uint32_t)(u).bits.manl;		\
67294227Sbr	(a)[1] = (uint32_t)((u).bits.manl >> 32);	\
68294227Sbr	(a)[2] = (uint32_t)(u).bits.manh;		\
69294227Sbr	(a)[3] = (uint32_t)((u).bits.manh >> 32);	\
70294227Sbr} while(0)
71294227Sbr#endif
72