Skip to content

Commit b8be27e

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

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

libcxx/include/__random/binomial_distribution.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,23 @@ 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 defined(_LIBCPP_GLIBC_PREREQ)
102+
# if _LIBCPP_GLIBC_PREREQ(2, 8)
103+
# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
104+
# endif
105+
#elif defined(__LLVM_LIBC__)
106+
# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
107+
#else
108+
# define _LIBCPP_LGAMMA_R_NOEXCEPT
109+
#endif
110+
111+
#if !defined(_LIBCPP_MSVCRT_LIKE)
112+
extern "C" double lgamma_r(double, int*) _LIBCPP_LGAMMA_R_NOEXCEPT;
103113
#endif
104114

105115
inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) {
106-
#if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__)
116+
#if defined(_LIBCPP_MSVCRT_LIKE)
107117
return lgamma(__d);
108118
#else
109119
int __sign;

0 commit comments

Comments
 (0)