_fpmath.h revision 267654
1185377Ssam/*-
2185377Ssam * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
3185377Ssam * All rights reserved.
4185377Ssam *
5185377Ssam * Redistribution and use in source and binary forms, with or without
6185377Ssam * modification, are permitted provided that the following conditions
7185377Ssam * are met:
8185377Ssam * 1. Redistributions of source code must retain the above copyright
9185377Ssam *    notice, this list of conditions and the following disclaimer.
10185377Ssam * 2. Redistributions in binary form must reproduce the above copyright
11185377Ssam *    notice, this list of conditions and the following disclaimer in the
12185377Ssam *    documentation and/or other materials provided with the distribution.
13185377Ssam *
14185377Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15185377Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16185377Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17204644Srpaulo * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18185377Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19185377Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20185377Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21185377Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22185377Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23185377Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24185377Ssam * SUCH DAMAGE.
25185377Ssam *
26185377Ssam * $FreeBSD: releng/9.3/lib/libc/amd64/_fpmath.h 175402 2008-01-17 16:39:07Z bde $
27185377Ssam */
28185377Ssam
29185377Ssamunion IEEEl2bits {
30185377Ssam	long double	e;
31185377Ssam	struct {
32185377Ssam		unsigned int	manl	:32;
33185377Ssam		unsigned int	manh	:32;
34185377Ssam		unsigned int	exp	:15;
35185377Ssam		unsigned int	sign	:1;
36185377Ssam		unsigned int	junkl	:16;
37185377Ssam		unsigned int	junkh	:32;
38185377Ssam	} bits;
39185377Ssam	struct {
40185377Ssam		unsigned long	man	:64;
41185377Ssam		unsigned int	expsign	:16;
42185377Ssam		unsigned long	junk	:48;
43185377Ssam	} xbits;
44185377Ssam};
45185377Ssam
46185377Ssam#define	LDBL_NBIT	0x80000000
47185377Ssam#define	mask_nbit_l(u)	((u).bits.manh &= ~LDBL_NBIT)
48185377Ssam
49185377Ssam#define	LDBL_MANH_SIZE	32
50185377Ssam#define	LDBL_MANL_SIZE	32
51185377Ssam
52185377Ssam#define	LDBL_TO_ARRAY32(u, a) do {			\
53185377Ssam	(a)[0] = (uint32_t)(u).bits.manl;		\
54185377Ssam	(a)[1] = (uint32_t)(u).bits.manh;		\
55185377Ssam} while (0)
56185377Ssam