1110566Smike/*-
2141379Sdas * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
3110566Smike * All rights reserved.
4110566Smike *
5110566Smike * Redistribution and use in source and binary forms, with or without
6110566Smike * modification, are permitted provided that the following conditions
7110566Smike * are met:
8110566Smike * 1. Redistributions of source code must retain the above copyright
9110566Smike *    notice, this list of conditions and the following disclaimer.
10110566Smike * 2. Redistributions in binary form must reproduce the above copyright
11110566Smike *    notice, this list of conditions and the following disclaimer in the
12110566Smike *    documentation and/or other materials provided with the distribution.
13110566Smike *
14110566Smike * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15110566Smike * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16110566Smike * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17110566Smike * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18110566Smike * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19110566Smike * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20110566Smike * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21110566Smike * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22110566Smike * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23110566Smike * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24110566Smike * SUCH DAMAGE.
25110566Smike *
26110566Smike * $FreeBSD$
27110566Smike */
28110566Smike
29110566Smikeunion IEEEl2bits {
30110566Smike	long double	e;
31110566Smike	struct {
32110566Smike		unsigned int	manl	:32;
33110566Smike		unsigned int	manh	:32;
34110566Smike		unsigned int	exp	:15;
35110566Smike		unsigned int	sign	:1;
36110566Smike		unsigned int	junk	:16;
37110566Smike	} bits;
38175402Sbde	struct {
39175402Sbde		unsigned long long man	:64;
40175402Sbde		unsigned int 	expsign	:16;
41175402Sbde		unsigned int	junk	:16;
42175402Sbde	} xbits;
43110566Smike};
44110566Smike
45143214Sdas#define	LDBL_NBIT	0x80000000
46143214Sdas#define	mask_nbit_l(u)	((u).bits.manh &= ~LDBL_NBIT)
47113145Sdas
48124653Sdas#define	LDBL_MANH_SIZE	32
49124653Sdas#define	LDBL_MANL_SIZE	32
50124653Sdas
51113145Sdas#define	LDBL_TO_ARRAY32(u, a) do {			\
52113145Sdas	(a)[0] = (uint32_t)(u).bits.manl;		\
53113145Sdas	(a)[1] = (uint32_t)(u).bits.manh;		\
54175402Sbde} while (0)
55