]>
Commit | Line | Data |
---|---|---|
f7eac6eb RM |
1 | /* Declarations for math functions. |
2 | Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc. | |
28f540f4 RM |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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 | |
17 | not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave, | |
18 | Cambridge, MA 02139, USA. */ | |
19 | ||
20 | /* | |
21 | * ANSI Standard: 4.5 MATHEMATICS <math.h> | |
22 | */ | |
23 | ||
24 | #ifndef _MATH_H | |
25 | ||
26 | #define _MATH_H 1 | |
27 | #include <features.h> | |
28 | ||
29 | __BEGIN_DECLS | |
30 | ||
31 | #define __need_Emath | |
32 | #include <errno.h> | |
33 | ||
f7eac6eb RM |
34 | /* Get machine-dependent HUGE_VAL value (returned on overflow). |
35 | On all IEEE754 machines, this is +Infinity. */ | |
28f540f4 RM |
36 | #include <huge_val.h> |
37 | ||
38 | /* Get machine-dependent NAN value (returned for some domain errors). */ | |
39 | #ifdef __USE_GNU | |
40 | #include <nan.h> | |
41 | #endif | |
42 | ||
43 | ||
f7eac6eb RM |
44 | /* The file <mathcalls.h> contains the prototypes for all the actual |
45 | math functions. These macros are used for those prototypes, so | |
46 | we can easily declare each function as both `name' and `__name', | |
47 | and can declare the float versions `namef' and `__namef'. */ | |
48 | ||
49 | #define __MATHCALL(function,suffix, args) \ | |
50 | __MATHDECL (_Mdouble_, function,suffix, args) | |
51 | #define __MATHDECL(type, function,suffix, args) \ | |
52 | __MATHDECL_1(type, function,suffix, args); \ | |
53 | __MATHDECL_1(type, __##function,suffix, args) | |
54 | #define __MATHDECL_1(type, function,suffix, args) \ | |
55 | extern type __MATH_PRECNAME(function,suffix) args | |
56 | ||
57 | #define _Mdouble_ double | |
58 | #define __MATH_PRECNAME(name,r) name##r | |
59 | #include <mathcalls.h> | |
60 | #undef _Mdouble_ | |
61 | #undef __MATH_PRECNAME | |
62 | ||
63 | #ifdef __USE_MISC | |
64 | /* Include the file of declarations again, this type using `float' | |
65 | instead of `double' and appending f to each function name. */ | |
66 | ||
67 | #define _Mdouble_ float | |
68 | #define __MATH_PRECNAME(name,r) name##f##r | |
69 | #include <mathcalls.h> | |
70 | #undef _Mdouble_ | |
71 | #undef __MATH_PRECNAME | |
28f540f4 RM |
72 | #endif |
73 | ||
28f540f4 RM |
74 | |
75 | #ifdef __USE_MISC | |
f7eac6eb | 76 | /* Support for various different standard error handling behaviors. */ |
28f540f4 | 77 | |
f7eac6eb | 78 | typedef enum { _IEEE_ = -1, _SVID_, _XOPEN_, _POSIX_ } _LIB_VERSION_TYPE; |
28f540f4 | 79 | |
f7eac6eb RM |
80 | /* This variable can be changed at run-time to any of the values above to |
81 | affect floating point error handling behavior (it may also be necessary | |
82 | to change the hardware FPU exception settings). */ | |
83 | extern _LIB_VERSION_TYPE _LIB_VERSION; | |
28f540f4 RM |
84 | #endif |
85 | ||
86 | ||
f7eac6eb RM |
87 | #ifdef __USE_SVID |
88 | /* In SVID error handling, `matherr' is called with this description | |
89 | of the exceptional condition. */ | |
90 | struct exception | |
91 | { | |
92 | int type; | |
93 | char *name; | |
94 | double arg1; | |
95 | double arg2; | |
96 | double retval; | |
97 | }; | |
28f540f4 | 98 | |
f7eac6eb | 99 | extern int matherr __P ((struct exception *)); |
28f540f4 | 100 | |
f7eac6eb | 101 | #define X_TLOSS 1.41484755040568800000e+16 |
28f540f4 | 102 | |
f7eac6eb RM |
103 | /* Types of exceptions in the `type' field. */ |
104 | #define DOMAIN 1 | |
105 | #define SING 2 | |
106 | #define OVERFLOW 3 | |
107 | #define UNDERFLOW 4 | |
108 | #define TLOSS 5 | |
109 | #define PLOSS 6 | |
28f540f4 | 110 | |
f7eac6eb RM |
111 | /* SVID mode specifies returning this large value instead of infinity. */ |
112 | #define HUGE FLT_MAX | |
113 | #include <float.h> /* Defines FLT_MAX. */ | |
28f540f4 | 114 | |
28f540f4 RM |
115 | #endif |
116 | ||
28f540f4 RM |
117 | |
118 | /* Get machine-dependent inline versions (if there are any). */ | |
119 | #include <__math.h> | |
120 | ||
f7eac6eb | 121 | |
28f540f4 RM |
122 | __END_DECLS |
123 | ||
124 | ||
125 | #ifdef __USE_BSD | |
126 | /* Some useful constants. */ | |
127 | #define M_E 2.7182818284590452354 /* e */ | |
128 | #define M_LOG2E 1.4426950408889634074 /* log 2e */ | |
129 | #define M_LOG10E 0.43429448190325182765 /* log 10e */ | |
130 | #define M_LN2 0.69314718055994530942 /* log e2 */ | |
131 | #define M_LN10 2.30258509299404568402 /* log e10 */ | |
132 | #define M_PI 3.14159265358979323846 /* pi */ | |
133 | #define M_PI_2 1.57079632679489661923 /* pi/2 */ | |
134 | #define M_PI_4 0.78539816339744830962 /* pi/4 */ | |
135 | #define M_1_PI 0.31830988618379067154 /* 1/pi */ | |
136 | #define M_2_PI 0.63661977236758134308 /* 2/pi */ | |
137 | #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ | |
138 | #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ | |
139 | #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ | |
140 | #endif | |
141 | ||
142 | ||
143 | #endif /* math.h */ |