_fpmath.h revision 124653
131921Sbrian/*-
231921Sbrian * Copyright (c) 2002, 2003 David Schultz <dschultz@uclink.Berkeley.EDU>
331921Sbrian * All rights reserved.
431921Sbrian *
531921Sbrian * Redistribution and use in source and binary forms, with or without
631921Sbrian * modification, are permitted provided that the following conditions
731921Sbrian * are met:
831921Sbrian * 1. Redistributions of source code must retain the above copyright
931921Sbrian *    notice, this list of conditions and the following disclaimer.
1031921Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1131921Sbrian *    notice, this list of conditions and the following disclaimer in the
1231921Sbrian *    documentation and/or other materials provided with the distribution.
1331921Sbrian *
1431921Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1531921Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1631921Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1731921Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1831921Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1931921Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2031921Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2131921Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2231921Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2331921Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2431921Sbrian * SUCH DAMAGE.
2531921Sbrian *
2650479Speter * $FreeBSD: head/lib/libc/amd64/_fpmath.h 124653 2004-01-18 07:57:02Z das $
2731690Sbrian */
2831690Sbrian
2937210Sbrianunion IEEEl2bits {
3037210Sbrian	long double	e;
3137210Sbrian	struct {
3237210Sbrian		unsigned int	manl	:32;
3337210Sbrian		unsigned int	manh	:32;
3437210Sbrian		unsigned int	exp	:15;
3537210Sbrian		unsigned int	sign	:1;
3637210Sbrian		unsigned int	junkl	:16;
3737210Sbrian		unsigned int	junkh	:32;
3831690Sbrian	} bits;
3937210Sbrian};
4037210Sbrian
4131690Sbrian#define	mask_nbit_l(u)	((u).bits.manh &= 0x7fffffff)
4231690Sbrian
4331690Sbrian#define	LDBL_MANH_SIZE	32
4431690Sbrian#define	LDBL_MANL_SIZE	32
4531690Sbrian
4637210Sbrian#define	LDBL_TO_ARRAY32(u, a) do {			\
4731690Sbrian	(a)[0] = (uint32_t)(u).bits.manl;		\
4831690Sbrian	(a)[1] = (uint32_t)(u).bits.manh;		\
4931690Sbrian} while(0)
5031690Sbrian