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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [native/] [fdlibm/] [mprec.h] - Blame information for rev 777

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

Line No. Rev Author Line
1 774 jeremybenn
/****************************************************************
2
 *
3
 * The author of this software is David M. Gay.
4
 *
5
 * Copyright (c) 1991, 2000 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
#ifndef __CLASSPATH_MPREC_H__
30
#define __CLASSPATH_MPREC_H__
31
 
32
#include <config.h>
33
#include "config-int.h"
34
#include "ieeefp.h"
35
/* CLASSPATH LOCAL */
36
#include "namespace.h"
37
 
38
#if defined HAVE_SYS_TYPES_H
39
#include <sys/types.h>
40
#endif
41
 
42
#if defined HAVE_SYS_CONFIG_H
43
#include <sys/config.h>
44
#endif
45
 
46
#ifdef __cplusplus
47
extern "C" {
48
#endif
49
 
50
  /* These typedefs are true for the targets running Java. */
51
 
52
#ifdef __IEEE_LITTLE_ENDIAN
53
#define IEEE_8087
54
#endif
55
 
56
#ifdef __IEEE_BIG_ENDIAN
57
#define IEEE_MC68k
58
#endif
59
 
60
#ifdef __Z8000__
61
#define Just_16
62
#endif
63
 
64
#ifdef DEBUG
65
#include "stdio.h"
66
#include <stdlib.h>
67
#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
68
#endif
69
 
70
 
71
#ifdef Unsigned_Shifts
72
#define Sign_Extend(a,b) if (b < 0) a |= (uint32_t)0xffff0000;
73
#else
74
#define Sign_Extend(a,b) /*no-op*/
75
#endif
76
 
77
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
78
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
79
#endif
80
 
81
/* If we are going to examine or modify specific bits in a double using
82
   the word0 and/or word1 macros, then we must wrap the double inside
83
   a union.  This is necessary to avoid undefined behavior according to
84
   the ANSI C spec.  */
85
union double_union
86
{
87
  double d;
88
  uint32_t i[2];
89
};
90
 
91
#ifdef IEEE_8087
92
#define word0(x) (x.i[1])
93
#define word1(x) (x.i[0])
94
#else
95
#define word0(x) (x.i[0])
96
#define word1(x) (x.i[1])
97
#endif
98
 
99
/* The following definition of Storeinc is appropriate for MIPS processors.
100
 * An alternative that might be better on some machines is
101
 * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
102
 */
103
#if defined(__IEEE_BYTES_LITTLE_ENDIAN) + defined(IEEE_8087) + defined(VAX)
104
#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
105
((unsigned short *)a)[0] = (unsigned short)c, a++)
106
#else
107
#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
108
((unsigned short *)a)[1] = (unsigned short)c, a++)
109
#endif
110
 
111
/* #define P DBL_MANT_DIG */
112
/* Ten_pmax = floor(P*log(2)/log(5)) */
113
/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
114
/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
115
/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
116
 
117
#if defined(IEEE_8087) + defined(IEEE_MC68k)
118
#if defined (_DOUBLE_IS_32BITS)
119
#define Exp_shift   23
120
#define Exp_shift1  23
121
#define Exp_msk1    ((uint32_t)0x00800000L)
122
#define Exp_msk11   ((uint32_t)0x00800000L)
123
#define Exp_mask    ((uint32_t)0x7f800000L)
124
#define P           24
125
#define Bias        127
126
#if 0
127
#define IEEE_Arith  /* it is, but the code doesn't handle IEEE singles yet */
128
#endif
129
#define Emin        (-126)
130
#define Exp_1       ((uint32_t)0x3f800000L)
131
#define Exp_11      ((uint32_t)0x3f800000L)
132
#define Ebits       8
133
#define Frac_mask   ((uint32_t)0x007fffffL)
134
#define Frac_mask1  ((uint32_t)0x007fffffL)
135
#define Ten_pmax    10
136
#define Sign_bit    ((uint32_t)0x80000000L)
137
#define Ten_pmax    10
138
#define Bletch      2
139
#define Bndry_mask  ((uint32_t)0x007fffffL)
140
#define Bndry_mask1 ((uint32_t)0x007fffffL)
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   5
147
#define Int_max     6
148
#define Infinite(x) (word0(x) == ((uint32_t)0x7f800000L))
149
#undef word0
150
#undef word1
151
 
152
#define word0(x) (x.i[0])
153
#define word1(x) 0
154
#else
155
 
