diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-05-16 15:18:10 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-05-16 15:18:10 (GMT) |
commit | 3edbf40ed20587c9ad742e51657047836967e4b5 (patch) | |
tree | 1384c3781ccf2b8ce7f9b0fcab97d94a8541155b /src | |
parent | d792fc837dc2e4e65211b3a9b13ac30343263610 (diff) | |
download | hdf5-3edbf40ed20587c9ad742e51657047836967e4b5.zip hdf5-3edbf40ed20587c9ad742e51657047836967e4b5.tar.gz hdf5-3edbf40ed20587c9ad742e51657047836967e4b5.tar.bz2 |
[svn-r6884] Purpose: bug fix
Description: H5Tget_native_type didn't handle special platform like Cray properly.
Solution: modify algorithm and test
Platforms tested: h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Tnative.c | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/src/H5Tnative.c b/src/H5Tnative.c index a143496..3cd6789 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -527,29 +527,45 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction, assert(size>0); if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(size==sizeof(char)) + if(size<=sizeof(char)) match=H5T_NATIVE_INT_MATCH_CHAR; - else if(size==sizeof(short)) + else if(size<=sizeof(short)) match=H5T_NATIVE_INT_MATCH_SHORT; - else if(size==sizeof(int)) + else if(size<=sizeof(int)) match=H5T_NATIVE_INT_MATCH_INT; - else if(size==sizeof(long)) + else if(size<=sizeof(long)) match=H5T_NATIVE_INT_MATCH_LONG; - else if(size==sizeof(long_long)) + else if(size<=sizeof(long_long)) match=H5T_NATIVE_INT_MATCH_LLONG; else /* If no native type matches the querried datatype, simply choose the type of biggest size. */ match=H5T_NATIVE_INT_MATCH_LLONG; } else if(direction == H5T_DIR_DESCEND) { - if(size==sizeof(long_long)) + if(size>=sizeof(long_long)) match=H5T_NATIVE_INT_MATCH_LLONG; - else if(size==sizeof(long)) - match=H5T_NATIVE_INT_MATCH_LONG; - else if(size==sizeof(int)) - match=H5T_NATIVE_INT_MATCH_INT; - else if(size==sizeof(short)) - match=H5T_NATIVE_INT_MATCH_SHORT; - else if(size==sizeof(char)) - match=H5T_NATIVE_INT_MATCH_CHAR; + else if(size>=sizeof(long)) { + if(size==sizeof(long)) + match=H5T_NATIVE_INT_MATCH_LONG; + else + match=H5T_NATIVE_INT_MATCH_LLONG; + } + else if(size>=sizeof(int)) { + if(size==sizeof(int)) + match=H5T_NATIVE_INT_MATCH_INT; + else + match=H5T_NATIVE_INT_MATCH_LONG; + } + else if(size>=sizeof(short)) { + if(size==sizeof(short)) + match=H5T_NATIVE_INT_MATCH_SHORT; + else + match=H5T_NATIVE_INT_MATCH_INT; + } + else if(size>=sizeof(char)) { + if(size==sizeof(char)) + match=H5T_NATIVE_INT_MATCH_CHAR; + else + match=H5T_NATIVE_INT_MATCH_SHORT; + } else /* If no native type matches the querried datatype, simple choose the type of smallest size. */ match=H5T_NATIVE_INT_MATCH_CHAR; } @@ -657,21 +673,29 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig assert(size>0); if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(size==sizeof(float)) + if(size<=sizeof(float)) match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - else if(size==sizeof(double)) + else if(size<=sizeof(double)) match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - else if(size==sizeof(long double)) + else if(size<=sizeof(long double)) match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; else /* If not match, return the biggest datatype */ match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; } else { - if(size==sizeof(long double)) + if(size>=sizeof(long double)) match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - else if(size==sizeof(double)) - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - else if(size==sizeof(float)) - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; + else if(size>=sizeof(double)) { + if(size==sizeof(double)) + match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; + else + match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + } + else if(size>=sizeof(float)) { + if(size==sizeof(float)) + match=H5T_NATIVE_FLOAT_MATCH_FLOAT; + else + match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; + } else match=H5T_NATIVE_FLOAT_MATCH_FLOAT; } |