2009-04-07 Andrew Stubbs <ams@codesourcery.com>
[official-gcc.git] / libstdc++-v3 / src / math_stubs_long_double.cc
blobe46400e7e4b3b8216d78a77d3a09a3ddc76fec93
1 // Stub definitions for long double math.
3 // Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 #include <cmath>
32 // For targets which do not have support for long double versions,
33 // we use the following crude approximations. We keep saying that we'll do
34 // better later, but never do.
36 extern "C"
38 #ifndef _GLIBCXX_HAVE_FABSL
39 long double
40 fabsl(long double x)
42 return fabs((double) x);
44 #endif
46 #ifndef _GLIBCXX_HAVE_ACOSL
47 long double
48 acosl(long double x)
50 return acos((double) x);
52 #endif
54 #ifndef _GLIBCXX_HAVE_ASINL
55 long double
56 asinl(long double x)
58 return asin((double) x);
60 #endif
62 #ifndef _GLIBCXX_HAVE_ATANL
63 long double
64 atanl(long double x)
66 return atan ((double) x);
68 #endif
70 #ifndef _GLIBCXX_HAVE_ATAN2L
71 long double
72 atan2l(long double x, long double y)
74 return atan2((double) x, (double) y);
76 #endif
78 #ifndef _GLIBCXX_HAVE_COSL
79 long double
80 cosl(long double x)
82 return cos((double) x);
84 #endif
86 #ifndef _GLIBCXX_HAVE_COSHL
87 long double
88 coshl(long double x)
90 return cosh((double) x);
92 #endif
94 #ifndef _GLIBCXX_HAVE_EXPL
95 long double
96 expl(long double x)
98 return exp((double) x);
100 #endif
102 #ifndef _GLIBCXX_HAVE_FLOORL
103 long double
104 floorl(long double x)
106 return floor((double) x);
108 #endif
110 #ifndef _GLIBCXX_HAVE_FMODL
111 long double
112 fmodl(long double x, long double y)
114 return fmod((double) x, (double) y);
116 #endif
118 #ifndef _GLIBCXX_HAVE_FREXPL
119 long double
120 frexpl(long double x, int *exp)
122 return frexp((double) x, exp);
124 #endif
126 #ifndef _GLIBCXX_HAVE_SQRTL
127 long double
128 sqrtl(long double x)
130 return sqrt((double) x);
132 #endif
134 #ifndef _GLIBCXX_HAVE_HYPOTL
135 long double
136 hypotl(long double x, long double y)
138 long double s = fabsl(x) + fabsl(y);
139 if (s == 0.0L)
140 return s;
141 x /= s; y /= s;
142 return s * sqrtl(x * x + y * y);
144 #endif
146 #ifndef _GLIBCXX_HAVE_LDEXPL
147 long double
148 ldexpl(long double x, int exp)
150 return ldexp((double) x, exp);
152 #endif
154 #ifndef _GLIBCXX_HAVE_LOGL
155 long double
156 logl(long double x)
158 return log((double) x);
160 #endif
162 #ifndef _GLIBCXX_HAVE_LOG10L
163 long double
164 log10l(long double x)
166 return log10((double) x);
168 #endif
170 #ifndef _GLIBCXX_HAVE_MODFL
171 long double
172 modfl(long double x, long double *iptr)
174 double result, temp;
176 result = modf((double) x, &temp);
177 *iptr = temp;
178 return result;
180 #endif
182 #ifndef _GLIBCXX_HAVE_POWL
183 long double
184 powl(long double x, long double y)
186 return pow((double) x, (double) y);
188 #endif
190 #ifndef _GLIBCXX_HAVE_SINL
191 long double
192 sinl(long double x)
194 return sin((double) x);
196 #endif
198 #ifndef _GLIBCXX_HAVE_SINHL
199 long double
200 sinhl(long double x)
202 return sinh((double) x);
204 #endif
206 #ifndef _GLIBCXX_HAVE_TANL
207 long double
208 tanl(long double x)
210 return tan((double) x);
212 #endif
214 #ifndef _GLIBCXX_HAVE_TANHL
215 long double
216 tanhl(long double x)
218 return tanh((double) x);
220 #endif
221 } // extern "C"