2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/* @(#)w_lgamma.c 5.1 93/09/24 */
|
|
|
|
/*
|
|
|
|
* ====================================================
|
|
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software is freely granted, provided that this notice
|
|
|
|
* is preserved.
|
|
|
|
* ====================================================
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* double lgamma(double x)
|
|
|
|
* Return the logarithm of the Gamma function of x.
|
|
|
|
*
|
|
|
|
* Method: call __ieee754_lgamma_r
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fdlibm.h"
|
|
|
|
#include <reent.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
Add --enable-newlib-reent-thread-local option
By default, Newlib uses a huge object of type struct _reent to store
thread-specific data. This object is returned by __getreent() if the
__DYNAMIC_REENT__ Newlib configuration option is defined.
The reentrancy structure contains for example errno and the standard input,
output, and error file streams. This means that if an application only uses
errno it has a dependency on the file stream support even if it does not use
it. This is an issue for lower end targets and applications which need to
qualify the software according to safety standards (for example ECSS-E-ST-40C,
ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333).
If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct
_reent is replaced by dedicated thread-local objects for each struct _reent
member. The thread-local objects are defined in translation units which use
the corresponding object.
2022-05-16 17:51:54 +08:00
|
|
|
#ifdef _REENT_THREAD_LOCAL
|
|
|
|
_Thread_local int _tls_gamma_signgam;
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _DOUBLE_IS_32BITS
|
|
|
|
|
|
|
|
#ifdef __STDC__
|
|
|
|
double lgamma(double x)
|
|
|
|
#else
|
|
|
|
double lgamma(x)
|
|
|
|
double x;
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
#ifdef _IEEE_LIBM
|
2002-02-03 17:24:18 +08:00
|
|
|
return __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT)));
|
2000-02-18 03:39:52 +08:00
|
|
|
#else
|
|
|
|
double y;
|
2002-02-03 17:24:18 +08:00
|
|
|
y = __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT)));
|
2000-02-18 03:39:52 +08:00
|
|
|
if(_LIB_VERSION == _IEEE_) return y;
|
|
|
|
if(!finite(y)&&finite(x)) {
|
2020-08-05 06:22:20 +08:00
|
|
|
/* lgamma(finite) overflow */
|
|
|
|
errno = ERANGE;
|
|
|
|
}
|
|
|
|
return y;
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* defined(_DOUBLE_IS_32BITS) */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|