[libcxx-commits] [libcxx] [libcxx] Use `lgamma` rather than `lgamma_r` with LLVM libc (PR #109556)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 1 13:21:28 PDT 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/109556

>From c34a87ba0d849e9d9e1b4bda524306c4e6179fea Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Sat, 21 Sep 2024 18:51:01 -0700
Subject: [PATCH] [libcxx] Use lgamma rather than lgamma_r with LLVM libc

lgamma_r is currently only available on GPU targets.
---
 libcxx/include/__random/binomial_distribution.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h
index 3f19746bae238c..9538c15e2dc97b 100644
--- a/libcxx/include/__random/binomial_distribution.h
+++ b/libcxx/include/__random/binomial_distribution.h
@@ -103,7 +103,7 @@ extern "C" double lgamma_r(double, int*);
 #endif
 
 inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) {
-#if defined(_LIBCPP_MSVCRT_LIKE)
+#if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__)
   return lgamma(__d);
 #else
   int __sign;



More information about the libcxx-commits mailing list