w_tgammal.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. */
  5. /*
  6. * ====================================================
  7. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  8. *
  9. * Developed at SunPro, a Sun Microsystems, Inc. business.
  10. * Permission to use, copy, modify, and distribute this
  11. * software is freely granted, provided that this notice
  12. * is preserved.
  13. * ====================================================
  14. */
  15. /* long double gammal(double x)
  16. * Return the Gamma function of x.
  17. */
  18. #include <math.h>
  19. #include "math_private.h"
  20. #if defined(__UCLIBC_HAS_FENV__)
  21. #include <errno.h>
  22. #endif
  23. #if !defined __NO_LONG_DOUBLE_MATH
  24. long double
  25. tgammal(long double x)
  26. {
  27. # if defined(__UCLIBC_HAS_FENV__)
  28. long double y = (long double) __ieee754_tgamma((long double)x);
  29. if(__builtin_expect (!isfinite (y) || y == 0, 0)
  30. && (isfinite (x) || (isinf (x) && x < 0.0))
  31. && _LIB_VERSION != _IEEE_) {
  32. if(x==0.0)
  33. return __kernel_standard_l(x,x,250); /* tgamma pole */
  34. else if(floorl(x)==x&&x<0.0L)
  35. return __kernel_standard_l(x,x,241); /* tgamma domain */
  36. else if (y == 0)
  37. __set_errno (ERANGE); /* tgamma underflow */
  38. else
  39. return __kernel_standard_l(x,x,240); /* tgamma overflow */
  40. }
  41. return y;
  42. # else
  43. return (long double) __ieee754_tgamma((long double)x);
  44. # endif /* __UCLIBC_HAS_FENV__ */
  45. }
  46. #endif /* __NO_LONG_DOUBLE_MATH */