1 /* vi: set sw=4 ts=4: */
3 * Wrapper functions implementing all the float math functions
4 * defined by SuSv3 by actually calling the double version of
5 * each function and then casting the result back to a float
6 * to return to the user.
8 * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
10 * GNU Lesser General Public License version 2.1 or later.
14 /* Prevent math.h from defining colliding inlines */
15 #undef __USE_EXTERN_INLINES
20 #define WRAPPER1(func) \
21 float func##f (float x) \
23 return (float) func((double)x); \
25 #define int_WRAPPER1(func) \
26 int func##f (float x) \
28 return func((double)x); \
30 #define long_WRAPPER1(func) \
31 long func##f (float x) \
33 return func((double)x); \
35 #define long_long_WRAPPER1(func) \
36 long long func##f (float x) \
38 return func((double)x); \
42 /* For the time being, do _NOT_ implement these functions
43 * that are defined by SuSv3 [because we don't need them
44 * and nobody asked to include them] */
45 #undef L_fdimf /*float fdimf(float, float);*/
46 #undef L_fmaf /*float fmaf(float, float, float);*/
47 #undef L_fmaxf /*float fmaxf(float, float);*/
48 #undef L_fminf /*float fminf(float, float);*/
49 #undef L_nearbyintf /*float nearbyintf(float);*/
50 #undef L_nexttowardf /*float nexttowardf(float, long double);*/
51 #undef L_remquof /*float remquof(float, float, int *);*/
52 #undef L_scalblnf /*float scalblnf(float, long);*/
53 #undef L_tgammaf /*float tgammaf(float);*/
55 /* Implement the following, as defined by SuSv3 */
61 float atan2f(float, float);
64 float cargf(float complex);
67 float copysignf(float, float);
77 float fmodf(float, float);
78 float frexpf(float value, int *);
79 float hypotf(float, float);
81 float ldexpf(float, int);
83 long long llroundf(float);
90 float modff(float, float *);
91 float powf(float, float);
92 float remainderf(float, float);
95 float scalbnf(float, int);
120 float atan2f (float x, float y)
122 return (float) atan2( (double)x, (double)y );
135 float cargf (float complex x)
137 return (float) carg( (double complex)x );
150 float copysignf (float x, float y)
152 return (float) copysign( (double)x, (double)y );
189 float fdimf (float x, float y)
191 return (float) fdim( (double)x, (double)y );
200 float fmaf (float x, float y, float z)
202 return (float) fma( (double)x, (double)y, (double)z );
207 float fmaxf (float x, float y)
209 return (float) fmax( (double)x, (double)y );
214 float fminf (float x, float y)
216 return (float) fmin( (double)x, (double)y );
221 float fmodf (float x, float y)
223 return (float) fmod( (double)x, (double)y );
228 float frexpf (float x, int *_exp)
230 return (float) frexp( (double)x, _exp );
235 float hypotf (float x, float y)
237 return (float) hypot( (double)x, (double)y );
246 float ldexpf (float x, int _exp)
248 return (float) ldexp( (double)x, _exp );
257 long_long_WRAPPER1(llrint)
261 long_long_WRAPPER1(llround)
289 long_WRAPPER1(lround)
293 float modff (float x, float *iptr)
296 result = modf ( x, &y );
298 return (float) result;
308 float nexttowardf (float x, long double y)
310 return (float) nexttoward( (double)x, (double)y );
315 float powf (float x, float y)
317 return (float) pow( (double)x, (double)y );
322 float remainderf (float x, float y)
324 return (float) remainder( (double)x, (double)y );
329 float remquof (float x, float y, int *quo)
331 return (float) remquo( (double)x, (double)y, quo );
344 float scalblnf (float x, long _exp)
346 return (float) scalbln( (double)x, _exp );
351 float scalbnf (float x, int _exp)
353 return (float) scalbn( (double)x, _exp );
386 float fmaf (float x, float y, float z)
388 return (float) fma( (double)x, (double)y, (double)z );
392 #if defined L_scalbf && defined __UCLIBC_SUSV3_LEGACY__
393 float scalbf (float x, float y)
395 return (float) scalb( (double)x, (double)y );
403 #ifdef L_significandf
404 WRAPPER1(significand)