Fix lgamma_r linking errors on Windows. It appears the normal lgamma function is thread safe anyway
llvm-svn: 302330
diff --git a/libcxx/include/random b/libcxx/include/random
index c83db12..6c36e8c 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -3997,7 +3997,18 @@
{return !(__x == __y);}
};
+#ifndef _LIBCPP_MSVCRT
extern "C" double lgamma_r(double, int *);
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {
+#if defined(_LIBCPP_MSVCRT)
+ return lgamma(__d);
+#else
+ int __sign;
+ return lgamma_r(__d, &__sign);
+#endif
+}
template<class _IntType>
binomial_distribution<_IntType>::param_type::param_type(const result_type __t, const double __p)
@@ -4005,11 +4016,10 @@
{
if (0 < __p_ && __p_ < 1)
{
- int __sign;
__r0_ = static_cast<result_type>((__t_ + 1) * __p_);
- __pr_ = _VSTD::exp(lgamma_r(__t_ + 1., &__sign) -
- lgamma_r(__r0_ + 1., &__sign) -
- lgamma_r(__t_ - __r0_ + 1., &__sign) + __r0_ * _VSTD::log(__p_) +
+ __pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) -
+ __libcpp_lgamma(__r0_ + 1.) -
+ __libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
(__t_ - __r0_) * _VSTD::log(1 - __p_));
__odds_ratio_ = __p_ / (1 - __p_);
}