summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-09-04 21:22:29 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-09-04 21:22:29 (GMT)
commitefda170169f7d61ab076ed49125282203bbcaa90 (patch)
tree8aa49af63d3072f9ada198f2924d1a9fd3466adf
parentdc5a388f8d2093cb7f43d6d93c9f6fb055fde58a (diff)
downloadhdf5-efda170169f7d61ab076ed49125282203bbcaa90.zip
hdf5-efda170169f7d61ab076ed49125282203bbcaa90.tar.gz
hdf5-efda170169f7d61ab076ed49125282203bbcaa90.tar.bz2
[svn-r4423] Purpose:
Thread-safety Bug Fixes Description: FreeBSD must use a different layout or mechanism for allocating objects on the stack when compiling for thread-safe operation. Unused bits in 'long double' variable are never used ('long double's on FreeBSD are stored in 12 bytes, but only use 10 bytes for computations), but set to different values, causing the endianness permutation testing to generate incorrect results and eventually fail an assertion. Solution: Clear the temporary variables used for determining the endianness permutation with memset (affecting all 12 bytes) instead of just assigning a 0.0 to them (affecting only 10 bytes) Platforms tested: FreeBSD 4.4 (hawkwind)
-rw-r--r--src/H5detect.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index c48e9a5..5955f23 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -203,6 +203,12 @@ precision (detected_t *d)
INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
\
+ /* Completely initialize temporary variables, in case the bits used in */ \
+ /* the type take less space than the number of bits used to store the type */ \
+ memset(&_v3,0,sizeof(TYPE)); \
+ memset(&_v2,0,sizeof(TYPE)); \
+ memset(&_v1,0,sizeof(TYPE)); \
+ \
/* Byte Order */ \
for (_i=0,_v1=0.0,_v2=1.0; _i<(signed)sizeof(TYPE); _i++) { \
_v3 = _v1; _v1 += _v2; _v2 /= 256.0; \