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