hdf5/PPC64LE-Fix-long-double-handling.patch
Dirk Stoecker aa78456748 Accepting request 1173662 from home:badshah400:branches:science
* Update to version 1.12.3.
* Drop upstreamed patches: Remove-duplicate-code.patch, H5O__pline_decode-Make-more-resilient-to-out-of-bounds-read.patch, H5O_dtype_decode_helper-Parent-of-enum-needs-to-have-same-size-as-enum-itself.patch, Pass-compact-chunk-size-info-to-ensure-requested-elements-are-within-bounds.patch, Make-sure-info-block-for-external-links-has-at-least-3-bytes.patch, Compound-datatypes-may-not-have-members-of-size-0.patch, H5IMget_image_info-H5Sget_simple_extent_dims-does-not-exceed-array-size.patch, Check-for-overflow-when-calculating-on-disk-attribute-data-size-2459.patch
* New BuildRequires: hostname.
* Work around an sed hack in upstream configure file by dropping "-Werror=return-type" from RPM %optflags.

OBS-URL: https://build.opensuse.org/request/show/1173662
OBS-URL: https://build.opensuse.org/package/show/science/hdf5?expand=0&rev=174
2024-05-14 15:19:49 +00:00

93 lines
3.9 KiB
Diff

From: Egbert Eich <eich@suse.com>
Date: Tue Nov 7 14:16:53 2017 +0100
Subject: [PATCH]PPC64LE: Fix long double handling
Git-commit: ad6559a71b7ba3cacb4b56d4747db63f28a12f55
References:
Signed-off-by: Egbert Eich <eich@suse.com>
Signed-off-by: Egbert Eich <eich@suse.com>
---
config/cmake/ConversionTests.c | 16 ++++++++++++++++
test/dt_arith.c | 27 +++++++++++++++++++++++++--
2 files changed, 41 insertions(+), 2 deletions(-)
Index: hdf5-1.12.3/test/dt_arith.c
===================================================================
--- hdf5-1.12.3.orig/test/dt_arith.c
+++ hdf5-1.12.3/test/dt_arith.c
@@ -3035,7 +3035,19 @@ test_conv_flt_1(const char *name, int ru
#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
}
else if (src_type == FLT_LDOUBLE) {
- INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts);
+ size_t mant_dig = LDBL_MANT_DIG;
+ if (mant_dig >= src_nbits) {
+ /* This happens for IBM long double in little endian.
+ The macro LDBL_MANT_DIG says 106 mantissa bits, but the
+ HDF5 detection code actually represents it as a normal 64bit
+ double (52 bit mantissa) with the upper double being
+ unspec bits (which is sort of okay as the testsuite
+ wouldn't deal with that format correctly anyway). So
+ override the mantissa size. */
+ mant_dig = 52;
+ }
+ INIT_FP_SPECIAL(src_size, src_nbits, sendian, mant_dig, dst_size,
+ buf, saved, nelmts);
#endif
}
else
@@ -3735,7 +3747,18 @@ test_conv_int_fp(const char *name, int r
nelmts);
}
else {
- INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts);
+ size_t mant_dig = LDBL_MANT_DIG;
+ if (mant_dig >= src_nbits) {
+ /* This happens for IBM long double in little endian.
+ The macro LDBL_MANT_DIG says 106 mantissa bits, but the
+ HDF5 detection code actually represents it as a normal 64bit
+ double (52 bit mantissa) with the upper double being
+ unspec bits (which is sort of okay as the testsuite
+ wouldn't deal with that format correctly anyway). So
+ override the mantissa size. */
+ mant_dig = 52;
+ }
+ INIT_FP_SPECIAL(src_size, src_nbits, sendian, mant_dig, dst_size, buf, saved, nelmts);
}
#endif
}
Index: hdf5-1.12.3/config/cmake/ConversionTests.c
===================================================================
--- hdf5-1.12.3.orig/config/cmake/ConversionTests.c
+++ hdf5-1.12.3/config/cmake/ConversionTests.c
@@ -34,6 +34,14 @@ int HDF_NO_UBSAN main(void)
unsigned char s2[8];
int ret = 1;
+#if defined __powerpc64__ && defined _LITTLE_ENDIAN
+ /* Don't bother checking on ppc64le, we know it'll work, and
+ that what hdf5 calls 'special algorithm' simply is
+ IBM ldouble 128 (i.e. two seperately scaled doubles).
+ The check below assumes big endian. */
+ ret = 0;
+#endif
+
if (sizeof(long double) == 16 && sizeof(long) == 8) {
/* Make sure the long double type has 16 bytes in size and
* 11 bits of exponent. If it is, the bit sequence should be
@@ -174,6 +182,14 @@ int HDF_NO_UBSAN main(void)
unsigned char s[16];
int ret = 0;
+#if defined __powerpc64__ && defined _LITTLE_ENDIAN
+ /* Don't bother checking on ppc64le, we know it'll work, and
+ that what hdf5 calls 'special algorithm' simply is
+ IBM ldouble 128 (i.e. two seperately scaled doubles).
+ The check below assumes big endian. */
+ ret = 0;
+#endif
+
if (sizeof(long double) == 16) {
/* Make sure the long double type is the same as the failing type
* which has 16 bytes in size and 11 bits of exponent. If it is,