w_tgammaf_compat.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* w_gammaf.c -- float version of w_gamma.c.
  2. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
  3. */
  4. /*
  5. * ====================================================
  6. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  7. *
  8. * Developed at SunPro, a Sun Microsystems, Inc. business.
  9. * Permission to use, copy, modify, and distribute this
  10. * software is freely granted, provided that this notice
  11. * is preserved.
  12. * ====================================================
  13. */
  14. #include <errno.h>
  15. #include <math.h>
  16. #include <math_private.h>
  17. #include <math-svid-compat.h>
  18. #include <libm-alias-float.h>
  19. #if LIBM_SVID_COMPAT
  20. float
  21. __tgammaf(float x)
  22. {
  23. int local_signgam;
  24. float y = __ieee754_gammaf_r(x,&local_signgam);
  25. if(__glibc_unlikely (!isfinite (y) || y == 0)
  26. && (isfinite (x) || (isinf (x) && x < 0.0))
  27. && _LIB_VERSION != _IEEE_) {
  28. if (x == (float)0.0)
  29. /* tgammaf pole */
  30. return __kernel_standard_f(x, x, 150);
  31. else if(floorf(x)==x&&x<0.0f)
  32. /* tgammaf domain */
  33. return __kernel_standard_f(x, x, 141);
  34. else if (y == 0)
  35. /* tgammaf underflow */
  36. __set_errno (ERANGE);
  37. else
  38. /* tgammaf overflow */
  39. return __kernel_standard_f(x, x, 140);
  40. }
  41. return local_signgam < 0 ? - y : y;
  42. }
  43. libm_alias_float (__tgamma, tgamma)
  44. #endif