summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Tnative.c98
1 files changed, 68 insertions, 30 deletions
diff --git a/src/H5Tnative.c b/src/H5Tnative.c
index 4516ddd..6248e27 100644
--- a/src/H5Tnative.c
+++ b/src/H5Tnative.c
@@ -524,6 +524,7 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction,
H5T_t *dt; /* Appropriate native datatype to copy */
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
size_t align=0; /* Alignment necessary for native datatype */
+ size_t native_size=0; /* Datatype size of the native type */
enum match_type { /* The different kinds of integers we can match */
H5T_NATIVE_INT_MATCH_CHAR,
H5T_NATIVE_INT_MATCH_SHORT,
@@ -539,47 +540,69 @@ 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))
+ native_size = sizeof(char);
+ } else if(size<=sizeof(short)) {
match=H5T_NATIVE_INT_MATCH_SHORT;
- else if(size<=sizeof(int))
+ native_size = sizeof(short);
+ } else if(size<=sizeof(int)) {
match=H5T_NATIVE_INT_MATCH_INT;
- else if(size<=sizeof(long))
+ native_size = sizeof(int);
+ } else if(size<=sizeof(long)) {
match=H5T_NATIVE_INT_MATCH_LONG;
- else if(size<=sizeof(long_long))
+ native_size = sizeof(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. */
+ native_size = sizeof(long long);
+ } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */
match=H5T_NATIVE_INT_MATCH_LLONG;
+ native_size = sizeof(long long);
+ }
} 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)) {
- if(size==sizeof(long))
+ native_size = sizeof(long long);
+ } else if(size>=sizeof(long)) {
+ if(size==sizeof(long)) {
match=H5T_NATIVE_INT_MATCH_LONG;
- else
+ native_size = sizeof(long);
+ } else {
match=H5T_NATIVE_INT_MATCH_LLONG;
+ native_size = sizeof(long long);
+ }
}
else if(size>=sizeof(int)) {
- if(size==sizeof(int))
+ if(size==sizeof(int)) {
match=H5T_NATIVE_INT_MATCH_INT;
- else
+ native_size = sizeof(int);
+ } else {
match=H5T_NATIVE_INT_MATCH_LONG;
+ native_size = sizeof(long);
+ }
}
else if(size>=sizeof(short)) {
- if(size==sizeof(short))
+ if(size==sizeof(short)) {
match=H5T_NATIVE_INT_MATCH_SHORT;
- else
+ native_size = sizeof(short);
+ } else {
match=H5T_NATIVE_INT_MATCH_INT;
+ native_size = sizeof(int);
+ }
}
else if(size>=sizeof(char)) {
- if(size==sizeof(char))
+ if(size==sizeof(char)) {
match=H5T_NATIVE_INT_MATCH_CHAR;
- else
+ native_size = sizeof(char);
+ } else {
match=H5T_NATIVE_INT_MATCH_SHORT;
+ native_size = sizeof(short);
+ }
}
- else /* If no native type matches the querried datatype, simple choose the type of smallest size. */
+ else { /* If no native type matches the querried datatype, simple choose the type of smallest size. */
match=H5T_NATIVE_INT_MATCH_CHAR;
+ native_size = sizeof(char);
+ }
}
/* Set the appropriate native datatype information */
@@ -641,7 +664,7 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
/* compute size and offset of compound type member. */
- if(H5T_cmp_offset(comp_size, offset, size, 1, align, struct_align)<0)
+ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
done:
@@ -671,6 +694,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
H5T_t *dt=NULL; /* Appropriate native datatype to copy */
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
size_t align=0; /* Alignment necessary for native datatype */
+ size_t native_size=0; /* Datatype size of the native type */
enum match_type { /* The different kinds of floating point types we can match */
H5T_NATIVE_FLOAT_MATCH_FLOAT,
H5T_NATIVE_FLOAT_MATCH_DOUBLE,
@@ -684,31 +708,45 @@ 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))
+ native_size = sizeof(float);
+ } else if(size<=sizeof(double)) {
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
- else if(size<=sizeof(long double))
+ native_size = sizeof(double);
+ } else if(size<=sizeof(long double)) {
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
- else /* If not match, return the biggest datatype */
+ native_size = sizeof(long double);
+ } else { /* If not match, return the biggest datatype */
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
+ native_size = sizeof(long);
+ }
} else {
- if(size>=sizeof(long double))
+ if(size>=sizeof(long double)) {
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
- else if(size>=sizeof(double)) {
- if(size==sizeof(double))
+ native_size = sizeof(long double);
+ } else if(size>=sizeof(double)) {
+ if(size==sizeof(double)) {
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
- else
+ native_size = sizeof(double);
+ } else {
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
+ native_size = sizeof(long double);
+ }
}
else if(size>=sizeof(float)) {
- if(size==sizeof(float))
+ if(size==sizeof(float)) {
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
- else
+ native_size = sizeof(float);
+ } else {
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
+ native_size = sizeof(double);
+ }
}
- else
+ else {
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
+ native_size = sizeof(float);
+ }
}
/* Set the appropriate native floating point information */
@@ -741,7 +779,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
/* compute offset of compound type member. */
- if(H5T_cmp_offset(comp_size, offset, size, 1, align, struct_align)<0)
+ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
done: