1 |
207 |
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 |
|
|
/* __dmath, __fmath, and __ldmath are only here for backwards compatibility
|
12 |
|
|
* in case any code used them. They are no longer used by Newlib, itself,
|
13 |
|
|
* other than legacy. */
|
14 |
|
|
union __dmath
|
15 |
|
|
{
|
16 |
|
|
double d;
|
17 |
|
|
__ULong i[2];
|
18 |
|
|
};
|
19 |
|
|
|
20 |
|
|
union __fmath
|
21 |
|
|
{
|
22 |
|
|
float f;
|
23 |
|
|
__ULong i[1];
|
24 |
|
|
};
|
25 |
|
|
|
26 |
|
|
#if defined(_HAVE_LONG_DOUBLE)
|
27 |
|
|
union __ldmath
|
28 |
|
|
{
|
29 |
|
|
long double ld;
|
30 |
|
|
__ULong i[4];
|
31 |
|
|
};
|
32 |
|
|
#endif
|
33 |
|
|
|
34 |
|
|
/* Natural log of 2 */
|
35 |
|
|
#define _M_LOG2_E 0.693147180559945309417
|
36 |
|
|
|
37 |
|
|
#if defined(__GNUC__) && \
|
38 |
|
|
( (__GNUC__ >= 4) || \
|
39 |
|
|
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
|
40 |
|
|
|
41 |
|
|
/* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
|
42 |
|
|
|
43 |
|
|
# ifndef HUGE_VAL
|
44 |
|
|
# define HUGE_VAL (__builtin_huge_val())
|
45 |
|
|
# endif
|
46 |
|
|
|
47 |
|
|
# ifndef HUGE_VALF
|
48 |
|
|
# define HUGE_VALF (__builtin_huge_valf())
|
49 |
|
|
# endif
|
50 |
|
|
|
51 |
|
|
# ifndef HUGE_VALL
|
52 |
|
|
# define HUGE_VALL (__builtin_huge_vall())
|
53 |
|
|
# endif
|
54 |
|
|
|
55 |
|
|
# ifndef INFINITY
|
56 |
|
|
# define INFINITY (__builtin_inff())
|
57 |
|
|
# endif
|
58 |
|
|
|
59 |
|
|
# ifndef NAN
|
60 |
|
|
# define NAN (__builtin_nanf(""))
|
61 |
|
|
# endif
|
62 |
|
|
|
63 |
|
|
#else /* !gcc >= 3.3 */
|
64 |
|
|
|
65 |
|
|
/* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY
|
66 |
|
|
* and NAN macros are required to be constant expressions. Using a variable--
|
67 |
|
|
* even a static const--does not meet this requirement, as it cannot be
|
68 |
|
|
* evaluated at translation time.)
|
69 |
|
|
* The infinities are done using numbers that are far in excess of
|
70 |
|
|
* something that would be expected to be encountered in a floating-point
|
71 |
|
|
* implementation. (A more certain way uses values from float.h, but that is
|
72 |
|
|
* avoided because system includes are not supposed to include each other.)
|
73 |
|
|
* This method might produce warnings from some compilers. (It does in
|
74 |
|
|
* newer GCCs, but not for ones that would hit this #else.) If this happens,
|
75 |
|
|
* please report details to the Newlib mailing list. */
|
76 |
|
|
|
77 |
|
|
#ifndef HUGE_VAL
|
78 |
|
|
#define HUGE_VAL (1.0e999999999)
|
79 |
|
|
#endif
|
80 |
|
|
|
81 |
|
|
#ifndef HUGE_VALF
|
82 |
|
|
#define HUGE_VALF (1.0e999999999F)
|
83 |
|
|
#endif
|
84 |
|
|
|
85 |
|
|
#if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE)
|
86 |
|
|
#define HUGE_VALL (1.0e999999999L)
|
87 |
|
|
#endif
|
88 |
|
|
|
89 |
|
|
#if !defined(INFINITY)
|
90 |
|
|
#define INFINITY (HUGE_VALF)
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
#if !defined(NAN)
|
94 |
|
|
#if defined(__GNUC__) && defined(__cplusplus)
|
95 |
|
|
/* Exception: older g++ versions warn about the divide by 0 used in the
|
96 |
|
|
* normal case (even though older gccs do not). This trick suppresses the
|
97 |
|
|
* warning, but causes errors for plain gcc, so is only used in the one
|
98 |
|
|
* special case. */
|
99 |
|
|
static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000};
|
100 |
|
|
#define NAN (__Nanf.__d)
|
101 |
|
|
#else
|
102 |
|
|
#define NAN (0.0F/0.0F)
|
103 |
|
|
#endif
|
104 |
|
|
#endif
|
105 |
|
|
|
106 |
|
|
#endif /* !gcc >= 3.3 */
|
107 |
|
|
|
108 |
|
|
/* Reentrant ANSI C functions. */
|
109 |
|
|
|
110 |
|
|
#ifndef __math_68881
|
111 |
|
|
extern double atan _PARAMS((double));
|
112 |
|
|
extern double cos _PARAMS((double));
|
113 |
|
|
extern double sin _PARAMS((double));
|
114 |
|
|
extern double tan _PARAMS((double));
|
115 |
|
|
extern double tanh _PARAMS((double));
|
116 |
|
|
extern double frexp _PARAMS((double, int *));
|
117 |
|
|
extern double modf _PARAMS((double, double *));
|
118 |
|
|
extern double ceil _PARAMS((double));
|
119 |
|
|
extern double fabs _PARAMS((double));
|
120 |
|
|
extern double floor _PARAMS((double));
|
121 |
|
|
#endif /* ! defined (__math_68881) */
|
122 |
|
|
|
123 |
|
|
/* Non reentrant ANSI C functions. */
|
124 |
|
|
|
125 |
|
|
#ifndef _REENT_ONLY
|
126 |
|
|
#ifndef __math_68881
|
127 |
|
|
extern double acos _PARAMS((double));
|
128 |
|
|
extern double asin _PARAMS((double));
|
129 |
|
|
extern double atan2 _PARAMS((double, double));
|
130 |
|
|
extern double cosh _PARAMS((double));
|
131 |
|
|
extern double sinh _PARAMS((double));
|
132 |
|
|
extern double exp _PARAMS((double));
|
133 |
|
|
extern double ldexp _PARAMS((double, int));
|
134 |
|
|
extern double log _PARAMS((double));
|
135 |
|
|
extern double log10 _PARAMS((double));
|
136 |
|
|
extern double pow _PARAMS((double, double));
|
137 |
|
|
extern double sqrt _PARAMS((double));
|
138 |
|
|
extern double fmod _PARAMS((double, double));
|
139 |
|
|
#endif /* ! defined (__math_68881) */
|
140 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
141 |
|
|
|
142 |
|
|
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
|
143 |
|
|
|
144 |
|
|
/* ISO C99 types and macros. */
|
145 |
|
|
|
146 |
|
|
#ifndef FLT_EVAL_METHOD
|
147 |
|
|
#define FLT_EVAL_METHOD 0
|
148 |
|
|
typedef float float_t;
|
149 |
|
|
typedef double double_t;
|
150 |
|
|
#endif /* FLT_EVAL_METHOD */
|
151 |
|
|
|
152 |
|
|
#define FP_NAN 0
|
153 |
|
|
#define FP_INFINITE 1
|
154 |
|
|
#define FP_ZERO 2
|
155 |
|
|
#define FP_SUBNORMAL 3
|
156 |
|
|
#define FP_NORMAL 4
|
157 |
|
|
|
158 |
|
|
#ifndef FP_ILOGB0
|
159 |
|
|
# define FP_ILOGB0 (-INT_MAX)
|
160 |
|
|
#endif
|
161 |
|
|
#ifndef FP_ILOGBNAN
|
162 |
|
|
# define FP_ILOGBNAN INT_MAX
|
163 |
|
|
#endif
|
164 |
|
|
|
165 |
|
|
#ifndef MATH_ERRNO
|
166 |
|
|
# define MATH_ERRNO 1
|
167 |
|
|
#endif
|
168 |
|
|
#ifndef MATH_ERREXCEPT
|
169 |
|
|
# define MATH_ERREXCEPT 2
|
170 |
|
|
#endif
|
171 |
|
|
#ifndef math_errhandling
|
172 |
|
|
# define math_errhandling MATH_ERRNO
|
173 |
|
|
#endif
|
174 |
|
|
|
175 |
|
|
extern int __isinff (float x);
|
176 |
|
|
extern int __isinfd (double x);
|
177 |
|
|
extern int __isnanf (float x);
|
178 |
|
|
extern int __isnand (double x);
|
179 |
|
|
extern int __fpclassifyf (float x);
|
180 |
|
|
extern int __fpclassifyd (double x);
|
181 |
|
|
extern int __signbitf (float x);
|
182 |
|
|
extern int __signbitd (double x);
|
183 |
|
|
|
184 |
|
|
#define fpclassify(__x) \
|
185 |
|
|
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
|
186 |
|
|
__fpclassifyd(__x))
|
187 |
|
|
|
188 |
|
|
#ifndef isfinite
|
189 |
|
|
#define isfinite(__y) \
|
190 |
|
|
(__extension__ ({int __cy = fpclassify(__y); \
|
191 |
|
|
__cy != FP_INFINITE && __cy != FP_NAN;}))
|
192 |
|
|
#endif
|
193 |
|
|
|
194 |
|
|
/* Note: isinf and isnan were once functions in newlib that took double
|
195 |
|
|
* arguments. C99 specifies that these names are reserved for macros
|
196 |
|
|
* supporting multiple floating point types. Thus, they are
|
197 |
|
|
* now defined as macros. Implementations of the old functions
|
198 |
|
|
* taking double arguments still exist for compatibility purposes
|
199 |
|
|
* (prototypes for them are in <ieeefp.h>). */
|
200 |
|
|
#ifndef isinf
|
201 |
|
|
#define isinf(y) (fpclassify(y) == FP_INFINITE)
|
202 |
|
|
#endif
|
203 |
|
|
|
204 |
|
|
#ifndef isnan
|
205 |
|
|
#define isnan(y) (fpclassify(y) == FP_NAN)
|
206 |
|
|
#endif
|
207 |
|
|
|
208 |
|
|
#define isnormal(y) (fpclassify(y) == FP_NORMAL)
|
209 |
|
|
#define signbit(__x) \
|
210 |
|
|
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \
|
211 |
|
|
__signbitd(__x))
|
212 |
|
|
|
213 |
|
|
#define isgreater(x,y) \
|
214 |
|
|
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
|
215 |
|
|
!isunordered(__x,__y) && (__x > __y);}))
|
216 |
|
|
#define isgreaterequal(x,y) \
|
217 |
|
|
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
|
218 |
|
|
!isunordered(__x,__y) && (__x >= __y);}))
|
219 |
|
|
#define isless(x,y) \
|
220 |
|
|
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
|
221 |
|
|
!isunordered(__x,__y) && (__x < __y);}))
|
222 |
|
|
#define islessequal(x,y) \
|
223 |
|
|
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
|
224 |
|
|
!isunordered(__x,__y) && (__x <= __y);}))
|
225 |
|
|
#define islessgreater(x,y) \
|
226 |
|
|
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
|
227 |
|
|
!isunordered(__x,__y) && (__x < __y || __x > __y);}))
|
228 |
|
|
|
229 |
|
|
#define isunordered(a,b) \
|
230 |
|
|
(__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
|
231 |
|
|
fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
|
232 |
|
|
|
233 |
|
|
/* Non ANSI double precision functions. */
|
234 |
|
|
|
235 |
|
|
extern double infinity _PARAMS((void));
|
236 |
|
|
extern double nan _PARAMS((const char *));
|
237 |
|
|
extern int finite _PARAMS((double));
|
238 |
|
|
extern double copysign _PARAMS((double, double));
|
239 |
|
|
extern double logb _PARAMS((double));
|
240 |
|
|
extern int ilogb _PARAMS((double));
|
241 |
|
|
|
242 |
|
|
extern double asinh _PARAMS((double));
|
243 |
|
|
extern double cbrt _PARAMS((double));
|
244 |
|
|
extern double nextafter _PARAMS((double, double));
|
245 |
|
|
extern double rint _PARAMS((double));
|
246 |
|
|
extern double scalbn _PARAMS((double, int));
|
247 |
|
|
|
248 |
|
|
extern double exp2 _PARAMS((double));
|
249 |
|
|
extern double scalbln _PARAMS((double, long int));
|
250 |
|
|
extern double tgamma _PARAMS((double));
|
251 |
|
|
extern double nearbyint _PARAMS((double));
|
252 |
|
|
extern long int lrint _PARAMS((double));
|
253 |
|
|
extern _LONG_LONG_TYPE int llrint _PARAMS((double));
|
254 |
|
|
extern double round _PARAMS((double));
|
255 |
|
|
extern long int lround _PARAMS((double));
|
256 |
|
|
extern long long int llround _PARAMS((double));
|
257 |
|
|
extern double trunc _PARAMS((double));
|
258 |
|
|
extern double remquo _PARAMS((double, double, int *));
|
259 |
|
|
extern double fdim _PARAMS((double, double));
|
260 |
|
|
extern double fmax _PARAMS((double, double));
|
261 |
|
|
extern double fmin _PARAMS((double, double));
|
262 |
|
|
extern double fma _PARAMS((double, double, double));
|
263 |
|
|
|
264 |
|
|
#ifndef __math_68881
|
265 |
|
|
extern double log1p _PARAMS((double));
|
266 |
|
|
extern double expm1 _PARAMS((double));
|
267 |
|
|
#endif /* ! defined (__math_68881) */
|
268 |
|
|
|
269 |
|
|
#ifndef _REENT_ONLY
|
270 |
|
|
extern double acosh _PARAMS((double));
|
271 |
|
|
extern double atanh _PARAMS((double));
|
272 |
|
|
extern double remainder _PARAMS((double, double));
|
273 |
|
|
extern double gamma _PARAMS((double));
|
274 |
|
|
extern double lgamma _PARAMS((double));
|
275 |
|
|
extern double erf _PARAMS((double));
|
276 |
|
|
extern double erfc _PARAMS((double));
|
277 |
|
|
extern double log2 _PARAMS((double));
|
278 |
|
|
#define log2(x) (log (x) / _M_LOG2_E)
|
279 |
|
|
|
280 |
|
|
#ifndef __math_68881
|
281 |
|
|
extern double hypot _PARAMS((double, double));
|
282 |
|
|
#endif
|
283 |
|
|
|
284 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
285 |
|
|
|
286 |
|
|
/* Single precision versions of ANSI functions. */
|
287 |
|
|
|
288 |
|
|
extern float atanf _PARAMS((float));
|
289 |
|
|
extern float cosf _PARAMS((float));
|
290 |
|
|
extern float sinf _PARAMS((float));
|
291 |
|
|
extern float tanf _PARAMS((float));
|
292 |
|
|
extern float tanhf _PARAMS((float));
|
293 |
|
|
extern float frexpf _PARAMS((float, int *));
|
294 |
|
|
extern float modff _PARAMS((float, float *));
|
295 |
|
|
extern float ceilf _PARAMS((float));
|
296 |
|
|
extern float fabsf _PARAMS((float));
|
297 |
|
|
extern float floorf _PARAMS((float));
|
298 |
|
|
|
299 |
|
|
#ifndef _REENT_ONLY
|
300 |
|
|
extern float acosf _PARAMS((float));
|
301 |
|
|
extern float asinf _PARAMS((float));
|
302 |
|
|
extern float atan2f _PARAMS((float, float));
|
303 |
|
|
extern float coshf _PARAMS((float));
|
304 |
|
|
extern float sinhf _PARAMS((float));
|
305 |
|
|
extern float expf _PARAMS((float));
|
306 |
|
|
extern float ldexpf _PARAMS((float, int));
|
307 |
|
|
extern float logf _PARAMS((float));
|
308 |
|
|
extern float log10f _PARAMS((float));
|
309 |
|
|
extern float powf _PARAMS((float, float));
|
310 |
|
|
extern float sqrtf _PARAMS((float));
|
311 |
|
|
extern float fmodf _PARAMS((float, float));
|
312 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
313 |
|
|
|
314 |
|
|
/* Other single precision functions. */
|
315 |
|
|
|
316 |
|
|
extern float exp2f _PARAMS((float));
|
317 |
|
|
extern float scalblnf _PARAMS((float, long int));
|
318 |
|
|
extern float tgammaf _PARAMS((float));
|
319 |
|
|
extern float nearbyintf _PARAMS((float));
|
320 |
|
|
extern long int lrintf _PARAMS((float));
|
321 |
|
|
extern _LONG_LONG_TYPE llrintf _PARAMS((float));
|
322 |
|
|
extern float roundf _PARAMS((float));
|
323 |
|
|
extern long int lroundf _PARAMS((float));
|
324 |
|
|
extern long long int llroundf _PARAMS((float));
|
325 |
|
|
extern float truncf _PARAMS((float));
|
326 |
|
|
extern float remquof _PARAMS((float, float, int *));
|
327 |
|
|
extern float fdimf _PARAMS((float, float));
|
328 |
|
|
extern float fmaxf _PARAMS((float, float));
|
329 |
|
|
extern float fminf _PARAMS((float, float));
|
330 |
|
|
extern float fmaf _PARAMS((float, float, float));
|
331 |
|
|
|
332 |
|
|
extern float infinityf _PARAMS((void));
|
333 |
|
|
extern float nanf _PARAMS((const char *));
|
334 |
|
|
extern int finitef _PARAMS((float));
|
335 |
|
|
extern float copysignf _PARAMS((float, float));
|
336 |
|
|
extern float logbf _PARAMS((float));
|
337 |
|
|
extern int ilogbf _PARAMS((float));
|
338 |
|
|
|
339 |
|
|
extern float asinhf _PARAMS((float));
|
340 |
|
|
extern float cbrtf _PARAMS((float));
|
341 |
|
|
extern float nextafterf _PARAMS((float, float));
|
342 |
|
|
extern float rintf _PARAMS((float));
|
343 |
|
|
extern float scalbnf _PARAMS((float, int));
|
344 |
|
|
extern float log1pf _PARAMS((float));
|
345 |
|
|
extern float expm1f _PARAMS((float));
|
346 |
|
|
|
347 |
|
|
#ifndef _REENT_ONLY
|
348 |
|
|
extern float acoshf _PARAMS((float));
|
349 |
|
|
extern float atanhf _PARAMS((float));
|
350 |
|
|
extern float remainderf _PARAMS((float, float));
|
351 |
|
|
extern float gammaf _PARAMS((float));
|
352 |
|
|
extern float lgammaf _PARAMS((float));
|
353 |
|
|
extern float erff _PARAMS((float));
|
354 |
|
|
extern float erfcf _PARAMS((float));
|
355 |
|
|
extern float log2f _PARAMS((float));
|
356 |
|
|
#define log2f(x) (logf (x) / (float) _M_LOG2_E)
|
357 |
|
|
extern float hypotf _PARAMS((float, float));
|
358 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
359 |
|
|
|
360 |
|
|
/* On platforms where long double equals double. */
|
361 |
|
|
#ifdef _LDBL_EQ_DBL
|
362 |
|
|
/* Reentrant ANSI C functions. */
|
363 |
|
|
#ifndef __math_68881
|
364 |
|
|
extern long double atanl _PARAMS((long double));
|
365 |
|
|
extern long double cosl _PARAMS((long double));
|
366 |
|
|
extern long double sinl _PARAMS((long double));
|
367 |
|
|
extern long double tanl _PARAMS((long double));
|
368 |
|
|
extern long double tanhl _PARAMS((long double));
|
369 |
|
|
extern long double frexpl _PARAMS((long double value, int *));
|
370 |
|
|
extern long double modfl _PARAMS((long double, long double *));
|
371 |
|
|
extern long double ceill _PARAMS((long double));
|
372 |
|
|
extern long double fabsl _PARAMS((long double));
|
373 |
|
|
extern long double floorl _PARAMS((long double));
|
374 |
|
|
extern long double log1pl _PARAMS((long double));
|
375 |
|
|
extern long double expm1l _PARAMS((long double));
|
376 |
|
|
#endif /* ! defined (__math_68881) */
|
377 |
|
|
/* Non reentrant ANSI C functions. */
|
378 |
|
|
#ifndef _REENT_ONLY
|
379 |
|
|
#ifndef __math_68881
|
380 |
|
|
extern long double acosl _PARAMS((long double));
|
381 |
|
|
extern long double asinl _PARAMS((long double));
|
382 |
|
|
extern long double atan2l _PARAMS((long double, long double));
|
383 |
|
|
extern long double coshl _PARAMS((long double));
|
384 |
|
|
extern long double sinhl _PARAMS((long double));
|
385 |
|
|
extern long double expl _PARAMS((long double));
|
386 |
|
|
extern long double ldexpl _PARAMS((long double, int));
|
387 |
|
|
extern long double logl _PARAMS((long double));
|
388 |
|
|
extern long double log10l _PARAMS((long double));
|
389 |
|
|
extern long double powl _PARAMS((long double, long double));
|
390 |
|
|
extern long double sqrtl _PARAMS((long double));
|
391 |
|
|
extern long double fmodl _PARAMS((long double, long double));
|
392 |
|
|
extern long double hypotl _PARAMS((long double, long double));
|
393 |
|
|
#endif /* ! defined (__math_68881) */
|
394 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
395 |
|
|
extern long double copysignl _PARAMS((long double, long double));
|
396 |
|
|
extern long double nanl _PARAMS((const char *));
|
397 |
|
|
extern int ilogbl _PARAMS((long double));
|
398 |
|
|
extern long double asinhl _PARAMS((long double));
|
399 |
|
|
extern long double cbrtl _PARAMS((long double));
|
400 |
|
|
extern long double nextafterl _PARAMS((long double, long double));
|
401 |
|
|
extern long double rintl _PARAMS((long double));
|
402 |
|
|
extern long double scalbnl _PARAMS((long double, int));
|
403 |
|
|
extern long double exp2l _PARAMS((long double));
|
404 |
|
|
extern long double scalblnl _PARAMS((long double, long));
|
405 |
|
|
extern long double tgammal _PARAMS((long double));
|
406 |
|
|
extern long double nearbyintl _PARAMS((long double));
|
407 |
|
|
extern long int lrintl _PARAMS((long double));
|
408 |
|
|
extern long long int llrintl _PARAMS((long double));
|
409 |
|
|
extern long double roundl _PARAMS((long double));
|
410 |
|
|
extern long lroundl _PARAMS((long double));
|
411 |
|
|
extern _LONG_LONG_TYPE int llroundl _PARAMS((long double));
|
412 |
|
|
extern long double truncl _PARAMS((long double));
|
413 |
|
|
extern long double remquol _PARAMS((long double, long double, int *));
|
414 |
|
|
extern long double fdiml _PARAMS((long double, long double));
|
415 |
|
|
extern long double fmaxl _PARAMS((long double, long double));
|
416 |
|
|
extern long double fminl _PARAMS((long double, long double));
|
417 |
|
|
extern long double fmal _PARAMS((long double, long double, long double));
|
418 |
|
|
#ifndef _REENT_ONLY
|
419 |
|
|
extern long double acoshl _PARAMS((long double));
|
420 |
|
|
extern long double atanhl _PARAMS((long double));
|
421 |
|
|
extern long double remainderl _PARAMS((long double, long double));
|
422 |
|
|
extern long double lgammal _PARAMS((long double));
|
423 |
|
|
extern long double erfl _PARAMS((long double));
|
424 |
|
|
extern long double erfcl _PARAMS((long double));
|
425 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
426 |
|
|
#else /* !_LDBL_EQ_DBL */
|
427 |
|
|
#ifdef __i386__
|
428 |
|
|
/* Other long double precision functions. */
|
429 |
|
|
extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
|
430 |
|
|
extern long int lrintl _PARAMS((_LONG_DOUBLE));
|
431 |
|
|
extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE));
|
432 |
|
|
#endif /* __i386__ */
|
433 |
|
|
#endif /* !_LDBL_EQ_DBL */
|
434 |
|
|
|
435 |
|
|
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */
|
436 |
|
|
|
437 |
|
|
#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
|
438 |
|
|
|
439 |
|
|
extern double cabs();
|
440 |
|
|
extern double drem _PARAMS((double, double));
|
441 |
|
|
extern void sincos _PARAMS((double, double *, double *));
|
442 |
|
|
extern double gamma_r _PARAMS((double, int *));
|
443 |
|
|
extern double lgamma_r _PARAMS((double, int *));
|
444 |
|
|
|
445 |
|
|
extern double y0 _PARAMS((double));
|
446 |
|
|
extern double y1 _PARAMS((double));
|
447 |
|
|
extern double yn _PARAMS((int, double));
|
448 |
|
|
extern double j0 _PARAMS((double));
|
449 |
|
|
extern double j1 _PARAMS((double));
|
450 |
|
|
extern double jn _PARAMS((int, double));
|
451 |
|
|
|
452 |
|
|
extern float cabsf();
|
453 |
|
|
extern float dremf _PARAMS((float, float));
|
454 |
|
|
extern void sincosf _PARAMS((float, float *, float *));
|
455 |
|
|
extern float gammaf_r _PARAMS((float, int *));
|
456 |
|
|
extern float lgammaf_r _PARAMS((float, int *));
|
457 |
|
|
|
458 |
|
|
extern float y0f _PARAMS((float));
|
459 |
|
|
extern float y1f _PARAMS((float));
|
460 |
|
|
extern float ynf _PARAMS((int, float));
|
461 |
|
|
extern float j0f _PARAMS((float));
|
462 |
|
|
extern float j1f _PARAMS((float));
|
463 |
|
|
extern float jnf _PARAMS((int, float));
|
464 |
|
|
|
465 |
|
|
/* GNU extensions */
|
466 |
|
|
# ifndef exp10
|
467 |
|
|
extern double exp10 _PARAMS((double));
|
468 |
|
|
# endif
|
469 |
|
|
# ifndef pow10
|
470 |
|
|
extern double pow10 _PARAMS((double));
|
471 |
|
|
# endif
|
472 |
|
|
# ifndef exp10f
|
473 |
|
|
extern float exp10f _PARAMS((float));
|
474 |
|
|
# endif
|
475 |
|
|
# ifndef pow10f
|
476 |
|
|
extern float pow10f _PARAMS((float));
|
477 |
|
|
# endif
|
478 |
|
|
|
479 |
|
|
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */
|
480 |
|
|
|
481 |
|
|
#ifndef __STRICT_ANSI__
|
482 |
|
|
|
483 |
|
|
/* The gamma functions use a global variable, signgam. */
|
484 |
|
|
#ifndef _REENT_ONLY
|
485 |
|
|
#define signgam (*__signgam())
|
486 |
|
|
extern int *__signgam _PARAMS((void));
|
487 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
488 |
|
|
|
489 |
|
|
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
|
490 |
|
|
|
491 |
|
|
/* The exception structure passed to the matherr routine. */
|
492 |
|
|
/* We have a problem when using C++ since `exception' is a reserved
|
493 |
|
|
name in C++. */
|
494 |
|
|
#ifdef __cplusplus
|
495 |
|
|
struct __exception
|
496 |
|
|
#else
|
497 |
|
|
struct exception
|
498 |
|
|
#endif
|
499 |
|
|
{
|
500 |
|
|
int type;
|
501 |
|
|
char *name;
|
502 |
|
|
double arg1;
|
503 |
|
|
double arg2;
|
504 |
|
|
double retval;
|
505 |
|
|
int err;
|
506 |
|
|
};
|
507 |
|
|
|
508 |
|
|
#ifdef __cplusplus
|
509 |
|
|
extern int matherr _PARAMS((struct __exception *e));
|
510 |
|
|
#else
|
511 |
|
|
extern int matherr _PARAMS((struct exception *e));
|
512 |
|
|
#endif
|
513 |
|
|
|
514 |
|
|
/* Values for the type field of struct exception. */
|
515 |
|
|
|
516 |
|
|
#define DOMAIN 1
|
517 |
|
|
#define SING 2
|
518 |
|
|
#define OVERFLOW 3
|
519 |
|
|
#define UNDERFLOW 4
|
520 |
|
|
#define TLOSS 5
|
521 |
|
|
#define PLOSS 6
|
522 |
|
|
|
523 |
|
|
/* Useful constants. */
|
524 |
|
|
|
525 |
|
|
#define MAXFLOAT 3.40282347e+38F
|
526 |
|
|
|
527 |
|
|
#define M_E 2.7182818284590452354
|
528 |
|
|
#define M_LOG2E 1.4426950408889634074
|
529 |
|
|
#define M_LOG10E 0.43429448190325182765
|
530 |
|
|
#define M_LN2 0.69314718055994530942
|
531 |
|
|
#define M_LN10 2.30258509299404568402
|
532 |
|
|
#define M_PI 3.14159265358979323846
|
533 |
|
|
#define M_TWOPI (M_PI * 2.0)
|
534 |
|
|
#define M_PI_2 1.57079632679489661923
|
535 |
|
|
#define M_PI_4 0.78539816339744830962
|
536 |
|
|
#define M_3PI_4 2.3561944901923448370E0
|
537 |
|
|
#define M_SQRTPI 1.77245385090551602792981
|
538 |
|
|
#define M_1_PI 0.31830988618379067154
|
539 |
|
|
#define M_2_PI 0.63661977236758134308
|
540 |
|
|
#define M_2_SQRTPI 1.12837916709551257390
|
541 |
|
|
#define M_SQRT2 1.41421356237309504880
|
542 |
|
|
#define M_SQRT1_2 0.70710678118654752440
|
543 |
|
|
#define M_LN2LO 1.9082149292705877000E-10
|
544 |
|
|
#define M_LN2HI 6.9314718036912381649E-1
|
545 |
|
|
#define M_SQRT3 1.73205080756887719000
|
546 |
|
|
#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
|
547 |
|
|
#define M_LOG2_E _M_LOG2_E
|
548 |
|
|
#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
|
549 |
|
|
|
550 |
|
|
/* Global control over fdlibm error handling. */
|
551 |
|
|
|
552 |
|
|
enum __fdlibm_version
|
553 |
|
|
{
|
554 |
|
|
__fdlibm_ieee = -1,
|
555 |
|
|
__fdlibm_svid,
|
556 |
|
|
__fdlibm_xopen,
|
557 |
|
|
__fdlibm_posix
|
558 |
|
|
};
|
559 |
|
|
|
560 |
|
|
#define _LIB_VERSION_TYPE enum __fdlibm_version
|
561 |
|
|
#define _LIB_VERSION __fdlib_version
|
562 |
|
|
|
563 |
|
|
extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION;
|
564 |
|
|
|
565 |
|
|
#define _IEEE_ __fdlibm_ieee
|
566 |
|
|
#define _SVID_ __fdlibm_svid
|
567 |
|
|
#define _XOPEN_ __fdlibm_xopen
|
568 |
|
|
#define _POSIX_ __fdlibm_posix
|
569 |
|
|
|
570 |
|
|
#endif /* ! defined (__STRICT_ANSI__) */
|
571 |
|
|
|
572 |
|
|
_END_STD_C
|
573 |
|
|
|
574 |
|
|
#ifdef __FAST_MATH__
|
575 |
|
|
#include <machine/fastmath.h>
|
576 |
|
|
#endif
|
577 |
|
|
|
578 |
|
|
#endif /* _MATH_H_ */
|