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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [include/] [math.h] - Blame information for rev 171

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

Line No. Rev Author Line
1 148 jeremybenn
#ifndef  _MATH_H_
2
 
3
#define  _MATH_H_
4
 
5
#include <sys/reent.h>
6
#include <machine/ieeefp.h>
7
#include "_ansi.h"
8
 
9
_BEGIN_STD_C
10
 
11
union __dmath
12
{
13
  __ULong i[2];
14
  double d;
15
};
16
 
17
union __fmath
18
{
19
  __ULong i[1];
20
  float f;
21
};
22
 
23
union __ldmath
24
{
25
  __ULong i[4];
26
  _LONG_DOUBLE ld;
27
};
28
 
29
/* Natural log of 2 */
30
#define _M_LOG2_E        0.693147180559945309417
31
 
32
#if defined(__GNUC__) && \
33
  ( (__GNUC__ >= 4) || \
34
    ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
35
 
36
 /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values.  */
37
 
38
# ifndef HUGE_VAL
39
#  define HUGE_VAL (__builtin_huge_val())
40
# endif
41
 
42
# ifndef HUGE_VALF
43
#  define HUGE_VALF (__builtin_huge_valf())
44
# endif
45
 
46
# ifndef HUGE_VALL
47
#  define HUGE_VALL (__builtin_huge_vall())
48
# endif
49
 
50
# ifndef INFINITY
51
#  define INFINITY (__builtin_inff())
52
# endif
53
 
54
# ifndef NAN
55
#  define NAN (__builtin_nanf(""))
56
# endif
57
 
58
#else /* !gcc >= 3.3  */
59
 
60
 /* No builtins.  Use floating-point unions instead.  Declare as an array
61
    without bounds so no matter what small data support a port and/or
62
    library has, the reference will be via the general method for accessing
63
    globals. */
64
 
65
 #ifndef HUGE_VAL
66
  extern __IMPORT const union __dmath __infinity[];
67
  #define HUGE_VAL (__infinity[0].d)
68
 #endif
69
 
70
 #ifndef HUGE_VALF
71
  extern __IMPORT const union __fmath __infinityf[];
72
  #define HUGE_VALF (__infinityf[0].f)
73
 #endif
74
 
75
 #ifndef HUGE_VALL
76
  extern __IMPORT const union __ldmath __infinityld[];
77
  #define HUGE_VALL (__infinityld[0].ld)
78
 #endif
79
 
80
#endif /* !gcc >= 3.3  */
81
 
82
/* Reentrant ANSI C functions.  */
83
 
84
#ifndef __math_68881
85
extern double atan _PARAMS((double));
86
extern double cos _PARAMS((double));
87
extern double sin _PARAMS((double));
88
extern double tan _PARAMS((double));
89
extern double tanh _PARAMS((double));
90
extern double frexp _PARAMS((double, int *));
91
extern double modf _PARAMS((double, double *));
92
extern double ceil _PARAMS((double));
93
extern double fabs _PARAMS((double));
94
extern double floor _PARAMS((double));
95
#endif /* ! defined (__math_68881) */
96
 
97
/* Non reentrant ANSI C functions.  */
98
 
99
#ifndef _REENT_ONLY
100
#ifndef __math_6881
101
extern double acos _PARAMS((double));
102
extern double asin _PARAMS((double));
103
extern double atan2 _PARAMS((double, double));
104
extern double cosh _PARAMS((double));
105
extern double sinh _PARAMS((double));
106
extern double exp _PARAMS((double));
107
extern double ldexp _PARAMS((double, int));
108
extern double log _PARAMS((double));
109
extern double log10 _PARAMS((double));
110
extern double pow _PARAMS((double, double));
111
extern double sqrt _PARAMS((double));
112
extern double fmod _PARAMS((double, double));
113
#endif /* ! defined (__math_68881) */
114
#endif /* ! defined (_REENT_ONLY) */
115
 
116
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
117
 
118
/* ISO C99 types and macros. */
119
 
120
#ifndef FLT_EVAL_METHOD
121
#define FLT_EVAL_METHOD 0
122
typedef float float_t;
123
typedef double double_t;
124
#endif /* FLT_EVAL_METHOD */
125
 
126
#define FP_NAN         0
127
#define FP_INFINITE    1
128
#define FP_ZERO        2
129
#define FP_SUBNORMAL   3
130
#define FP_NORMAL      4
131
 
132
#ifndef FP_ILOGB0
133
# define FP_ILOGB0 (-INT_MAX)
134
#endif
135
#ifndef FP_ILOGBNAN
136
# define FP_ILOGBNAN INT_MAX
137
#endif
138
 
139
#ifndef MATH_ERRNO
140
# define MATH_ERRNO 1
141
#endif
142
#ifndef MATH_ERREXCEPT
143
# define MATH_ERREXCEPT 2
144
#endif
145
#ifndef math_errhandling
146
# define math_errhandling MATH_ERRNO
147
#endif
148
 
149
extern int __isinff (float x);
150
extern int __isinfd (double x);
151
extern int __isnanf (float x);
152
extern int __isnand (double x);
153
extern int __fpclassifyf (float x);
154
extern int __fpclassifyd (double x);
155
extern int __signbitf (float x);
156
extern int __signbitd (double x);
157
 
158
#define fpclassify(x) \
159
          (__extension__ ({__typeof__(x) __x = (x); \
160
                           (sizeof (__x) == sizeof (float))  ? __fpclassifyf(__x) : __fpclassifyd(__x);}))
161
 
162
#ifndef isfinite
163
#define isfinite(y) \
164
          (__extension__ ({__typeof__(y) __y = (y); \
165
                           fpclassify(__y) != FP_INFINITE && fpclassify(__y) != FP_NAN;}))
166
#endif
167
 
168
/* Note: isinf and isnan were once functions in newlib that took double
169
 *       arguments.  C99 specifies that these names are reserved for macros
170
 *       supporting multiple floating point types.  Thus, they are
171
 *       now defined as macros.  Implementations of the old functions
172
 *       taking double arguments still exist for compatibility purposes.  */
173
#ifndef isinf
174
#define isinf(x) \
175
          (__extension__ ({__typeof__(x) __x = (x); \
176
                           (sizeof (__x) == sizeof (float))  ? __isinff(__x) : __isinfd(__x);}))
177
#endif
178
 
179
#ifndef isnan
180
#define isnan(x) \
181
          (__extension__ ({__typeof__(x) __x = (x); \
182
                           (sizeof (__x) == sizeof (float))  ? __isnanf(__x) : __isnand(__x);}))
183
#endif
184
 
185
#define isnormal(y) (fpclassify(y) == FP_NORMAL)
186
#define signbit(x) \
187
          (__extension__ ({__typeof__(x) __x = (x); \
188
                           (sizeof(__x) == sizeof(float)) ? __signbitf(__x) : __signbitd(__x);}))
189
 
190
#define isgreater(x,y) \
191
          (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
192
                           !isunordered(__x,__y) && (__x > __y);}))
