Skip to content

Commit b97b5cc

Browse files
authored
Merge pull request #978 from cppalliance/977
Fix duplicate symbols on some PPC64 platforms
2 parents 5a02e6a + 92eaf39 commit b97b5cc

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

include/boost/decimal/detail/config.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,20 @@ typedef unsigned __int128 builtin_uint128_t;
382382

383383
#endif // Exceptions
384384

385+
#ifndef BOOST_DECIMAL_BULID_MODULE
386+
# include <cfloat>
387+
# include <type_traits>
388+
#endif
389+
390+
// Check for PPC64LE with IEEE long double (which is an alias to __float128) or x64 with "-mlong-double-128"
391+
//
392+
// IBM128 has 106 Mantissa Digits whereas IEEE128 has 113
393+
// https://developers.redhat.com/articles/2023/05/16/benefits-fedora-38-long-double-transition-ppc64le#
394+
#if ((defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) && (defined(__LONG_DOUBLE_IEEE128__) || LDBL_MANT_DIG == 113))
395+
396+
#define BOOST_DECIMAL_LDBL_IS_FLOAT128
397+
static_assert(std::is_same<long double, __float128>::value, "__float128 should be an alias to long double. Please open an issue at: https://github.com/cppalliance/decimal");
398+
399+
#endif
400+
385401
#endif // BOOST_DECIMAL_DETAIL_CONFIG_HPP

include/boost/decimal/detail/ryu/ryu_generic_128.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ BOOST_DECIMAL_CXX20_CONSTEXPR auto floating_point_to_fd128<long double>(long dou
348348

349349
#endif
350350

351-
#if defined(BOOST_DECIMAL_HAS_FLOAT128)
351+
#if defined(BOOST_DECIMAL_HAS_FLOAT128) && !defined(BOOST_DECIMAL_LDBL_IS_FLOAT128)
352352

353353
template <>
354354
BOOST_DECIMAL_CXX20_CONSTEXPR auto floating_point_to_fd128<__float128>(__float128 val) noexcept -> floating_decimal_128

include/boost/decimal/detail/type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ constexpr bool is_integral_v = is_integral<T>::value;
121121
template <typename T>
122122
struct is_floating_point { static constexpr bool value = std::is_floating_point<T>::value; };
123123

124-
#ifdef BOOST_DECIMAL_HAS_FLOAT128
124+
#if defined(BOOST_DECIMAL_HAS_FLOAT128) && !defined(BOOST_DECIMAL_LDBL_IS_FLOAT128)
125125
template <>
126126
struct is_floating_point<__float128> { static constexpr bool value = true; };
127127
#endif

0 commit comments

Comments
 (0)