summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-04-28 20:57:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-04-28 20:57:44 (GMT)
commitd0a1730ad855a181e5d7f31071c29a131b1449bd (patch)
tree55dc8a66837dae832cc2ca6585bae1ed6c57ce2f /src/H5detect.c
parent1c2f19b16e8cf20651b8893cfff884c9635586bd (diff)
downloadhdf5-d0a1730ad855a181e5d7f31071c29a131b1449bd.zip
hdf5-d0a1730ad855a181e5d7f31071c29a131b1449bd.tar.gz
hdf5-d0a1730ad855a181e5d7f31071c29a131b1449bd.tar.bz2
[svn-r18661] Description:
Tweak H5detect to be even more careful about its actions, to allow gcc 4.5 to use '-O3'. Also, minor code cleanups in H5Tfloat.c Tested on: FreeBSD/64 6.3 (liberty) w/gcc 4.5 & production mode (h5committest not necessary/appropriate)
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index 1cfce96..5bae2bb 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -288,33 +288,39 @@ precision (detected_t *d)
*-------------------------------------------------------------------------
*/
#define DETECT_F(TYPE,VAR,INFO) { \
- volatile TYPE _v1, _v2, _v3; \
- int _i, _j, _first=(-1), _last=(-1); \
+ volatile TYPE _v1, _v2, _v3; \
+ unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \
+ int _i, _j, _first = (-1), _last = (-1); \
char *_mesg; \
\
- memset (&INFO, 0, sizeof(INFO)); \
+ memset(&INFO, 0, sizeof(INFO)); \
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)); \
+ 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; \
- _j=byte_cmp(sizeof(TYPE), &_v3, &_v1); \
- if(_j>=0) { \
- if (0==_i || INFO.perm[_i-1]!=_j) { \
+ for(_i = 0, _v1 = 0.0, _v2 = 1.0; _i < (int)sizeof(TYPE); _i++) { \
+ _v3 = _v1; \
+ _v1 += _v2; \
+ _v2 /= 256.0; \
+ memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
+ memcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \
+ _j = byte_cmp(sizeof(TYPE), &_buf3, &_buf1); \
+ if(_j >= 0) { \
+ if(0 == _i || INFO.perm[_i - 1] != _j) { \
INFO.perm[_i] = _j; \
_last = _i; \
- if (_first<0) _first = _i; \
+ if(_first < 0) \
+ _first = _i; \
} \
} \
} \
- fix_order (sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \
+ fix_order(sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \
\
if(!strcmp(_mesg, "VAX")) \
INFO.is_vax = TRUE; \