OSDN Git Service

2009-01-15 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / src / math_stubs_long_double.cc
1 // Stub definitions for long double math.
2
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.
10
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.
15
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.
20
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.
29
30 #include <cmath>
31
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.
35
36 extern "C" 
37 {
38 #ifndef _GLIBCXX_HAVE_FABSL
39   long double
40   fabsl(long double x)
41   {
42     return fabs((double) x);
43   }
44 #endif
45
46 #ifndef _GLIBCXX_HAVE_ACOSL
47   long double
48   acosl(long double x)
49   {
50     return acos((double) x);
51   }
52 #endif
53
54 #ifndef _GLIBCXX_HAVE_ASINL
55   long double
56   asinl(long double x)
57   {
58     return asin((double) x);
59   }
60 #endif
61
62 #ifndef _GLIBCXX_HAVE_ATANL
63   long double
64   atanl(long double x)
65   {
66     return atan ((double) x);
67   }
68 #endif
69
70 #ifndef _GLIBCXX_HAVE_ATAN2L
71   long double
72   atan2l(long double x, long double y)
73   {
74     return atan2((double) x, (double) y);
75   }
76 #endif
77
78 #ifndef _GLIBCXX_HAVE_COSL
79   long double
80   cosl(long double x)
81   {
82     return cos((double) x);
83   }
84 #endif
85
86 #ifndef _GLIBCXX_HAVE_COSHL
87   long double
88   coshl(long double x)
89   {
90     return cosh((double) x);
91   }
92 #endif
93
94 #ifndef _GLIBCXX_HAVE_EXPL
95   long double
96   expl(long double x)
97   {
98     return exp((double) x);
99   }
100 #endif
101
102 #ifndef _GLIBCXX_HAVE_FLOORL
103   long double
104   floorl(long double x)
105   {
106     return floor((double) x);
107   }
108 #endif
109
110 #ifndef _GLIBCXX_HAVE_FMODL
111   long double
112   fmodl(long double x, long double y)
113   {
114     return fmod((double) x, (double) y);
115   }
116 #endif
117
118 #ifndef _GLIBCXX_HAVE_FREXPL
119   long double
120   frexpl(long double x, int *exp)
121   {
122     return frexp((double) x, exp);
123   }
124 #endif
125
126 #ifndef _GLIBCXX_HAVE_SQRTL
127   long double
128   sqrtl(long double x)
129   {
130     return  sqrt((double) x);
131   }
132 #endif
133
134 #ifndef _GLIBCXX_HAVE_HYPOTL
135   long double
136   hypotl(long double x, long double y)
137   {
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);
143   }
144 #endif
145
146 #ifndef _GLIBCXX_HAVE_LDEXPL
147   long double
148   ldexpl(long double x, int exp)
149   {
150     return ldexp((double) x, exp);
151   }
152 #endif
153
154 #ifndef _GLIBCXX_HAVE_LOGL
155   long double
156   logl(long double x)
157   {
158     return log((double) x);
159   }
160 #endif
161
162 #ifndef _GLIBCXX_HAVE_LOG10L
163   long double
164   log10l(long double x)
165   {
166     return log10((double) x);
167   }
168 #endif
169
170 #ifndef _GLIBCXX_HAVE_MODFL
171   long double
172   modfl(long double x, long double *iptr)
173   {
174     double result, temp;
175
176     result = modf((double) x, &temp);
177     *iptr = temp;
178     return result;
179   }
180 #endif
181
182 #ifndef _GLIBCXX_HAVE_POWL
183   long double
184   powl(long double x, long double y)
185   {
186     return pow((double) x, (double) y);
187   }
188 #endif
189
190 #ifndef _GLIBCXX_HAVE_SINL
191   long double
192   sinl(long double x)
193   {
194     return sin((double) x);
195   }
196 #endif
197
198 #ifndef _GLIBCXX_HAVE_SINHL
199   long double
200   sinhl(long double x)
201   {
202     return sinh((double) x);
203   }
204 #endif
205
206 #ifndef _GLIBCXX_HAVE_TANL
207   long double
208   tanl(long double x)
209   {
210     return tan((double) x);
211   }
212 #endif
213
214 #ifndef _GLIBCXX_HAVE_TANHL
215   long double
216   tanhl(long double x)
217   {
218     return tanh((double) x);
219   }
220 #endif
221 } // extern "C"