1// Stub definitions for float math.
2
3// Copyright (C) 2001-2020 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 3, 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// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23// <http://www.gnu.org/licenses/>.
24
25#include <cmath>
26
27// For targets which do not have support for float versions,
28// we use the following crude approximations. We keep saying that we'll do
29// better later, but never do.
30
31extern "C"
32{
33#ifndef _GLIBCXX_HAVE_FABSF
34  float
35  fabsf(float x)
36  {
37    return (float) fabs(x);
38  }
39#endif
40
41#ifndef _GLIBCXX_HAVE_ACOSF
42  float
43  acosf(float x)
44  {
45    return (float) acos(x);
46  }
47#endif
48
49#ifndef _GLIBCXX_HAVE_ASINF
50  float
51  asinf(float x)
52  {
53    return (float) asin(x);
54  }
55#endif
56
57#ifndef _GLIBCXX_HAVE_ATANF
58  float
59  atanf(float x)
60  {
61    return (float) atan(x);
62  }
63#endif
64
65#ifndef _GLIBCXX_HAVE_ATAN2F
66  float
67  atan2f(float x, float y)
68  {
69    return (float) atan2(x, y);
70  }
71#endif
72
73#ifndef _GLIBCXX_HAVE_CEILF
74  float
75  ceilf(float x)
76  {
77    return (float) ceil(x);
78  }
79#endif
80
81#ifndef _GLIBCXX_HAVE_COSF
82  float
83  cosf(float x)
84  {
85    return (float) cos(x);
86  }
87#endif
88
89#ifndef _GLIBCXX_HAVE_COSHF
90  float
91  coshf(float x)
92  {
93    return (float) cosh(x);
94  }
95#endif
96
97#ifndef _GLIBCXX_HAVE_EXPF
98  float
99  expf(float x)
100  {
101    return (float) exp(x);
102  }
103#endif
104
105#ifndef _GLIBCXX_HAVE_FLOORF
106  float
107  floorf(float x)
108  {
109    return (float) floor(x);
110  }
111#endif
112
113#ifndef _GLIBCXX_HAVE_FMODF
114  float
115  fmodf(float x, float y)
116  {
117    return (float) fmod(x, y);
118  }
119#endif
120
121#ifndef _GLIBCXX_HAVE_FREXPF
122  float
123  frexpf(float x, int *exp)
124  {
125    return (float) frexp(x, exp);
126  }
127#endif
128
129#ifndef _GLIBCXX_HAVE_SQRTF
130  float
131  sqrtf(float x)
132  {
133    return (float) sqrt(x);
134  }
135#endif
136
137#ifndef _GLIBCXX_HAVE_HYPOTF
138  float
139  hypotf(float x, float y)
140  {
141    float s = fabsf(x) + fabsf(y);
142    if (s == 0.0F)
143      return s;
144    x /= s; y /= s;
145    return s * sqrtf(x * x + y * y);
146  }
147#endif
148
149#ifndef _GLIBCXX_HAVE_LDEXPF
150  float
151  ldexpf(float x, int exp)
152  {
153    return (float) ldexp(x, exp);
154  }
155#endif
156
157#ifndef _GLIBCXX_HAVE_LOGF
158  float
159  logf(float x)
160  {
161    return (float) log(x);
162  }
163#endif
164
165#ifndef _GLIBCXX_HAVE_LOG10F
166  float
167  log10f(float x)
168  {
169    return (float) log10(x);
170  }
171#endif
172
173#ifndef _GLIBCXX_HAVE_MODFF
174  float
175  modff(float x, float *iptr)
176  {
177    double result, temp;
178
179    result = modf(x, &temp);
180    *iptr = (float) temp;
181    return (float) result;
182  }
183#endif
184
185#ifndef _GLIBCXX_HAVE_POWF
186  float
187  powf(float x, float y)
188  {
189    return (float) pow(x, y);
190  }
191#endif
192
193#ifndef _GLIBCXX_HAVE_SINF
194  float
195  sinf(float x)
196  {
197    return (float) sin(x);
198  }
199#endif
200
201#ifndef _GLIBCXX_HAVE_SINHF
202  float
203  sinhf(float x)
204  {
205    return (float) sinh(x);
206  }
207#endif
208
209#ifndef _GLIBCXX_HAVE_TANF
210  float
211  tanf(float x)
212  {
213    return (float) tan(x);
214  }
215#endif
216
217#ifndef _GLIBCXX_HAVE_TANHF
218  float
219  tanhf(float x)
220  {
221    return (float) tanh(x);
222  }
223#endif
224} // extern "C"
225