193
#define isgreaterequal(x,y) \
194
          (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
195
                           !isunordered(__x,__y) && (__x >= __y);}))
196
#define isless(x,y) \
197
          (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
198
                           !isunordered(__x,__y) && (__x < __y);}))
199
#define islessequal(x,y) \
200
          (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
201
                           !isunordered(__x,__y) && (__x <= __y);}))
202
#define islessgreater(x,y) \
203
          (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
204
                           !isunordered(__x,__y) && (__x < __y || __x > __y);}))
205
 
206
#define isunordered(a,b) \
207
          (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
208
                           fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
209
 
210
/* Non ANSI double precision functions.  */
211
 
212
extern double infinity _PARAMS((void));
213
extern double nan _PARAMS((const char *));
214
extern int finite _PARAMS((double));
215
extern double copysign _PARAMS((double, double));
216
extern int ilogb _PARAMS((double));
217
 
218
extern double asinh _PARAMS((double));
219
extern double cbrt _PARAMS((double));
220
extern double nextafter _PARAMS((double, double));
221
extern double rint _PARAMS((double));
222
extern double scalbn _PARAMS((double, int));
223
 
224
extern double exp2 _PARAMS((double));
225
extern double scalbln _PARAMS((double, long int));
226
extern double tgamma _PARAMS((double));
227
extern double nearbyint _PARAMS((double));
228
extern long int lrint _PARAMS((double));
229
extern _LONG_LONG_TYPE int llrint _PARAMS((double));
230
extern double round _PARAMS((double));
231
extern long int lround _PARAMS((double));
232
extern double trunc _PARAMS((double));
233
extern double remquo _PARAMS((double, double, int *));
234
extern double copysign _PARAMS((double, double));
235
extern double fdim _PARAMS((double, double));
236
extern double fmax _PARAMS((double, double));
237
extern double fmin _PARAMS((double, double));
238
extern double fma _PARAMS((double, double, double));
239
 
240
#ifndef __math_68881
241
extern double log1p _PARAMS((double));
242
extern double expm1 _PARAMS((double));
243
#endif /* ! defined (__math_68881) */
244
 
245
#ifndef _REENT_ONLY
246
extern double acosh _PARAMS((double));
247
extern double atanh _PARAMS((double));
248
extern double remainder _PARAMS((double, double));
249
extern double gamma _PARAMS((double));
250
extern double lgamma _PARAMS((double));
251
extern double erf _PARAMS((double));
252
extern double erfc _PARAMS((double));
253
#define log2(x) (log (x) / _M_LOG2_E)
254
 
255
#ifndef __math_68881
256
extern double hypot _PARAMS((double, double));
257
#endif
258
 
259
#endif /* ! defined (_REENT_ONLY) */
260
 
261
/* Single precision versions of ANSI functions.  */
262
 
263
extern float atanf _PARAMS((float));
264
extern float cosf _PARAMS((float));
265
extern float sinf _PARAMS((float));
266
extern float tanf _PARAMS((float));
267
extern float tanhf _PARAMS((float));
268
extern float frexpf _PARAMS((float, int *));
269
extern float modff _PARAMS((float, float *));
270
extern float ceilf _PARAMS((float));
271
extern float fabsf _PARAMS((float));
272
extern float floorf _PARAMS((float));
273
 
274
#ifndef _REENT_ONLY
275
extern float acosf _PARAMS((float));
276
extern float asinf _PARAMS((float));
277
extern float atan2f _PARAMS((float, float));
278
extern float coshf _PARAMS((float));
279
extern float sinhf _PARAMS((float));
280
extern float expf _PARAMS((float));
281
extern float ldexpf _PARAMS((float, int));
282
extern float logf _PARAMS((float));
283
extern float log10f _PARAMS((float));
284
extern float powf _PARAMS((float, float));
285
extern float sqrtf _PARAMS((float));
286
extern float fmodf _PARAMS((float, float));
287
#endif /* ! defined (_REENT_ONLY) */
288
 
289
/* Other single precision functions.  */
290
 
291
extern float exp2f _PARAMS((float));
292
extern float scalblnf _PARAMS((float, long int));
293
extern float tgammaf _PARAMS((float));
294
extern float nearbyintf _PARAMS((float));
295
extern long int lrintf _PARAMS((float));
296
extern _LONG_LONG_TYPE llrintf _PARAMS((float));
297
extern float roundf _PARAMS((float));
298
extern long int lroundf _PARAMS((float));
299
extern float truncf _PARAMS((float));
300
extern float remquof _PARAMS((float, float, int *));
301
extern float copysignf _PARAMS((float, float));
302
extern float fdimf _PARAMS((float, float));
303
extern float fmaxf _PARAMS((float, float));
304
extern float fminf _PARAMS((float, float));
305
extern float fmaf _PARAMS((float, float, float));
306
 
307
extern float infinityf _PARAMS((void));
308
extern float nanf _PARAMS((const char *));
309
extern int isnanf _PARAMS((float));
310
extern int isinff _PARAMS((float));
311
extern int finitef _PARAMS((float));
312
extern float copysignf _PARAMS((float, float));
313
extern int ilogbf _PARAMS((float));
314
 
315
extern float asinhf _PARAMS((float));
316
extern float cbrtf _PARAMS((float));
317
extern float nextafterf _PARAMS((float, float));
318
extern float rintf _PARAMS((float));
319
extern float scalbnf _PARAMS((float, int));
320
extern float log1pf _PARAMS((float));
321
extern float expm1f _PARAMS((float));
322
 
323
#ifndef _REENT_ONLY
324
extern float acoshf _PARAMS((float));
325
extern float atanhf _PARAMS((float));
326
extern float remainderf _PARAMS((float, float));
327
extern float gammaf _PARAMS((float));
328
extern float lgammaf _PARAMS((float));
329
extern float erff _PARAMS((float));
330
extern float erfcf _PARAMS((float));
331
#define log2f(x) (logf (x) / (float) _M_LOG2_E)
332
extern float hypotf _PARAMS((float, float));
333
#endif /* ! defined (_REENT_ONLY) */
334
 
335
/* Other long double precision functions.  */
336
extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
337
extern long int lrintl _PARAMS((_LONG_DOUBLE));
338
extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE));
339
 
