summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2020-06-26 23:57:38 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2020-06-26 23:57:38 (GMT)
commite767f44e953047297fece364218147c908e8b585 (patch)
treed4b6909f14b78bb732b6947adc46ac3cd3ca54f6 /src/H5T.c
parent949649a2b6e00297cbdc49437e70a27e455e92d2 (diff)
parenta08ab621febde7b09e4d86eab80cb029c123e9f6 (diff)
downloadhdf5-e767f44e953047297fece364218147c908e8b585.zip
hdf5-e767f44e953047297fece364218147c908e8b585.tar.gz
hdf5-e767f44e953047297fece364218147c908e8b585.tar.bz2
Merge remote-tracking branch 'origin/develop' into monotonic_timer
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c2332
1 files changed, 1444 insertions, 888 deletions
diff --git a/src/H5T.c b/src/H5T.c
index 4f0c700..25c1f75 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -28,23 +28,20 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* Files */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5FOprivate.h" /* File objects */
-#include "H5Gprivate.h" /* Groups */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Tpkg.h" /* Datatypes */
-
-/* Check for header needed for SGI floating-point code */
-#ifdef H5_HAVE_SYS_FPU_H
-#include <sys/fpu.h>
-#endif /* H5_HAVE_SYS_FPU_H */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* Files */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5FOprivate.h" /* File objects */
+#include "H5Gprivate.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5Tpkg.h" /* Datatypes */
+#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -229,18 +226,35 @@
#define H5T_INIT_TYPE_REF_COMMON { \
H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \
H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \
+ dt->shared->force_conv = TRUE; \
+ dt->shared->u.atomic.u.r.file = NULL; \
+ dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; \
+ dt->shared->u.atomic.u.r.cls = NULL; \
}
#define H5T_INIT_TYPE_OBJREF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
- dt->shared->force_conv = TRUE; \
- dt->shared->u.atomic.u.r.rtype = H5R_OBJECT; \
- dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; \
+ dt->shared->u.atomic.u.r.rtype = H5R_OBJECT1; \
+ dt->shared->u.atomic.u.r.opaque = FALSE; \
+ dt->shared->u.atomic.u.r.version = 0; \
}
#define H5T_INIT_TYPE_REGREF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
- dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION; \
+ dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION1; \
+ dt->shared->u.atomic.u.r.opaque = FALSE; \
+ dt->shared->u.atomic.u.r.version = 0; \
+}
+
+/* rtype value is only used as a placeholder to differentiate the type from
+ * other types, any opaque (i.e. "new") reference type could be used.
+ */
+#define H5T_INIT_TYPE_REF_CORE { \
+ H5T_INIT_TYPE_REF_COMMON \
+ dt->shared->u.atomic.u.r.rtype = H5R_OBJECT2; \
+ dt->shared->u.atomic.u.r.opaque = TRUE; \
+ dt->shared->u.atomic.u.r.version = H5R_ENCODE_VERSION; \
+ dt->shared->version = H5O_DTYPE_VERSION_4; \
}
/* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */
@@ -287,23 +301,33 @@
/* Local Typedefs */
/******************/
+/* Typedef for recursive const-correct datatype copying routines */
+typedef H5T_t *(*H5T_copy_func_t)(H5T_t *old_dt);
+
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
- H5T_t *dst, H5T_conv_t func, hid_t dxpl_id);
-static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src,
- H5T_t *dst, H5T_conv_t func, hid_t dxpl_id, hbool_t api_call);
-static htri_t H5T_compiler_conv(H5T_t *src, H5T_t *dst);
-static herr_t H5T_set_size(H5T_t *dt, size_t size);
+static herr_t H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_lib_conv_t func);
+static herr_t H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_func_t *conv);
+static herr_t H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func);
+static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst);
+static herr_t H5T__set_size(H5T_t *dt, size_t size);
+static herr_t H5T__close_cb(H5T_t *dt);
+static H5T_path_t *H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_func_t *conv);
+static hbool_t H5T__detect_vlen_ref(const H5T_t *dt);
+static H5T_t *H5T__initiate_copy(const H5T_t *old_dt);
+static H5T_t *H5T__copy_transient(H5T_t *old_dt);
+static H5T_t *H5T__copy_all(H5T_t *old_dt);
+static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt,
+ H5T_shared_t *reopened_fo, hbool_t set_memory_type, H5T_copy_func_t copyfn);
/*****************************/
/* Library Private Variables */
/*****************************/
-/* The native endianess of the platform */
+/* The native endianness of the platform */
H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR;
@@ -355,6 +379,7 @@ hid_t H5T_STD_B64BE_g = FAIL;
hid_t H5T_STD_B64LE_g = FAIL;
hid_t H5T_STD_REF_OBJ_g = FAIL;
hid_t H5T_STD_REF_DSETREG_g = FAIL;
+hid_t H5T_STD_REF_g = FAIL;
hid_t H5T_UNIX_D32BE_g = FAIL;
hid_t H5T_UNIX_D32LE_g = FAIL;
@@ -445,6 +470,7 @@ size_t H5T_POINTER_COMP_ALIGN_g = 0;
size_t H5T_HVL_COMP_ALIGN_g = 0;
size_t H5T_HOBJREF_COMP_ALIGN_g = 0;
size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0;
+size_t H5T_REF_COMP_ALIGN_g = 0;
/*
* Alignment constraints for native types. These are initialized at run time
@@ -510,6 +536,14 @@ double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f;
H5FL_DEFINE(H5T_t);
H5FL_DEFINE(H5T_shared_t);
+/* Format version bounds for datatype */
+const unsigned H5O_dtype_ver_bounds[] = {
+ H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */
+ H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V110 */
+ H5O_DTYPE_VERSION_4, /* H5F_LIBVER_V112 */
+ H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */
+};
/*******************/
/* Local Variables */
@@ -533,17 +567,18 @@ H5FL_DEFINE_STATIC(H5T_path_t);
/* Datatype ID class */
static const H5I_class_t H5I_DATATYPE_CLS[1] = {{
- H5I_DATATYPE, /* ID class value */
- 0, /* Class flags */
- 8, /* # of reserved IDs for class */
- (H5I_free_t)H5T_close /* Callback routine for closing objects of this class */
+ H5I_DATATYPE, /* ID class value */
+ 0, /* Class flags */
+ 8, /* # of reserved IDs for class */
+ (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */
}};
+
/* Flag indicating "top" of interface has been initialized */
static hbool_t H5T_top_package_initialize_s = FALSE;
-
+
/*-------------------------------------------------------------------------
* Function: H5T_init
*
@@ -569,7 +604,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_init() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T__init_inf
*
@@ -682,7 +717,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__init_inf() */
-
+
/*--------------------------------------------------------------------------
NAME
H5T__init_package -- Initialize interface-specific information
@@ -729,10 +764,12 @@ H5T__init_package(void)
H5T_t *enum_type=NULL; /* Datatype structure for enum objects */
H5T_t *vlen=NULL; /* Datatype structure for vlen objects */
H5T_t *array=NULL; /* Datatype structure for array objects */
- H5T_t *objref=NULL; /* Datatype structure for object reference objects */
+ H5T_t *objref=NULL; /* Datatype structure for deprecated reference objects */
+ H5T_t *regref=NULL; /* Datatype structure for deprecated region references */
+ H5T_t *ref=NULL; /* Datatype structure for opaque references */
hsize_t dim[1]={1}; /* Dimension info for array datatype */
herr_t status;
- unsigned copied_dtype=1; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */
+ hbool_t copied_dtype = TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -981,12 +1018,23 @@ H5T__init_package(void)
*------------------------------------------------------------
*/
- /* Object reference (i.e. object header address in file) */
- H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, SET, H5R_OBJ_REF_BUF_SIZE)
+ /* Deprecated object reference type */
+ H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, NOSET, -)
+ if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
objref = dt; /* Keep type for later */
- /* Dataset Region reference (i.e. selection inside a dataset) */
- H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, SET, H5R_DSET_REG_REF_BUF_SIZE)
+ /* Deprecated region reference type */
+ H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, NOSET, -)
+ if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
+ regref = dt; /* Keep type for later */
+
+ /* Opaque reference type */
+ H5T_INIT_TYPE(REF, H5T_STD_REF_g, ALLOC, -, NOSET, -)
+ if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
+ ref = dt; /* Keep type for later */
/*
* Register conversion functions beginning with the most general and
@@ -1004,24 +1052,28 @@ H5T__init_package(void)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
status = 0;
- status |= H5T_register(H5T_PERS_SOFT, "i_i", fixedpt, fixedpt, H5T__conv_i_i, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "i_f", fixedpt, floatpt, H5T__conv_i_f, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "f_f", floatpt, floatpt, H5T__conv_f_f, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "f_i", floatpt, fixedpt, H5T__conv_f_i, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "s_s", string, string, H5T__conv_s_s, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "b_b", bitfield, bitfield, H5T__conv_b_b, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "ibo", fixedpt, fixedpt, H5T__conv_order, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "ibo(opt)", fixedpt, fixedpt, H5T__conv_order_opt, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "fbo", floatpt, floatpt, H5T__conv_order, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "fbo(opt)", floatpt, floatpt, H5T__conv_order_opt, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "struct(no-opt)", compound, compound, H5T__conv_struct, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "struct(opt)", compound, compound, H5T__conv_struct_opt, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "enum", enum_type, enum_type, H5T__conv_enum, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "enum_i", enum_type, fixedpt, H5T__conv_enum_numeric, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "enum_f", enum_type, floatpt, H5T__conv_enum_numeric, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "vlen", vlen, vlen, H5T__conv_vlen, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "array", array, array, H5T__conv_array, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_order_opt, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_SOFT, "i_i", fixedpt, fixedpt, H5T__conv_i_i);
+ status |= H5T__register_int(H5T_PERS_SOFT, "i_f", fixedpt, floatpt, H5T__conv_i_f);
+ status |= H5T__register_int(H5T_PERS_SOFT, "f_f", floatpt, floatpt, H5T__conv_f_f);
+ status |= H5T__register_int(H5T_PERS_SOFT, "f_i", floatpt, fixedpt, H5T__conv_f_i);
+ status |= H5T__register_int(H5T_PERS_SOFT, "s_s", string, string, H5T__conv_s_s);
+ status |= H5T__register_int(H5T_PERS_SOFT, "b_b", bitfield, bitfield, H5T__conv_b_b);
+ status |= H5T__register_int(H5T_PERS_SOFT, "ibo", fixedpt, fixedpt, H5T__conv_order);
+ status |= H5T__register_int(H5T_PERS_SOFT, "ibo(opt)", fixedpt, fixedpt, H5T__conv_order_opt);
+ status |= H5T__register_int(H5T_PERS_SOFT, "fbo", floatpt, floatpt, H5T__conv_order);
+ status |= H5T__register_int(H5T_PERS_SOFT, "fbo(opt)", floatpt, floatpt, H5T__conv_order_opt);
+ status |= H5T__register_int(H5T_PERS_SOFT, "struct(no-opt)", compound, compound, H5T__conv_struct);
+ status |= H5T__register_int(H5T_PERS_SOFT, "struct(opt)", compound, compound, H5T__conv_struct_opt);
+ status |= H5T__register_int(H5T_PERS_SOFT, "enum", enum_type, enum_type, H5T__conv_enum);
+ status |= H5T__register_int(H5T_PERS_SOFT, "enum_i", enum_type, fixedpt, H5T__conv_enum_numeric);
+ status |= H5T__register_int(H5T_PERS_SOFT, "enum_f", enum_type, floatpt, H5T__conv_enum_numeric);
+ status |= H5T__register_int(H5T_PERS_SOFT, "vlen", vlen, vlen, H5T__conv_vlen);
+ status |= H5T__register_int(H5T_PERS_SOFT, "array", array, array, H5T__conv_array);
+ status |= H5T__register_int(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_noop);
+ status |= H5T__register_int(H5T_PERS_SOFT, "regref", regref, regref, H5T__conv_noop);
+ status |= H5T__register_int(H5T_PERS_SOFT, "ref", ref, ref, H5T__conv_ref);
+ status |= H5T__register_int(H5T_PERS_SOFT, "objref_ref", objref, ref, H5T__conv_ref);
+ status |= H5T__register_int(H5T_PERS_SOFT, "regref_ref", regref, ref, H5T__conv_ref);
/*
* Native conversions should be listed last since we can use hardware to
@@ -1032,221 +1084,221 @@ H5T__init_package(void)
*/
/* floating point */
- status |= H5T_register(H5T_PERS_HARD, "flt_dbl", native_float, native_double, H5T__conv_float_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_flt", native_double, native_float, H5T__conv_double_float, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_dbl", native_float, native_double, H5T__conv_float_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_flt", native_double, native_float, H5T__conv_double_float);
#if H5_SIZEOF_LONG_DOUBLE != 0
- status |= H5T_register(H5T_PERS_HARD, "flt_ldbl", native_float, native_ldouble, H5T__conv_float_ldouble, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_ldbl", native_double, native_ldouble, H5T__conv_double_ldouble, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_flt", native_ldouble, native_float, H5T__conv_ldouble_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_dbl", native_ldouble, native_double, H5T__conv_ldouble_double, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_ldbl", native_float, native_ldouble, H5T__conv_float_ldouble);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_ldbl", native_double, native_ldouble, H5T__conv_double_ldouble);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_flt", native_ldouble, native_float, H5T__conv_ldouble_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_dbl", native_ldouble, native_double, H5T__conv_ldouble_double);
#endif /* H5_SIZEOF_LONG_DOUBLE != 0 */
/* from long long */
- status |= H5T_register(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T__conv_llong_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T__conv_ullong_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_long", native_llong, native_long, H5T__conv_llong_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T__conv_llong_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T__conv_ullong_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T__conv_ullong_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T__conv_llong_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T__conv_llong_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T__conv_ullong_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, H5T__conv_ullong_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_int", native_llong, native_int, H5T__conv_llong_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_uint", native_llong, native_uint, H5T__conv_llong_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_int", native_ullong, native_int, H5T__conv_ullong_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T__conv_ullong_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T__conv_llong_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T__conv_llong_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T__conv_ullong_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T__conv_ullong_uchar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T__conv_llong_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T__conv_ullong_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_long", native_llong, native_long, H5T__conv_llong_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T__conv_llong_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T__conv_ullong_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T__conv_ullong_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T__conv_llong_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T__conv_llong_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T__conv_ullong_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, H5T__conv_ullong_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_int", native_llong, native_int, H5T__conv_llong_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_uint", native_llong, native_uint, H5T__conv_llong_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_int", native_ullong, native_int, H5T__conv_ullong_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T__conv_ullong_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T__conv_llong_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T__conv_llong_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T__conv_ullong_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T__conv_ullong_uchar);
/* From long */
- status |= H5T_register(H5T_PERS_HARD, "long_llong", native_long, native_llong, H5T__conv_long_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T__conv_long_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T__conv_ulong_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T__conv_ulong_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_ulong", native_long, native_ulong, H5T__conv_long_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_long", native_ulong, native_long, H5T__conv_ulong_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_short", native_long, native_short, H5T__conv_long_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T__conv_long_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T__conv_ulong_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T__conv_ulong_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_int", native_long, native_int, H5T__conv_long_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_uint", native_long, native_uint, H5T__conv_long_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_int", native_ulong, native_int, H5T__conv_ulong_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_uint", native_ulong, native_uint, H5T__conv_ulong_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_schar", native_long, native_schar, H5T__conv_long_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_uchar", native_long, native_uchar, H5T__conv_long_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T__conv_ulong_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T__conv_ulong_uchar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_llong", native_long, native_llong, H5T__conv_long_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T__conv_long_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T__conv_ulong_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T__conv_ulong_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_ulong", native_long, native_ulong, H5T__conv_long_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_long", native_ulong, native_long, H5T__conv_ulong_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_short", native_long, native_short, H5T__conv_long_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T__conv_long_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T__conv_ulong_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T__conv_ulong_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_int", native_long, native_int, H5T__conv_long_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_uint", native_long, native_uint, H5T__conv_long_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_int", native_ulong, native_int, H5T__conv_ulong_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_uint", native_ulong, native_uint, H5T__conv_ulong_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_schar", native_long, native_schar, H5T__conv_long_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_uchar", native_long, native_uchar, H5T__conv_long_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T__conv_ulong_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T__conv_ulong_uchar);
/* From short */
- status |= H5T_register(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T__conv_short_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T__conv_short_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T__conv_ushort_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, H5T__conv_ushort_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_long", native_short, native_long, H5T__conv_short_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T__conv_short_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T__conv_ushort_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T__conv_ushort_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T__conv_short_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T__conv_ushort_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_int", native_short, native_int, H5T__conv_short_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_uint", native_short, native_uint, H5T__conv_short_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_int", native_ushort, native_int, H5T__conv_ushort_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T__conv_ushort_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T__conv_short_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T__conv_short_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T__conv_ushort_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T__conv_ushort_uchar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T__conv_short_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T__conv_short_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T__conv_ushort_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, H5T__conv_ushort_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_long", native_short, native_long, H5T__conv_short_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T__conv_short_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T__conv_ushort_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T__conv_ushort_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T__conv_short_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T__conv_ushort_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_int", native_short, native_int, H5T__conv_short_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_uint", native_short, native_uint, H5T__conv_short_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_int", native_ushort, native_int, H5T__conv_ushort_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T__conv_ushort_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T__conv_short_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T__conv_short_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T__conv_ushort_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T__conv_ushort_uchar);
/* From int */
- status |= H5T_register(H5T_PERS_HARD, "int_llong", native_int, native_llong, H5T__conv_int_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_ullong", native_int, native_ullong, H5T__conv_int_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_llong", native_uint, native_llong, H5T__conv_uint_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T__conv_uint_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_long", native_int, native_long, H5T__conv_int_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_ulong", native_int, native_ulong, H5T__conv_int_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_long", native_uint, native_long, H5T__conv_uint_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_ulong", native_uint, native_ulong, H5T__conv_uint_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_short", native_int, native_short, H5T__conv_int_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_ushort", native_int, native_ushort, H5T__conv_int_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_short", native_uint, native_short, H5T__conv_uint_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T__conv_uint_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_uint", native_int, native_uint, H5T__conv_int_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_int", native_uint, native_int, H5T__conv_uint_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_schar", native_int, native_schar, H5T__conv_int_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_uchar", native_int, native_uchar, H5T__conv_int_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_schar", native_uint, native_schar, H5T__conv_uint_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_uchar", native_uint, native_uchar, H5T__conv_uint_uchar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_llong", native_int, native_llong, H5T__conv_int_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_ullong", native_int, native_ullong, H5T__conv_int_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_llong", native_uint, native_llong, H5T__conv_uint_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T__conv_uint_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_long", native_int, native_long, H5T__conv_int_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_ulong", native_int, native_ulong, H5T__conv_int_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_long", native_uint, native_long, H5T__conv_uint_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_ulong", native_uint, native_ulong, H5T__conv_uint_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_short", native_int, native_short, H5T__conv_int_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_ushort", native_int, native_ushort, H5T__conv_int_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_short", native_uint, native_short, H5T__conv_uint_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T__conv_uint_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_uint", native_int, native_uint, H5T__conv_int_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_int", native_uint, native_int, H5T__conv_uint_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_schar", native_int, native_schar, H5T__conv_int_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_uchar", native_int, native_uchar, H5T__conv_int_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_schar", native_uint, native_schar, H5T__conv_uint_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_uchar", native_uint, native_uchar, H5T__conv_uint_uchar);
/* From char */
- status |= H5T_register(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T__conv_schar_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T__conv_schar_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T__conv_uchar_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T__conv_uchar_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_long", native_schar, native_long, H5T__conv_schar_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T__conv_schar_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_long", native_uchar, native_long, H5T__conv_uchar_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T__conv_uchar_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T__conv_schar_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T__conv_schar_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T__conv_uchar_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T__conv_uchar_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_int", native_schar, native_int, H5T__conv_schar_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_uint", native_schar, native_uint, H5T__conv_schar_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_int", native_uchar, native_int, H5T__conv_uchar_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_uint", native_uchar, native_uint, H5T__conv_uchar_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T__conv_schar_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T__conv_uchar_schar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T__conv_schar_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T__conv_schar_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T__conv_uchar_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T__conv_uchar_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_long", native_schar, native_long, H5T__conv_schar_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T__conv_schar_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_long", native_uchar, native_long, H5T__conv_uchar_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T__conv_uchar_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T__conv_schar_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T__conv_schar_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T__conv_uchar_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T__conv_uchar_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_int", native_schar, native_int, H5T__conv_schar_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_uint", native_schar, native_uint, H5T__conv_schar_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_int", native_uchar, native_int, H5T__conv_uchar_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_uint", native_uchar, native_uint, H5T__conv_uchar_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T__conv_schar_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T__conv_uchar_schar);
/* From char to floats */
- status |= H5T_register(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T__conv_schar_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T__conv_schar_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble);
/* From unsigned char to floats */
- status |= H5T_register(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T__conv_uchar_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T__conv_uchar_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble);
/* From short to floats */
- status |= H5T_register(H5T_PERS_HARD, "short_flt", native_short, native_float, H5T__conv_short_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_flt", native_short, native_float, H5T__conv_short_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble);
/* From unsigned short to floats */
- status |= H5T_register(H5T_PERS_HARD, "ushort_flt", native_ushort, native_float, H5T__conv_ushort_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, H5T__conv_ushort_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_flt", native_ushort, native_float, H5T__conv_ushort_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, H5T__conv_ushort_ldouble);
/* From int to floats */
- status |= H5T_register(H5T_PERS_HARD, "int_flt", native_int, native_float, H5T__conv_int_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_dbl", native_int, native_double, H5T__conv_int_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "int_ldbl", native_int, native_ldouble, H5T__conv_int_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_flt", native_int, native_float, H5T__conv_int_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_dbl", native_int, native_double, H5T__conv_int_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "int_ldbl", native_int, native_ldouble, H5T__conv_int_ldouble);
/* From unsigned int to floats */
- status |= H5T_register(H5T_PERS_HARD, "uint_flt", native_uint, native_float, H5T__conv_uint_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_dbl", native_uint, native_double, H5T__conv_uint_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_flt", native_uint, native_float, H5T__conv_uint_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_dbl", native_uint, native_double, H5T__conv_uint_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble);
/* From long to floats */
- status |= H5T_register(H5T_PERS_HARD, "long_flt", native_long, native_float, H5T__conv_long_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_dbl", native_long, native_double, H5T__conv_long_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_flt", native_long, native_float, H5T__conv_long_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_dbl", native_long, native_double, H5T__conv_long_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble);
/* From unsigned long to floats */
- status |= H5T_register(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T__conv_ulong_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T__conv_ulong_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double);
+ status |= H5T__register_int(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble);
/* From long long to floats */
- status |= H5T_register(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T__conv_llong_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T__conv_llong_double, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T__conv_llong_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T__conv_llong_double);
#ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE
- status |= H5T_register(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble);
#endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */
/* From unsigned long long to floats */
- status |= H5T_register(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T__conv_ullong_float, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T__conv_ullong_double, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T__conv_ullong_float);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T__conv_ullong_double);
#ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE
- status |= H5T_register(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T__conv_ullong_ldouble, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T__conv_ullong_ldouble);
#endif /* H5T_CONV_INTERNAL_ULLONG_LDOUBLE */
/* From floats to char */
- status |= H5T_register(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T__conv_float_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T__conv_float_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar);
/* From floats to unsigned char */
- status |= H5T_register(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T__conv_float_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T__conv_float_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar);
/* From floats to short */
- status |= H5T_register(H5T_PERS_HARD, "flt_short", native_float, native_short, H5T__conv_float_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_short", native_float, native_short, H5T__conv_float_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short);
/* From floats to unsigned short */
- status |= H5T_register(H5T_PERS_HARD, "flt_ushort", native_float, native_ushort, H5T__conv_float_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, H5T__conv_ldouble_ushort, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_ushort", native_float, native_ushort, H5T__conv_float_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, H5T__conv_ldouble_ushort);
/* From floats to int */
- status |= H5T_register(H5T_PERS_HARD, "flt_int", native_float, native_int, H5T__conv_float_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_int", native_double, native_int, H5T__conv_double_int, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_int", native_ldouble, native_int, H5T__conv_ldouble_int, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_int", native_float, native_int, H5T__conv_float_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_int", native_double, native_int, H5T__conv_double_int);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_int", native_ldouble, native_int, H5T__conv_ldouble_int);
/* From floats to unsigned int */
- status |= H5T_register(H5T_PERS_HARD, "flt_uint", native_float, native_uint, H5T__conv_float_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_uint", native_double, native_uint, H5T__conv_double_uint, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_uint", native_float, native_uint, H5T__conv_float_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_uint", native_double, native_uint, H5T__conv_double_uint);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint);
/* From floats to long */
- status |= H5T_register(H5T_PERS_HARD, "flt_long", native_float, native_long, H5T__conv_float_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_long", native_double, native_long, H5T__conv_double_long, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_long", native_float, native_long, H5T__conv_float_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_long", native_double, native_long, H5T__conv_double_long);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long);
/* From floats to unsigned long */
- status |= H5T_register(H5T_PERS_HARD, "flt_ulong", native_float, native_ulong, H5T__conv_float_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_ulong", native_float, native_ulong, H5T__conv_float_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong);
/* From floats to long long */
- status |= H5T_register(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong);
#ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG
- status |= H5T_register(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong);
#endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */
/* From floats to unsigned long long */
- status |= H5T_register(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong, H5AC_noio_dxpl_id, FALSE);
- status |= H5T_register(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong);
+ status |= H5T__register_int(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong);
#if H5T_CONV_INTERNAL_LDOUBLE_ULLONG
- status |= H5T_register(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, H5T__conv_ldouble_ullong, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, H5T__conv_ldouble_ullong);
#endif /* H5T_CONV_INTERNAL_LDOUBLE_ULLONG */
/*
@@ -1254,7 +1306,7 @@ H5T__init_package(void)
* data types we use are not important as long as the source and
* destination are equal.
*/
- status |= H5T_register(H5T_PERS_HARD, "no-op", native_int, native_int, H5T__conv_noop, H5AC_noio_dxpl_id, FALSE);
+ status |= H5T__register_int(H5T_PERS_HARD, "no-op", native_int, native_int, H5T__conv_noop);
/* Initialize the +/- Infinity values for floating-point types */
status |= H5T__init_inf();
@@ -1282,20 +1334,20 @@ H5T__init_package(void)
done:
/* General cleanup */
if(compound != NULL)
- H5T_close(compound);
+ (void)H5T_close_real(compound);
if(enum_type != NULL)
- H5T_close(enum_type);
+ (void)H5T_close_real(enum_type);
if(vlen != NULL)
- H5T_close(vlen);
+ (void)H5T_close_real(vlen);
if(array != NULL)
- H5T_close(array);
+ (void)H5T_close_real(array);
/* Error cleanup */
if(ret_value < 0) {
if(dt) {
- /* Check if we should call H5T_close or H5FL_FREE */
+ /* Check if we should call H5T_close_real or H5FL_FREE */
if(copied_dtype)
- H5T_close(dt);
+ (void)H5T_close_real(dt);
else {
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
dt = H5FL_FREE(H5T_t, dt);
@@ -1306,7 +1358,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__init_package() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T__unlock_cb
*
@@ -1339,7 +1391,7 @@ H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5T__unlock_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_top_term_package
*
@@ -1371,27 +1423,41 @@ H5T_top_term_package(void)
path = H5T_g.path[i];
HDassert(path);
- if(path->func) {
+ if(path->conv.u.app_func) {
H5T__print_stats(path, &nprint/*in,out*/);
path->cdata.command = H5T_CONV_FREE;
- if((path->func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0,
- (size_t)0, (size_t)0, NULL, NULL,H5AC_noio_dxpl_id) < 0) {
+ if(path->conv.is_app) {
+ if((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: conversion function "
- "0x%08lx failed to free private data for "
- "%s (ignored)\n",
- (unsigned long)(path->func), path->name);
- } /* end if */
+ if (H5DEBUG(T)) {
+ HDfprintf(H5DEBUG(T), "H5T: conversion function "
+ "0x%08lx failed to free private data for "
+ "%s (ignored)\n",
+ (unsigned long)(path->conv.u.app_func), path->name);
+ } /* end if */
#endif
- H5E_clear_stack(NULL); /*ignore the error*/
+ H5E_clear_stack(NULL); /*ignore the error*/
+ } /* end if */
} /* end if */
+ else {
+ if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
+#ifdef H5T_DEBUG
+ if (H5DEBUG(T)) {
+ HDfprintf(H5DEBUG(T), "H5T: conversion function "
+ "0x%08lx failed to free private data for "
+ "%s (ignored)\n",
+ (unsigned long)(path->conv.u.lib_func), path->name);
+ } /* end if */
+#endif
+ H5E_clear_stack(NULL); /*ignore the error*/
+ } /* end if */
+ } /* end else */
} /* end if */
if(path->src)
- H5T_close(path->src);
+ (void)H5T_close_real(path->src);
if(path->dst)
- H5T_close(path->dst);
+ (void)H5T_close_real(path->dst);
path = H5FL_FREE(H5T_path_t, path);
H5T_g.path[i] = NULL;
} /* end for */
@@ -1451,6 +1517,7 @@ H5T_top_term_package(void)
H5T_STD_B64LE_g = FAIL;
H5T_STD_REF_OBJ_g = FAIL;
H5T_STD_REF_DSETREG_g = FAIL;
+ H5T_STD_REF_g = FAIL;
H5T_UNIX_D32BE_g = FAIL;
H5T_UNIX_D32LE_g = FAIL;
@@ -1526,7 +1593,7 @@ H5T_top_term_package(void)
FUNC_LEAVE_NOAPI(n)
} /* end H5T_top_term_package() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_term_package
*
@@ -1568,7 +1635,50 @@ H5T_term_package(void)
FUNC_LEAVE_NOAPI(n)
} /* end H5T_term_package() */
-
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__close_cb
+ *
+ * Purpose: Called when the ref count reaches zero on the datatype's ID
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5T__close_cb(H5T_t *dt)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(dt);
+ HDassert(dt->shared);
+
+ /* If this datatype is VOL-managed (i.e.: has a VOL object),
+ * close it through the VOL connector.
+ */
+ if(NULL != dt->vol_obj) {
+ /* Close the connector-managed datatype data */
+ if(H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype")
+
+ /* Free the VOL object */
+ if(H5VL_free_object(dt->vol_obj) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object")
+ dt->vol_obj = NULL;
+ } /* end if */
+
+ /* Close the datatype */
+ if(H5T_close(dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__close_cb() */
+
+
/*-------------------------------------------------------------------------
* Function: H5Tcreate
*
@@ -1599,73 +1709,76 @@ H5Tcreate(H5T_class_t type, size_t size)
/* check args. We support string (fixed-size or variable-length) now. */
if(size <= 0 && size != H5T_VARIABLE)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive")
/* create the type */
if(NULL == (dt = H5T__create(type, size)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type")
/* Get an ID for the datatype */
if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tcreate() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tcopy
*
- * Purpose: Copies a datatype. The resulting datatype is not locked.
- * The datatype should be closed when no longer needed by
- * calling H5Tclose().
+ * Purpose: Copies a datatype. The resulting datatype is not locked.
+ * The datatype should be closed when no longer needed by
+ * calling H5Tclose().
*
- * Return: Success: The ID of a new datatype.
+ * Return: Success: The ID of a new datatype
*
- * Failure: Negative
+ * Failure: H5I_INVALID_HID
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
- *
- * Modifications:
- *
- * Robb Matzke, 4 Jun 1998
- * The returned type is always transient and unlocked. If the TYPE_ID
- * argument is a dataset instead of a datatype then this function
- * returns a transient, modifiable datatype which is a copy of the
- * dataset's datatype.
+ * Note: The returned type is always transient and unlocked. If the
+ * TYPE_ID argument is a dataset instead of a datatype then
+ * this function returns a transient, modifiable datatype
+ * which is a copy of the dataset's datatype.
*
*-------------------------------------------------------------------------
*/
hid_t
-H5Tcopy(hid_t type_id)
+H5Tcopy(hid_t obj_id)
{
- H5T_t *dt; /* Pointer to the datatype to copy */
- H5T_t *new_dt = NULL;
- hid_t ret_value; /* Return value */
+ H5T_t *dt = NULL; /* Pointer to the datatype to copy */
+ H5T_t *new_dt = NULL; /* Pointer to the new datatype */
+ hid_t dset_tid = H5I_INVALID_HID; /* Datatype ID from dataset */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
- H5TRACE1("i", "i", type_id);
+ FUNC_ENTER_API(H5I_INVALID_HID)
+ H5TRACE1("i", "i", obj_id);
- switch(H5I_get_type(type_id)) {
+ switch(H5I_get_type(obj_id)) {
case H5I_DATATYPE:
/* The argument is a datatype handle */
- if(NULL == (dt = (H5T_t *)H5I_object(type_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(NULL == (dt = (H5T_t *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "obj_id is not a datatype ID")
break;
case H5I_DATASET:
- {
- H5D_t *dset; /* Dataset for datatype */
+ {
+ H5VL_object_t *vol_obj = NULL; /* Dataset structure */
- /* The argument is a dataset handle */
- if(NULL == (dset = (H5D_t *)H5I_object(type_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- if(NULL == (dt = H5D_typeof(dset)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get the dataset datatype")
- }
- break;
+ /* The argument is a dataset handle */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a dataset ID")
+
+ /* Get the datatype from the dataset
+ * NOTE: This will have to be closed after we're done with it.
+ */
+ if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &dset_tid) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype from the dataset")
+
+ /* Unwrap the type ID */
+ if(NULL == (dt = (H5T_t *)H5I_object(dset_tid)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "received invalid datatype from the dataset")
+ }
+ break;
case H5I_UNINIT:
case H5I_BADID:
@@ -1673,35 +1786,44 @@ H5Tcopy(hid_t type_id)
case H5I_GROUP:
case H5I_DATASPACE:
case H5I_ATTR:
- case H5I_REFERENCE:
+ case H5I_MAP:
case H5I_VFL:
+ case H5I_VOL:
case H5I_GENPROP_CLS:
case H5I_GENPROP_LST:
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
case H5I_NTYPES:
default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype or dataset")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype or dataset")
} /* end switch */
/* Copy datatype */
if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy");
- /* Atomize result */
+ /* Get an ID for the copied datatype */
if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype atom")
done:
- if(ret_value < 0)
- if(new_dt && H5T_close(new_dt) < 0)
- HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to release datatype info")
+
+ /* If we got a type ID from a passed-in dataset, we need to close that */
+ if(dset_tid != H5I_INVALID_HID)
+ if(H5I_dec_app_ref(dset_tid) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADATOM, FAIL, "problem freeing temporary dataset type ID")
+
+ /* Close the new datatype on errors */
+ if(H5I_INVALID_HID == ret_value)
+ if(new_dt && H5T_close_real(new_dt) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release datatype info")
FUNC_LEAVE_API(ret_value)
} /* end H5Tcopy() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tclose
*
@@ -1736,7 +1858,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tclose() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tequal
*
@@ -1773,12 +1895,12 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tequal() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tlock
*
- * Purpose: Locks a type, making it read only and non-destructable. This
- * is normally done by the library for predefined datatypes so
+ * Purpose: Locks a type, making it read only and non-destructable.
+ * This is normally done by the library for predefined datatypes so
* the application doesn't inadvertently change or delete a
* predefined type.
*
@@ -1808,9 +1930,9 @@ H5Tlock(hid_t type_id)
H5TRACE1("e", "i", type_id);
/* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if(H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state)
+ if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to lock named datatype")
if(H5T_lock(dt, TRUE) < 0)
@@ -1820,7 +1942,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tlock() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tget_class
*
@@ -1855,7 +1977,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_class() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_get_class
*
@@ -1897,7 +2019,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_get_class() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tdetect_class
*
@@ -1933,7 +2055,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tdetect_class() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_detect_class
*
@@ -1945,15 +2067,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, November 29, 2000
*
- * Modifications:
- * Raymond Lu
- * 4 December 2009
- * Added a flag as a parameter to indicate whether the caller is
- * H5Tdetect_class. I also added the check for VL string type
- * just like the public function. Because we want to tell users
- * VL string is a string type but we treat it as a VL type
- * internally, H5T_detect_class needs to know where the caller
- * is from.
*-------------------------------------------------------------------------
*/
htri_t
@@ -2018,7 +2131,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_detect_class() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tis_variable_str
*
@@ -2052,7 +2165,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tis_variable_str() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_is_variable_str
*
@@ -2073,7 +2186,7 @@ H5T_is_variable_str(const H5T_t *dt)
FUNC_LEAVE_NOAPI(H5T_IS_VL_STRING(dt->shared))
} /* end H5T_is_variable_str() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tget_size
*
@@ -2110,7 +2223,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_size() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tset_size
*
@@ -2159,14 +2272,14 @@ H5Tset_size(hid_t type_id, size_t size)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype")
/* Modify the datatype */
- if(H5T_set_size(dt, size) < 0)
+ if(H5T__set_size(dt, size) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for datatype")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tset_size() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tget_super
*
@@ -2186,27 +2299,27 @@ H5Tget_super(hid_t type)
{
H5T_t *dt; /* Datatype to query */
H5T_t *super = NULL; /* Supertype */
- hid_t ret_value; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE1("i", "i", type);
if(NULL == (dt = (H5T_t *)H5I_object_verify(type,H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype")
if(NULL == (super = H5T_get_super(dt)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "not a datatype")
if((ret_value = H5I_register(H5I_DATATYPE, super, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register parent datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register parent datatype")
done:
- if(ret_value < 0)
- if(super && H5T_close(super) < 0)
- HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to release super datatype info")
+ if(H5I_INVALID_HID == ret_value)
+ if(super && H5T_close_real(super) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release super datatype info")
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_super() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_get_super
*
@@ -2215,34 +2328,74 @@ done:
* the return value is an integer type.
*
* Return: Success: Data type for base data type.
- *
* Failure: NULL
*
* Programmer: Raymond Lu
- * October 9, 2002
+ * October 9, 2002
+ *
*-------------------------------------------------------------------------
*/
H5T_t *
H5T_get_super(const H5T_t *dt)
{
- H5T_t *ret_value=NULL;
+ H5T_t *ret_value = NULL;
FUNC_ENTER_NOAPI(NULL)
HDassert(dt);
- if (!dt->shared->parent)
+ if(!dt->shared->parent)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type");
- if (NULL==(ret_value=H5T_copy(dt->shared->parent, H5T_COPY_ALL)))
+ if(NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type");
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5T_get_super() */
+
-
/*-------------------------------------------------------------------------
- * Function: H5T_register
+ * Function: H5T__register_int
+ *
+ * Purpose: Register a library internal datatype conversion routine.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, March 7, 1998
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
+ H5T_lib_conv_t func)
+{
+ H5T_conv_func_t conv_func; /* Conversion function wrapper */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Check args */
+ HDassert(H5T_PERS_HARD == pers || H5T_PERS_SOFT == pers);
+ HDassert(name && *name);
+ HDassert(src);
+ HDassert(dst);
+ HDassert(func);
+
+ /* Set up conversion function wrapper */
+ conv_func.is_app = FALSE;
+ conv_func.u.lib_func = func;
+
+ /* Register conversion */
+ if(H5T__register(pers, name, src, dst, &conv_func) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register internal datatype conversion routine")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__register_int() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__register
*
* Purpose: Register a hard or soft conversion function for a data type
* conversion path. The path is specified by the source and
@@ -2260,8 +2413,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
- H5T_conv_t func, hid_t dxpl_id, hbool_t api_call)
+H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
+ H5T_conv_func_t *conv)
{
hid_t tmp_sid = -1, tmp_did = -1; /*temporary data type IDs */
H5T_path_t *old_path = NULL; /*existing conversion path */
@@ -2271,12 +2424,12 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
int i; /*counter */
herr_t ret_value = SUCCEED; /*return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(src);
HDassert(dst);
- HDassert(func);
+ HDassert(conv);
HDassert(H5T_PERS_HARD==pers || H5T_PERS_SOFT==pers);
HDassert(name && *name);
@@ -2284,11 +2437,10 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
/* Only bother to register the path if it's not a no-op path (for this machine) */
if(H5T_cmp(src, dst, FALSE)) {
/* Locate or create a new conversion path */
- if(NULL == (new_path = H5T_path_find(src, dst, name, func, dxpl_id, api_call)))
+ if(NULL == (new_path = H5T__path_find_real(src, dst, name, conv)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate/allocate conversion path")
- /*
- * Notify all other functions to recalculate private data since some
+ /* Notify all other functions to recalculate private data since some
* functions might cache a list of conversion functions. For
* instance, the compound type converter caches a list of conversion
* functions for the members, so adding a new function should cause
@@ -2314,7 +2466,7 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN - 1] = '\0';
H5T_g.soft[H5T_g.nsoft].src = src->shared->type;
H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type;
- H5T_g.soft[H5T_g.nsoft].func = func;
+ H5T_g.soft[H5T_g.nsoft].conv = *conv;
H5T_g.nsoft++;
/*
@@ -2322,29 +2474,38 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
* conversion function applies should be replaced by a new path that
* uses this function.
*/
- for (i=1; i<H5T_g.npaths; i++) {
+ for(i = 1; i < H5T_g.npaths; i++) {
old_path = H5T_g.path[i];
HDassert(old_path);
/* Does the new soft conversion function apply to this path? */
- if (old_path->is_hard ||
- old_path->src->shared->type!=src->shared->type ||
- old_path->dst->shared->type!=dst->shared->type) {
+ if(old_path->is_hard ||
+ old_path->src->shared->type != src->shared->type ||
+ old_path->dst->shared->type != dst->shared->type)
continue;
- }
+
if((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 ||
(tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query")
HDmemset(&cdata, 0, sizeof cdata);
cdata.command = H5T_CONV_INIT;
- if((func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0,
- NULL, NULL, dxpl_id) < 0) {
- H5I_dec_ref(tmp_sid);
- H5I_dec_ref(tmp_did);
- tmp_sid = tmp_did = -1;
- H5E_clear_stack(NULL);
- continue;
+ if(conv->is_app) {
+ if((conv->u.app_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) {
+ H5I_dec_ref(tmp_sid);
+ H5I_dec_ref(tmp_did);
+ tmp_sid = tmp_did = -1;
+ H5E_clear_stack(NULL);
+ continue;
+ } /* end if */
} /* end if */
+ else
+ if((conv->u.lib_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
+ H5I_dec_ref(tmp_sid);
+ H5I_dec_ref(tmp_did);
+ tmp_sid = tmp_did = -1;
+ H5E_clear_stack(NULL);
+ continue;
+ } /* end if */
/* Create a new conversion path */
if(NULL == (new_path = H5FL_CALLOC(H5T_path_t)))
@@ -2354,7 +2515,7 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
if(NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) ||
NULL == (new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types")
- new_path->func = func;
+ new_path->conv = *conv;
new_path->is_hard = FALSE;
new_path->cdata = cdata;
@@ -2365,18 +2526,27 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
/* Free old path */
H5T__print_stats(old_path, &nprint);
old_path->cdata.command = H5T_CONV_FREE;
- if ((old_path->func)(tmp_sid, tmp_did, &(old_path->cdata),
- (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id)<0) {
+ if(old_path->conv.is_app) {
+ if((old_path->conv.u.app_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx "
- "failed to free private data for %s (ignored)\n",
- (unsigned long)(old_path->func), old_path->name);
- }
+ if(H5DEBUG(T))
+ HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx "
+ "failed to free private data for %s (ignored)\n",
+ (unsigned long)(old_path->conv.u.app_func), old_path->name);
#endif
+ } /* end if */
} /* end if */
- H5T_close(old_path->src);
- H5T_close(old_path->dst);
+ else
+ if((old_path->conv.u.lib_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
+#ifdef H5T_DEBUG
+ if(H5DEBUG(T))
+ HDfprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx "
+ "failed to free private data for %s (ignored)\n",
+ (unsigned long)(old_path->conv.u.lib_func), old_path->name);
+#endif
+ } /* end if */
+ (void)H5T_close_real(old_path->src);
+ (void)H5T_close_real(old_path->dst);
old_path = H5FL_FREE(H5T_path_t, old_path);
/* Release temporary atoms */
@@ -2393,9 +2563,9 @@ done:
if(ret_value < 0) {
if(new_path) {
if(new_path->src)
- H5T_close(new_path->src);
+ (void)H5T_close_real(new_path->src);
if(new_path->dst)
- H5T_close(new_path->dst);
+ (void)H5T_close_real(new_path->dst);
new_path = H5FL_FREE(H5T_path_t, new_path);
} /* end if */
if(tmp_sid >= 0)
@@ -2405,9 +2575,9 @@ done:
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_register() */
+} /* end H5T__register() */
+
-
/*-------------------------------------------------------------------------
* Function: H5Tregister
*
@@ -2429,10 +2599,11 @@ done:
*/
herr_t
H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
- H5T_conv_t func)
+ H5T_conv_t func)
{
H5T_t *src; /*source data type descriptor */
H5T_t *dst; /*destination data type desc */
+ H5T_conv_func_t conv_func; /* Conversion function wrapper */
herr_t ret_value = SUCCEED; /*return value */
FUNC_ENTER_API(FAIL)
@@ -2450,44 +2621,44 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
if(!func)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function specified")
+ /* Set up conversion function wrapper */
+ conv_func.is_app = TRUE;
+ conv_func.u.app_func = func;
+
/* Go register the function */
- if(H5T_register(pers, name, src, dst, func, H5AC_noio_dxpl_id, TRUE) < 0)
+ if(H5T__register(pers, name, src, dst, &conv_func) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register conversion function")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tregister() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5T_unregister
+ * Function: H5T__unregister
*
* Purpose: Removes conversion paths that match the specified criteria.
* All arguments are optional. Missing arguments are wild cards.
* The special no-op path cannot be removed.
*
* Return: Succeess: non-negative
- *
* Failure: negative
*
* Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
- * Modifications:
- * Adapted to non-API function - QAK, 11/17/99
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
- H5T_conv_t func, hid_t dxpl_id)
+H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
+ H5T_conv_t func)
{
H5T_path_t *path = NULL; /*conversion path */
H5T_soft_t *soft = NULL; /*soft conversion information */
int nprint = 0; /*number of paths shut down */
int i; /*counter */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Remove matching entries from the soft list */
if(H5T_PERS_DONTCARE == pers || H5T_PERS_SOFT == pers) {
@@ -2500,7 +2671,7 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
continue;
if(dst && dst->shared->type != soft->dst)
continue;
- if(func && func != soft->func)
+ if(func && func != soft->conv.u.app_func)
continue;
HDmemmove(H5T_g.soft + i, H5T_g.soft + i + 1, (size_t)(H5T_g.nsoft - (i + 1)) * sizeof(H5T_soft_t));
@@ -2519,7 +2690,7 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
(name && *name && HDstrcmp(name, path->name)) ||
(src && H5T_cmp(src, path->src, FALSE)) ||
(dst && H5T_cmp(dst, path->dst, FALSE)) ||
- (func && func!=path->func)) {
+ (func && func != path->conv.u.app_func)) {
/*
* Notify all other functions to recalculate private data since some
* functions might cache a list of conversion functions. For
@@ -2537,27 +2708,36 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
/* Shut down path */
H5T__print_stats(path, &nprint);
path->cdata.command = H5T_CONV_FREE;
- if((path->func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata),
- (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0) {
+ if(path->conv.is_app) {
+ if((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) {
#ifdef H5T_DEBUG
- if(H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed "
- "to free private data for %s (ignored)\n",
- (unsigned long)(path->func), path->name);
- }
+ if(H5DEBUG(T))
+ HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed "
+ "to free private data for %s (ignored)\n",
+ (unsigned long)(path->conv.u.app_func), path->name);
#endif
- }
- H5T_close(path->src);
- H5T_close(path->dst);
+ } /* end if */
+ } /* end if */
+ else
+ if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
+#ifdef H5T_DEBUG
+ if(H5DEBUG(T))
+ HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed "
+ "to free private data for %s (ignored)\n",
+ (unsigned long)(path->conv.u.lib_func), path->name);
+#endif
+ } /* end if */
+ (void)H5T_close_real(path->src);
+ (void)H5T_close_real(path->dst);
path = H5FL_FREE(H5T_path_t, path);
H5E_clear_stack(NULL); /*ignore all shutdown errors*/
} /* end else */
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5T_unregister() */
+} /* end H5T__unregister() */
+
-
/*-------------------------------------------------------------------------
* Function: H5Tunregister
*
@@ -2576,7 +2756,7 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
*/
herr_t
H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
- H5T_conv_t func)
+ H5T_conv_t func)
{
H5T_t *src = NULL, *dst = NULL; /* Datatype descriptors */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2590,14 +2770,14 @@ H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
if(dst_id > 0 && (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type")
- if(H5T_unregister(pers, name, src, dst, func, H5AC_noio_dxpl_id) < 0)
+ if(H5T__unregister(pers, name, src, dst, func) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "internal unregister function failed")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tunregister() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tfind
*
@@ -2634,20 +2814,20 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no address to receive cdata pointer")
/* Find it */
- if(NULL == (path = H5T_path_find(src, dst, NULL, NULL, H5AC_noio_dxpl_id, FALSE)))
+ if(NULL == (path = H5T_path_find(src, dst)))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "conversion function not found")
if(pcdata)
*pcdata = &(path->cdata);
/* Set return value */
- ret_value = path->func;
+ ret_value = path->conv.u.app_func;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tfind() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tcompiler_conv
*
@@ -2680,14 +2860,14 @@ H5Tcompiler_conv(hid_t src_id, hid_t dst_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
/* Find it */
- if((ret_value = H5T_compiler_conv(src, dst)) < 0)
+ if((ret_value = H5T__compiler_conv(src, dst)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "conversion function not found")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tcompiler_conv() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tconvert
*
@@ -2732,18 +2912,71 @@ H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf,
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset transfer property list")
+ /* Set DXPL for operation */
+ H5CX_set_dxpl(dxpl_id);
+
/* Find the conversion function */
- if(NULL == (tpath = H5T_path_find(src, dst, NULL, NULL, dxpl_id, FALSE)))
+ if(NULL == (tpath = H5T_path_find(src, dst)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types")
- if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background, dxpl_id) < 0)
+ if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tconvert() */
-
+
+/*-------------------------------------------------------------------------
+ * Function: H5Treclaim
+ *
+ * Purpose: Frees the buffers allocated for storing variable-length data
+ * in memory. Only frees the VL data in the selection defined in the
+ * dataspace. The dataset transfer property list is required to find the
+ * correct allocation/free methods for the VL data in the buffer.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, June 10, 1999
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Treclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf)
+{
+ H5S_t *space; /* Dataspace for iteration */
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf);
+
+ /* Check args */
+ if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
+ if(!(H5S_has_extent(space)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
+
+ /* Get the default dataset transfer property list if the user didn't provide one */
+ if(H5P_DEFAULT == dxpl_id)
+ dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
+
+ /* Set DXPL for operation */
+ H5CX_set_dxpl(dxpl_id);
+
+ /* Call internal routine */
+ ret_value = H5T_reclaim(type_id, space, buf);
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Treclaim() */
+
+
/*-------------------------------------------------------------------------
* Function: H5Tencode
*
@@ -2782,7 +3015,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tencode() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Tdecode
*
@@ -2815,8 +3048,13 @@ H5Tdecode(const void *buf)
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty buffer")
- /* Create datatype by decoding buffer */
- if(NULL == (dt = H5T_decode((const unsigned char *)buf)))
+ /* Create datatype by decoding buffer
+ * There is no way to get the size of the buffer, so we pass in
+ * SIZE_MAX and assume the caller knows what they are doing.
+ * Really fixing this will require an H5Tdecode2() call that
+ * takes a size parameter.
+ */
+ if(NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object")
/* Register the type and return the ID */
@@ -2832,7 +3070,7 @@ done:
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* Function: H5T_encode
*
@@ -2888,7 +3126,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_encode() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_decode
*
@@ -2905,7 +3143,7 @@ done:
*-------------------------------------------------------------------------
*/
H5T_t *
-H5T_decode(const unsigned char *buf)
+H5T_decode(size_t buf_size, const unsigned char *buf)
{
H5F_t *f = NULL; /* Fake file structure*/
H5T_t *ret_value = NULL; /* Return value */
@@ -2925,13 +3163,15 @@ H5T_decode(const unsigned char *buf)
HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, NULL, "unknown version of encoded datatype")
/* Decode the serialized datatype message */
- if(NULL == (ret_value = (H5T_t *)H5O_msg_decode(f, H5AC_noio_dxpl_id, NULL, H5O_DTYPE_ID, buf)))
+ if(NULL == (ret_value = (H5T_t *)H5O_msg_decode(f, NULL, H5O_DTYPE_ID, buf_size, buf)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object")
/* Mark datatype as being in memory now */
if(H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
+ /* No VOL object */
+ ret_value->vol_obj = NULL;
done:
/* Release fake file structure */
if(f && H5F_fake_free(f) < 0)
@@ -2940,7 +3180,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_decode() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T__create
*
@@ -2985,7 +3225,7 @@ H5T__create(H5T_class_t type, size_t size)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy");
/* Modify the datatype */
- if(H5T_set_size(dt, size) < 0)
+ if(H5T__set_size(dt, size) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set size for string type")
}
break;
@@ -3048,13 +3288,16 @@ H5T__create(H5T_class_t type, size_t size)
case H5T_REFERENCE:
case H5T_NCLASSES:
default:
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL, "unknown data type class")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "unknown data type class")
} /* end switch */
/* Set the size except VL string */
if(H5T_STRING != type || H5T_VARIABLE != size)
dt->shared->size = size;
+ /* No VOL object */
+ dt->vol_obj = NULL;
+
/* Set return value */
ret_value = dt;
@@ -3063,153 +3306,158 @@ done:
if(dt) {
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
dt = H5FL_FREE(H5T_t, dt);
- } /* end if */
- } /* end if */
+ }
+ }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__create() */
/*-------------------------------------------------------------------------
- * Function: H5T_copy
+ * Function: H5T__initiate_copy
*
- * Purpose: Copies datatype OLD_DT. The resulting data type is not
- * locked and is a transient type.
+ * Purpose: Allocates datatype structures, copies core fields, and initializes
+ * VOL fields.
*
* Return: Success: Pointer to a new copy of the OLD_DT argument.
- *
* Failure: NULL
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
- *
- * Modifications:
- *
- * Robb Matzke, 4 Jun 1998
- * Added the METHOD argument. If it's H5T_COPY_TRANSIENT then the
- * result will be an unlocked transient type. Otherwise if it's
- * H5T_COPY_ALL then the result is a named type if the original is a
- * named type, but the result is not opened. Finally, if it's
- * H5T_COPY_REOPEN and the original type is a named type then the result
- * is a named type and the type object header is opened again. The
- * H5T_COPY_REOPEN method is used when returning a named type to the
- * application.
- *
- * Robb Matzke, 22 Dec 1998
- * Now able to copy enumeration data types.
+ * Note: Common code for both H5T_copy and H5T_copy_reopen, as part of
+ * the const-correct datatype copying routines.
*
- * Robb Matzke, 20 May 1999
- * Now able to copy opaque types.
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 21 Sep 2002
- * Added a deep copy of the symbol table entry
+ * Programmer: David Young
+ * January 18, 2020
*
*-------------------------------------------------------------------------
*/
-H5T_t *
-H5T_copy(H5T_t *old_dt, H5T_copy_t method)
+static H5T_t *
+H5T__initiate_copy(const H5T_t *old_dt)
{
- H5T_t *new_dt = NULL, *tmp = NULL;
- H5T_shared_t *reopened_fo = NULL;
- unsigned i;
- char *s;
- H5T_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
+ H5T_t *new_dt = NULL; /* Copy of datatype */
+ H5T_t *ret_value = NULL; /* Return value */
- /* check args */
- HDassert(old_dt);
+ FUNC_ENTER_STATIC
/* Allocate space */
if(NULL == (new_dt = H5FL_MALLOC(H5T_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "H5T_t memory allocation failed")
if(NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "H5T_shared_t memory allocation failed")
- /* Copy shared information (entry information is copied last) */
+ /* Copy shared information */
*(new_dt->shared) = *(old_dt->shared);
- /* Check what sort of copy we are making */
- switch (method) {
- case H5T_COPY_TRANSIENT:
- /*
- * Return an unlocked transient type.
- */
- new_dt->shared->state = H5T_STATE_TRANSIENT;
- break;
+ /* Reset VOL fields */
+ new_dt->vol_obj = NULL;
+ new_dt->shared->owned_vol_obj = NULL;
- case H5T_COPY_ALL:
- /*
- * Return a transient type (locked or unlocked) or an unopened named
- * type. Immutable transient types are degraded to read-only.
- */
- if(H5T_STATE_OPEN==old_dt->shared->state)
- new_dt->shared->state = H5T_STATE_NAMED;
- else if(H5T_STATE_IMMUTABLE==old_dt->shared->state)
- new_dt->shared->state = H5T_STATE_RDONLY;
- break;
+ /* Set return value */
+ ret_value = new_dt;
- case H5T_COPY_REOPEN:
- /*
- * Return a transient type (locked or unlocked) or an opened named
- * type. Immutable transient types are degraded to read-only.
- */
- if(old_dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
- /* Check if the object is already open */
- if(NULL == (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) {
- /* Clear any errors from H5FO_opened() */
- H5E_clear_stack(NULL);
+done:
+ if(ret_value == NULL)
+ if(new_dt) {
+ if(new_dt->shared)
+ new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
+ new_dt = H5FL_FREE(H5T_t, new_dt);
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__initiate_copy() */
- /* Open named datatype again */
- if(H5O_open(&old_dt->oloc) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type");
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__copy_transient
+ *
+ * Purpose: Part of recursive framework for const-correct datatype copying.
+ *
+ * Return: Success: Pointer to a new copy of the OLD_DT argument.
+ * Failure: NULL
+ *
+ * Programmer: David Young
+ * January 18, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static H5T_t *
+H5T__copy_transient(H5T_t *old_dt)
+{
+ H5T_t *ret_value = NULL; /* Return value */
- /* Insert opened named datatype into opened object list for the file */
- if(H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects")
+ FUNC_ENTER_STATIC
- /* Increment object count for the object in the top file */
- if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
+ /* Copy datatype, with correct method */
+ if(NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't make 'transient' copy of datatype")
- new_dt->shared->fo_count = 1;
- } /* end if */
- else {
- /* The object is already open. Free the H5T_shared_t struct
- * we had been using and use the one that already exists.
- * Not terribly efficient. */
- new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
- new_dt->shared = reopened_fo;
-
- reopened_fo->fo_count++;
-
- /* Check if the object has been opened through the top file yet */
- if(H5FO_top_count(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) == 0) {
- /* Open the object through this top file */
- if(H5O_open(&old_dt->oloc) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header")
- } /* end if */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__copy_transient() */
- /* Increment object count for the object in the top file */
- if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
- } /* end else */
- new_dt->shared->state = H5T_STATE_OPEN;
- }
- else if(H5T_STATE_IMMUTABLE == old_dt->shared->state) {
- new_dt->shared->state = H5T_STATE_RDONLY;
- }
- break;
- default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "invalid copy method type")
- } /* end switch */
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__copy_all
+ *
+ * Purpose: Part of recursive framework for const-correct datatype copying.
+ *
+ * Return: Success: Pointer to a new copy of the OLD_DT argument.
+ * Failure: NULL
+ *
+ * Programmer: David Young
+ * January 18, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static H5T_t *
+H5T__copy_all(H5T_t *old_dt)
+{
+ H5T_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Copy datatype, with correct method */
+ if(NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_ALL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't make 'all' copy of datatype")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__copy_transient() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__complete_copy
+ *
+ * Purpose: Completes copying datatype fields, as part of the recursive
+ * const-correct datatype copy routines.
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Note: Common code for both H5T_copy and H5T_copy_reopen.
+ *
+ * Programmer: David Young
+ * January 18, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo,
+ hbool_t set_memory_type, H5T_copy_func_t copyfn)
+{
+ H5T_t *tmp = NULL; /* Temporary copy of compound field's datatype */
+ char *s; /* Temporary copy of compound field name / enum value name */
+ unsigned i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
/* Update fields in the new struct, if we aren't sharing an already opened
* committed datatype */
if(!reopened_fo) {
/* Copy parent information */
if(old_dt->shared->parent)
- new_dt->shared->parent = H5T_copy(old_dt->shared->parent, method);
+ if(NULL == (new_dt->shared->parent = (*copyfn)(old_dt->shared->parent)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy datatype's parent type")
switch(new_dt->shared->type) {
case H5T_COMPOUND:
@@ -3223,12 +3471,10 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
*/
/* Only malloc if space has been allocated for members - NAF */
if(new_dt->shared->u.compnd.nalloc > 0) {
- new_dt->shared->u.compnd.memb =
- (H5T_cmemb_t *)H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t));
- if (NULL == new_dt->shared->u.compnd.memb)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if(NULL == (new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t))))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed")
- HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
+ H5MM_memcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t));
} /* end if */
@@ -3236,15 +3482,17 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
unsigned j;
int old_match;
- s = new_dt->shared->u.compnd.memb[i].name;
- new_dt->shared->u.compnd.memb[i].name = H5MM_xstrdup(s);
- tmp = H5T_copy (old_dt->shared->u.compnd.memb[i].type, method);
+ if(NULL == (s = H5MM_xstrdup(new_dt->shared->u.compnd.memb[i].name)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy string for compound field's name")
+ new_dt->shared->u.compnd.memb[i].name = s;
+ if(NULL == (tmp = (*copyfn)(old_dt->shared->u.compnd.memb[i].type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy compound field's datatype")
new_dt->shared->u.compnd.memb[i].type = tmp;
HDassert(tmp != NULL);
/* Range check against compound member's offset */
- if ((accum_change < 0) && ((ssize_t) new_dt->shared->u.compnd.memb[i].offset < accum_change))
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype");
+ if((accum_change < 0) && ((ssize_t) new_dt->shared->u.compnd.memb[i].offset < accum_change))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype")
/* Apply the accumulated size change to the offset of the field */
new_dt->shared->u.compnd.memb[i].offset += (size_t) accum_change;
@@ -3259,7 +3507,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
/* check if we couldn't find a match */
if(old_match < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "fields in datatype corrupted")
} /* end if */
else
old_match = (int) i;
@@ -3274,8 +3522,8 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
} /* end for */
/* Range check against datatype size */
- if ((accum_change < 0) && ((ssize_t) new_dt->shared->size < accum_change))
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype");
+ if((accum_change < 0) && ((ssize_t) new_dt->shared->size < accum_change))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype")
/* Apply the accumulated size change to the size of the compound struct */
new_dt->shared->size += (size_t) accum_change;
@@ -3288,27 +3536,25 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
* of each new member with copied values. That is, H5T_copy() is a
* deep copy.
*/
- new_dt->shared->u.enumer.name =
- (char **)H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char*));
- new_dt->shared->u.enumer.value =
- (uint8_t *)H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size);
- if(NULL == new_dt->shared->u.enumer.value)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- HDmemcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value,
+ if(NULL == (new_dt->shared->u.enumer.name = H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char*))))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "enam name array memory allocation failed")
+ if(NULL == (new_dt->shared->u.enumer.value = H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "enam value array memory allocation failed")
+ H5MM_memcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value,
new_dt->shared->u.enumer.nmembs * new_dt->shared->size);
for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) {
- s = old_dt->shared->u.enumer.name[i];
- new_dt->shared->u.enumer.name[i] = H5MM_xstrdup(s);
+ if(NULL == (s = H5MM_xstrdup(old_dt->shared->u.enumer.name[i])))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy string for enum value's name")
+ new_dt->shared->u.enumer.name[i] = s;
} /* end for */
break;
case H5T_VLEN:
case H5T_REFERENCE:
- if(method == H5T_COPY_TRANSIENT || method == H5T_COPY_REOPEN) {
+ if(set_memory_type)
/* H5T_copy converts any type into a memory type */
if(H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location");
- } /* end if */
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
case H5T_OPAQUE:
@@ -3320,7 +3566,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
case H5T_ARRAY:
/* Re-compute the array's size, in case it's base type changed size */
- new_dt->shared->size=new_dt->shared->u.array.nelem*new_dt->shared->parent->shared->size;
+ new_dt->shared->size = new_dt->shared->u.array.nelem * new_dt->shared->parent->shared->size;
break;
case H5T_NO_CLASS:
@@ -3339,15 +3585,15 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
* type and the new type is also named.
*/
if(H5O_loc_reset(&new_dt->oloc) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, NULL, "unable to initialize location")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location")
if(H5G_name_reset(&new_dt->path) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset path")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path")
if(new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) {
- if(H5O_loc_copy(&(new_dt->oloc), &(old_dt->oloc), H5_COPY_DEEP) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location")
+ if(H5O_loc_copy_deep(&(new_dt->oloc), &(old_dt->oloc)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy object location")
if(H5G_name_copy(&(new_dt->path), &(old_dt->path), H5_COPY_DEEP) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to copy path")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy path")
} /* end if */
/* Copy shared location information if the new type is named or if it is
@@ -3356,29 +3602,195 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method)
if((old_dt->sh_loc.type == H5O_SHARE_TYPE_SOHM || old_dt->sh_loc.type == H5O_SHARE_TYPE_HERE) ||
new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) {
if(H5O_set_shared(&(new_dt->sh_loc), &(old_dt->sh_loc)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy shared information")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy shared information")
} /* end if */
else
/* Reset shared component info */
H5O_msg_reset_share(H5O_DTYPE_ID, new_dt);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__complete_copy() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_copy
+ *
+ * Purpose: Copies datatype OLD_DT. The resulting data type is not
+ * locked and is a transient type.
+ *
+ * Return: Success: Pointer to a new copy of the OLD_DT argument.
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
+{
+ H5T_t *new_dt = NULL; /* New datatype */
+ H5T_copy_func_t copyfn; /* Pointer to correct copy routine */
+ H5T_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* check args */
+ HDassert(old_dt);
+
+ /* Allocate and copy core datatype information */
+ if(NULL == (new_dt = H5T__initiate_copy(old_dt)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy core datatype info")
+
+ /* Check what sort of copy we are making */
+ switch (method) {
+ case H5T_COPY_TRANSIENT:
+ /*
+ * Return an unlocked transient type.
+ */
+ new_dt->shared->state = H5T_STATE_TRANSIENT;
+ copyfn = H5T__copy_transient;
+ break;
+
+ case H5T_COPY_ALL:
+ /*
+ * Return a transient type (locked or unlocked) or an unopened named
+ * type. Immutable transient types are degraded to read-only.
+ */
+ if(H5T_STATE_OPEN==old_dt->shared->state)
+ new_dt->shared->state = H5T_STATE_NAMED;
+ else if(H5T_STATE_IMMUTABLE==old_dt->shared->state)
+ new_dt->shared->state = H5T_STATE_RDONLY;
+ copyfn = H5T__copy_all;
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "invalid copy method type")
+ } /* end switch */
+
+ /* Finish making the copy of the datatype */
+ if(H5T__complete_copy(new_dt, old_dt, NULL, (method == H5T_COPY_TRANSIENT), copyfn) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't complete datatype initialization")
+
/* Set return value */
ret_value = new_dt;
done:
- if(ret_value == NULL) {
+ if(ret_value == NULL)
if(new_dt) {
- if(new_dt->shared)
- new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
+ HDassert(new_dt->shared);
+ new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
new_dt = H5FL_FREE(H5T_t, new_dt);
} /* end if */
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_copy() */
/*-------------------------------------------------------------------------
+ * Function: H5T_copy_reopen
+ *
+ * Purpose: Copy a datatype, possibly reopening a named datatype, as part
+ * the const-correct datatype copying routines.
+ *
+ * Return: Success: Pointer to a new copy of the OLD_DT argument.
+ * Failure: NULL
+ *
+ * Programmer: David Young
+ * January 18, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_copy_reopen(H5T_t *old_dt)
+{
+ H5T_t *new_dt = NULL; /* New datatype */
+ H5T_shared_t *reopened_fo = NULL; /* Pointer to reopened existing named datatype */
+ H5T_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* check args */
+ HDassert(old_dt);
+
+ /* Allocate and copy core datatype information */
+ if(NULL == (new_dt = H5T__initiate_copy(old_dt)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy core datatype info")
+
+ /*
+ * Return a transient type (locked or unlocked) or an opened named
+ * type. Immutable transient types are degraded to read-only.
+ */
+ if(old_dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
+ /* Check if the object is already open */
+ if(NULL == (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) {
+ /* Clear any errors from H5FO_opened() */
+ H5E_clear_stack(NULL);
+
+ /* Open named datatype again */
+ if(H5O_open(&old_dt->oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type")
+
+ /* Insert opened named datatype into opened object list for the file */
+ if(H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects")
+
+ /* Increment object count for the object in the top file */
+ if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
+
+ new_dt->shared->fo_count = 1;
+ } /* end if */
+ else {
+ /* The object is already open. Free the H5T_shared_t struct
+ * we had been using and use the one that already exists.
+ * Not terribly efficient. */
+ new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
+ new_dt->shared = reopened_fo;
+
+ reopened_fo->fo_count++;
+
+ /* Check if the object has been opened through the top file yet */
+ if(H5FO_top_count(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) == 0) {
+ /* Open the object through this top file */
+ if(H5O_open(&old_dt->oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header")
+ } /* end if */
+
+ /* Increment object count for the object in the top file */
+ if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
+ } /* end else */
+
+ /* Set state for new datatype */
+ new_dt->shared->state = H5T_STATE_OPEN;
+ } /* end if */
+ else
+ /* Downgrade immutable datatypes to read-only */
+ if(H5T_STATE_IMMUTABLE == old_dt->shared->state)
+ new_dt->shared->state = H5T_STATE_RDONLY;
+
+ /* Finish making the copy of the datatype */
+ if(H5T__complete_copy(new_dt, old_dt, reopened_fo, TRUE, H5T_copy_reopen) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't complete datatype initialization")
+
+ /* Set return value */
+ ret_value = new_dt;
+
+done:
+ if(ret_value == NULL)
+ if(new_dt) {
+ HDassert(new_dt->shared);
+ new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
+ new_dt = H5FL_FREE(H5T_t, new_dt);
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_copy_reopen() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5T_lock
*
* Purpose: Lock a transient data type making it read-only. If IMMUTABLE
@@ -3395,9 +3807,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5T_lock (H5T_t *dt, hbool_t immutable)
+H5T_lock(H5T_t *dt, hbool_t immutable)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -3408,7 +3820,8 @@ H5T_lock (H5T_t *dt, hbool_t immutable)
dt->shared->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY;
break;
case H5T_STATE_RDONLY:
- if (immutable) dt->shared->state = H5T_STATE_IMMUTABLE;
+ if(immutable)
+ dt->shared->state = H5T_STATE_IMMUTABLE;
break;
case H5T_STATE_IMMUTABLE:
case H5T_STATE_NAMED:
@@ -3423,7 +3836,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
-
+
/*-------------------------------------------------------------------------
* Function: H5T__alloc
*
@@ -3456,6 +3869,9 @@ H5T__alloc(void)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
dt->shared->version = H5O_DTYPE_VERSION_1;
+ /* No VOL object initially */
+ dt->vol_obj = NULL;
+
/* Assign return value */
ret_value = dt;
@@ -3470,13 +3886,13 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__alloc() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T__free
*
* Purpose: Frees all memory associated with a datatype, but does not
* free the H5T_t or H5T_shared_t structures (which should
- * be done in H5T_close).
+ * be done in H5T_close / H5T_close_real).
*
* Return: Non-negative on success/Negative on failure
*
@@ -3495,32 +3911,11 @@ H5T__free(H5T_t *dt)
HDassert(dt && dt->shared);
- /*
- * If a named type is being closed then close the object header and
- * remove from the list of open objects in the file.
- */
- if(H5T_STATE_OPEN == dt->shared->state) {
- HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED);
- HDassert(H5F_addr_defined(dt->sh_loc.u.loc.oh_addr));
- HDassert(H5F_addr_defined(dt->oloc.addr));
-
- /* Remove the datatype from the list of opened objects in the file */
- if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
- if(H5FO_delete(dt->sh_loc.file, H5AC_ind_read_dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects")
- if(H5O_close(&dt->oloc, NULL) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header")
- dt->shared->state = H5T_STATE_NAMED;
- } /* end if */
-
/* Free the ID to name info */
H5G_name_free(&(dt->path));
- /*
- * Don't free locked datatypes.
- */
- if(H5T_STATE_IMMUTABLE==dt->shared->state)
+ /* Don't free locked datatypes */
+ if(H5T_STATE_IMMUTABLE == dt->shared->state)
HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype")
/* Close the datatype */
@@ -3528,8 +3923,8 @@ H5T__free(H5T_t *dt)
case H5T_COMPOUND:
for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
dt->shared->u.compnd.memb[i].name = (char *)H5MM_xfree(dt->shared->u.compnd.memb[i].name);
- H5T_close(dt->shared->u.compnd.memb[i].type);
- } /* end for */
+ (void)H5T_close_real(dt->shared->u.compnd.memb[i].type);
+ }
dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_xfree(dt->shared->u.compnd.memb);
dt->shared->u.compnd.nmembs = 0;
break;
@@ -3563,69 +3958,127 @@ H5T__free(H5T_t *dt)
/* Close the parent */
HDassert(dt->shared->parent != dt);
- if(dt->shared->parent && H5T_close(dt->shared->parent) < 0)
+ if(dt->shared->parent && H5T_close_real(dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type")
dt->shared->parent = NULL;
+ /* Close the owned VOL object */
+ if(dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object")
+ dt->shared->owned_vol_obj = NULL;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__free() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5T_close
+ * Function: H5T_close_real
+ *
+ * Purpose: Frees a datatype and all associated memory.
*
- * Purpose: Frees a data type and all associated memory. If the data
- * type is locked then nothing happens.
+ * Note: Does _not_ deal with open named datatypes, etc. so this
+ * should never see a type managed by a VOL connector.
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke
- * Monday, December 8, 1997
+ * Programmer: Quincey Koziol
+ * Monday, February 12, 2018
*
*-------------------------------------------------------------------------
*/
herr_t
-H5T_close(H5T_t *dt)
+H5T_close_real(H5T_t *dt)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
+ /* Sanity check */
HDassert(dt && dt->shared);
- if(dt->shared->state == H5T_STATE_OPEN)
+ /* Clean up resources, depending on shared state */
+ if(dt->shared->state != H5T_STATE_OPEN) {
+ if(H5T__free(dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype");
+
+ dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
+ } /* end if */
+ else
+ /* Free the group hier. path since we're not calling H5T__free() */
+ H5G_name_free(&(dt->path));
+
+ /* Free the 'top' datatype struct */
+ dt = H5FL_FREE(H5T_t, dt);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_close_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_close
+ *
+ * Purpose: Frees a data type and all associated memory. Deals with
+ * open named datatypes appropriately.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_close(H5T_t *dt)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(dt);
+ HDassert(dt->shared);
+
+ /* Named datatype cleanups */
+ if(dt->shared->state == H5T_STATE_OPEN) {
+ /* Decrement refcount count on open named datatype */
dt->shared->fo_count--;
- if(dt->shared->state != H5T_STATE_OPEN || dt->shared->fo_count == 0) {
- /* Uncork cache entries with object address tag for named datatype only */
- if(dt->shared->state == H5T_STATE_OPEN && dt->shared->fo_count == 0) {
- hbool_t corked; /* Whether the named datatype is corked or not */
+ /* Sanity checks */
+ HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED);
+ HDassert(H5F_addr_defined(dt->sh_loc.u.loc.oh_addr));
+ HDassert(H5F_addr_defined(dt->oloc.addr));
+
+ /* If a named type is being closed then close the object header and
+ * remove from the list of open objects in the file.
+ */
+ /* Decrement the ref. count for this object in the top file */
+ if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
+
+ /* Close things down if this is the last reference to the open named datatype */
+ if(0 == dt->shared->fo_count) {
+ hbool_t corked; /* Whether the named datatype is corked or not */
+
+ /* Uncork cache entries with object address tag for named datatype */
if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
if(corked)
if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__UNCORK, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTUNCORK, FAIL, "unable to uncork an object")
- } /* end if */
-
- if(H5T__free(dt) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype");
- dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
- } /* end if */
- else {
- /*
- * If a named type is being closed then close the object header and
- * remove from the list of open objects in the file.
- */
- if(H5T_STATE_OPEN == dt->shared->state) {
- HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED);
-
- /* Decrement the ref. count for this object in the top file */
- if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
+ /* Remove the datatype from the list of opened objects in the file */
+ if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects")
+ if(H5O_close(&dt->oloc, NULL) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header")
+ /* Mark named datatype closed now */
+ dt->shared->state = H5T_STATE_NAMED;
+ } /* end if */
+ else {
/* Check reference count for this object in the top file */
if(H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) {
/* Close object location for named datatype */
@@ -3633,26 +4086,23 @@ H5T_close(H5T_t *dt)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close")
} /* end if */
else
- /* Free object location (i.e. "unhold" the file if appropriate)
- */
+ /* Free object location (i.e. "unhold" the file if appropriate) */
if(H5O_loc_free(&(dt->oloc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location")
- } /* end if */
-
- /* Free the group hier. path since we're not calling H5T__free() */
- H5G_name_free(&(dt->path));
- } /* end else */
+ } /* end else */
+ } /* end if */
- /* Free the datatype struct */
- dt = H5FL_FREE(H5T_t, dt);
+ /* Clean up resources */
+ if(H5T_close_real(dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype");
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_close() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5T_set_size
+ * Function: H5T__set_size
*
* Purpose: Sets the total size in bytes for a data type (this operation
* is not permitted on reference data types). If the size is
@@ -3675,19 +4125,15 @@ done:
* Programmer: Robb Matzke
* Tuesday, December 22, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works with derived data types.
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5T_set_size(H5T_t *dt, size_t size)
+H5T__set_size(H5T_t *dt, size_t size)
{
size_t prec, offset;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(dt);
@@ -3695,8 +4141,8 @@ H5T_set_size(H5T_t *dt, size_t size)
HDassert(H5T_REFERENCE!=dt->shared->type);
HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs));
- if (dt->shared->parent) {
- if (H5T_set_size(dt->shared->parent, size)<0)
+ if(dt->shared->parent) {
+ if(H5T__set_size(dt->shared->parent, size) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type");
/* Adjust size of datatype appropriately */
@@ -3719,11 +4165,10 @@ H5T_set_size(H5T_t *dt, size_t size)
if (prec > 8*size)
prec = 8 * size;
}
- else {
+ else
prec = offset = 0;
- }
- switch (dt->shared->type) {
+ switch(dt->shared->type) {
case H5T_INTEGER:
case H5T_TIME:
case H5T_BITFIELD:
@@ -3748,20 +4193,20 @@ H5T_set_size(H5T_t *dt, size_t size)
if(memb_offset > max_offset) {
max_offset = memb_offset;
max_index = i;
- }
- }
+ } /* end if */
+ } /* end for */
max_size = H5T__get_member_size(dt, max_index);
if(size < (max_offset + max_size))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member ");
- }
+ } /* end if */
/* Compound must not have been packed previously */
/* We will check if resizing changed the packed state of
* this type at the end of this function */
HDassert(!dt->shared->u.compnd.packed);
- }
+ } /* end if */
break;
@@ -3801,8 +4246,7 @@ H5T_set_size(H5T_t *dt, size_t size)
/* Set up VL information */
if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location");
-
- }
+ } /* end if */
else {
prec = 8 * size;
offset = 0;
@@ -3814,7 +4258,7 @@ H5T_set_size(H5T_t *dt, size_t size)
* The sign, mantissa, and exponent fields should be adjusted
* first when decreasing the size of a floating point type.
*/
- if (dt->shared->u.atomic.u.f.sign >= prec+offset ||
+ if(dt->shared->u.atomic.u.f.sign >= prec+offset ||
dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset ||
dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) {
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first");
@@ -3827,14 +4271,16 @@ H5T_set_size(H5T_t *dt, size_t size)
case H5T_REFERENCE:
HDassert("can't happen" && 0);
break;
+
case H5T_NO_CLASS:
case H5T_NCLASSES:
HDassert("invalid type" && 0);
break;
+
default:
HDassert("not implemented yet" && 0);
break;
- }
+ } /* end switch */
/* Commit (if we didn't convert this type to a VL string) */
if(dt->shared->type != H5T_VLEN) {
@@ -3848,13 +4294,13 @@ H5T_set_size(H5T_t *dt, size_t size)
/* Check if the new compound type is packed */
if(dt->shared->type == H5T_COMPOUND)
H5T__update_packed(dt);
- }
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5T__set_size() */
+
-
/*-------------------------------------------------------------------------
* Function: H5T_get_size
*
@@ -3880,9 +4326,9 @@ H5T_get_size(const H5T_t *dt)
HDassert(dt);
FUNC_LEAVE_NOAPI(dt->shared->size)
-}
+} /* end H5T_get_size() */
+
-
/*-------------------------------------------------------------------------
* Function: H5T_cmp
*
@@ -4130,8 +4576,8 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
idx = u;
} /* end else */
- tmp = HDmemcmp(dt1->shared->u.enumer.value+idx1[u]*base_size,
- dt2->shared->u.enumer.value+idx2[idx]*base_size,
+ tmp = HDmemcmp((uint8_t *)dt1->shared->u.enumer.value + idx1[u] * base_size,
+ (uint8_t *)dt2->shared->u.enumer.value + idx2[idx] * base_size,
base_size);
if(tmp<0) HGOTO_DONE(-1);
if(tmp>0) HGOTO_DONE(1);
@@ -4168,9 +4614,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
}
/* Don't allow VL types in different files to compare as equal */
- if(dt1->shared->u.vlen.f < dt2->shared->u.vlen.f)
+ if(dt1->shared->u.vlen.file < dt2->shared->u.vlen.file)
HGOTO_DONE(-1);
- if(dt1->shared->u.vlen.f > dt2->shared->u.vlen.f)
+ if(dt1->shared->u.vlen.file > dt2->shared->u.vlen.file)
HGOTO_DONE(1);
break;
@@ -4297,28 +4743,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
HGOTO_DONE(-1);
if(dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype)
HGOTO_DONE(1);
-
- switch(dt1->shared->u.atomic.u.r.rtype) {
- case H5R_OBJECT:
- if(dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc)
- HGOTO_DONE(-1);
- if(dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc)
- HGOTO_DONE(1);
- break;
-
- case H5R_DATASET_REGION:
- /* Does this need more to distinguish it? -QAK 11/30/98 */
- /*void */
- break;
-
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- HDassert("invalid type" && 0);
- break;
- default:
- HDassert("not implemented yet" && 0);
- break;
- }
+ if(dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc)
+ HGOTO_DONE(-1);
+ if(dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc)
+ HGOTO_DONE(1);
break;
case H5T_NO_CLASS:
@@ -4344,10 +4772,57 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_cmp() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_path_find
*
+ * Purpose: Library-internal wrapper to find the path which converts type
+ * SRC_ID to type DST_ID.
+ *
+ * If SRC and DST are both null pointers then the special no-op
+ * conversion path is used.
+ *
+ * Return: Success: Pointer to the path, valid until the path
+ * database is modified.
+ *
+ * Failure: NULL if the path does not exist and no
+ * function can be found to apply to the new path.
+ *
+ * Programmer: Quincey Koziol
+ * Monday, March 5, 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_path_t *
+H5T_path_find(const H5T_t *src, const H5T_t *dst)
+{
+ H5T_conv_func_t conv_func; /* Conversion function wrapper */
+ H5T_path_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* Sanity check */
+ HDassert(src);
+ HDassert(src->shared);
+ HDassert(dst);
+ HDassert(dst->shared);
+
+ /* Set up conversion function wrapper */
+ conv_func.is_app = FALSE;
+ conv_func.u.lib_func = NULL;
+
+ /* Call the internal routine, with additional parameters */
+ if(NULL == (ret_value = H5T__path_find_real(src, dst, NULL, &conv_func)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't find datatype conversion path")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_path_find() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__path_find_real
+ *
* Purpose: Finds the path which converts type SRC_ID to type DST_ID,
* creating a new path if necessary. If FUNC is non-zero then
* it is set as the hard conversion function for that path
@@ -4361,30 +4836,19 @@ done:
* first path in the path table.
*
* Return: Success: Pointer to the path, valid until the path
- * database is modified.
+ * database is modified.
*
* Failure: NULL if the path does not exist and no
- * function can be found to apply to the new
- * path.
- *
- * Programmer: Robb Matzke
- * Tuesday, January 13, 1998
+ * function can be found to apply to the new path.
*
- * Modifications:
- * Added a parameter IS_API to indicate whether to an API
- * function issued a call to this function. If a API
- * function like H5Tregister() is calling this function to
- * register a new hard conversion function, IS_API is TRUE
- * and the old path is replaced. If a private function like
- * H5T__init_package() is trying to register hard conversions,
- * IS_API is FALSE and the old hard path is not replaced.
- * Tuesday, Sept 13, 2005
+ * Programmer: Robb Matzke
+ * Tuesday, January 13, 1998
*
*-------------------------------------------------------------------------
*/
-H5T_path_t *
-H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
- H5T_conv_t func, hid_t dxpl_id, hbool_t is_api)
+static H5T_path_t *
+H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name,
+ H5T_conv_func_t *conv)
{
int lt, rt; /* left and right edges */
int md; /* middle */
@@ -4397,7 +4861,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
int nprint = 0; /* lines of output printed */
H5T_path_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI(NULL)
+ FUNC_ENTER_STATIC
/* Sanity check */
HDassert(src);
@@ -4415,12 +4879,13 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
if(NULL == (H5T_g.path[0] = H5FL_CALLOC(H5T_path_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for no-op conversion path")
HDsnprintf(H5T_g.path[0]->name, sizeof(H5T_g.path[0]->name), "no-op");
- H5T_g.path[0]->func = H5T__conv_noop;
+ H5T_g.path[0]->conv.is_app = FALSE;
+ H5T_g.path[0]->conv.u.lib_func = H5T__conv_noop;
H5T_g.path[0]->cdata.command = H5T_CONV_INIT;
- if(H5T__conv_noop((hid_t)FAIL, (hid_t)FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0) {
+ if(H5T__conv_noop((hid_t)FAIL, (hid_t)FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
#ifdef H5T_DEBUG
if(H5DEBUG(T))
- fprintf(H5DEBUG(T), "H5T: unable to initialize no-op conversion function (ignored)\n");
+ HDfprintf(H5DEBUG(T), "H5T: unable to initialize no-op conversion function (ignored)\n");
#endif
H5E_clear_stack(NULL); /*ignore the error*/
} /* end if */
@@ -4428,8 +4893,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
H5T_g.npaths = 1;
} /* end if */
- /*
- * Find the conversion path. If source and destination types are equal
+ /* Find the conversion path. If source and destination types are equal
* then use entry[0], otherwise do a binary search over the
* remaining entries.
*
@@ -4468,13 +4932,12 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
*/
old_npaths = H5T_g.npaths;
- /*
- * If we didn't find the path, if the caller is an API function specifying
+ /* If we didn't find the path, if the caller is an API function specifying
* a new hard conversion function, or if the caller is a private function
* specifying a new hard conversion and the path is a soft conversion, then
* create a new path and add the new function to the path.
*/
- if(!table || (table && func && is_api) || (table && !table->is_hard && func && !is_api)) {
+ if(!table || (table && conv->is_app && conv->u.app_func) || (table && !table->is_hard && !conv->is_app && conv->u.lib_func)) {
if(NULL == (path = H5FL_CALLOC(H5T_path_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path")
if(name && *name) {
@@ -4491,28 +4954,32 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
else
path = table;
- /*
- * If a hard conversion function is specified and none is defined for the
+ /* If a hard conversion function is specified and none is defined for the
* path, or the caller is an API function, or the caller is a private function but
* the existing path is a soft function, then add the new conversion to the path
* and initialize its conversion data.
*/
- if(func && (!table || (table && is_api) || (table && !table->is_hard && !is_api))) {
+ if(conv->u.app_func && (!table || (table && conv->is_app) || (table && !table->is_hard && !conv->is_app))) {
HDassert(path != table);
- HDassert(NULL == path->func);
+ HDassert(NULL == path->conv.u.app_func);
if(path->src && (src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source conversion type for query")
if(path->dst && (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination conversion type for query")
path->cdata.command = H5T_CONV_INIT;
- if((func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function")
+ if(conv->is_app) {
+ if((conv->u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function")
+ } /* end if */
+ else
+ if((conv->u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function")
if(src_id >= 0)
H5I_dec_ref(src_id);
if(dst_id >= 0)
H5I_dec_ref(dst_id);
src_id = dst_id = -1;
- path->func = func;
+ path->conv = *conv;
path->is_hard = TRUE;
} /* end if */
@@ -4522,8 +4989,10 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* for an applicable function and add it to the path. This can't happen
* for the no-op conversion path.
*/
- HDassert(path->func || (src && dst));
- for(i = H5T_g.nsoft - 1; i >= 0 && !path->func; --i) {
+ HDassert(path->conv.u.app_func || (src && dst));
+ for(i = H5T_g.nsoft - 1; i >= 0 && !path->conv.u.app_func; --i) {
+ hbool_t path_init_error = FALSE;
+
if(src->shared->type != H5T_g.soft[i].src || dst->shared->type != H5T_g.soft[i].dst)
continue;
if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0)
@@ -4531,21 +5000,32 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register dst conversion type for query")
path->cdata.command = H5T_CONV_INIT;
- if((H5T_g.soft[i].func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0) {
- HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t));
- H5E_clear_stack(H5E_DEFAULT); /*ignore the error*/
+ if(H5T_g.soft[i].conv.is_app) {
+ if((H5T_g.soft[i].conv.u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) {
+ HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t));
+ H5E_clear_stack(NULL); /*ignore the error*/
+ path_init_error = TRUE;
+ } /* end if */
} /* end if */
- else {
+ else
+ if((H5T_g.soft[i].conv.u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
+ HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t));
+ H5E_clear_stack(NULL); /*ignore the error*/
+ path_init_error = TRUE;
+ } /* end if */
+
+ /* Finish operation, if no error */
+ if(!path_init_error) {
HDstrncpy(path->name, H5T_g.soft[i].name, (size_t)H5T_NAMELEN);
path->name[H5T_NAMELEN - 1] = '\0';
- path->func = H5T_g.soft[i].func;
+ path->conv = H5T_g.soft[i].conv;
path->is_hard = FALSE;
} /* end else */
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
src_id = dst_id = -1;
} /* end for */
- if(!path->func)
+ if(!path->conv.u.app_func)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no appropriate function for conversion path")
/* Check if paths were inserted into the table through a recursive call
@@ -4576,24 +5056,33 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
HDassert(table == H5T_g.path[md]);
H5T__print_stats(table, &nprint/*in,out*/);
table->cdata.command = H5T_CONV_FREE;
- if((table->func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0) {
+ if(table->conv.is_app) {
+ if((table->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) {
#ifdef H5T_DEBUG
- if(H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free "
- "failed for %s (ignored)\n",
- (unsigned long)(path->func), path->name);
- } /* end if */
+ if(H5DEBUG(T))
+ HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n",
+ (unsigned long)(path->conv.u.app_func), path->name);
#endif
- H5E_clear_stack(NULL); /*ignore the failure*/
+ H5E_clear_stack(NULL); /*ignore the failure*/
+ } /* end if */
} /* end if */
+ else
+ if((table->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) {
+#ifdef H5T_DEBUG
+ if(H5DEBUG(T))
+ HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n",
+ (unsigned long)(path->conv.u.lib_func), path->name);
+#endif
+ H5E_clear_stack(NULL); /*ignore the failure*/
+ } /* end if */
if(table->src)
- H5T_close(table->src);
+ (void)H5T_close_real(table->src);
if(table->dst)
- H5T_close(table->dst);
+ (void)H5T_close_real(table->dst);
table = H5FL_FREE(H5T_path_t, table);
table = path;
H5T_g.path[md] = path;
- }
+ } /* end if */
else if(path != table) {
HDassert(cmp);
if((size_t)H5T_g.npaths >= H5T_g.apaths) {
@@ -4624,9 +5113,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
done:
if(!ret_value && path && path != table) {
if(path->src)
- H5T_close(path->src);
+ (void)H5T_close_real(path->src);
if(path->dst)
- H5T_close(path->dst);
+ (void)H5T_close_real(path->dst);
path = H5FL_FREE(H5T_path_t, path);
} /* end if */
if(src_id >= 0)
@@ -4635,9 +5124,9 @@ done:
H5I_dec_ref(dst_id);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_path_find() */
+} /* end H5T__path_find_real() */
+
-
/*-------------------------------------------------------------------------
* Function: H5T_path_noop
*
@@ -4662,7 +5151,7 @@ H5T_path_noop(const H5T_path_t *p)
FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0==H5T_cmp(p->src, p->dst, FALSE)))
} /* end H5T_path_noop() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_path_compound_subset
*
@@ -4706,7 +5195,7 @@ H5T_path_compound_subset(const H5T_path_t *p)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_path_compound_subset */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_path_bkg
*
@@ -4728,9 +5217,9 @@ H5T_path_bkg(const H5T_path_t *p)
FUNC_LEAVE_NOAPI(p->cdata.need_bkg)
} /* end H5T_path_bkg() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5T_compiler_conv
+ * Function: H5T__compiler_conv
*
* Purpose: Private function for H5Tcompiler_conv. Finds out whether the
* library's conversion function from type SRC to type DST
@@ -4745,24 +5234,24 @@ H5T_path_bkg(const H5T_path_t *p)
*-------------------------------------------------------------------------
*/
static htri_t
-H5T_compiler_conv(H5T_t *src, H5T_t *dst)
+H5T__compiler_conv(H5T_t *src, H5T_t *dst)
{
H5T_path_t *path;
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Find it */
- if (NULL==(path=H5T_path_find(src, dst, NULL, NULL, H5AC_noio_dxpl_id, FALSE)))
+ if(NULL == (path = H5T_path_find(src, dst)))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "conversion function not found")
ret_value = (htri_t)path->is_hard;
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5T__compiler_conv() */
+
-
/*-------------------------------------------------------------------------
* Function: H5T_convert
*
@@ -4776,43 +5265,16 @@ done:
* Programmer: Robb Matzke
* Tuesday, December 15, 1998
*
- * Modifications:
- * Robb Matzke, 1999-06-16
- * The timers are updated only if H5T debugging is enabled at
- * runtime in addition to compile time.
- *
- * Robb Matzke, 1999-06-16
- * Added support for non-zero strides. If BUF_STRIDE is non-zero
- * then convert one value at each memory location advancing
- * BUF_STRIDE bytes each time; otherwise assume both source and
- * destination values are packed.
- *
- * Quincey Koziol, 1999-07-01
- * Added dataset transfer properties, to allow custom VL
- * datatype allocation function to be passed down to VL
- * conversion routine.
- *
- * Robb Matzke, 2000-05-17
- * Added the BKG_STRIDE argument which gets passed to all the
- * conversion functions. If BUF_STRIDE is non-zero then each
- * data element is at a multiple of BUF_STRIDE bytes in BUF
- * (on both input and output). If BKG_STRIDE is also set then
- * the BKG buffer is used in such a way that temporary space
- * for each element is aligned on a BKG_STRIDE byte boundary.
- * If either BUF_STRIDE or BKG_STRIDE are zero then the BKG
- * buffer will be accessed as though it were a packed array
- * of destination datatype.
*-------------------------------------------------------------------------
*/
herr_t
H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts,
- size_t buf_stride, size_t bkg_stride, void *buf, void *bkg,
- hid_t dset_xfer_plist)
+ size_t buf_stride, size_t bkg_stride, void *buf, void *bkg)
{
#ifdef H5T_DEBUG
H5_timer_t timer; /* Timer for conversion */
#endif
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -4826,10 +5288,13 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts,
/* Call the appropriate conversion callback */
tpath->cdata.command = H5T_CONV_CONV;
- if((tpath->func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride,
- bkg_stride, buf, bkg, dset_xfer_plist) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "data type conversion failed");
-
+ if(tpath->conv.is_app) {
+ if((tpath->conv.u.app_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg, H5CX_get_dxpl()) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
+ } /* end if */
+ else
+ if((tpath->conv.u.lib_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
#ifdef H5T_DEBUG
if(H5DEBUG(T)) {
/* Stop timer */
@@ -4848,7 +5313,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_convert() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_oloc
*
@@ -4889,7 +5354,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_oloc() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_nameof
*
@@ -4904,7 +5369,7 @@ done:
*-------------------------------------------------------------------------
*/
H5G_name_t *
-H5T_nameof(H5T_t *dt)
+H5T_nameof(const H5T_t *dt)
{
H5G_name_t *ret_value = NULL;
@@ -4929,7 +5394,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_nameof() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_is_immutable
*
@@ -4959,18 +5424,14 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
-
+
/*-------------------------------------------------------------------------
* Function: H5T_is_named
*
- * Purpose: Check if a datatype is named.
+ * Purpose: Check if a datatype is named/committed.
*
- * Return: TRUE
+ * Return: TRUE/FALSE/FAIL
*
- * FALSE
- *
- * Programmer: Pedro Vicente
- * Tuesday, Sep 3, 2002
*-------------------------------------------------------------------------
*/
htri_t
@@ -4982,8 +5443,10 @@ H5T_is_named(const H5T_t *dt)
HDassert(dt);
- if(dt->shared->state == H5T_STATE_OPEN || dt->shared->state == H5T_STATE_NAMED)
+ if(dt->vol_obj)
ret_value = TRUE;
+ else
+ ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -5025,14 +5488,28 @@ H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f)
if(H5G_name_free(&dt->path) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path")
+ /* If the datatype is committed through the VOL, close it */
+ if(NULL != dt->vol_obj) {
+ H5VL_object_t *vol_obj = dt->vol_obj;
+
+ /* Close the datatype through the VOL*/
+ if(H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype")
+
+ /* Free the datatype and set the VOL object pointer to NULL */
+ if(H5VL_free_object(vol_obj) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object")
+ dt->vol_obj = NULL;
+ } /* end if */
+
dt->shared->state = H5T_STATE_TRANSIENT;
- }
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_convert_committed_datatype() */
-
+
/*--------------------------------------------------------------------------
* Function: H5T_get_ref_type
*
@@ -5061,7 +5538,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_get_ref_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_is_sensible
*
@@ -5123,7 +5600,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
-
+
/*--------------------------------------------------------------------------
NAME
H5T_set_loc
@@ -5133,7 +5610,7 @@ done:
htri_t H5T_set_loc(dt,f,loc)
H5T_t *dt; IN/OUT: Pointer to the datatype to mark
H5F_t *f; IN: Pointer to the file the datatype is in
- H5T_vlen_type_t loc IN: location of type
+ H5T_loc_t loc IN: location of type
RETURNS
One of two values on success:
@@ -5146,7 +5623,7 @@ done:
--------------------------------------------------------------------------
*/
htri_t
-H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc)
+H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc)
{
htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */
htri_t ret_value = 0; /* Indicate that success, but no location change */
@@ -5170,8 +5647,8 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc)
old_size=dt->shared->parent->shared->size;
/* Mark the VL, compound or array type */
- if((changed=H5T_set_loc(dt->shared->parent,f,loc))<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
+ if((changed=H5T_set_loc(dt->shared->parent, file, loc))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location")
if(changed>0)
ret_value=changed;
@@ -5210,13 +5687,18 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc)
old_size = memb_type->shared->size;
/* Mark the VL, compound, enum or array type */
- if((changed = H5T_set_loc(memb_type,f,loc)) < 0)
+ if((changed = H5T_set_loc(memb_type, file, loc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(changed > 0)
ret_value = changed;
/* Check if the field changed size */
if(old_size != memb_type->shared->size) {
+
+ /* Fail if the old_size is zero */
+ if (0 == old_size)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero");
+
/* Adjust the size of the member */
dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size;
@@ -5239,31 +5721,23 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc)
/* Recurse if it's VL, compound, enum or array */
/* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */
if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) {
- if((changed = H5T_set_loc(dt->shared->parent,f,loc)) < 0)
+ if((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(changed > 0)
ret_value = changed;
} /* end if */
/* Mark this VL sequence */
- if((changed = H5T__vlen_set_loc(dt, f, loc)) < 0)
+ if((changed = H5T__vlen_set_loc(dt, file, loc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(changed > 0)
ret_value = changed;
break;
case H5T_REFERENCE:
- /* Only need to change location of object references */
- if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) {
- /* Mark this reference */
- if(loc != dt->shared->u.atomic.u.r.loc) {
- /* Set the location */
- dt->shared->u.atomic.u.r.loc = loc;
-
- /* Indicate that the location changed */
- ret_value = TRUE;
- } /* end if */
- } /* end if */
+ /* Reference types go through type conversion */
+ if((ret_value = H5T__ref_set_loc(dt, file, loc)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "Unable to set reference location");
break;
case H5T_NO_CLASS:
@@ -5284,13 +5758,13 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_set_loc() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_is_relocatable
*
* Purpose: Check if a datatype will change between disk and memory.
*
- * Notes: Currently, only variable-length and object references change
+ * Notes: Currently, only variable-length and references change
* between disk & memory (see cases where things are changed in
* the H5T_set_loc() code above).
*
@@ -5323,7 +5797,113 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_is_relocatable() */
-
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__detect_vlen_ref
+ *
+ * Purpose: Check whether a datatype contains (or is) a vlen reference
+ * datatype.
+ *
+ * Return: TRUE (1) or FALSE (0) on success
+ * (Can't fail)
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, January 5, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+H5T__detect_vlen_ref(const H5T_t *dt)
+{
+ unsigned u; /* Local index variable */
+ hbool_t ret_value = FALSE; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity checks */
+ HDassert(dt);
+
+ /* Check if this datatype is a vlen reference */
+ /* TODO currently H5T_STD_REF is always considered as a vlen type */
+ if(H5T_REFERENCE == dt->shared->type && !dt->shared->u.atomic.u.r.opaque)
+ HGOTO_DONE(TRUE);
+
+ /* Check for types that might have the correct type as a component */
+ switch(dt->shared->type) {
+ case H5T_COMPOUND:
+ /* Iterate over all the compound datatype's fields */
+ for(u = 0; u < dt->shared->u.compnd.nmembs; u++)
+ /* Recurse on field's datatype */
+ if(H5T__detect_vlen_ref(dt->shared->u.compnd.memb[u].type))
+ HGOTO_DONE(TRUE);
+ break;
+
+ case H5T_ARRAY:
+ case H5T_VLEN:
+ case H5T_ENUM:
+ HGOTO_DONE(H5T__detect_vlen_ref(dt->shared->parent));
+ break;
+
+ case H5T_NO_CLASS:
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_TIME:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_REFERENCE:
+ case H5T_NCLASSES:
+ default:
+ break;
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T__detect_vlen_ref() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_is_vl_storage
+ *
+ * Purpose: Check if a datatype will be stored in a variable-length form.
+ *
+ * Notes: Currently, only variable-length string & sequences and region
+ * references are stored in a variable-length form.
+ *
+ * Return:
+ * One of two values on success:
+ * TRUE - If the datatype will be stored in a variable-length form
+ * FALSE - If the datatype will NOT be stored in a variable-length form
+ * <0 is returned on failure
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, January 5, 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5T_is_vl_storage(const H5T_t *dt)
+{
+ htri_t ret_value = FALSE;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(dt);
+
+ /* VL and region reference datatypes are stored in variable-length form */
+ if(H5T_detect_class(dt, H5T_VLEN, FALSE))
+ ret_value = TRUE;
+ else if(H5T_detect_class(dt, H5T_REFERENCE, FALSE))
+ ret_value = H5T__detect_vlen_ref(dt);
+ else
+ ret_value = FALSE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_is_vl_storage() */
+
+
/*-------------------------------------------------------------------------
* Function: H5T_upgrade_version_cb
*
@@ -5381,7 +5961,7 @@ H5T_upgrade_version_cb(H5T_t *dt, void *op_value)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5T_upgrade_version_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T__upgrade_version
*
@@ -5414,38 +5994,48 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__upgrade_version() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5T_set_latest_version
+ * Function: H5T_set_version
*
- * Purpose: Set the encoding for a datatype to the latest version.
+ * Purpose: Set the encoding for a datatype to the version indicated by
+ * the file's low bound if that is higher than the datatype's
+ * version.
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * Thursday, July 19, 2007
+ * Programmer: Vailin Choi; December 2017
*
*-------------------------------------------------------------------------
*/
herr_t
-H5T_set_latest_version(H5T_t *dt)
+H5T_set_version(H5F_t *f, H5T_t *dt)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned vers; /* The version */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
+ HDassert(f);
HDassert(dt);
- /* Upgrade the format version for the datatype to the latest */
- if(H5T__upgrade_version(dt, H5O_DTYPE_VERSION_LATEST) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding")
+ vers = H5O_dtype_ver_bounds[H5F_LOW_BOUND(f)];
+ if(vers > dt->shared->version) {
+ /* Upgrade the format version for the datatype */
+ if(H5T__upgrade_version(dt, vers) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding")
+ }
+
+ /* Version bounds check */
+ if(dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)])
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "Datatype version out of bounds")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_set_latest_version() */
+} /* end H5T_set_version() */
+
-
/*-------------------------------------------------------------------------
* Function: H5T_patch_file
*
@@ -5481,12 +6071,12 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_patch_file() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_patch_vlen_file
*
- * Purpose: Patch the top-level file pointer contained in (dt->shared->u.vlen.f)
- * to point to f. This is possible because
+ * Purpose: Patch the top-level file pointer contained in (dt->shared->u.vlen.file)
+ * to point to file. This is possible because
* the top-level file pointer can be closed out from under
* dt while dt is contained in the shared file's cache.
*
@@ -5495,90 +6085,56 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5T_patch_vlen_file(H5T_t *dt, H5F_t *f)
+H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Sanity check */
HDassert(dt);
HDassert(dt->shared);
- HDassert(f);
+ HDassert(file);
- if((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.f != f)
- dt->shared->u.vlen.f = f;
+ if((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.file != file)
+ dt->shared->u.vlen.file = file;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5T_patch_vlen_file() */
-
-/*-------------------------------------------------------------------------
- * Function: H5Tflush
- *
- * Purpose: Flushes all buffers associated with a named datatype to disk.
- *
- * Return: Non-negative on success, negative on failure
- *
- * Programmer: Mike McGreevy
- * May 19, 2010
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5Tflush(hid_t type_id)
-{
- H5T_t *dt; /* Datatype for this operation */
- herr_t ret_value = SUCCEED; /* return value */
-
- FUNC_ENTER_API(FAIL)
- H5TRACE1("e", "i", type_id);
-
- /* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if(!H5T_is_named(dt))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
-
- /* To flush metadata and invoke flush callback if there is */
- if(H5O_flush_common(&dt->oloc, type_id, H5AC_ind_read_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype and object flush callback")
-done:
- FUNC_LEAVE_API(ret_value)
-} /* H5Tflush */
-
-
/*-------------------------------------------------------------------------
- * Function: H5Trefresh
+ * Function: H5T_own_vol_obj
*
- * Purpose: Refreshes all buffers associated with a named datatype.
+ * Purpose: Transfers ownership of the supplied VOL object to the
+ * datatype, the VOL object will be freed when the datatype
+ * is closed.
*
- * Return: Non-negative on success, negative on failure
- *
- * Programmer: Mike McGreevy
- * July 21, 2010
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
-H5Trefresh(hid_t type_id)
+H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj)
{
- H5T_t * dt = NULL;
- herr_t ret_value = SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER_API(FAIL)
- H5TRACE1("e", "i", type_id);
+ FUNC_ENTER_NOAPI(FAIL)
- /* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if(!H5T_is_named(dt))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
+ /* Sanity check */
+ HDassert(dt);
+ HDassert(dt->shared);
+ HDassert(vol_obj);
- /* Call private function to refresh datatype object */
- if ((H5O_refresh_metadata(type_id, dt->oloc, H5AC_ind_read_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype")
+ /* Currently no support for owning multiple VOL objects, free the previous
+ * owned object. Currently this is only used for holding open VOL objects
+ * used in the "loc" for vlens and references, so if this is being
+ * overwritten we don't need the old one anyways. */
+ if(dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object")
+
+ /* Take ownership */
+ dt->shared->owned_vol_obj = vol_obj;
done:
- FUNC_LEAVE_API(ret_value)
-} /* H5Trefresh */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_own_vol_obj() */