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