mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
5928eab2c4
* Fix lgamma race.
31 lines
677 B
C++
31 lines
677 B
C++
#include <Functions/FunctionMathUnary.h>
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#if defined(OS_DARWIN)
|
|
extern "C"
|
|
{
|
|
/// Is defined in libglibc-compatibility.a
|
|
double lgamma_r(double x, int * signgamp);
|
|
}
|
|
#endif
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Use wrapper and use lgamma_r version because std::lgamma is not threadsafe.
|
|
static Float64 lgamma_wrapper(Float64 arg)
|
|
{
|
|
int signp;
|
|
return lgamma_r(arg, &signp);
|
|
}
|
|
|
|
struct LGammaName { static constexpr auto name = "lgamma"; };
|
|
using FunctionLGamma = FunctionMathUnary<UnaryFunctionPlain<LGammaName, lgamma_wrapper>>;
|
|
|
|
void registerFunctionLGamma(FunctionFactory & factory)
|
|
{
|
|
factory.registerFunction<FunctionLGamma>();
|
|
}
|
|
|
|
}
|