156
#define Exp_shift  20
157
#define Exp_shift1 20
158
#define Exp_msk1    ((uint32_t)0x100000L)
159
#define Exp_msk11   ((uint32_t)0x100000L)
160
#define Exp_mask  ((uint32_t)0x7ff00000L)
161
#define P 53
162
#define Bias 1023
163
#define IEEE_Arith
164
#define Emin (-1022)
165
#define Exp_1  ((uint32_t)0x3ff00000L)
166
#define Exp_11 ((uint32_t)0x3ff00000L)
167
#define Ebits 11
168
#define Frac_mask  ((uint32_t)0xfffffL)
169
#define Frac_mask1 ((uint32_t)0xfffffL)
170
#define Ten_pmax 22
171
#define Bletch 0x10
172
#define Bndry_mask  ((uint32_t)0xfffffL)
173
#define Bndry_mask1 ((uint32_t)0xfffffL)
174
#define LSB 1
175
#define Sign_bit ((uint32_t)0x80000000L)
176
#define Log2P 1
177
#define Tiny0 0
178
#define Tiny1 1
179
#define Quick_max 14
180
#define Int_max 14
181
#define Infinite(x) (word0(x) == ((uint32_t)0x7ff00000L)) /* sufficient test for here */
182
#endif
183
 
184
#else
185
#undef  Sudden_Underflow
186
#define Sudden_Underflow
187
#ifdef IBM
188
#define Exp_shift  24
189
#define Exp_shift1 24
190
#define Exp_msk1   ((uint32_t)0x1000000L)
191
#define Exp_msk11  ((uint32_t)0x1000000L)
192
#define Exp_mask  ((uint32_t)0x7f000000L)
193
#define P 14
194
#define Bias 65
195
#define Exp_1  ((uint32_t)0x41000000L)
196
#define Exp_11 ((uint32_t)0x41000000L)
197
#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
198
#define Frac_mask  ((uint32_t)0xffffffL)
199
#define Frac_mask1 ((uint32_t)0xffffffL)
200
#define Bletch 4
201
#define Ten_pmax 22
202
#define Bndry_mask  ((uint32_t)0xefffffL)
203
#define Bndry_mask1 ((uint32_t)0xffffffL)
204
#define LSB 1
205
#define Sign_bit ((uint32_t)0x80000000L)
206
#define Log2P 4
207
#define Tiny0 ((uint32_t)0x100000L)
208
#define Tiny1 0
209
#define Quick_max 14
210
#define Int_max 15
211
#else /* VAX */
212
#define Exp_shift  23
213
#define Exp_shift1 7
214
#define Exp_msk1    0x80
215
#define Exp_msk11   ((uint32_t)0x800000L)
216
#define Exp_mask  ((uint32_t)0x7f80L)
217
#define P 56
218
#define Bias 129
219
#define Exp_1  ((uint32_t)0x40800000L)
220
#define Exp_11 ((uint32_t)0x4080L)
221
#define Ebits 8
222
#define Frac_mask  ((uint32_t)0x7fffffL)
223
#define Frac_mask1 ((uint32_t)0xffff007fL)
224
#define Ten_pmax 24
225
#define Bletch 2
226
#define Bndry_mask  ((uint32_t)0xffff007fL)
227
#define Bndry_mask1 ((uint32_t)0xffff007fL)
228
#define LSB ((uint32_t)0x10000L)
229
#define Sign_bit ((uint32_t)0x8000L)
230
#define Log2P 1
231
#define Tiny0 0x80
232
#define Tiny1 0
233
#define Quick_max 15
234
#define Int_max 15
235
#endif
236
#endif
237
 
238
#ifndef IEEE_Arith
239
#define ROUND_BIASED
240
#endif
241
 
242
#ifdef RND_PRODQUOT
243
#define rounded_product(a,b) a = rnd_prod(a, b)
244
#define rounded_quotient(a,b) a = rnd_quot(a, b)
245
#ifdef KR_headers
246
extern double rnd_prod(), rnd_quot();
247
#else
248
extern double rnd_prod(double, double), rnd_quot(double, double);
249
#endif
250
#else
251
#define rounded_product(a,b) a *= b
252
#define rounded_quotient(a,b) a /= b
253
#endif
254
 
255
#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
256
#define Big1 ((uint32_t)0xffffffffL)
257
 
258
#ifndef Just_16
259
/* When Pack_32 is not defined, we store 16 bits per 32-bit long.
260
 * This makes some inner loops simpler and sometimes saves work
261
 * during multiplications, but it often seems to make things slightly
262
 * slower.  Hence the default is now to store 32 bits per long.
263
 */
264
 
265
#ifndef Pack_32
266
#if SIZEOF_VOID_P != 8
267
#define Pack_32
268
#endif
269
#endif
270
#endif
271
 
272
 
273
#define MAX_BIGNUMS 16
274
#ifdef Pack_32
275
#define MAX_BIGNUM_WDS 32
276
#else
277
  /* Note that this is a workaround for */
278
#define MAX_BIGNUM_WDS 128
279
#endif
280
 
281
struct _Jv_Bigint
282
{
283
  struct _Jv_Bigint *_next;
284
  int _k, _maxwds, _sign, _wds;
285
  unsigned long _x[1];
286
};
287
 
288
 
