Blame math/w_tgamma_compat.c

Packit 6c4009
/* @(#)w_gamma.c 5.1 93/09/24 */
Packit 6c4009
/*
Packit 6c4009
 * ====================================================
Packit 6c4009
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
Packit 6c4009
 *
Packit 6c4009
 * Developed at SunPro, a Sun Microsystems, Inc. business.
Packit 6c4009
 * Permission to use, copy, modify, and distribute this
Packit 6c4009
 * software is freely granted, provided that this notice
Packit 6c4009
 * is preserved.
Packit 6c4009
 * ====================================================
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/* double gamma(double x)
Packit 6c4009
 * Return  the logarithm of the Gamma function of x or the Gamma function of x,
Packit 6c4009
 * depending on the library mode.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <errno.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <math-svid-compat.h>
Packit 6c4009
#include <libm-alias-double.h>
Packit 6c4009
Packit 6c4009
#if LIBM_SVID_COMPAT
Packit 6c4009
double
Packit 6c4009
__tgamma(double x)
Packit 6c4009
{
Packit 6c4009
	int local_signgam;
Packit 6c4009
	double y = __ieee754_gamma_r(x,&local_signgam);
Packit 6c4009
Packit 6c4009
	if(__glibc_unlikely (!isfinite (y) || y == 0)
Packit 6c4009
	   && (isfinite (x) || (isinf (x) && x < 0.0))
Packit 6c4009
	   && _LIB_VERSION != _IEEE_) {
Packit 6c4009
	  if (x == 0.0)
Packit 6c4009
	    return __kernel_standard(x,x,50); /* tgamma pole */
Packit 6c4009
	  else if(__floor(x)==x&&x<0.0)
Packit 6c4009
	    return __kernel_standard(x,x,41); /* tgamma domain */
Packit 6c4009
	  else if (y == 0)
Packit 6c4009
	    __set_errno (ERANGE); /* tgamma underflow */
Packit 6c4009
	  else
Packit 6c4009
	    return __kernel_standard(x,x,40); /* tgamma overflow */
Packit 6c4009
	}
Packit 6c4009
	return local_signgam < 0 ? -y : y;
Packit 6c4009
}
Packit 6c4009
libm_alias_double (__tgamma, tgamma)
Packit 6c4009
#endif