OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdio/] [vfieeefp.h] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 joel
/****************************************************************
2
 *
3
 * The author of this software is David M. Gay.
4
 *
5
 * Copyright (c) 1991 by AT&T.
6
 *
7
 * Permission to use, copy, modify, and distribute this software for any
8
 * purpose without fee is hereby granted, provided that this entire notice
9
 * is included in all copies of any software which is or includes a copy
10
 * or modification of this software and in all copies of the supporting
11
 * documentation for such software.
12
 *
13
 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
14
 * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
15
 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
16
 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
17
 *
18
 ***************************************************************/
19
 
20
/* Please send bug reports to
21
        David M. Gay
22
        AT&T Bell Laboratories, Room 2C-463
23
        600 Mountain Avenue
24
        Murray Hill, NJ 07974-2070
25
        U.S.A.
26
        dmg@research.att.com or research!dmg
27
 */
28
 
29
/* This header file is a modification of mprec.h that only contains floating
30
   point union code. */
31
 
32
#include <ieeefp.h>
33
#include <math.h>
34
#include <float.h>
35
#include <errno.h>
36
#include <sys/config.h>
37
 
38
#ifdef __IEEE_LITTLE_ENDIAN
39
#define IEEE_8087
40
#endif
41
 
42
#ifdef __IEEE_BIG_ENDIAN
43
#define IEEE_MC68k
44
#endif
45
 
46
#ifdef __Z8000__
47
#define Just_16
48
#endif
49
 
50
#ifdef Unsigned_Shifts
51
#define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000;
52
#else
53
#define Sign_Extend(a,b) /*no-op*/
54
#endif
55
 
56
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
57
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
58
#endif
59
 
60
/* If we are going to examine or modify specific bits in a double using
61
   the word0 and/or word1 macros, then we must wrap the double inside
62
   a union.  This is necessary to avoid undefined behavior according to
63
   the ANSI C spec.  */
64
union double_union
65
{
66
  double d;
67
  __uint32_t i[2];
68
};
69
 
70
#ifdef IEEE_8087
71
#define word0(x) (x.i[1])
72
#define word1(x) (x.i[0])
73
#else
74
#define word0(x) (x.i[0])
75
#define word1(x) (x.i[1])
76
#endif
77
 
78
/* #define P DBL_MANT_DIG */
79
/* Ten_pmax = floor(P*log(2)/log(5)) */
80
/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
81
/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
82
/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
83
 
84
#if defined(IEEE_8087) + defined(IEEE_MC68k)
85
#if defined (_DOUBLE_IS_32BITS) 
86
#define Exp_shift   23
87
#define Exp_shift1  23
88
#define Exp_msk1    ((__uint32_t)0x00800000L)
89
#define Exp_msk11   ((__uint32_t)0x00800000L)
90
#define Exp_mask    ((__uint32_t)0x7f800000L)
91
#define P           24
92
#define Bias        127
93
#if 0
94
#define IEEE_Arith  /* it is, but the code doesn't handle IEEE singles yet */
95
#endif
96
#define Emin        (-126)
97
#define Exp_1       ((__uint32_t)0x3f800000L)
98
#define Exp_11      ((__uint32_t)0x3f800000L)
99
#define Ebits       8
100
#define Frac_mask   ((__uint32_t)0x007fffffL)
101
#define Frac_mask1  ((__uint32_t)0x007fffffL)
102
#define Ten_pmax    10
103
#define Sign_bit    ((__uint32_t)0x80000000L)
104
#define Ten_pmax    10
105
#define Bletch      2
106
#define Bndry_mask  ((__uint32_t)0x007fffffL)
107
#define Bndry_mask1 ((__uint32_t)0x007fffffL)
108
#define LSB 1
109
#define Sign_bit    ((__uint32_t)0x80000000L)
110
#define Log2P       1
111
#define Tiny0       0
112
#define Tiny1       1
113
#define Quick_max   5
114
#define Int_max     6
115
#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L))
116
#undef word0
117
#undef word1
118
 
119
#define word0(x) (x.i[0])
120
#define word1(x) 0
121
#else
122
 
123
#define Exp_shift  20
124
#define Exp_shift1 20
125
#define Exp_msk1    ((__uint32_t)0x100000L)
126
#define Exp_msk11   ((__uint32_t)0x100000L)
127
#define Exp_mask  ((__uint32_t)0x7ff00000L)
128
#define P 53
129
#define Bias 1023
130
#define IEEE_Arith
131
#define Emin (-1022)
132
#define Exp_1  ((__uint32_t)0x3ff00000L)
133
#define Exp_11 ((__uint32_t)0x3ff00000L)
134
#define Ebits 11
135
#define Frac_mask  ((__uint32_t)0xfffffL)
136
#define Frac_mask1 ((__uint32_t)0xfffffL)
137
#define Ten_pmax 22
138
#define Bletch 0x10
139
#define Bndry_mask  ((__uint32_t)0xfffffL)
140
#define Bndry_mask1 ((__uint32_t)0xfffffL)
141
#define LSB 1
142
#define Sign_bit ((__uint32_t)0x80000000L)
143
#define Log2P 1
144
#define Tiny0 0
145
#define Tiny1 1
146
#define Quick_max 14
147
#define Int_max 14
148
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */
149
#endif
150
 
151
#else
152
#undef  Sudden_Underflow
153
#define Sudden_Underflow
154
#ifdef IBM
155
#define Exp_shift  24
156
#define Exp_shift1 24
157
#define Exp_msk1   ((__uint32_t)0x1000000L)
158
#define Exp_msk11  ((__uint32_t)0x1000000L)
159
#define Exp_mask  ((__uint32_t)0x7f000000L)
160
#define P 14
161
#define Bias 65
162
#define Exp_1  ((__uint32_t)0x41000000L)
163
#define Exp_11 ((__uint32_t)0x41000000L)
164
#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
165
#define Frac_mask  ((__uint32_t)0xffffffL)
166
#define Frac_mask1 ((__uint32_t)0xffffffL)
167
#define Bletch 4
168
#define Ten_pmax 22
169
#define Bndry_mask  ((__uint32_t)0xefffffL)
170
#define Bndry_mask1 ((__uint32_t)0xffffffL)
171
#define LSB 1
172
#define Sign_bit ((__uint32_t)0x80000000L)
173
#define Log2P 4
174
#define Tiny0 ((__uint32_t)0x100000L)
175
#define Tiny1 0
176
#define Quick_max 14
177
#define Int_max 15
178
#else /* VAX */
179
#define Exp_shift  23
180
#define Exp_shift1 7
181
#define Exp_msk1    0x80
182
#define Exp_msk11   ((__uint32_t)0x800000L)
183
#define Exp_mask  ((__uint32_t)0x7f80L)
184
#define P 56
185
#define Bias 129
186
#define Exp_1  ((__uint32_t)0x40800000L)
187
#define Exp_11 ((__uint32_t)0x4080L)
188
#define Ebits 8
189
#define Frac_mask  ((__uint32_t)0x7fffffL)
190
#define Frac_mask1 ((__uint32_t)0xffff007fL)
191
#define Ten_pmax 24
192
#define Bletch 2
193
#define Bndry_mask  ((__uint32_t)0xffff007fL)
194
#define Bndry_mask1 ((__uint32_t)0xffff007fL)
195
#define LSB ((__uint32_t)0x10000L)
196
#define Sign_bit ((__uint32_t)0x8000L)
197
#define Log2P 1
198
#define Tiny0 0x80
199
#define Tiny1 0
200
#define Quick_max 15
201
#define Int_max 15
202
#endif
203
#endif
204
 
205
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.