289
#define _PTR            void *
290
#define _AND            ,
291
#define _NOARGS         void
292
#define _CONST          const
293
#define _VOLATILE       volatile
294
#define _SIGNED         signed
295
#define _DOTS           , ...
296
#define _VOID void
297
#ifndef _EXFUN
298
#define _EXFUN(name, proto)             name proto
299
#endif  /* !EXFUN */
300
#define _DEFUN(name, arglist, args)     name(args)
301
#define _DEFUN_VOID(name)               name(_NOARGS)
302
#define _CAST_VOID (void)
303
 
304
 
305
struct _Jv_reent
306
{
307
  /* local copy of errno */
308
  int _errno;
309
 
310
  /* used by mprec routines */
311
  struct _Jv_Bigint *_result;
312
  int _result_k;
313
  struct _Jv_Bigint *_p5s;
314
 
315
  struct _Jv_Bigint **_freelist;
316
  int _max_k;
317
};
318
 
319
 
320
typedef struct _Jv_Bigint _Jv_Bigint;
321
 
322
#define Balloc  _Jv_Balloc
323
#define Bfree   _Jv_Bfree
324
#define multadd _Jv_multadd
325
#define s2b     _Jv_s2b
326
#define lo0bits _Jv_lo0bits
327
#define hi0bits _Jv_hi0bits
328
#define i2b     _Jv_i2b
329
#define mult    _Jv_mult
330
#define pow5mult        _Jv_pow5mult
331
#define lshift  _Jv_lshift
332
#define cmp     _Jv__mcmp
333
#define diff    _Jv__mdiff
334
#define ulp     _Jv_ulp
335
#define b2d     _Jv_b2d
336
#define d2b     _Jv_d2b
337
#define ratio   _Jv_ratio
338
 
339
#define tens _Jv__mprec_tens
340
#define bigtens _Jv__mprec_bigtens
341
#define tinytens _Jv__mprec_tinytens
342
 
343
#define _dtoa _Jv_dtoa
344
#define _dtoa_r _Jv_dtoa_r
345
#define _strtod_r _Jv_strtod_r
346
 
347
extern double _EXFUN(_strtod_r, (struct _Jv_reent *ptr, const char *s00, char **se));
348
extern char* _EXFUN(_dtoa_r, (struct _Jv_reent *ptr, double d,
349
                              int mode, int ndigits, int *decpt, int *sign,
350
                              char **rve, int float_type));
351
void _EXFUN(_dtoa, (double d, int mode, int ndigits, int *decpt, int *sign,
352
                    char **rve, char *buf, int float_type));
353
 
354
double          _EXFUN(ulp,(double x));
355
double          _EXFUN(b2d,(_Jv_Bigint *a , int *e));
356
_Jv_Bigint *    _EXFUN(Balloc,(struct _Jv_reent *p, int k));
357
void            _EXFUN(Bfree,(struct _Jv_reent *p, _Jv_Bigint *v));
358
_Jv_Bigint *    _EXFUN(multadd,(struct _Jv_reent *p, _Jv_Bigint *, int, int));
359
_Jv_Bigint *    _EXFUN(s2b,(struct _Jv_reent *, const char*, int, int, unsigned long));
360
_Jv_Bigint *    _EXFUN(i2b,(struct _Jv_reent *,int));
361
_Jv_Bigint *    _EXFUN(mult, (struct _Jv_reent *, _Jv_Bigint *, _Jv_Bigint *));
362
_Jv_Bigint *    _EXFUN(pow5mult, (struct _Jv_reent *, _Jv_Bigint *, int k));
363
int             _EXFUN(hi0bits,(unsigned long));
364
int             _EXFUN(lo0bits,(unsigned long *));
365
_Jv_Bigint *    _EXFUN(d2b,(struct _Jv_reent *p, double d, int *e, int *bits));
366
_Jv_Bigint *    _EXFUN(lshift,(struct _Jv_reent *p, _Jv_Bigint *b, int k));
367
_Jv_Bigint *    _EXFUN(diff,(struct _Jv_reent *p, _Jv_Bigint *a, _Jv_Bigint *b));
368
int             _EXFUN(cmp,(_Jv_Bigint *a, _Jv_Bigint *b));
369
 
370
double          _EXFUN(ratio,(_Jv_Bigint *a, _Jv_Bigint *b));
371
#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(long) + 2*sizeof(int))
372
 
373
#if defined(_DOUBLE_IS_32BITS) && defined(__v800)
374
#define n_bigtens 2
375
#else
376
#define n_bigtens 5
377
#endif
378
 
379
extern _CONST double tinytens[];
380
extern _CONST double bigtens[];
381
extern _CONST double tens[];
382
 
383
#ifdef __cplusplus
384
}
385
#endif
386
 
387
#endif /* __CLASSPATH_MPREC_H__ */

powered by: WebSVN 2.1.0

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