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 [why?] */
44 #undef L_exp2f /*float exp2f(float);*/
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_log2f /*float log2f(float);*/
50 #undef L_nearbyintf /*float nearbyintf(float);*/
51 #undef L_nexttowardf /*float nexttowardf(float, long double);*/
52 #undef L_remquof /*float remquof(float, float, int *);*/
53 #undef L_scalblnf /*float scalblnf(float, long);*/
54 #undef L_tgammaf /*float tgammaf(float);*/
56 /* Implement the following, as defined by SuSv3 */
62 float atan2f(float, float);
65 float cargf(float complex);
68 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);
89 float modff(float, float *);
90 float powf(float, float);
91 float remainderf(float, float);
94 float scalbnf(float, int);
119 float atan2f (float x
, float y
)
121 return (float) atan2( (double)x
, (double)y
);
134 float cargf (float complex x
)
136 return (float) carg( (double complex)x
);
149 float copysignf (float x
, float y
)
151 return (float) copysign( (double)x
, (double)y
);
188 float fdimf (float x
, float y
)
190 return (float) fdim( (double)x
, (double)y
);
199 float fmaf (float x
, float y
, float z
)
201 return (float) fma( (double)x
, (double)y
, (double)z
);
206 float fmaxf (float x
, float y
)
208 return (float) fmax( (double)x
, (double)y
);
213 float fminf (float x
, float y
)
215 return (float) fmin( (double)x
, (double)y
);
220 float fmodf (float x
, float y
)
222 return (float) fmod( (double)x
, (double)y
);
227 float frexpf (float x
, int *_exp
)
229 return (float) frexp( (double)x
, _exp
);
234 float hypotf (float x
, float y
)
236 return (float) hypot( (double)x
, (double)y
);
245 float ldexpf (float x
, int _exp
)
247 return (float) ldexp( (double)x
, _exp
);
256 long_long_WRAPPER1(llrint
)
260 long_long_WRAPPER1(llround
)
288 long_WRAPPER1(lround
)
292 float modff (float x
, float *iptr
)
295 result
= modf ( x
, &y
);
297 return (float) result
;
307 float nexttowardf (float x
, long double y
)
309 return (float) nexttoward( (double)x
, (double)y
);
314 float powf (float x
, float y
)
316 return (float) pow( (double)x
, (double)y
);
321 float remainderf (float x
, float y
)
323 return (float) remainder( (double)x
, (double)y
);
328 float remquof (float x
, float y
, int *quo
)
330 return (float) remquo( (double)x
, (double)y
, quo
);
343 float scalblnf (float x
, long _exp
)
345 return (float) scalbln( (double)x
, _exp
);
350 float scalbnf (float x
, int _exp
)
352 return (float) scalbn( (double)x
, _exp
);
385 float fmaf (float x
, float y
, float z
)
387 return (float) fma( (double)x
, (double)y
, (double)z
);
391 #if defined L_scalbf && defined __UCLIBC_SUSV3_LEGACY__
392 float scalbf (float x
, float y
)
394 return (float) scalb( (double)x
, (double)y
);
402 #ifdef L_significandf
403 WRAPPER1(significand
)