linuxthreads: install libpthread_nonshared.a
[uclibc-ng.git] / libm / ldouble_wrappers.c
blob840293fe6df27cd70cb8f44ee2c9d0181d77ca0b
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 #if !defined __NO_LONG_DOUBLE_MATH
20 # define WRAPPER1(func) \
21 long double func##l(long double x) \
22 { \
23 return (long double) func((double) x); \
25 # define WRAPPER2(func) \
26 long double func##l(long double x, long double y) \
27 { \
28 return (long double) func((double) x, (double) y); \
30 # define int_WRAPPER1(func) \
31 int func##l(long double x) \
32 { \
33 return func((double) x); \
35 # define long_WRAPPER1(func) \
36 long func##l(long double x) \
37 { \
38 return func((double) x); \
40 # define long_long_WRAPPER1(func) \
41 long long func##l(long double x) \
42 { \
43 return func((double) x); \
46 #ifndef __DO_XSI_MATH__
47 # undef L_j0l /* long double j0l(long double x); */
48 # undef L_j1l /* long double j1l(long double x); */
49 # undef L_jnl /* long double jnl(int n, long double x); */
50 # undef L_y0l /* long double y0l(long double x); */
51 # undef L_y1l /* long double y1l(long double x); */
52 # undef L_ynl /* long double ynl(int n, long double x); */
53 #endif
55 /* Implement the following, as defined by SuSv3 */
56 #if 0
57 long double acoshl(long double);
58 long double acosl(long double);
59 long double asinhl(long double);
60 long double asinl(long double);
61 long double atan2l(long double, long double);
62 long double atanhl(long double);
63 long double atanl(long double);
64 long double cargl(long double complex);
65 long double cbrtl(long double);
66 long double ceill(long double);
67 long double copysignl(long double, long double);
68 long double coshl(long double);
69 long double cosl(long double);
70 long double erfcl(long double);
71 long double erfl(long double);
72 long double exp2l(long double);
73 long double expl(long double);
74 long double expm1l(long double);
75 long double fabsl(long double);
76 long double fdiml(long double, long double);
77 long double floorl(long double);
78 long double fmal(long double, long double, long double);
79 long double fmaxl(long double, long double);
80 long double fminl(long double, long double);
81 long double fmodl(long double, long double);
82 long double frexpl(long double value, int *);
83 long double hypotl(long double, long double);
84 int ilogbl(long double);
85 long double ldexpl(long double, int);
86 long double lgammal(long double);
87 long long llrintl(long double);
88 long long llroundl(long double);
89 long double log10l(long double);
90 long double log1pl(long double);
91 long double log2l(long double);
92 long double logbl(long double);
93 long double logl(long double);
94 long lrintl(long double);
95 long lroundl(long double);
96 long double modfl(long double, long double *);
97 long double nearbyintl(long double);
98 long double nextafterl(long double, long double);
99 long double nexttowardl(long double, long double);
100 long double powl(long double, long double);
101 long double remainderl(long double, long double);
102 long double remquol(long double, long double, int *);
103 long double rintl(long double);
104 long double roundl(long double);
105 long double scalblnl(long double, long);
106 long double scalbnl(long double, int);
107 long double sinhl(long double);
108 long double sinl(long double);
109 long double sqrtl(long double);
110 long double tanhl(long double);
111 long double tanl(long double);
112 long double tgammal(long double);
113 long double truncl(long double);
114 #endif
116 #ifdef L_acoshl
117 WRAPPER1(acosh)
118 #endif
120 #ifdef L_acosl
121 WRAPPER1(acos)
122 #endif
124 #ifdef L_asinhl
125 WRAPPER1(asinh)
126 #endif
128 #ifdef L_asinl
129 WRAPPER1(asin)
130 #endif
132 #ifdef L_atan2l
133 WRAPPER2(atan2)
134 #endif
136 #ifdef L_atanhl
137 WRAPPER1(atanh)
138 #endif
140 #ifdef L_atanl
141 WRAPPER1(atan)
142 #endif
144 #ifdef L_cargl
145 long double cargl (long double complex x)
147 return (long double) carg( (double complex)x );
149 #endif
151 #ifdef L_cbrtl
152 WRAPPER1(cbrt)
153 #endif
155 #ifdef L_ceill
156 WRAPPER1(ceil)
157 #endif
159 #ifdef L_copysignl
160 WRAPPER2(copysign)
161 #endif
163 #ifdef L_coshl
164 WRAPPER1(cosh)
165 #endif
167 #ifdef L_cosl
168 WRAPPER1(cos)
169 libm_hidden_def(cosl)
170 #endif
172 #ifdef L_erfcl
173 WRAPPER1(erfc)
174 #endif
176 #ifdef L_erfl
177 WRAPPER1(erf)
178 #endif
180 #ifdef L_exp2l
181 WRAPPER1(exp2)
182 #endif
184 #ifdef L_expl
185 WRAPPER1(exp)
186 libm_hidden_def(expl)
187 #endif
189 #ifdef L_expm1l
190 WRAPPER1(expm1)
191 #endif
193 #ifdef L_fabsl
194 WRAPPER1(fabs)
195 #endif
197 #ifdef L_fdiml
198 WRAPPER2(fdim)
199 #endif
201 #ifdef L_floorl
202 WRAPPER1(floor)
203 #endif
205 #ifdef L_fmal
206 long double fmal (long double x, long double y, long double z)
208 return (long double) fma( (double)x, (double)y, (double)z );
210 #endif
212 #ifdef L_fmaxl
213 WRAPPER2(fmax)
214 #endif
216 #ifdef L_fminl
217 WRAPPER2(fmin)
218 #endif
220 #ifdef L_fmodl
221 WRAPPER2(fmod)
222 #endif
224 #ifdef L_frexpl
225 long double frexpl (long double x, int *ex)
227 return (long double) frexp( (double)x, ex );
229 #endif
231 #ifdef L_gammal
232 WRAPPER1(gamma)
233 #endif
235 #ifdef L_hypotl
236 WRAPPER2(hypot)
237 libm_hidden_def(hypotl)
238 #endif
240 #ifdef L_ilogbl
241 int_WRAPPER1(ilogb)
242 #endif
244 #ifdef L_j0l
245 WRAPPER1(j0)
246 #endif
248 #ifdef L_j1l
249 WRAPPER1(j1)
250 #endif
252 #ifdef L_jnl
253 long double jnl(int n, long double x)
255 return (long double) jn(n, (double)x);
257 #endif
259 #ifdef L_ldexpl
260 long double ldexpl (long double x, int ex)
262 return (long double) ldexp( (double)x, ex );
264 #endif
266 #ifdef L_lgammal
267 WRAPPER1(lgamma)
268 #endif
270 #ifdef L_llrintl
271 long_long_WRAPPER1(llrint)
272 #endif
274 #ifdef L_llroundl
275 long_long_WRAPPER1(llround)
276 #endif
278 #ifdef L_log10l
279 WRAPPER1(log10)
280 #endif
282 #ifdef L_log1pl
283 WRAPPER1(log1p)
284 #endif
286 #ifdef L_log2l
287 WRAPPER1(log2)
288 #endif
290 #ifdef L_logbl
291 WRAPPER1(logb)
292 #endif
294 #ifdef L_logl
295 WRAPPER1(log)
296 #endif
298 #ifdef L_lrintl
299 long_WRAPPER1(lrint)
300 #endif
302 #ifdef L_lroundl
303 long_WRAPPER1(lround)
304 #endif
306 #ifdef L_modfl
307 long double modfl (long double x, long double *iptr)
309 double y, result;
310 result = modf ( x, &y );
311 *iptr = (long double)y;
312 return (long double) result;
314 #endif
316 #ifdef L_nearbyintl
317 WRAPPER1(nearbyint)
318 #endif
320 #ifdef L_nextafterl
321 WRAPPER2(nextafter)
322 libm_hidden_def(nextafterl)
323 #endif
325 #ifdef L_nexttowardl
326 # if 0 /* TODO */
327 strong_alias(nextafterl, nexttowardl)
328 # else
329 long double nexttowardl(long double x, long double y)
331 return nextafterl(x, y);
333 #endif
334 #endif
336 #ifdef L_powl
337 WRAPPER2(pow)
338 #endif
340 #ifdef L_remainderl
341 WRAPPER2(remainder)
342 #endif
344 #ifdef L_remquol
345 long double remquol (long double x, long double y, int *quo)
347 return (long double) remquo( (double)x, (double)y, quo );
349 #endif
351 #ifdef L_rintl
352 WRAPPER1(rint)
353 #endif
355 #ifdef L_roundl
356 WRAPPER1(round)
357 #endif
359 #ifdef L_scalblnl
360 long double scalblnl (long double x, long ex)
362 return (long double) scalbln( (double)x, ex );
364 #endif
366 #ifdef L_scalbnl
367 long double scalbnl (long double x, int ex)
369 return (long double) scalbn( (double)x, ex );
371 #endif
373 /* scalb is an obsolete function */
375 #ifdef L_sinhl
376 WRAPPER1(sinh)
377 #endif
379 #ifdef L_sinl
380 WRAPPER1(sin)
381 libm_hidden_def(sinl)
382 #endif
384 #ifdef L_sqrtl
385 WRAPPER1(sqrt)
386 #endif
388 #ifdef L_tanhl
389 WRAPPER1(tanh)
390 #endif
392 #ifdef L_tanl
393 WRAPPER1(tan)
394 #endif
396 #ifdef L_tgammal
397 WRAPPER1(tgamma)
398 #endif
400 #ifdef L_truncl
401 WRAPPER1(trunc)
402 #endif
404 #ifdef L_significandl
405 WRAPPER1(significand)
406 #endif
408 #ifdef L_y0l
409 WRAPPER1(y0)
410 #endif
412 #ifdef L_y1l
413 WRAPPER1(y1)
414 #endif
416 #ifdef L_ynl
417 long double ynl(int n, long double x)
419 return (long double) yn(n, (double)x);
421 #endif
424 #if defined __DO_C99_MATH__ && !defined __NO_LONG_DOUBLE_MATH
426 # ifdef L___fpclassifyl
427 int_WRAPPER1(__fpclassify)
428 libm_hidden_def(__fpclassifyl)
429 # endif
431 # ifdef L___finitel
432 int_WRAPPER1(__finite)
433 libm_hidden_def(__finitel)
434 # endif
436 # ifdef L___signbitl
437 int_WRAPPER1(__signbit)
438 libm_hidden_def(__signbitl)
439 # endif
441 # ifdef L___isnanl
442 int_WRAPPER1(__isnan)
443 libm_hidden_def(__isnanl)
444 # endif
446 # ifdef L___isinfl
447 int_WRAPPER1(__isinf)
448 libm_hidden_def(__isinfl)
449 # endif
451 #endif /* __DO_C99_MATH__ */
453 #endif /* __NO_LONG_DOUBLE_MATH */