diff options
| author | Eric Fiselier <eric@efcs.ca> | 2017-05-06 02:58:43 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2017-05-06 02:58:43 +0000 |
| commit | 28d89dbd3fc9a175bb2ad1964d17d9149d9f2526 (patch) | |
| tree | af30be46f7aee75747b4cecea98e6c15091a8605 /libcxx/include/random | |
| parent | 99c86baab754e7386be3dc5bb6392f78e27b510e (diff) | |
| download | bcm5719-llvm-28d89dbd3fc9a175bb2ad1964d17d9149d9f2526.tar.gz bcm5719-llvm-28d89dbd3fc9a175bb2ad1964d17d9149d9f2526.zip | |
Fix lgamma_r linking errors on Windows. It appears the normal lgamma function is thread safe anyway
llvm-svn: 302330
Diffstat (limited to 'libcxx/include/random')
| -rw-r--r-- | libcxx/include/random | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libcxx/include/random b/libcxx/include/random index c83db12af30..6c36e8c01ae 100644 --- a/libcxx/include/random +++ b/libcxx/include/random @@ -3997,7 +3997,18 @@ public: {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 @@ binomial_distribution<_IntType>::param_type::param_type(const result_type __t, c { 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_); } |

