diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-08-25 20:09:18 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-08-25 20:09:18 (GMT) |
commit | 73608d3f90a4e6c4ba7de6afc6da8bcaa2f1842d (patch) | |
tree | fe1afa111970d9749c8c2bcfdd36d70d1906853b /src/H5Tnative.c | |
parent | b987255ed0b7c3eca9c03676f5b130f4cf080a89 (diff) | |
download | hdf5-73608d3f90a4e6c4ba7de6afc6da8bcaa2f1842d.zip hdf5-73608d3f90a4e6c4ba7de6afc6da8bcaa2f1842d.tar.gz hdf5-73608d3f90a4e6c4ba7de6afc6da8bcaa2f1842d.tar.bz2 |
[svn-r7406] Purpose:
Bug fix
Description:
Correct bug creating native versions of "complex" compound datatypes
on certain architectures (Sparc-Solaris) which require stricter alignment.
Also, correct bug where metadata (padding type, etc.) for strings was
incorrectly dropped.
Platforms tested:
FreeBSD 4.8 (sleipnir)
h5committest
Diffstat (limited to 'src/H5Tnative.c')
-rw-r--r-- | src/H5Tnative.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/src/H5Tnative.c b/src/H5Tnative.c index c05b8aa..17e2ef8 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -195,40 +195,17 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig break; case H5T_STRING: - { - size_t align; - size_t pointer_size; - - if(H5T_is_variable_str(dtype)) { - if(NULL==(dt=H5I_object(H5T_C_S1))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); - if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); - if(H5T_set_size(ret_value, H5T_VARIABLE)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot set size"); - - /* Update size, offset and compound alignment for parent. */ - align = H5T_POINTER_COMP_ALIGN_g; - pointer_size = sizeof(char*); - - if(H5T_cmp_offset(comp_size, offset, pointer_size, 1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); - - } else { - if(NULL==(dt=H5I_object(H5T_C_S1))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); - if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); - if(H5T_set_size(ret_value, size)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot set size"); - - /* Update size, offset and compound alignment for parent. */ - align = H5T_NATIVE_SCHAR_COMP_ALIGN_g; - - if(H5T_cmp_offset(comp_size, offset, sizeof(char), size, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); - } + if(H5T_is_variable_str(dtype)) { + /* Update size, offset and compound alignment for parent. */ + if(H5T_cmp_offset(comp_size, offset, sizeof(char *), 1, H5T_POINTER_COMP_ALIGN_g, struct_align)<0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + } else { + /* Update size, offset and compound alignment for parent. */ + if(H5T_cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align)<0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); } break; @@ -241,6 +218,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type"); break; + case H5T_REFERENCE: { size_t align; @@ -304,10 +282,8 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig } /* The alignment for whole compound type */ - if(children_st_align && children_size % children_st_align) { - memb_offset[nmemb-1] += children_size % children_st_align; - children_size += children_size % children_st_align; - } + if(children_st_align && children_size % children_st_align) + children_size += children_st_align-(children_size % children_st_align); /* Construct new compound type based on native type */ if((new_type=H5T_create(H5T_COMPOUND, children_size))==NULL) |