test: disable posix_fallocate64 for small embedded systems
[uclibc-ng.git] / libm / ldouble_wrappers.c
blob118a78f647cfeee3cf2f0877d95aa70a7dac5fa0
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Wrapper functions implementing all the long double math functions
4 * defined by SuSv3 by actually calling the double version of
5 * each function and then casting the result back to a long double
6 * to return to the user.
8 * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
10 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
13 #include <features.h>
14 /* Prevent math.h from defining colliding inlines */
15 #undef __USE_EXTERN_INLINES
16 #include "math.h"
17 #include <complex.h>
19 #define WRAPPER1(func) \
20 long double func##l(long double x) \
21 { \
22 return (long double) func((double) x); \
24 #define WRAPPER2(func) \
25 long double func##l(long double x, long double y) \
26 { \
27 return (long double) func((double) x, (double) y); \
29 #define int_WRAPPER1(func) \
30 int func##l(long double x) \
31 { \
32 return func((double) x); \
34 #define long_WRAPPER1(func) \
35 long func##l(long double x) \
36 { \
37 return func((double) x); \
39 #define long_long_WRAPPER1(func) \
40 long long func##l(long double x) \
41 { \
42 return func((double) x); \
45 /* Implement the following, as defined by SuSv3 */
46 #if 0
47 long double acoshl(long double);
48 long double acosl(long double);
49 long double asinhl(long double);
50 long double asinl(long double);
51 long double atan2l(long double, long double);
52 long double atanhl(long double);
53 long double atanl(long double);
54 long double cargl(long double complex);
55 long double cbrtl(long double);
56 long double ceill(long double);
57 long double copysignl(long double, long double);
58 long double coshl(long double);
59 long double cosl(long double);
60 long double erfcl(long double);
61 long double erfl(long double);
62 long double exp2l(long double);
63 long double expl(long double);
64 long double expm1l(long double);
65 long double fabsl(long double);
66 long double fdiml(long double, long double);
67 long double floorl(long double);
68 long double fmal(long double, long double, long double);
69 long double fmaxl(long double, long double);
70 long double fminl(long double, long double);
71 long double fmodl(long double, long double);
72 long double frexpl(long double value, int *);
73 long double hypotl(long double, long double);
74 int ilogbl(long double);
75 long double ldexpl(long double, int);
76 long double lgammal(long double);
77 long long llrintl(long double);
78 long long llroundl(long double);
79 long double log10l(long double);
80 long double log1pl(long double);
81 long double log2l(long double);
82 long double logbl(long double);
83 long double logl(long double);
84 long lrintl(long double);
85 long lroundl(long double);
86 long double modfl(long double, long double *);
87 long double nearbyintl(long double);
88 long double nextafterl(long double, long double);
89 long double nexttowardl(long double, long double);
90 long double powl(long double, long double);
91 long double remainderl(long double, long double);
92 long double remquol(long double, long double, int *);
93 long double rintl(long double);
94 long double roundl(long double);
95 long double scalblnl(long double, long);
96 long double scalbnl(long double, int);
97 long double sinhl(long double);
98 long double sinl(long double);
99 long double sqrtl(long double);
100 long double tanhl(long double);
101 long double tanl(long double);
102 long double tgammal(long double);
103 long double truncl(long double);
104 #endif
106 #ifdef L_acoshl
107 WRAPPER1(acosh)
108 #endif
110 #ifdef L_acosl
111 WRAPPER1(acos)
112 #endif
114 #ifdef L_asinhl
115 WRAPPER1(asinh)
116 #endif
118 #ifdef L_asinl
119 WRAPPER1(asin)
120 #endif
122 #ifdef L_atan2l
123 WRAPPER2(atan2)
124 #endif
126 #ifdef L_atanhl
127 WRAPPER1(atanh)
128 #endif
130 #ifdef L_atanl
131 WRAPPER1(atan)
132 #endif
134 #ifdef L_cargl
135 long double cargl (long double complex x)
137 return (long double) carg( (double complex)x );
139 #endif
141 #ifdef L_cbrtl
142 WRAPPER1(cbrt)
143 #endif
145 #ifdef L_ceill
146 WRAPPER1(ceil)
147 #endif
149 #ifdef L_copysignl
150 WRAPPER2(copysign)
151 #endif
153 #ifdef L_coshl
154 WRAPPER1(cosh)
155 #endif
157 #ifdef L_cosl
158 WRAPPER1(cos)
159 #endif
161 #ifdef L_erfcl
162 WRAPPER1(erfc)
163 #endif
165 #ifdef L_erfl
166 WRAPPER1(erf)
167 #endif
169 #ifdef L_exp2l
170 WRAPPER1(exp2)
171 #endif
173 #ifdef L_expl
174 WRAPPER1(exp)
175 #endif
177 #ifdef L_expm1l
178 WRAPPER1(expm1)
179 #endif
181 #ifdef L_fabsl
182 WRAPPER1(fabs)
183 #endif
185 #ifdef L_fdiml
186 WRAPPER2(fdim)
187 #endif
189 #ifdef L_floorl
190 WRAPPER1(floor)
191 #endif
193 #ifdef L_fmal
194 long double fmal (long double x, long double y, long double z)
196 return (long double) fma( (double)x, (double)y, (double)z );
198 #endif
200 #ifdef L_fmaxl
201 WRAPPER2(fmax)
202 #endif
204 #ifdef L_fminl
205 WRAPPER2(fmin)
206 #endif
208 #ifdef L_fmodl
209 WRAPPER2(fmod)
210 #endif
212 #ifdef L_frexpl
213 long double frexpl (long double x, int *ex)
215 return (long double) frexp( (double)x, ex );
217 #endif
219 #ifdef L_gammal
220 WRAPPER1(gamma)
221 #endif
223 #ifdef L_hypotl
224 WRAPPER2(hypot)
225 #endif
227 #ifdef L_ilogbl
228 int_WRAPPER1(ilogb)
229 #endif
231 #ifdef L_ldexpl
232 long double ldexpl (long double x, int ex)
234 return (long double) ldexp( (double)x, ex );
236 #endif
238 #ifdef L_lgammal
239 WRAPPER1(lgamma)
240 #endif
242 #ifdef L_llrintl
243 long_long_WRAPPER1(llrint)
244 #endif
246 #ifdef L_llroundl
247 long_long_WRAPPER1(llround)
248 #endif
250 #ifdef L_log10l
251 WRAPPER1(log10)
252 #endif
254 #ifdef L_log1pl
255 WRAPPER1(log1p)
256 #endif
258 #ifdef L_log2l
259 WRAPPER1(log2)
260 #endif
262 #ifdef L_logbl
263 WRAPPER1(logb)
264 #endif
266 #ifdef L_logl
267 WRAPPER1(log)
268 #endif
270 #ifdef L_lrintl
271 long_WRAPPER1(lrint)
272 #endif
274 #ifdef L_lroundl
275 long_WRAPPER1(lround)
276 #endif
278 #ifdef L_modfl
279 long double modfl (long double x, long double *iptr)
281 double y, result;
282 result = modf ( x, &y );
283 *iptr = (long double)y;
284 return (long double) result;
286 #endif
288 #ifdef L_nearbyintl
289 WRAPPER1(nearbyint)
290 #endif
292 #ifdef L_nextafterl
293 WRAPPER2(nextafter)
294 #endif
296 /* Disabled in Makefile.in */
297 #if 0 /* def L_nexttowardl */
298 WRAPPER2(nexttoward)
299 libm_hidden_def(nexttowardl)
300 #endif
302 #ifdef L_powl
303 WRAPPER2(pow)
304 #endif
306 #ifdef L_remainderl
307 WRAPPER2(remainder)
308 #endif
310 #ifdef L_remquol
311 long double remquol (long double x, long double y, int *quo)
313 return (long double) remquo( (double)x, (double)y, quo );
315 #endif
317 #ifdef L_rintl
318 WRAPPER1(rint)
319 #endif
321 #ifdef L_roundl
322 WRAPPER1(round)
323 #endif
325 #ifdef L_scalblnl
326 long double scalblnl (long double x, long ex)
328 return (long double) scalbln( (double)x, ex );
330 #endif
332 #ifdef L_scalbnl
333 long double scalbnl (long double x, int ex)
335 return (long double) scalbn( (double)x, ex );
337 #endif
339 /* scalb is an obsolete function */
341 #ifdef L_sinhl
342 WRAPPER1(sinh)
343 #endif
345 #ifdef L_sinl
346 WRAPPER1(sin)
347 #endif
349 #ifdef L_sqrtl
350 WRAPPER1(sqrt)
351 #endif
353 #ifdef L_tanhl
354 WRAPPER1(tanh)
355 #endif
357 #ifdef L_tanl
358 WRAPPER1(tan)
359 #endif
361 #ifdef L_tgammal
362 WRAPPER1(tgamma)
363 #endif
365 #ifdef L_truncl
366 WRAPPER1(trunc)
367 #endif
369 #ifdef L_significandl
370 WRAPPER1(significand)
371 #endif
373 #if defined __DO_C99_MATH__ && !defined __NO_LONG_DOUBLE_MATH
375 # ifdef L___fpclassifyl
376 int_WRAPPER1(__fpclassify)
377 libm_hidden_def(__fpclassifyl)
378 # endif
380 # ifdef L___finitel
381 int_WRAPPER1(__finite)
382 libm_hidden_def(__finitel)
383 # endif
385 # ifdef L___signbitl
386 int_WRAPPER1(__signbit)
387 libm_hidden_def(__signbitl)
388 # endif
390 # ifdef L___isnanl
391 int_WRAPPER1(__isnan)
392 libm_hidden_def(__isnanl)
393 # endif
395 # ifdef L___isinfl
396 int_WRAPPER1(__isinf)
397 libm_hidden_def(__isinfl)
398 # endif
400 #endif