(root)/
glibc-2.38/
math/
w_tgamma_compat.c
       1  /* @(#)w_gamma.c 5.1 93/09/24 */
       2  /*
       3   * ====================================================
       4   * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
       5   *
       6   * Developed at SunPro, a Sun Microsystems, Inc. business.
       7   * Permission to use, copy, modify, and distribute this
       8   * software is freely granted, provided that this notice
       9   * is preserved.
      10   * ====================================================
      11   */
      12  
      13  /* double gamma(double x)
      14   * Return  the logarithm of the Gamma function of x or the Gamma function of x,
      15   * depending on the library mode.
      16   */
      17  
      18  #include <errno.h>
      19  #include <math.h>
      20  #include <math_private.h>
      21  #include <math-svid-compat.h>
      22  #include <libm-alias-double.h>
      23  
      24  #if LIBM_SVID_COMPAT
      25  double
      26  __tgamma(double x)
      27  {
      28  	int local_signgam;
      29  	double y = __ieee754_gamma_r(x,&local_signgam);
      30  
      31  	if(__glibc_unlikely (!isfinite (y) || y == 0)
      32  	   && (isfinite (x) || (isinf (x) && x < 0.0))
      33  	   && _LIB_VERSION != _IEEE_) {
      34  	  if (x == 0.0)
      35  	    return __kernel_standard(x,x,50); /* tgamma pole */
      36  	  else if(floor(x)==x&&x<0.0)
      37  	    return __kernel_standard(x,x,41); /* tgamma domain */
      38  	  else if (y == 0)
      39  	    __set_errno (ERANGE); /* tgamma underflow */
      40  	  else
      41  	    return __kernel_standard(x,x,40); /* tgamma overflow */
      42  	}
      43  	return local_signgam < 0 ? -y : y;
      44  }
      45  libm_alias_double (__tgamma, tgamma)
      46  #endif