Skip to content

Commit ae1da16

Browse files
[libc++] Conditionally declarelgamma_r as noexcept
1 parent 3ed91d8 commit ae1da16

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

libcxx/include/__random/binomial_distribution.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,19 @@ class binomial_distribution {
9797
}
9898
};
9999

100-
// The LLVM C library provides this with conflicting `noexcept` attributes.
101-
#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__)
102-
extern "C" double lgamma_r(double, int*);
100+
// Some libc declares the math functions to be `noexcept`.
101+
#if _LIBCPP_GLIBC_PREREQ(2, 8) || defined(__LLVM_LIBC__)
102+
# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
103+
else
104+
# define _LIBCPP_LGAMMA_R_NOEXCEPT
105+
#endif
106+
107+
#if !defined(_LIBCPP_MSVCRT_LIKE)
108+
extern "C" double lgamma_r(double, int*) _LIBCPP_LGAMMA_R_NOEXCEPT;
103109
#endif
104110

105111
inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) {
106-
#if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__)
112+
#if defined(_LIBCPP_MSVCRT_LIKE)
107113
return lgamma(__d);
108114
#else
109115
int __sign;

0 commit comments

Comments
 (0)