Home | History | Annotate | Line # | Download | only in include
ieee.h revision 1.7.12.1
      1  1.7.12.1      tls /*	$NetBSD: ieee.h,v 1.7.12.1 2013/02/25 00:28:51 tls Exp $	*/
      2       1.6     matt 
      3       1.6     matt /*
      4       1.6     matt  * Copyright (c) 1992, 1993
      5       1.6     matt  *	The Regents of the University of California.  All rights reserved.
      6       1.6     matt  *
      7       1.6     matt  * This software was developed by the Computer Systems Engineering group
      8       1.6     matt  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9       1.6     matt  * contributed to Berkeley.
     10       1.6     matt  *
     11       1.6     matt  * All advertising materials mentioning features or use of this software
     12       1.6     matt  * must display the following acknowledgement:
     13       1.6     matt  *	This product includes software developed by the University of
     14       1.6     matt  *	California, Lawrence Berkeley Laboratory.
     15       1.6     matt  *
     16       1.6     matt  * Redistribution and use in source and binary forms, with or without
     17       1.6     matt  * modification, are permitted provided that the following conditions
     18       1.6     matt  * are met:
     19       1.6     matt  * 1. Redistributions of source code must retain the above copyright
     20       1.6     matt  *    notice, this list of conditions and the following disclaimer.
     21       1.6     matt  * 2. Redistributions in binary form must reproduce the above copyright
     22       1.6     matt  *    notice, this list of conditions and the following disclaimer in the
     23       1.6     matt  *    documentation and/or other materials provided with the distribution.
     24       1.6     matt  * 3. Neither the name of the University nor the names of its contributors
     25       1.6     matt  *    may be used to endorse or promote products derived from this software
     26       1.6     matt  *    without specific prior written permission.
     27       1.6     matt  *
     28       1.6     matt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29       1.6     matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30       1.6     matt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31       1.6     matt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32       1.6     matt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33       1.6     matt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34       1.6     matt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35       1.6     matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36       1.6     matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37       1.6     matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38       1.6     matt  * SUCH DAMAGE.
     39       1.6     matt  *
     40       1.6     matt  *	@(#)ieee.h	8.1 (Berkeley) 6/11/93
     41       1.6     matt  */
     42       1.6     matt 
     43       1.6     matt /*
     44       1.6     matt  * ieee.h defines the machine-dependent layout of the machine's IEEE
     45       1.6     matt  * floating point.  It does *not* define (yet?) any of the rounding
     46       1.6     matt  * mode bits, exceptions, and so forth.
     47       1.6     matt  */
     48       1.6     matt 
     49       1.6     matt #ifndef _MIPS_IEEE_H
     50       1.6     matt #define _MIPS_IEEE_H
     51       1.1  mycroft 
     52       1.3   kleink #include <sys/ieee754.h>
     53       1.4   kleink 
     54       1.4   kleink /*
     55       1.6     matt  * The SPARC architecture defines the following IEEE 754 compliant
     56       1.6     matt  * 128-bit extended-precision format, which is supported only by the
     57       1.6     matt  * v9 toolchain.
     58       1.4   kleink  */
     59       1.4   kleink 
     60       1.6     matt #if defined(__mips_n32) || defined(__mips_n64)
     61       1.6     matt 
     62       1.6     matt #define	EXT_EXPBITS	15
     63       1.6     matt #define EXT_FRACHBITS	16
     64       1.6     matt #define	EXT_FRACHMBITS	32
     65       1.6     matt #define	EXT_FRACLMBITS	32
     66       1.6     matt #define	EXT_FRACLBITS	32
     67       1.6     matt #define	EXT_FRACBITS	(EXT_FRACLBITS + EXT_FRACLMBITS + EXT_FRACHMBITS + EXT_FRACHBITS)
     68       1.6     matt 
     69       1.6     matt #define	EXT_TO_ARRAY32(u, a) do {			\
     70       1.6     matt 	(a)[0] = (uint32_t)(u).extu_ext.ext_fracl;	\
     71       1.6     matt 	(a)[1] = (uint32_t)(u).extu_ext.ext_fraclm;	\
     72       1.6     matt 	(a)[2] = (uint32_t)(u).extu_ext.ext_frachm;	\
     73       1.6     matt 	(a)[3] = (uint32_t)(u).extu_ext.ext_frach;	\
     74       1.6     matt } while(/*CONSTCOND*/0)
     75       1.6     matt 
     76       1.6     matt struct ieee_ext {
     77       1.6     matt #if _BYTE_ORDER == _BIG_ENDIAN
     78       1.6     matt 	u_int	ext_sign:1;
     79       1.6     matt 	u_int	ext_exp:EXT_EXPBITS;
     80       1.6     matt 	u_int	ext_frach:EXT_FRACHBITS;
     81       1.6     matt 	u_int	ext_frachm;
     82       1.6     matt 	u_int	ext_fraclm;
     83       1.6     matt 	u_int	ext_fracl;
     84       1.6     matt #else
     85       1.6     matt 	u_int	ext_fracl;
     86       1.6     matt 	u_int	ext_fraclm;
     87       1.6     matt 	u_int	ext_frachm;
     88       1.6     matt 	u_int	ext_frach:EXT_FRACHBITS;
     89       1.6     matt 	u_int	ext_exp:EXT_EXPBITS;
     90       1.6     matt 	u_int	ext_sign:1;
     91       1.6     matt #endif
     92       1.6     matt };
     93       1.6     matt 
     94       1.6     matt /*
     95       1.6     matt  * Floats whose exponent is in [1..INFNAN) (of whatever type) are
     96       1.6     matt  * `normal'.  Floats whose exponent is INFNAN are either Inf or NaN.
     97       1.6     matt  * Floats whose exponent is zero are either zero (iff all fraction
     98       1.6     matt  * bits are zero) or subnormal values.
     99       1.6     matt  *
    100       1.6     matt  * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
    101       1.6     matt  * high fraction; if the bit is set, it is a `quiet NaN'.
    102       1.6     matt  */
    103       1.6     matt #define	EXT_EXP_INFNAN	0x7fff
    104       1.6     matt #define	EXT_EXP_INF	0x7fff
    105       1.6     matt #define	EXT_EXP_NAN	0x7fff
    106       1.6     matt 
    107       1.4   kleink #if 0
    108       1.4   kleink #define	SNG_QUIETNAN	(1 << 22)
    109       1.4   kleink #define	DBL_QUIETNAN	(1 << 19)
    110       1.6     matt #define	EXT_QUIETNAN	(1 << 15)
    111       1.4   kleink #endif
    112       1.6     matt 
    113       1.6     matt /*
    114       1.6     matt  * Exponent biases.
    115       1.6     matt  */
    116       1.6     matt #define	EXT_EXP_BIAS	16383
    117       1.6     matt 
    118       1.6     matt /*
    119       1.6     matt  * Convenience data structures.
    120       1.6     matt  */
    121       1.6     matt union ieee_ext_u {
    122       1.6     matt 	long double		extu_ld;
    123       1.6     matt 	struct ieee_ext		extu_ext;
    124       1.6     matt };
    125       1.6     matt 
    126       1.6     matt #define extu_exp	extu_ext.ext_exp
    127       1.6     matt #define extu_sign	extu_ext.ext_sign
    128       1.6     matt #define extu_fracl	extu_ext.ext_fracl
    129       1.7     matt #define extu_fraclm	extu_ext.ext_fraclm
    130       1.7     matt #define extu_frachm	extu_ext.ext_frachm
    131       1.6     matt #define extu_frach	extu_ext.ext_frach
    132       1.6     matt 
    133  1.7.12.1      tls #define LDBL_IMPLICIT_NBIT	1	/* our NBIT is implicit */
    134       1.6     matt 
    135       1.6     matt #endif /* __mips_n32 || __mips_n64 */
    136       1.6     matt 
    137       1.6     matt #endif /* _MIPS_IEEE_H */
    138