]>
Commit | Line | Data |
---|---|---|
f7eac6eb | 1 | /* Declarations for math functions. |
2f6d1f1b | 2 | Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc. |
ba1ffaa1 | 3 | This file is part of the GNU C Library. |
28f540f4 | 4 | |
ba1ffaa1 UD |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
28f540f4 | 9 | |
ba1ffaa1 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Library General Public License for more details. | |
28f540f4 | 14 | |
ba1ffaa1 UD |
15 | You should have received a copy of the GNU Library General Public |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
28f540f4 RM |
19 | |
20 | /* | |
ba1ffaa1 | 21 | * ISO C Standard: 4.5 MATHEMATICS <math.h> |
28f540f4 RM |
22 | */ |
23 | ||
24 | #ifndef _MATH_H | |
25 | ||
26 | #define _MATH_H 1 | |
27 | #include <features.h> | |
28 | ||
29 | __BEGIN_DECLS | |
30 | ||
f7eac6eb RM |
31 | /* Get machine-dependent HUGE_VAL value (returned on overflow). |
32 | On all IEEE754 machines, this is +Infinity. */ | |
28f540f4 RM |
33 | #include <huge_val.h> |
34 | ||
35 | /* Get machine-dependent NAN value (returned for some domain errors). */ | |
36 | #ifdef __USE_GNU | |
37 | #include <nan.h> | |
38 | #endif | |
39 | ||
40 | ||
f7eac6eb RM |
41 | /* The file <mathcalls.h> contains the prototypes for all the actual |
42 | math functions. These macros are used for those prototypes, so | |
43 | we can easily declare each function as both `name' and `__name', | |
44 | and can declare the float versions `namef' and `__namef'. */ | |
45 | ||
46 | #define __MATHCALL(function,suffix, args) \ | |
47 | __MATHDECL (_Mdouble_, function,suffix, args) | |
48 | #define __MATHDECL(type, function,suffix, args) \ | |
49 | __MATHDECL_1(type, function,suffix, args); \ | |
50 | __MATHDECL_1(type, __##function,suffix, args) | |
51 | #define __MATHDECL_1(type, function,suffix, args) \ | |
52 | extern type __MATH_PRECNAME(function,suffix) args | |
53 | ||
54 | #define _Mdouble_ double | |
55 | #define __MATH_PRECNAME(name,r) name##r | |
56 | #include <mathcalls.h> | |
57 | #undef _Mdouble_ | |
58 | #undef __MATH_PRECNAME | |
59 | ||
60 | #ifdef __USE_MISC | |
76060ec0 | 61 | |
999493cb RM |
62 | |
63 | /* Include the file of declarations again, this time using `float' | |
f7eac6eb RM |
64 | instead of `double' and appending f to each function name. */ |
65 | ||
999493cb RM |
66 | #ifndef _Mfloat_ |
67 | #define _Mfloat_ float | |
68 | #endif | |
69 | #define _Mdouble_ _Mfloat_ | |
f7eac6eb RM |
70 | #define __MATH_PRECNAME(name,r) name##f##r |
71 | #include <mathcalls.h> | |
72 | #undef _Mdouble_ | |
73 | #undef __MATH_PRECNAME | |
76060ec0 | 74 | |
999493cb | 75 | /* Include the file of declarations again, this time using `long double' |
76060ec0 RM |
76 | instead of `double' and appending l to each function name. */ |
77 | ||
999493cb RM |
78 | #ifndef _Mlong_double_ |
79 | #define _Mlong_double_ long double | |
80 | #endif | |
81 | #define _Mdouble_ _Mlong_double_ | |
76060ec0 RM |
82 | #define __MATH_PRECNAME(name,r) name##l##r |
83 | #include <mathcalls.h> | |
84 | #undef _Mdouble_ | |
85 | #undef __MATH_PRECNAME | |
86 | ||
87 | #endif /* Use misc. */ | |
28f540f4 | 88 | |
28f540f4 RM |
89 | |
90 | #ifdef __USE_MISC | |
f7eac6eb | 91 | /* Support for various different standard error handling behaviors. */ |
28f540f4 | 92 | |
f7eac6eb | 93 | typedef enum { _IEEE_ = -1, _SVID_, _XOPEN_, _POSIX_ } _LIB_VERSION_TYPE; |
28f540f4 | 94 | |
f7eac6eb RM |
95 | /* This variable can be changed at run-time to any of the values above to |
96 | affect floating point error handling behavior (it may also be necessary | |
97 | to change the hardware FPU exception settings). */ | |
98 | extern _LIB_VERSION_TYPE _LIB_VERSION; | |
28f540f4 RM |
99 | #endif |
100 | ||
101 | ||
2f6d1f1b | 102 | #if defined __USE_SVID && !defined __cplusplus |
f7eac6eb | 103 | /* In SVID error handling, `matherr' is called with this description |
2f6d1f1b UD |
104 | of the exceptional condition. |
105 | ||
106 | We have a problem when using C++ since `exception' is reserved in | |
107 | C++. */ | |
f7eac6eb RM |
108 | struct exception |
109 | { | |
110 | int type; | |
111 | char *name; | |
112 | double arg1; | |
113 | double arg2; | |
114 | double retval; | |
115 | }; | |
28f540f4 | 116 | |
23396375 | 117 | extern int __matherr __P ((struct exception *)); |
f7eac6eb | 118 | extern int matherr __P ((struct exception *)); |
28f540f4 | 119 | |
f7eac6eb | 120 | #define X_TLOSS 1.41484755040568800000e+16 |
28f540f4 | 121 | |
f7eac6eb RM |
122 | /* Types of exceptions in the `type' field. */ |
123 | #define DOMAIN 1 | |
124 | #define SING 2 | |
125 | #define OVERFLOW 3 | |
126 | #define UNDERFLOW 4 | |
127 | #define TLOSS 5 | |
128 | #define PLOSS 6 | |
28f540f4 | 129 | |
f7eac6eb RM |
130 | /* SVID mode specifies returning this large value instead of infinity. */ |
131 | #define HUGE FLT_MAX | |
132 | #include <float.h> /* Defines FLT_MAX. */ | |
28f540f4 | 133 | |
2f6d1f1b | 134 | #endif /* SVID && !C++ */ |
28f540f4 | 135 | |
28f540f4 | 136 | |
28f540f4 | 137 | #ifdef __USE_BSD |
710f7bab | 138 | |
28f540f4 | 139 | /* Some useful constants. */ |
710f7bab RM |
140 | #define M_E _Mldbl(2.7182818284590452354) /* e */ |
141 | #define M_LOG2E _Mldbl(1.4426950408889634074) /* log 2e */ | |
142 | #define M_LOG10E _Mldbl(0.43429448190325182765) /* log 10e */ | |
143 | #define M_LN2 _Mldbl(0.69314718055994530942) /* log e2 */ | |
144 | #define M_LN10 _Mldbl(2.30258509299404568402) /* log e10 */ | |
145 | #define M_PI _Mldbl(3.14159265358979323846) /* pi */ | |
146 | #define M_PI_2 _Mldbl(1.57079632679489661923) /* pi/2 */ | |
147 | #define M_PI_4 _Mldbl(0.78539816339744830962) /* pi/4 */ | |
148 | #define M_1_PI _Mldbl(0.31830988618379067154) /* 1/pi */ | |
149 | #define M_2_PI _Mldbl(0.63661977236758134308) /* 2/pi */ | |
150 | #define M_2_SQRTPI _Mldbl(1.12837916709551257390) /* 2/sqrt(pi) */ | |
151 | #define M_SQRT2 _Mldbl(1.41421356237309504880) /* sqrt(2) */ | |
152 | #define M_SQRT1_2 _Mldbl(0.70710678118654752440) /* 1/sqrt(2) */ | |
153 | ||
154 | /* Our constants might specify more precision than `double' can represent. | |
155 | Use `long double' constants in standard and GNU C, where they are | |
156 | supported and the cast to `double'. */ | |
157 | #if __STDC__ - 0 || __GNUC__ - 0 | |
158 | #define _Mldbl(x) x##L | |
159 | #else /* Traditional C. */ | |
160 | #define _Mldbl(x) x | |
161 | #endif /* Standard or GNU C. */ | |
162 | ||
28f540f4 RM |
163 | #endif |
164 | ||
165 | ||
4d585333 RM |
166 | /* Get machine-dependent inline versions (if there are any). */ |
167 | #if defined (__NO_MATH_INLINES) || defined (__OPTIMIZE__) | |
168 | #include <__math.h> | |
169 | #endif | |
170 | ||
171 | ||
172 | __END_DECLS | |
173 | ||
174 | ||
28f540f4 | 175 | #endif /* math.h */ |