source: trunk/gcc/libstdc++-v3/libmath/stubs.c

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.2 KB
Line 
1/* Stub definitions for libmath subpart of libstdc++. */
2
3/* Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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 <math.h>
31#include "config.h"
32
33/* For targets which do not have support for long double versions,
34 we use the crude approximation. We'll do better later. */
35
36
37#ifndef HAVE_ATAN2F
38float
39atan2f(float x, float y)
40{
41 return (float) atan2(x, y);
42}
43#endif
44
45#ifndef HAVE_ATAN2L
46long double
47atan2l(long double x, long double y)
48{
49 return atan2((double) x, (double) y);
50}
51#endif
52
53
54#ifndef HAVE_COSF
55float
56cosf(float x)
57{
58 return (float) cos(x);
59}
60#endif
61
62#ifndef HAVE_COSL
63long double
64cosl(long double x)
65{
66 return cos((double) x);
67}
68#endif
69
70
71#ifndef HAVE_COSHF
72float
73coshf(float x)
74{
75 return (float) cosh(x);
76}
77#endif
78
79#ifndef HAVE_COSHL
80long double
81coshl(long double x)
82{
83 return cosh((double) x);
84}
85#endif
86
87
88#ifndef HAVE_EXPF
89float
90expf(float x)
91{
92 return (float) exp(x);
93}
94#endif
95
96#ifndef HAVE_EXPL
97long double
98expl(long double x)
99{
100 return exp((double) x);
101}
102#endif
103
104
105/* Compute the hypothenuse of a right triangle with side x and y. */
106#ifndef HAVE_HYPOTF
107float
108hypotf(float x, float y)
109{
110 float s = fabsf(x) + fabsf(y);
111 if (s == 0.0F)
112 return s;
113 x /= s; y /= s;
114 return s * sqrtf(x * x + y * y);
115}
116#endif
117
118#ifndef HAVE_HYPOT
119double
120hypot(double x, double y)
121{
122 double s = fabs(x) + fabs(y);
123 if (s == 0.0)
124 return s;
125 x /= s; y /= s;
126 return s * sqrt(x * x + y * y);
127}
128#endif
129
130#ifndef HAVE_HYPOTL
131long double
132hypotl(long double x, long double y)
133{
134 long double s = fabsl(x) + fabsl(y);
135 if (s == 0.0L)
136 return s;
137 x /= s; y /= s;
138 return s * sqrtl(x * x + y * y);
139}
140#endif
141
142
143
144#ifndef HAVE_LOGF
145float
146logf(float x)
147{
148 return (float) log(x);
149}
150#endif
151
152#ifndef HAVE_LOGL
153long double
154logl(long double x)
155{
156 return log((double) x);
157}
158#endif
159
160
161#ifndef HAVE_LOG10F
162float
163log10f(float x)
164{
165 return (float) log10(x);
166}
167#endif
168
169#ifndef HAVE_LOG10L
170long double
171log10l(long double x)
172{
173 return log10((double) x);
174}
175#endif
176
177
178#ifndef HAVE_POWF
179float
180powf(float x, float y)
181{
182 return (float) pow(x, y);
183}
184#endif
185
186#ifndef HAVE_POWL
187long double
188powl(long double x, long double y)
189{
190 return pow((double) x, (double) y);
191}
192#endif
193
194
195#ifndef HAVE_SINF
196float
197sinf(float x)
198{
199 return (float) sin(x);
200}
201#endif
202
203#ifndef HAVE_SINL
204long double
205sinl(long double x)
206{
207 return sin((double) x);
208}
209#endif
210
211
212#ifndef HAVE_SINHF
213float
214sinhf(float x)
215{
216 return (float) sinh(x);
217}
218#endif
219
220#ifndef HAVE_SINHL
221long double
222sinhl(long double x)
223{
224 return sinh((double) x);
225}
226#endif
227
228
229#ifndef HAVE_SQRTF
230float
231sqrtf(float x)
232{
233 return (float) sqrt(x);
234}
235#endif
236
237#ifndef HAVE_SQRTL
238long double
239sqrtl(long double x)
240{
241 return sqrt((double) x);
242}
243#endif
244
245
246#ifndef HAVE_TANF
247float
248tanf(float x)
249{
250 return (float) tan(x);
251}
252#endif
253
254#ifndef HAVE_TANL
255long double
256tanl(long double x)
257{
258 return tan((double) x);
259}
260#endif
261
262
263#ifndef HAVE_TANHF
264float
265tanhf(float x)
266{
267 return (float) tanh(x);
268}
269#endif
270
271#ifndef HAVE_TANHL
272long double
273tanhl(long double x)
274{
275 return tanh((double) x);
276}
277#endif
Note: See TracBrowser for help on using the repository browser.