Control: tags -1 + patch

On ppc64el, the build failure occurred because both quad-precision implementations were enabled simultaneously: one using the native IEEE-754 128-bit long double, and the other using libquadmath.

The error: ‘fpclassifyq’ was not declared in this scope
occurs because required quad-math helper macros, such as fpclassifyq and ldexpq, were not defined consistently when both paths were active.

In the source src/include/testerutil.hpp both of the following blocks are enabled in case of ppc64el

#ifdef QUADMATH_H
#define ENABLE_QUAD
typedef __float128 quad
#define M_PIq_ M_PIq

std::ostream& operator<<(std::ostream &os, const __float128& f) {
  char buf[128];
  quadmath_snprintf(buf, sizeof(buf), "%.32Qg", f);
  return os << std::string(buf);
}
#endif

#ifdef TLFLOAT_LONGDOUBLE_IS_FLOAT128
#define ENABLE_QUAD
typedef long double quad;
#define fabsq fabsl
#define fmaq fmal
#define sqrtq sqrtl
#define ilogbq ilogbl
#define finiteq finitel
#define isnanq isnanl
#define isinfq isinfl
#define truncq truncl
#define floorq floorl
#define ceilq ceill
#define roundq roundl
#define rintq rintl
#define M_PIq_ M_PIl
#endif


Because these two code paths were not separated, the quad type was defined more than once, macros were redefined, required quad-math helpers such as fpclassifyq and ldexpq were missing, and the compiler became confused about which functions to use, causing the build to fail.


The attached patch addresses this by:


--- tlfloat-1.15.0.orig/src/include/testerutil.hpp
+++ tlfloat-1.15.0/src/include/testerutil.hpp
@@ -322,19 +322,9 @@ bool equal(BigUInt<7> u0, __uint128_t b0

 //

-#ifdef QUADMATH_H
-#define ENABLE_QUAD
-typedef __float128 quad;
-#define M_PIq_ M_PIq
-
-std::ostream& operator<<(std::ostream &os, const __float128& f) {
-  char buf[128];
-  quadmath_snprintf(buf, sizeof(buf), "%.32Qg", f);
-  return os << std::string(buf);
-}
-#endif

 #ifdef TLFLOAT_LONGDOUBLE_IS_FLOAT128
+// Native 128-bit long double (ppc64el, etc.) - prefer over libquadmath
 #define ENABLE_QUAD
 typedef long double quad;
 #define fabsq fabsl
@@ -349,7 +339,22 @@ typedef long double quad;
 #define ceilq ceill
 #define roundq roundl
 #define rintq rintl
+#define fpclassifyq fpclassify
+#define ldexpq ldexpl
 #define M_PIq_ M_PIl
+#elif QUADMATH_H
+// libquadmath __float128 (x86, etc.)
+#define ENABLE_QUAD
+typedef __float128 quad;
+#define fpclassifyq fpclassify
+#define ldexpq ldexpl
+#define M_PIq_ M_PIq
+
+std::ostream& operator<<(std::ostream &os, const __float128& f) {
+  char buf[128];
+  quadmath_snprintf(buf, sizeof(buf), "%.32Qg", f);
+  return os << std::string(buf);
+}
 #endif


making the native long double and libquadmath code paths mutually exclusive providing the required quad-math macro definitions in both implementations

With this fix applied, tlfloat builds successfully on ppc64el.

The patch has been shared for review. Please let me know if you have any suggestions or if further adjustments are needed.

The changes still need to be checked on other architectures.


Thanks,
Trupti
Description:

 Fix quad-precision macro and typedef conflicts on ppc64el
 by making  native 128-bit long double and libquadmath 
 blocks mutually exclusive, and defining fpclassifyq and 
 ldexpq macros in both blocks for portability.


--- tlfloat-1.15.0.orig/src/include/testerutil.hpp
+++ tlfloat-1.15.0/src/include/testerutil.hpp
@@ -322,19 +322,9 @@ bool equal(BigUInt<7> u0, __uint128_t b0
 
 //
 
-#ifdef QUADMATH_H
-#define ENABLE_QUAD
-typedef __float128 quad;
-#define M_PIq_ M_PIq
-
-std::ostream& operator<<(std::ostream &os, const __float128& f) {
-  char buf[128];
-  quadmath_snprintf(buf, sizeof(buf), "%.32Qg", f);
-  return os << std::string(buf);
-}
-#endif
 
 #ifdef TLFLOAT_LONGDOUBLE_IS_FLOAT128
+// Native 128-bit long double (ppc64el, etc.) - prefer over libquadmath
 #define ENABLE_QUAD
 typedef long double quad;
 #define fabsq fabsl
@@ -349,7 +339,22 @@ typedef long double quad;
 #define ceilq ceill
 #define roundq roundl
 #define rintq rintl
+#define fpclassifyq fpclassify
+#define ldexpq ldexpl
 #define M_PIq_ M_PIl
+#elif QUADMATH_H
+// libquadmath __float128 (x86, etc.)
+#define ENABLE_QUAD
+typedef __float128 quad;
+#define fpclassifyq fpclassify
+#define ldexpq ldexpl
+#define M_PIq_ M_PIq
+
+std::ostream& operator<<(std::ostream &os, const __float128& f) {
+  char buf[128];
+  quadmath_snprintf(buf, sizeof(buf), "%.32Qg", f);
+  return os << std::string(buf);
+}
 #endif
 
 #ifdef _MSC_VER

Reply via email to