diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2024-03-10 07:47:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-10 07:47:31 (GMT) |
commit | ef401a5f5edf2fc689334a485a6c2ec3f53ecb85 (patch) | |
tree | 4807deea31bdb83a5f3903f9dc3fddd48a1e0785 /test/dt_arith.c | |
parent | 28aaeb967ce66477441dc1f92fc45dddb51255c2 (diff) | |
download | hdf5-ef401a5f5edf2fc689334a485a6c2ec3f53ecb85.zip hdf5-ef401a5f5edf2fc689334a485a6c2ec3f53ecb85.tar.gz hdf5-ef401a5f5edf2fc689334a485a6c2ec3f53ecb85.tar.bz2 |
Refactor datatype conversion code to use pointers rather than IDs (#4104)
The datatype conversion code previously used IDs for the source and
destination datatypes rather than pointers to the internal structures
for those datatypes. This was mostly due to the need for an ID for these
datatypes that can be passed to an application-registered datatype
conversion function or datatype conversion exception function. However,
using IDs internally caused a lot of unnecessary ID lookups and hurt
performance of datatype conversions in general. This was especially
problematic for compound datatype conversions, where the ID lookups were
occuring on every member of every compound element of a dataset. The
code has now been refactored to use pointers internally and only create
IDs for datatypes when necessary.
Fixed a test issue in dt_arith where a library datatype conversion
function was being cast to an application conversion function. Since the
two have different prototypes, this started failing after the parameters
for a library conversion function changed from hid_t to H5T_t * and an
extra parameter was added. This appears to have worked coincidentally in
the past since the only different between a library conversion function
and application conversion function was an extra DXPL parameter at the
end of an application conversion function
Fixed an issue where memory wasn't being freed in the h5fc_chk_idx test
program. Even though the program exits quickly after allocating the
memory, it still causes failures when testing with -fsanitize=address
Diffstat (limited to 'test/dt_arith.c')
-rw-r--r-- | test/dt_arith.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/test/dt_arith.c b/test/dt_arith.c index 4a99811..9870ea1 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -487,6 +487,16 @@ except_func(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 return ret; } +static herr_t +my_conv_int_float_func(hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, + H5T_cdata_t H5_ATTR_UNUSED *cdata, size_t H5_ATTR_UNUSED nelmts, + size_t H5_ATTR_UNUSED buf_stride, size_t H5_ATTR_UNUSED bkg_stride, + void H5_ATTR_UNUSED *buf, void H5_ATTR_UNUSED *bkg, + hid_t H5_ATTR_UNUSED dset_xfer_plist) +{ + return SUCCEED; +} + /*------------------------------------------------------------------------- * Function: test_hard_query * @@ -511,20 +521,21 @@ test_hard_query(void) goto error; } - /* Unregister the hard conversion from int to float. Verify the conversion - * is a soft conversion. */ - H5Tunregister(H5T_PERS_HARD, NULL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT, - (H5T_conv_t)((void (*)(void))H5T__conv_int_float)); + /* Unregister all hard conversion paths */ + H5Tunregister(H5T_PERS_HARD, NULL, H5I_INVALID_HID, H5I_INVALID_HID, NULL); + + /* Verify the conversion is now a soft conversion */ if (H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != false) { H5_FAILED(); printf("Can't query conversion function\n"); goto error; } - /* Register the hard conversion from int to float. Verify the conversion - * is a hard conversion. */ + /* Register our custom int to float conversion function */ H5Tregister(H5T_PERS_HARD, "int_flt", H5T_NATIVE_INT, H5T_NATIVE_FLOAT, - (H5T_conv_t)((void (*)(void))H5T__conv_int_float)); + (H5T_conv_t)((void (*)(void))my_conv_int_float_func)); + + /* Verify the conversion is now a hard conversion */ if (H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != true) { H5_FAILED(); printf("Can't query conversion function\n"); |