File: 0012-Deactivate-further-overloads-for-__float128-if-it-is.patch

package info (click to toggle)
opm-common 2025.04%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 98,816 kB
  • sloc: cpp: 277,946; python: 3,553; sh: 198; xml: 174; pascal: 136; makefile: 12
file content (109 lines) | stat: -rw-r--r-- 3,185 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From: Markus Blatt <markus@dr-blatt.de>
Date: Wed, 17 Sep 2025 18:55:59 +0200
Subject: Deactivate further overloads for __float128 if it is long double.

This fixes compilation on pc64el.
---
 cmake/Modules/FindQuadMath.cmake | 16 +++++++++++++++-
 opm/material/common/quad.hpp     | 10 +++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/cmake/Modules/FindQuadMath.cmake b/cmake/Modules/FindQuadMath.cmake
index 7712379..96873f6 100644
--- a/cmake/Modules/FindQuadMath.cmake
+++ b/cmake/Modules/FindQuadMath.cmake
@@ -55,8 +55,22 @@ if(QuadMath_FOUND AND NOT TARGET QuadMath::QuadMath)
      static_assert(std::numeric_limits<__float128>::is_specialized);
      return 0;
   }" QuadMath_HAS_LIMITS)
-  cmake_pop_check_state()  # Reset CMAKE_REQUIRED_XXX variables
+
   if(QuadMath_HAS_LIMITS)
     target_compile_definitions(QuadMath::QuadMath INTERFACE LIMITS_HAS_QUAD=1)
   endif()
+  check_cxx_source_compiles("
+  #include <limits>
+  #include <iostream>
+  int main()
+  {
+     __float128 b=0;
+     std::cout<<b;
+     return 0;
+  }" QuadMath_HAS_IO_OPERATOR)
+  cmake_pop_check_state()  # Reset CMAKE_REQUIRED_XXX variables
+  if(QuadMath_HAS_IO_OPERATOR)
+    target_compile_definitions(QuadMath::QuadMath INTERFACE QUADMATH_HAS_IO_OPERATOR=1)
+  endif()
+
 endif()
diff --git a/opm/material/common/quad.hpp b/opm/material/common/quad.hpp
index cd32c71..9f4c10a 100644
--- a/opm/material/common/quad.hpp
+++ b/opm/material/common/quad.hpp
@@ -246,6 +246,7 @@ struct is_convertible<quad, OtherType>
     : public is_arithmetic<OtherType>
 { };
 
+#if !QUADMATH_HAS_IO_OPERATOR
 inline std::ostream& operator<<(std::ostream& os, const quad& val)
 {
     if (os.precision() > std::numeric_limits<double>::digits10)
@@ -256,13 +257,14 @@ inline std::ostream& operator<<(std::ostream& os, const quad& val)
     return os << static_cast<double>(val);
 }
 
-inline std::istream& operator>>(std::istream& is, quad& val)
+inline typename std::istream& operator>>(std::istream& is, quad& val)
 {
     double tmp = 0.0;
     std::istream& ret = (is >> tmp);
     val = tmp;
     return ret;
 }
+#endif
 
 inline quad real(quad val)
 { return val; }
@@ -276,6 +278,7 @@ inline quad imag(quad)
 inline quad imag(const std::complex<quad>& val)
 { return val.imag(); }
 
+#if !LIMITS_HAS_QUAD
 inline quad abs(quad val)
 { return (val < 0) ? -val : val; }
 
@@ -284,6 +287,7 @@ inline quad floor(quad val)
 
 inline quad ceil(quad val)
 { return ceilq(val); }
+#endif
 
 inline quad max(quad a, quad b)
 { return (a > b) ? a : b; }
@@ -291,8 +295,10 @@ inline quad max(quad a, quad b)
 inline quad min(quad a, quad b)
 { return (a < b) ? a : b; }
 
+#if !LIMITS_HAS_QUAD
 inline quad sqrt(quad val)
 { return sqrtq(val); }
+#endif
 
 template <class ExpType>
 inline quad pow(quad base, ExpType exp)
@@ -302,6 +308,7 @@ template <class BaseType>
 inline quad pow(BaseType base, quad exp)
 { return powq(static_cast<quad>(base), exp); }
 
+#if !LIMITS_HAS_QUAD
 inline quad pow(quad base, quad exp)
 { return powq(base, exp); }
 
@@ -337,6 +344,7 @@ inline bool isnan(quad val)
 
 inline bool isinf(quad val)
 { return isinfq(val); }
+#endif
 
 } // namespace std