340
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */
341
 
342
#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
343
 
344
extern double cabs();
345
extern double drem _PARAMS((double, double));
346
extern void sincos _PARAMS((double, double *, double *));
347
extern double gamma_r _PARAMS((double, int *));
348
extern double lgamma_r _PARAMS((double, int *));
349
 
350
extern double y0 _PARAMS((double));
351
extern double y1 _PARAMS((double));
352
extern double yn _PARAMS((int, double));
353
extern double j0 _PARAMS((double));
354
extern double j1 _PARAMS((double));
355
extern double jn _PARAMS((int, double));
356
 
357
extern float cabsf();
358
extern float dremf _PARAMS((float, float));
359
extern void sincosf _PARAMS((float, float *, float *));
360
extern float gammaf_r _PARAMS((float, int *));
361
extern float lgammaf_r _PARAMS((float, int *));
362
 
363
extern float y0f _PARAMS((float));
364
extern float y1f _PARAMS((float));
365
extern float ynf _PARAMS((int, float));
366
extern float j0f _PARAMS((float));
367
extern float j1f _PARAMS((float));
368
extern float jnf _PARAMS((int, float));
369
 
370
/* GNU extensions */
371
# ifndef exp10
372
extern double exp10 _PARAMS((double));
373
# endif
374
# ifndef pow10
375
extern double pow10 _PARAMS((double));
376
# endif
377
# ifndef exp10f
378
extern float exp10f _PARAMS((float));
379
# endif
380
# ifndef pow10f
381
extern float pow10f _PARAMS((float));
382
# endif
383
 
