os/ossrv/genericopenlibs/openenvcore/libc/include/fpmath.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*-
sl@0
     2
 * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
sl@0
     3
 * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG>
sl@0
     4
 * All rights reserved.
sl@0
     5
 *
sl@0
     6
 * Redistribution and use in source and binary forms, with or without
sl@0
     7
 * modification, are permitted provided that the following conditions
sl@0
     8
 * are met:
sl@0
     9
 * 1. Redistributions of source code must retain the above copyright
sl@0
    10
 *    notice, this list of conditions and the following disclaimer.
sl@0
    11
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    12
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    13
 *    documentation and/or other materials provided with the distribution.
sl@0
    14
 *
sl@0
    15
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
sl@0
    16
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    18
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
sl@0
    19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    21
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    22
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    23
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    24
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    25
 * SUCH DAMAGE.
sl@0
    26
 *
sl@0
    27
 * $FreeBSD: src/lib/libc/include/fpmath.h,v 1.3 2005/02/06 03:23:31 das Exp $
sl@0
    28
 */
sl@0
    29
sl@0
    30
#include <sys/endian.h>
sl@0
    31
#include "_fpmath.h"
sl@0
    32
sl@0
    33
union IEEEf2bits {
sl@0
    34
	float	f;
sl@0
    35
	struct {
sl@0
    36
#if _BYTE_ORDER == _LITTLE_ENDIAN
sl@0
    37
		unsigned int	man	:23;
sl@0
    38
		unsigned int	exp	:8;
sl@0
    39
		unsigned int	sign	:1;
sl@0
    40
#else /* _BIG_ENDIAN */
sl@0
    41
		unsigned int	sign	:1;
sl@0
    42
		unsigned int	exp	:8;
sl@0
    43
		unsigned int	man	:23;
sl@0
    44
#endif
sl@0
    45
	} bits;
sl@0
    46
};
sl@0
    47
sl@0
    48
#define	DBL_MANH_SIZE	20
sl@0
    49
#define	DBL_MANL_SIZE	32
sl@0
    50
sl@0
    51
union IEEEd2bits {
sl@0
    52
	double	d;
sl@0
    53
	struct {
sl@0
    54
#if _BYTE_ORDER == _LITTLE_ENDIAN
sl@0
    55
		unsigned int	manl	:32;
sl@0
    56
		unsigned int	manh	:20;
sl@0
    57
		unsigned int	exp	:11;
sl@0
    58
		unsigned int	sign	:1;
sl@0
    59
#else /* _BIG_ENDIAN */
sl@0
    60
		unsigned int	sign	:1;
sl@0
    61
		unsigned int	exp	:11;
sl@0
    62
		unsigned int	manh	:20;
sl@0
    63
		unsigned int	manl	:32;
sl@0
    64
#endif
sl@0
    65
	} bits;
sl@0
    66
};