[libcxx-commits] [libcxx] 5f2389d - [libc++] Do not redeclare lgamma_r when targeting the LLVM C library (#102036)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 27 14:46:07 PDT 2024
Author: Joseph Huber
Date: 2024-08-27T17:46:03-04:00
New Revision: 5f2389d49fef36ed2e97dcc6b54036542c160a36
URL: https://github.com/llvm/llvm-project/commit/5f2389d49fef36ed2e97dcc6b54036542c160a36
DIFF: https://github.com/llvm/llvm-project/commit/5f2389d49fef36ed2e97dcc6b54036542c160a36.diff
LOG: [libc++] Do not redeclare lgamma_r when targeting the LLVM C library (#102036)
We use lgamma_r for the random normal distribution support. In this
code we redeclare it, which causes issues with the LLVM C library as
this function is marked noexcept in LLVM libc. This patch ensures that
we don't redeclare that function when targeting LLVM libc.
Added:
Modified:
libcxx/include/__configuration/platform.h
libcxx/include/__random/binomial_distribution.h
Removed:
################################################################################
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index 27f68d04e8a8d9..2a92ce209b91f8 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -30,15 +30,18 @@
// ... add new file formats here ...
#endif
-// Need to detect which libc we're using if we're on Linux.
-#if defined(__linux__)
+// To detect which libc we're using
+#if __has_include(<features.h>)
# include <features.h>
+#endif
+
+#if defined(__linux__)
# if defined(__GLIBC_PREREQ)
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
# else
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
# endif // defined(__GLIBC_PREREQ)
-#endif // defined(__linux__)
+#endif
#ifndef __BYTE_ORDER__
# error \
diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h
index e8774bb8d67ee1..3f19746bae238c 100644
--- a/libcxx/include/__random/binomial_distribution.h
+++ b/libcxx/include/__random/binomial_distribution.h
@@ -97,7 +97,8 @@ class _LIBCPP_TEMPLATE_VIS binomial_distribution {
}
};
-#ifndef _LIBCPP_MSVCRT_LIKE
+// The LLVM C library provides this with conflicting `noexcept` attributes.
+#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__)
extern "C" double lgamma_r(double, int*);
#endif
More information about the libcxx-commits
mailing list