384
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */
385
 
386
#ifndef __STRICT_ANSI__
387
 
388
/* The gamma functions use a global variable, signgam.  */
389
#ifndef _REENT_ONLY
390
#define signgam (*__signgam())
391
extern int *__signgam _PARAMS((void));
392
#endif /* ! defined (_REENT_ONLY) */
393
 
394
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
395
 
396
/* The exception structure passed to the matherr routine.  */
397
/* We have a problem when using C++ since `exception' is a reserved
398
   name in C++.  */
399
#ifdef __cplusplus
400
struct __exception
401
#else
402
struct exception
403
#endif
404
{
405
  int type;
406
  char *name;
407
  double arg1;
408
  double arg2;
409
  double retval;
410
  int err;
411
};
412
 
413
#ifdef __cplusplus
414
extern int matherr _PARAMS((struct __exception *e));
415
#else
416
extern int matherr _PARAMS((struct exception *e));
417
#endif
418
 
419
/* Values for the type field of struct exception.  */
420
 
421
#define DOMAIN 1
422
#define SING 2
423
#define OVERFLOW 3
424
#define UNDERFLOW 4
425
#define TLOSS 5
426
#define PLOSS 6
427
 
428
/* Useful constants.  */
429
 
430
#define MAXFLOAT        3.40282347e+38F
431
 
432
#define M_E             2.7182818284590452354
433
#define M_LOG2E         1.4426950408889634074
434
#define M_LOG10E        0.43429448190325182765
435
#define M_LN2           0.69314718055994530942
436
#define M_LN10          2.30258509299404568402
437
#define M_PI            3.14159265358979323846
438
#define M_TWOPI         (M_PI * 2.0)
439
#define M_PI_2          1.57079632679489661923
440
#define M_PI_4          0.78539816339744830962
441
#define M_3PI_4         2.3561944901923448370E0
442
#define M_SQRTPI        1.77245385090551602792981
443
#define M_1_PI          0.31830988618379067154
444
#define M_2_PI          0.63661977236758134308
445
#define M_2_SQRTPI      1.12837916709551257390
446
#define M_SQRT2         1.41421356237309504880
447
#define M_SQRT1_2       0.70710678118654752440
448
#define M_LN2LO         1.9082149292705877000E-10
449
#define M_LN2HI         6.9314718036912381649E-1
450
#define M_SQRT3 1.73205080756887719000
451
#define M_IVLN10        0.43429448190325182765 /* 1 / log(10) */
452
#define M_LOG2_E        _M_LOG2_E
453
#define M_INVLN2        1.4426950408889633870E0  /* 1 / log(2) */
454
 
455
/* Global control over fdlibm error handling.  */
456
 
457
enum __fdlibm_version
458
{
459
  __fdlibm_ieee = -1,
460
  __fdlibm_svid,
461
  __fdlibm_xopen,
462
  __fdlibm_posix
463
};
464
 
465
#define _LIB_VERSION_TYPE enum __fdlibm_version
466
#define _LIB_VERSION __fdlib_version
467
 
468
extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION;
469
 
470
#define _IEEE_  __fdlibm_ieee
471
#define _SVID_  __fdlibm_svid
472
#define _XOPEN_ __fdlibm_xopen
473
#define _POSIX_ __fdlibm_posix
474
 
475
#endif /* ! defined (__STRICT_ANSI__) */
476
 
477
_END_STD_C
478
 
479
#ifdef __FAST_MATH__
480
#include <machine/fastmath.h>
481
#endif
482
 
483
#endif /* _MATH_H_ */

powered by: WebSVN 2.1.0

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