summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2005-02-07 17:56:20 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2005-02-07 17:56:20 (GMT)
commit3ca585e46cf4dd53be7eaded5484a9ff496d2312 (patch)
treea7fb446a8a05288107ac20a01972928a97d2a4a8 /src/H5detect.c
parentb9d5eb15435f6480fda9d60f34a1faa5c01edbf1 (diff)
downloadhdf5-3ca585e46cf4dd53be7eaded5484a9ff496d2312.zip
hdf5-3ca585e46cf4dd53be7eaded5484a9ff496d2312.tar.gz
hdf5-3ca585e46cf4dd53be7eaded5484a9ff496d2312.tar.bz2
[svn-r9951] Purpose: Minor bug fix.
Description: The byte order for all 1-byte integer types was fixed as little-endian even on a big-endian machine. This's corrected in h5detect.c. When types are only 1 byte long, a native int is used substitute the type to detect byte order. Some tools like h5dump and h5repack are also corrected in this case. Platforms tested: fuss, copper, sol.(There're some failures from the recent configure change). Misc. update: Information in the RELEASE.txt.
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index b79911d..73ded41 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -195,17 +195,31 @@ precision (detected_t *d)
*/
#define DETECT_I(TYPE,VAR,INFO) { \
TYPE _v; \
+ int _int_v; \
int _i, _j; \
unsigned char *_x; \
+ \
memset (&INFO, 0, sizeof(INFO)); \
INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
- for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
- for (_i=0,_x=(unsigned char *)&_v; _i<(signed)sizeof(TYPE); _i++) { \
- _j = (*_x++)-1; \
- assert (_j<(signed)sizeof(TYPE)); \
- INFO.perm[_i] = _j; \
- } \
+ \
+ if(sizeof(TYPE)!=1) { \
+ for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
+ for (_i=0,_x=(unsigned char *)&_v; _i<(signed)sizeof(TYPE); _i++) { \
+ _j = (*_x++)-1; \
+ assert (_j<(signed)sizeof(TYPE)); \
+ INFO.perm[_i] = _j; \
+ } \
+ } else { /*Not able to detect order if type size is 1 byte. Use native int \
+ *instead. No effect on data, just make it look correct. */ \
+ for (_i=sizeof(int),_int_v=0; _i>0; --_i) _int_v = (_int_v<<8) + _i; \
+ for (_i=0,_x=(unsigned char *)&_int_v; _i<(signed)sizeof(int); _i++) { \
+ _j = (*_x++)-1; \
+ assert (_j<(signed)sizeof(int)); \
+ INFO.perm[_i] = _j; \
+ } \
+ } \
+ \
INFO.sign = ('U'!=*(#VAR)); \
precision (&(INFO)); \
ALIGNMENT(TYPE, INFO); \