hasmntopt: better option matching
[uclibc-ng.git] / libm / float_wrappers.c
blob948f6bc1436017888eed0d33c246e5ac76c8b8aa
1 /*
2 * Wrapper functions implementing all the float math functions
3 * defined by SuSv3 by actually calling the double version of
4 * each function and then casting the result back to a float
5 * to return to the user.
7 * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
9 * GNU Lesser General Public License version 2.1 or later.
12 #include <features.h>
13 /* Prevent math.h from defining colliding inlines */
14 #undef __USE_EXTERN_INLINES
15 #include <math.h>
16 #include <complex.h>
19 #define WRAPPER1(func) \
20 float func##f (float x) \
21 { \
22 return (float) func((double)x); \
24 #define int_WRAPPER1(func) \
25 int func##f (float x) \
26 { \
27 return func((double)x); \
29 #define long_WRAPPER1(func) \
30 long func##f (float x) \
31 { \
32 return func((double)x); \
34 #define long_long_WRAPPER1(func) \
35 long long func##f (float x) \
36 { \
37 return func((double)x); \
40 /* Implement the following, as defined by SuSv3 */
41 #if 0
42 float asinhf(float);
43 float atanf(float);
44 float cargf(float complex);
45 float cbrtf(float);
46 float ceilf(float);
47 float copysignf(float, float);
48 float cosf(float);
49 float erfcf(float);
50 float erff(float);
51 float expm1f(float);
52 float fabsf(float);
53 float floorf(float);
54 float frexpf(float value, int *);
55 int ilogbf(float);
56 float ldexpf(float, int);
57 long long llroundf(float);
58 float log1pf(float);
59 float logbf(float);
60 long lroundf(float);
61 float modff(float, float *);
62 float rintf(float);
63 float roundf(float);
64 float scalbnf(float, int);
65 float sinf(float);
66 float tanf(float);
67 float tanhf(float);
68 #endif
70 /* The following functions implemented as wrappers
71 * in separate files (w_funcf.c)
73 #if 0
74 float acosf(float);
75 float acoshf(float);
76 float asinf(float);
77 float atan2f(float, float);
78 float atanhf(float);
79 float coshf(float);
80 float exp2f(float);
81 float expf(float);
82 float fmodf(float, float);
83 float hypotf(float, float);
84 float lgammaf(float);
85 float log10f(float);
86 float log2f(float);
87 float logf(float);
88 float powf(float, float);
89 float remainderf(float, float);
90 float sinhf(float);
91 float sqrtf(float);
92 float j0f(float x);
93 float j1f(float x);
94 float jnf(int n, float x);
95 float y0f(float x);
96 float y1f(float x);
97 float ynf(int n, float x);
98 float tgammaf(float x);
99 float scalbf(float x, float fn);
100 float gammaf(float x);
101 float scalbl(float x, float fn);
102 #endif
104 #ifdef L_asinhf
105 WRAPPER1(asinh)
106 #endif
108 #ifdef L_atanf
109 WRAPPER1(atan)
110 #endif
112 #ifdef L_cargf
113 float cargf (float complex x)
115 return (float) carg( (double complex)x );
117 #endif
119 #ifdef L_cbrtf
120 WRAPPER1(cbrt)
121 #endif
123 #ifdef L_ceilf
124 WRAPPER1(ceil)
125 #endif
127 #ifdef L_copysignf
128 float copysignf (float x, float y)
130 return (float) copysign( (double)x, (double)y );
132 #endif
134 #ifdef L_cosf
135 WRAPPER1(cos)
136 libm_hidden_def(cosf)
137 #endif
139 #ifdef L_erfcf
140 WRAPPER1(erfc)
141 #endif
143 #ifdef L_erff
144 WRAPPER1(erf)
145 #endif
147 #ifdef L_expm1f
148 WRAPPER1(expm1)
149 #endif
151 #ifdef L_fabsf
152 WRAPPER1(fabs)
153 #endif
155 #ifdef L_fdimf
156 float fdimf (float x, float y)
158 return (float) fdim( (double)x, (double)y );
160 #endif
162 #ifdef L_floorf
163 WRAPPER1(floor)
164 #endif
166 #ifdef L_fmaf
167 float fmaf (float x, float y, float z)
169 return (float) fma( (double)x, (double)y, (double)z );
171 #endif
173 #ifdef L_fmaxf
174 float fmaxf (float x, float y)
176 return (float) fmax( (double)x, (double)y );
178 #endif
180 #ifdef L_fminf
181 float fminf (float x, float y)
183 return (float) fmin( (double)x, (double)y );
185 #endif
187 #ifdef L_frexpf
188 float frexpf (float x, int *_exp)
190 return (float) frexp( (double)x, _exp );
192 #endif
194 #ifdef L_ilogbf
195 int_WRAPPER1(ilogb)
196 #endif
198 #ifdef L_ldexpf
199 float ldexpf (float x, int _exp)
201 return (float) ldexp( (double)x, _exp );
203 #endif
205 #ifdef L_llrintf
206 long_long_WRAPPER1(llrint)
207 #endif
209 #ifdef L_llroundf
210 long_long_WRAPPER1(llround)
211 #endif
213 #ifdef L_log1pf
214 WRAPPER1(log1p)
215 #endif
217 #ifdef L_logbf
218 WRAPPER1(logb)
219 #endif
221 #ifdef L_lrintf
222 long_WRAPPER1(lrint)
223 #endif
225 #ifdef L_lroundf
226 long_WRAPPER1(lround)
227 #endif
229 #ifdef L_modff
230 float modff (float x, float *iptr)
232 double y, result;
233 result = modf( x, &y );
234 *iptr = (float)y;
235 return (float) result;
237 #endif
239 #ifdef L_nearbyintf
240 WRAPPER1(nearbyint)
241 #endif
243 #ifdef L_nexttowardf
244 float nexttowardf (float x, long double y)
246 return (float) nexttoward( (double)x, (long double)y );
248 #endif
250 #ifdef L_remquof
251 float remquof (float x, float y, int *quo)
253 return (float) remquo( (double)x, (double)y, quo );
255 #endif
257 #ifdef L_rintf
258 WRAPPER1(rint)
259 #endif
261 #ifdef L_roundf
262 WRAPPER1(round)
263 #endif
265 #ifdef L_scalblnf
266 float scalblnf (float x, long _exp)
268 return (float) scalbln( (double)x, _exp );
270 #endif
272 #ifdef L_scalbnf
273 float scalbnf (float x, int _exp)
275 return (float) scalbn( (double)x, _exp );
277 #endif
279 #ifdef L_sinf
280 WRAPPER1(sin)
281 libm_hidden_def(sinf)
282 #endif
284 #ifdef L_tanf
285 WRAPPER1(tan)
286 #endif
288 #ifdef L_tanhf
289 WRAPPER1(tanh)
290 #endif
292 #ifdef L_truncf
293 WRAPPER1(trunc)
294 #endif
296 #ifdef L_significandf
297 WRAPPER1(significand)
298 #endif