fix TLS memory leak with dlopen
[uclibc-ng.git] / libm / w_tgammal.c
blobc97a77a2a968fd530f215972cb09c3c155bb4370
1 /* w_gammal.c -- long double version of w_gamma.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
4 */
6 /*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
17 /* long double gammal(double x)
18 * Return the Gamma function of x.
21 #include <math.h>
22 #include "math_private.h"
23 #if defined(__UCLIBC_HAS_FENV__)
24 #include <errno.h>
25 #endif
27 #if !defined __NO_LONG_DOUBLE_MATH
28 long double
29 tgammal(long double x)
31 # if defined(__UCLIBC_HAS_FENV__)
32 long double y = (long double) __ieee754_tgamma((long double)x);
34 if(__builtin_expect (!isfinite (y) || y == 0, 0)
35 && (isfinite (x) || (isinf (x) && x < 0.0))
36 && _LIB_VERSION != _IEEE_) {
37 if(x==0.0)
38 return __kernel_standard_l(x,x,250); /* tgamma pole */
39 else if(floorl(x)==x&&x<0.0L)
40 return __kernel_standard_l(x,x,241); /* tgamma domain */
41 else if (y == 0)
42 __set_errno (ERANGE); /* tgamma underflow */
43 else
44 return __kernel_standard_l(x,x,240); /* tgamma overflow */
46 return y;
47 # else
48 return (long double) __ieee754_tgamma((long double)x);
49 # endif /* __UCLIBC_HAS_FENV__ */
51 #endif /* __NO_LONG_DOUBLE_MATH */