From 4b7f34acc16c7d071a5c1d4519ba2a01354e51db Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 2 Jun 2021 15:29:46 -0500 Subject: Combo set of async and other changes (#161) * Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * Apply patch for dynamically registering optional VOL operations * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Remove H5Dwait & H5Fwait (moved to the async connector). Added H5atclose routine. Updated 'optional op' operations. * Fix missed merge marker, and reformatted line * Update API tracing infrastructure for H5atclose callback * Clean up some warnings * Normalize against develop branch * Correct level of indirection * Add doxygen info for H5is_library_terminating and regression tests for it and H5atclose * Relocate prototype (and doxygen info) for H5Aclose * Align w/changes on develop * Move group package initialization code to H5Gint.c, and update tracing macros * Change non-static function declarations to be static * Correct GCC diagnostic macro * Ensure that H5TSpublic.h header gets installed (#129) * Finish moving API routines that invoke VOL framework to main source files. * Fix position of H5Fmount and H5Funmount * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Add wrappers for dynamically registered optional operations * Fix typo * Update doxygen comment for H5atclose with additional detail. * Add H5VL\*_vararg versions of H5VL routines that use va_list parameters * Implement and test H5S_BLOCK * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Finish another iteration on public H5ES routines, along with running the code reformatter * Another round of reformatting * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) * Remove H5Dwait and H5Fwait calls, which were incorrectly brought back in * Tiny cleanup of H5Lcreate_hard_async * Run source formatter * Allow for canceled operation in wait_cb * Attempt to fix switch on string value * Re-run source formatter * Add H5S_BLOCK testfile to CMake clean target * Add H5Pset_vol_async API routine and 'get_cap_flags' VOL introspection callback * Clean up warnings * Add H5P(set\|get)_vol_implicit_async API routines to allow \/ disallow implicit asynchronous operations (default is disallowed) * Run formatting script * Remove H5VL_REQUEST_WAIT\* * Warning cleanup * Eliminate strdup()s on statically allocated strings * Warning cleanup * Split H5VLrestore_lib_state into H5VLstart_lib_state and H5VLrestore_lib_state, and rename H5VLreset_lib_state to H5VLfinish_lib_state. * Duplicate strings when building err_info to return to applicatin * Move connector author routines into seperate header files, all included in the new hdf5dev.h header * Run bin/trace to add TRACE macros * Allow H5ES_NONE as a valid, but no-op, parameter to all H5ES API routines that accept an event set ID * Clean up formatting * Remove H5Pset/get_vol_implicit_async * Clean up warning * Remove H5Pget_vol_async and replace with more generic H5Pget_vol_cap_flags * Clean up warnings * Add H5ESfree_err_info convenience routine * Fix typo * Correct matching for cached VOL plugins * Add developer header file * Update for C99 compatibility * Add missing trace macro * Stop clang-format from messing with the trace macros. Don't set up VOL wrappers for 'infrastructure' objects like requests and blobs * Fix warning about formatting a directory * Clean up formatting for H5E_BEGIN_TRY / H5E_END_TRY * Reduce scope of H5ES__close * Enable CMake checks for various types on MacOS * Clean up properly when H5CX_retrieve_state() fails. Also clean up many compiler warnings. * Committing clang-format changes * Merge from develop * Fix mis-placed assert * Remove commented-out code * Re-add macro for unsetenv on Windows (I think it accidentally was merged out) * Strengthen sanity check from error report to assertion * Committing clang-format changes * Add units to the comments for a few fields * Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it. * Committing clang-format changes * Remove H5ESget_time_estimate * Committing clang-format changes * Create developer header for datatype routines and move type conversion register/unregister routines there. * Simplify internal H5VL_setup_name_args and H5VL_setup_idx_args routines * Add H5VLlink_optional_op, allowing dynamicly registered optional operations for the link VOL subclass, also added H5VL_loc_params argument to the link 'optional' callback to allow them to work correctly. * Run bin/format_source on current code * Add H5VLobject_optional_op, allowing dynamicly registered optional operations for the object VOL subclass, also added H5VL_loc_params argument to the object 'optional' callback to allow them to work correctly. * Run bin/format_source on current code * Committing clang-format changes * Revert "Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it." This reverts commit 5ac92014da2682bdba62d7a2524b8d90e38f6b19. * Committing clang-format changes * Convert attribute 'get' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Update tracing macros * Convert attribute 'specific' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert dataset 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to attribute 'get' and 'specific' operation parameters. * Convert datatype 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to H5O_refresh_metadata arguments. * Reduce warnings * Reduce warnings * Track change to datatype 'get' callback * Fix bug with file pointer getting invalidated when object closed * Reformat source * Convert file and group VOL classes 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also small cleanup to the attribute get name operation. Also moved 'mount' and 'unmount' operations to be group specific operations, instead of file specific, to better align with their behavior (mounted files are on groups, so a group is what is operated on). * Remove remainder of merge conflict marking * Convert link VOL class 'create' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Remove some unused local variables * Convert link VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor 'get name by idx' routines to return actual length of name with a parameter instead of the return value, and move some callback context structs for the link interface from the private header file into the source code module, to reduce their visibility scope. * Update tracing macros * Convert link VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert object VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert object VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor H5G_loc_exists, et al, to return 'exists' flag in a parameter and errors with the function return value, instead of overloading both into the return value. And, corrected logic error in test/links.c around non-existant objects in a file. * Convert request VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert blob VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also removes the H5VL_BLOB_GETSIZE operation, as it's unused in the library and the blob ID size for a container is now returned with H5VL_FILE_GET_CONT_INFO. * Add 'const' to several parameters that are only queried. * Convert all VOL classes' 'optional' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Convert several 'get' routines to return the length of an array in a parameter instead of combining it into the return value. Move several routines to be in less public namespace. Correct direct_chunk test to verify that parameters aren't modified on error. * Switch get/specific/optional VOL callback argument structures to be 'async-friendly'. Also other minor cleanups and bug-fixes. * Add H5Pset_dataset_io_hyperslab_selection / H5S_PLIST feature, to allow skipping H5Dget_space + H5Sselect_hyperslab for async operation * Add dynamic optional operations for request objects * Update dynamic operation test for optional request operations * Update a comment for an operation argument * Run trace and format_source scripts * Committing clang-format changes * Committing clang-format changes Co-authored-by: vchoi Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF Co-authored-by: Dana Robinson Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- MANIFEST | 11 +- bin/trace | 4 +- c++/src/H5DataType.h | 3 + config/cmake_ext_mod/ConfigureChecks.cmake | 16 +- examples/h5_elink_unix2win.c | 1 + examples/h5_extlink.c | 1 + fortran/src/H5Tf.c | 3 + fortran/src/H5Zf.c | 1 + fortran/src/H5_f.c | 1 + java/src/jni/h5Constants.c | 1 + java/src/jni/h5lImp.c | 1 + java/src/jni/h5zImp.c | 1 + src/CMakeLists.txt | 11 +- src/H5A.c | 355 +++--- src/H5AC.c | 25 +- src/H5ACprivate.h | 10 +- src/H5Adeprec.c | 35 +- src/H5Aint.c | 40 +- src/H5Apkg.h | 16 +- src/H5CS.c | 14 +- src/H5CX.c | 435 +++---- src/H5Cmpio.c | 2 + src/H5Cprivate.h | 8 +- src/H5Cquery.c | 10 +- src/H5D.c | 391 ++++--- src/H5Dchunk.c | 107 +- src/H5Ddeprec.c | 31 +- src/H5Dint.c | 27 +- src/H5Dio.c | 77 +- src/H5Dpkg.h | 4 +- src/H5Dprivate.h | 11 +- src/H5Dpublic.h | 5 +- src/H5Dvirtual.c | 2 +- src/H5E.c | 33 +- src/H5ES.c | 407 +++++-- src/H5ESdevelop.h | 50 + src/H5ESevent.c | 16 +- src/H5ESint.c | 434 ++++++- src/H5ESpkg.h | 18 +- src/H5ESprivate.h | 5 +- src/H5ESpublic.h | 70 +- src/H5Eint.c | 20 +- src/H5F.c | 756 +++++++++---- src/H5FDdevelop.h | 262 +++++ src/H5FDlog.c | 2 - src/H5FDmulti.c | 1 + src/H5FDprivate.h | 3 +- src/H5FDpublic.h | 238 +--- src/H5FDstdio.c | 1 + src/H5FL.c | 56 +- src/H5Faccum.c | 2 +- src/H5Fdeprec.c | 53 +- src/H5Fint.c | 72 +- src/H5Fmount.c | 25 +- src/H5Fmpi.c | 45 +- src/H5Fpkg.h | 32 +- src/H5Fprivate.h | 8 +- src/H5Fpublic.h | 3 +- src/H5G.c | 83 +- src/H5Gcompact.c | 18 +- src/H5Gdense.c | 39 +- src/H5Gdeprec.c | 291 +++-- src/H5Gloc.c | 62 +- src/H5Gname.c | 55 +- src/H5Gobj.c | 21 +- src/H5Gpkg.h | 79 +- src/H5Gprivate.h | 73 +- src/H5Gstab.c | 26 +- src/H5Gtest.c | 6 +- src/H5I.c | 20 +- src/H5Idevelop.h | 139 +++ src/H5Iprivate.h | 3 +- src/H5Ipublic.h | 90 -- src/H5Itest.c | 10 +- src/H5L.c | 425 ++++--- src/H5Ldeprec.c | 146 ++- src/H5Ldevelop.h | 314 ++++++ src/H5Lexternal.c | 14 +- src/H5Lint.c | 69 +- src/H5Lpkg.h | 43 +- src/H5Lprivate.h | 47 +- src/H5Lpublic.h | 257 ----- src/H5M.c | 346 ++++-- src/H5MF.c | 22 +- src/H5MFprivate.h | 3 +- src/H5Mprivate.h | 7 +- src/H5Mpublic.h | 110 ++ src/H5O.c | 450 +++++--- src/H5Odeprec.c | 155 ++- src/H5Oflush.c | 31 +- src/H5Opkg.h | 5 + src/H5Oprivate.h | 7 +- src/H5PLextern.h | 4 +- src/H5PLint.c | 2 + src/H5PLplugin_cache.c | 80 +- src/H5Pdxpl.c | 278 ++++- src/H5Pfapl.c | 58 + src/H5Pint.c | 3 +- src/H5Ppublic.h | 87 +- src/H5R.c | 199 ++-- src/H5RS.c | 6 +- src/H5RSprivate.h | 2 +- src/H5Rdeprec.c | 133 ++- src/H5Rint.c | 13 +- src/H5S.c | 51 +- src/H5Sprivate.h | 1 - src/H5Spublic.h | 8 +- src/H5T.c | 11 +- src/H5TSdevelop.h | 50 + src/H5TSprivate.h | 4 +- src/H5TSpublic.h | 52 - src/H5Tcommit.c | 119 +- src/H5Tdevelop.h | 227 ++++ src/H5Tprivate.h | 5 +- src/H5Tpublic.h | 179 +-- src/H5Tref.c | 125 ++- src/H5Tvlen.c | 50 +- src/H5VL.c | 180 ++- src/H5VLcallback.c | 1687 +++++++++++++++------------- src/H5VLconnector.h | 883 ++++++++++++--- src/H5VLconnector_passthru.h | 101 +- src/H5VLdyn_ops.c | 334 ++++++ src/H5VLint.c | 270 ++++- src/H5VLnative.c | 45 +- src/H5VLnative.h | 403 ++++++- src/H5VLnative_attr.c | 244 ++-- src/H5VLnative_blob.c | 34 +- src/H5VLnative_dataset.c | 425 ++++--- src/H5VLnative_datatype.c | 77 +- src/H5VLnative_file.c | 387 +++---- src/H5VLnative_group.c | 160 ++- src/H5VLnative_introspect.c | 38 +- src/H5VLnative_link.c | 166 +-- src/H5VLnative_object.c | 207 ++-- src/H5VLnative_private.h | 72 +- src/H5VLnative_token.c | 4 + src/H5VLpassthru.c | 684 ++++------- src/H5VLpkg.h | 12 + src/H5VLprivate.h | 116 +- src/H5VLpublic.h | 8 +- src/H5VLtest.c | 96 ++ src/H5Zdevelop.h | 421 +++++++ src/H5Zprivate.h | 3 +- src/H5Zpublic.h | 373 +----- src/H5err.txt | 4 +- src/H5private.h | 3 + src/H5system.c | 9 +- src/H5trace.c | 88 +- src/H5win32defs.h | 1 + src/Makefile.am | 11 +- src/hdf5.h | 1 - src/hdf5dev.h | 38 + test/CMakeTests.cmake | 2 + test/Makefile.am | 2 +- test/chunk_info.c | 6 +- test/direct_chunk.c | 94 +- test/dsets.c | 369 ++++++ test/event_set.c | 66 ++ test/filter_plugin1_dsets.c | 2 +- test/filter_plugin2_dsets.c | 2 +- test/filter_plugin3_dsets.c | 2 +- test/filter_plugin4_groups.c | 2 +- test/h5test.h | 3 +- test/links.c | 8 +- test/null_vol_connector.c | 2 +- test/tfile.c | 1 + test/trefstr.c | 2 +- test/vol.c | 926 ++++++++++++++- testpar/t_filters_parallel.c | 8 +- tools/lib/h5tools.c | 1 + tools/test/h5copy/dynlib_copy.c | 2 +- tools/test/h5diff/dynlib_diff.c | 2 +- tools/test/h5diff/h5diffgentest.c | 1 + tools/test/h5dump/dynlib_dump.c | 2 +- tools/test/h5jam/h5jamgentest.c | 1 + tools/test/h5ls/dynlib_ls.c | 2 +- tools/test/h5repack/dynlib_rpk.c | 2 +- tools/test/h5repack/dynlib_vrpk.c | 2 +- tools/test/perform/chunk.c | 2 +- utils/mirror_vfd/mirror_remote.h | 1 + 180 files changed, 12450 insertions(+), 6135 deletions(-) create mode 100644 src/H5ESdevelop.h create mode 100644 src/H5FDdevelop.h create mode 100644 src/H5Idevelop.h create mode 100644 src/H5Ldevelop.h create mode 100644 src/H5TSdevelop.h delete mode 100644 src/H5TSpublic.h create mode 100644 src/H5Tdevelop.h create mode 100644 src/H5VLdyn_ops.c create mode 100644 src/H5VLtest.c create mode 100644 src/H5Zdevelop.h create mode 100644 src/hdf5dev.h diff --git a/MANIFEST b/MANIFEST index 46771bb..e114586 100644 --- a/MANIFEST +++ b/MANIFEST @@ -733,6 +733,7 @@ ./src/H5EAstat.c ./src/H5EAtest.c ./src/H5ES.c +./src/H5ESdevelop.h ./src/H5ESevent.c ./src/H5ESint.c ./src/H5ESlist.c @@ -776,6 +777,7 @@ ./src/H5FD.c ./src/H5FDcore.c ./src/H5FDcore.h +./src/H5FDdevelop.h ./src/H5FDdirect.c ./src/H5FDdirect.h ./src/H5FDdrvr_module.h @@ -889,6 +891,7 @@ ./src/H5HPprivate.h ./src/H5I.c ./src/H5Idbg.c +./src/H5Idevelop.h ./src/H5Iint.c ./src/H5Imodule.h ./src/H5Ipkg.h @@ -897,6 +900,7 @@ ./src/H5Itest.c ./src/H5L.c ./src/H5Ldeprec.c +./src/H5Ldevelop.h ./src/H5Lexternal.c ./src/H5Lint.c ./src/H5Lmodule.h @@ -1047,6 +1051,7 @@ ./src/H5Tcset.c ./src/H5Tdbg.c ./src/H5Tdeprec.c +./src/H5Tdevelop.h ./src/H5Tenum.c ./src/H5Tfields.c ./src/H5Tfixed.c @@ -1067,14 +1072,15 @@ ./src/H5Tvisit.c ./src/H5Tvlen.c ./src/H5TS.c +./src/H5TSdevelop.h ./src/H5TSprivate.h -./src/H5TSpublic.h ./src/H5UC.c ./src/H5UCprivate.h ./src/H5VL.c ./src/H5VLcallback.c ./src/H5VLconnector.h ./src/H5VLconnector_passthru.h +./src/H5VLdyn_ops.c ./src/H5VLint.c ./src/H5VLmodule.h ./src/H5VLnative.c @@ -1095,12 +1101,14 @@ ./src/H5VLpkg.h ./src/H5VLprivate.h ./src/H5VLpublic.h +./src/H5VLtest.c ./src/H5VM.c ./src/H5VMprivate.h ./src/H5WB.c ./src/H5WBprivate.h ./src/H5Z.c ./src/H5Zdeflate.c +./src/H5Zdevelop.h ./src/H5Zfletcher32.c ./src/H5Zmodule.h ./src/H5Znbit.c @@ -1113,6 +1121,7 @@ ./src/H5Ztrans.c ./src/Makefile.am ./src/hdf5.h +./src/hdf5dev.h ./src/libhdf5.settings.in ./src/H5win32defs.h ./src/uthash.h diff --git a/bin/trace b/bin/trace index 0eef8ce..1623438 100755 --- a/bin/trace +++ b/bin/trace @@ -57,8 +57,10 @@ $Source = ""; "herr_t" => "e", "H5E_auto1_t" => "Ea", "H5E_auto2_t" => "EA", + "H5ES_event_complete_func_t" => "EC", "H5E_direction_t" => "Ed", "H5E_error_t" => "Ee", + "H5ES_event_insert_func_t" => "EI", "H5ES_status_t" => "Es", "H5E_type_t" => "Et", "H5FD_class_t" => "FC", @@ -159,7 +161,7 @@ $Source = ""; "H5VL_file_specific_t" => "Vh", "H5VL_group_get_t" => "Vi", "H5VL_group_specific_t" => "Vj", - "H5VL_link_create_type_t" => "Vk", + "H5VL_link_create_t" => "Vk", "H5VL_link_get_t" => "Vl", "H5VL_get_conn_lvl_t" => "VL", "H5VL_link_specific_t" => "Vm", diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 7dd371b..d696455 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -15,6 +15,9 @@ #ifndef H5DataType_H #define H5DataType_H +/* Include package's developer header */ +#include "H5Tdevelop.h" + namespace H5 { /*! \class DataType diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 708fb3e..0c310e2 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -376,15 +376,13 @@ HDF_CHECK_TYPE_SIZE (uint_least64_t ${HDF_PREFIX}_SIZEOF_UINT_LEAST64_T) HDF_CHECK_TYPE_SIZE (int_fast64_t ${HDF_PREFIX}_SIZEOF_INT_FAST64_T) HDF_CHECK_TYPE_SIZE (uint_fast64_t ${HDF_PREFIX}_SIZEOF_UINT_FAST64_T) -if (NOT APPLE) - HDF_CHECK_TYPE_SIZE (size_t ${HDF_PREFIX}_SIZEOF_SIZE_T) - HDF_CHECK_TYPE_SIZE (ssize_t ${HDF_PREFIX}_SIZEOF_SSIZE_T) - if (NOT ${HDF_PREFIX}_SIZEOF_SSIZE_T) - set (${HDF_PREFIX}_SIZEOF_SSIZE_T 0) - endif () - if (MINGW OR NOT WINDOWS) - HDF_CHECK_TYPE_SIZE (ptrdiff_t ${HDF_PREFIX}_SIZEOF_PTRDIFF_T) - endif () +HDF_CHECK_TYPE_SIZE (size_t ${HDF_PREFIX}_SIZEOF_SIZE_T) +HDF_CHECK_TYPE_SIZE (ssize_t ${HDF_PREFIX}_SIZEOF_SSIZE_T) +if (NOT ${HDF_PREFIX}_SIZEOF_SSIZE_T) + set (${HDF_PREFIX}_SIZEOF_SSIZE_T 0) +endif () +if (MINGW OR NOT WINDOWS) + HDF_CHECK_TYPE_SIZE (ptrdiff_t ${HDF_PREFIX}_SIZEOF_PTRDIFF_T) endif () HDF_CHECK_TYPE_SIZE (off_t ${HDF_PREFIX}_SIZEOF_OFF_T) diff --git a/examples/h5_elink_unix2win.c b/examples/h5_elink_unix2win.c index 6eca266..60c75dc 100644 --- a/examples/h5_elink_unix2win.c +++ b/examples/h5_elink_unix2win.c @@ -24,6 +24,7 @@ */ #include "hdf5.h" +#include "hdf5dev.h" #include #include diff --git a/examples/h5_extlink.c b/examples/h5_extlink.c index f9d4046..44e55a9 100644 --- a/examples/h5_extlink.c +++ b/examples/h5_extlink.c @@ -19,6 +19,7 @@ */ #include "hdf5.h" +#include "hdf5dev.h" #include #define SOURCE_FILE "extlink_source.h5" diff --git a/fortran/src/H5Tf.c b/fortran/src/H5Tf.c index 1516cc7..3da4a29 100644 --- a/fortran/src/H5Tf.c +++ b/fortran/src/H5Tf.c @@ -21,6 +21,9 @@ #include "H5f90.h" +/* Include package's developer header */ +#include "H5Tdevelop.h" + /****if* H5Tf/h5topen_c * NAME * h5topen_c diff --git a/fortran/src/H5Zf.c b/fortran/src/H5Zf.c index b31878c..33d9fb3 100644 --- a/fortran/src/H5Zf.c +++ b/fortran/src/H5Zf.c @@ -20,6 +20,7 @@ */ #include "H5f90.h" +#include "hdf5dev.h" /****if* H5Zf/h5zunregister_c * NAME diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index d245cae..52fc276 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -21,6 +21,7 @@ #include "H5f90.h" #include "H5fort_type_defines.h" +#include "hdf5dev.h" int IntKinds_SizeOf[] = H5_FORTRAN_INTEGER_KINDS_SIZEOF; diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index 7354e95..a0deea3 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -22,6 +22,7 @@ extern "C" { #endif /* __cplusplus */ #include "hdf5.h" +#include "hdf5dev.h" #include #include #include "h5jni.h" diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index 43db4e9..1407fef 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -23,6 +23,7 @@ extern "C" { #include #include #include "hdf5.h" +#include "hdf5dev.h" #include "h5jni.h" #include "h5lImp.h" diff --git a/java/src/jni/h5zImp.c b/java/src/jni/h5zImp.c index d750ee8..d8c93be 100644 --- a/java/src/jni/h5zImp.c +++ b/java/src/jni/h5zImp.c @@ -22,6 +22,7 @@ extern "C" { #endif /* __cplusplus */ #include "hdf5.h" +#include "hdf5dev.h" #include #include #include "h5jni.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 555fb98..9eeac7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,7 @@ set (H5_SOURCES set (H5_HDRS ${HDF5_SRC_DIR}/hdf5.h + ${HDF5_SRC_DIR}/hdf5dev.h ${HDF5_SRC_DIR}/H5api_adpt.h ${HDF5_SRC_DIR}/H5public.h #${HDF5_SRC_DIR}/H5version.h @@ -180,6 +181,7 @@ set (H5ES_SOURCES ${HDF5_SRC_DIR}/H5ESlist.c ) set (H5ES_HDRS + ${HDF5_SRC_DIR}/H5ESdevelop.h ${HDF5_SRC_DIR}/H5ESpublic.h ) IDE_GENERATED_PROPERTIES ("H5ES" "${H5ES_HDRS}" "${H5ES_SOURCES}" ) @@ -251,6 +253,7 @@ set (H5FD_SOURCES set (H5FD_HDRS ${HDF5_SRC_DIR}/H5FDcore.h + ${HDF5_SRC_DIR}/H5FDdevelop.h ${HDF5_SRC_DIR}/H5FDdirect.h ${HDF5_SRC_DIR}/H5FDfamily.h ${HDF5_SRC_DIR}/H5FDhdfs.h @@ -389,6 +392,7 @@ set (H5I_SOURCES ${HDF5_SRC_DIR}/H5Itest.c ) set (H5I_HDRS + ${HDF5_SRC_DIR}/H5Idevelop.h ${HDF5_SRC_DIR}/H5Ipublic.h ) IDE_GENERATED_PROPERTIES ("H5I" "${H5I_HDRS}" "${H5I_SOURCES}" ) @@ -401,6 +405,7 @@ set (H5L_SOURCES ${HDF5_SRC_DIR}/H5Lint.c ) set (H5L_HDRS + ${HDF5_SRC_DIR}/H5Ldevelop.h ${HDF5_SRC_DIR}/H5Lpublic.h ) IDE_GENERATED_PROPERTIES ("H5L" "${H5L_HDRS}" "${H5L_SOURCES}" ) @@ -629,6 +634,7 @@ set (H5T_SOURCES ) set (H5T_HDRS + ${HDF5_SRC_DIR}/H5Tdevelop.h ${HDF5_SRC_DIR}/H5Tpublic.h ) IDE_GENERATED_PROPERTIES ("H5T" "${H5T_HDRS}" "${H5T_SOURCES}" ) @@ -638,7 +644,7 @@ set (H5TS_SOURCES ${HDF5_SRC_DIR}/H5TS.c ) set (H5TS_HDRS - ${HDF5_SRC_DIR}/H5TSpublic.h + ${HDF5_SRC_DIR}/H5TSdevelop.h ) IDE_GENERATED_PROPERTIES ("H5TS" "${H5TS_HDRS}" "${H5TS_SOURCES}" ) @@ -654,6 +660,7 @@ IDE_GENERATED_PROPERTIES ("H5UC" "${H5UC_HDRS}" "${H5UC_SOURCES}" ) set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VL.c ${HDF5_SRC_DIR}/H5VLcallback.c + ${HDF5_SRC_DIR}/H5VLdyn_ops.c ${HDF5_SRC_DIR}/H5VLint.c ${HDF5_SRC_DIR}/H5VLnative.c ${HDF5_SRC_DIR}/H5VLnative_attr.c @@ -667,6 +674,7 @@ set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VLnative_object.c ${HDF5_SRC_DIR}/H5VLnative_token.c ${HDF5_SRC_DIR}/H5VLpassthru.c + ${HDF5_SRC_DIR}/H5VLtest.c ) set (H5VL_HDRS ${HDF5_SRC_DIR}/H5VLconnector.h @@ -710,6 +718,7 @@ endif () set (H5Z_HDRS + ${HDF5_SRC_DIR}/H5Zdevelop.h ${HDF5_SRC_DIR}/H5Zpublic.h ) IDE_GENERATED_PROPERTIES ("H5Z" "${H5Z_HDRS}" "${H5Z_SOURCES}" ) diff --git a/src/H5A.c b/src/H5A.c index aaf3383..5d8737f 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -320,7 +320,7 @@ H5A__create_by_name_api_common(hid_t loc_id, const char *obj_name, const char *a /* obj_name is verified in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, obj_name, H5P_CLS_LACC, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, obj_name, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") /* Verify access property list and set up collective metadata if appropriate */ @@ -630,7 +630,7 @@ H5A__open_by_name_api_common(hid_t loc_id, const char *obj_name, const char *att /* obj_name is verified in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, obj_name, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, obj_name, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") /* Verify access property list and set up collective metadata if appropriate */ @@ -764,8 +764,8 @@ H5A__open_by_idx_api_common(hid_t loc_id, const char *obj_name, H5_index_t idx_t HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid iteration order specified") /* Set up object access arguments */ - if (H5VL_setup_idx_args(loc_id, obj_name, idx_type, order, n, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, - &loc_params) < 0) + if (H5VL_setup_idx_args(loc_id, obj_name, idx_type, order, n, FALSE, lapl_id, vol_obj_ptr, &loc_params) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") /* Verify access property list and set up collective metadata if appropriate */ @@ -1057,7 +1057,7 @@ done: *--------------------------------------------------------------------------*/ herr_t H5Aread_async(const char *app_file, const char *app_func, unsigned app_line, hid_t attr_id, hid_t dtype_id, - void *buf, hid_t es_id) + void *buf /*out*/, hid_t es_id) { H5VL_object_t *vol_obj = NULL; /* Object for attr_id */ void * token = NULL; /* Request token for async operation */ @@ -1065,7 +1065,7 @@ H5Aread_async(const char *app_file, const char *app_func, unsigned app_line, hid herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*s*sIuii*xi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id); + H5TRACE7("e", "*s*sIuiixi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id); /* Set up request token pointer for asynchronous operation */ if (H5ES_NONE != es_id) @@ -1079,7 +1079,7 @@ H5Aread_async(const char *app_file, const char *app_func, unsigned app_line, hid if (NULL != token) /* clang-format off */ if (H5ES_insert(es_id, vol_obj->connector, token, - H5ARG_TRACE7(FUNC, "*s*sIuii*xi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id)) < 0) + H5ARG_TRACE7(FUNC, "*s*sIuiixi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set") @@ -1106,8 +1106,9 @@ done: hid_t H5Aget_space(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); @@ -1116,11 +1117,17 @@ H5Aget_space(hid_t attr_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_SPACE; + vol_cb_args.args.get_space.space_id = H5I_INVALID_HID; + /* Get the dataspace */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < - 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace of attribute") + /* Set the return value */ + ret_value = vol_cb_args.args.get_space.space_id; + done: FUNC_LEAVE_API(ret_value) } /* H5Aget_space() */ @@ -1144,8 +1151,9 @@ done: hid_t H5Aget_type(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); @@ -1154,10 +1162,17 @@ H5Aget_type(hid_t attr_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_TYPE; + vol_cb_args.args.get_type.type_id = H5I_INVALID_HID; + /* Get the datatype */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype of attribute") + /* Set the return value */ + ret_value = vol_cb_args.args.get_type.type_id; + done: FUNC_LEAVE_API(ret_value) } /* H5Aget_type() */ @@ -1184,8 +1199,9 @@ done: hid_t H5Aget_create_plist(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); @@ -1196,11 +1212,18 @@ H5Aget_create_plist(hid_t attr_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_ACPL; + vol_cb_args.args.get_acpl.acpl_id = H5I_INVALID_HID; + /* Get the acpl */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_ACPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get creation property list for attribute") + /* Set the return value */ + ret_value = vol_cb_args.args.get_acpl.acpl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_create_plist() */ @@ -1229,9 +1252,10 @@ done: ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf /*out*/) { - H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ - H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + size_t attr_name_len = 0; /* Length of attribute name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "izx", attr_id, buf_size, buf); @@ -1242,15 +1266,21 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf /*out*/) if (!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "buf cannot be NULL if buf_size is non-zero") - /* Set location struct parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(attr_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_NAME; + vol_cb_args.args.get_name.loc_params.type = H5VL_OBJECT_BY_SELF; + vol_cb_args.args.get_name.loc_params.obj_type = H5I_get_type(attr_id); + vol_cb_args.args.get_name.buf_size = buf_size; + vol_cb_args.args.get_name.buf = buf; + vol_cb_args.args.get_name.attr_name_len = &attr_name_len; /* Get the attribute name */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, - buf_size, buf, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute name") + /* Set the return value */ + ret_value = (ssize_t)attr_name_len; + done: FUNC_LEAVE_API(ret_value) } /* H5Aget_name() */ @@ -1276,9 +1306,10 @@ ssize_t H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj; - H5VL_loc_params_t loc_params; - ssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + size_t attr_name_len = 0; /* Length of attribute name */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("Zs", "i*sIiIohxzi", loc_id, obj_name, idx_type, order, n, name, size, lapl_id); @@ -1303,19 +1334,26 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = obj_name; - loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_NAME; + vol_cb_args.args.get_name.loc_params.type = H5VL_OBJECT_BY_IDX; + vol_cb_args.args.get_name.loc_params.loc_data.loc_by_idx.name = obj_name; + vol_cb_args.args.get_name.loc_params.loc_data.loc_by_idx.idx_type = idx_type; + vol_cb_args.args.get_name.loc_params.loc_data.loc_by_idx.order = order; + vol_cb_args.args.get_name.loc_params.loc_data.loc_by_idx.n = n; + vol_cb_args.args.get_name.loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + vol_cb_args.args.get_name.loc_params.obj_type = H5I_get_type(loc_id); + vol_cb_args.args.get_name.buf_size = size; + vol_cb_args.args.get_name.buf = name; + vol_cb_args.args.get_name.attr_name_len = &attr_name_len; /* Get the name */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, - size, name, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get name") + /* Set the return value */ + ret_value = (ssize_t)attr_name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_name_by_idx() */ @@ -1340,8 +1378,10 @@ done: hsize_t H5Aget_storage_size(hid_t attr_id) { - H5VL_object_t *vol_obj; - hsize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hsize_t storage_size = 0; /* Storage size of attribute */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", attr_id); @@ -1350,10 +1390,16 @@ H5Aget_storage_size(hid_t attr_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_STORAGE_SIZE; + vol_cb_args.args.get_storage_size.data_size = &storage_size; + /* Get the storage size */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, 0, "unable to get acpl") + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, 0, "unable to get storage size") + + /* Set the return value */ + ret_value = storage_size; done: FUNC_LEAVE_API(ret_value) @@ -1375,9 +1421,9 @@ done: herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/) { - H5VL_object_t * vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", attr_id, ainfo); @@ -1388,12 +1434,15 @@ H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/) if (!ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "attribute_info parameter cannot be NULL") - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(attr_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_INFO; + vol_cb_args.args.get_info.loc_params.type = H5VL_OBJECT_BY_SELF; + vol_cb_args.args.get_info.loc_params.obj_type = H5I_get_type(attr_id); + vol_cb_args.args.get_info.attr_name = NULL; + vol_cb_args.args.get_info.ainfo = ainfo; /* Get the attribute information */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, - ainfo) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1417,9 +1466,9 @@ herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*sxi", loc_id, obj_name, attr_name, ainfo, lapl_id); @@ -1438,18 +1487,21 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = obj_name; - loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); - /* Get the object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_INFO; + vol_cb_args.args.get_info.loc_params.type = H5VL_OBJECT_BY_NAME; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_name.name = obj_name; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + vol_cb_args.args.get_info.loc_params.obj_type = H5I_get_type(loc_id); + vol_cb_args.args.get_info.attr_name = attr_name; + vol_cb_args.args.get_info.ainfo = ainfo; + /* Get the attribute information */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, - ainfo, attr_name) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1474,9 +1526,9 @@ herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_attr_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIohxi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id); @@ -1497,21 +1549,24 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = obj_name; - loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); - /* Get the object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_GET_INFO; + vol_cb_args.args.get_info.loc_params.type = H5VL_OBJECT_BY_IDX; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_idx.name = obj_name; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_idx.idx_type = idx_type; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_idx.order = order; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_idx.n = n; + vol_cb_args.args.get_info.loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + vol_cb_args.args.get_info.loc_params.obj_type = H5I_get_type(loc_id); + vol_cb_args.args.get_info.attr_name = NULL; + vol_cb_args.args.get_info.ainfo = ainfo; + /* Get the attribute information */ - if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, - ainfo) < 0) + if (H5VL_attr_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1541,12 +1596,19 @@ H5A__rename_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const HDassert(new_name); /* Avoid thrashing things if the names are the same */ - if (HDstrcmp(old_name, new_name) != 0) + if (HDstrcmp(old_name, new_name) != 0) { + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_RENAME; + vol_cb_args.args.rename.old_name = old_name; + vol_cb_args.args.rename.new_name = new_name; + /* Rename the attribute */ - if (H5VL_attr_specific(vol_obj, loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, token_ptr, - old_name, new_name) < 0) + if (H5VL_attr_specific(vol_obj, loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute from '%s' to '%s'", old_name, new_name) + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1700,7 +1762,7 @@ H5A__rename_by_name_api_common(hid_t loc_id, const char *obj_name, const char *o /* obj_name is verified in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, obj_name, H5P_CLS_LACC, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, obj_name, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set object access arguments") /* Rename the attribute */ @@ -1830,14 +1892,15 @@ herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx /*in,out */, H5A_operator2_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hAO*x", loc_id, idx_type, order, idx, op, op_data); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1845,16 +1908,25 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *i if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + /* Get the loc object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set the location access parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the loc object */ - if (NULL == (vol_obj = H5VL_vol_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_ITER; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx = idx; + vol_cb_args.args.iterate.op = op; + vol_cb_args.args.iterate.op_data = op_data; /* Iterate over attributes */ - if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) + if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: @@ -1908,9 +1980,10 @@ herr_t H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx /*in,out */, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object location */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hAO*xi", loc_id, obj_name, idx_type, order, idx, op, op_data, lapl_id); @@ -1929,18 +2002,27 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + /* get the loc object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set the location access parameters */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.obj_type = H5I_get_type(loc_id); loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - /* get the loc object */ - if (NULL == (vol_obj = H5VL_vol_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_ITER; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx = idx; + vol_cb_args.args.iterate.op = op; + vol_cb_args.args.iterate.op_data = op_data; /* Iterate over attributes */ - if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) + if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); done: @@ -1964,9 +2046,10 @@ done: herr_t H5Adelete(hid_t loc_id, const char *name) { - H5VL_object_t * vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); @@ -1983,17 +2066,20 @@ H5Adelete(hid_t loc_id, const char *name) if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") - /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); - /* Get the object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set the location access parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_DELETE; + vol_cb_args.args.del.name = name; + /* Delete the attribute */ - if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -2019,9 +2105,10 @@ done: herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5VL_object_t * vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, obj_name, attr_name, lapl_id); @@ -2038,19 +2125,22 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Fill in location struct fields */ + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Set the location access parameters */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* Get the object */ - if (NULL == (vol_obj = H5VL_vol_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_DELETE; + vol_cb_args.args.del.name = attr_name; /* Delete the attribute */ - if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - attr_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -2085,9 +2175,10 @@ herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5VL_object_t * vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, obj_name, idx_type, order, n, lapl_id); @@ -2106,21 +2197,24 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_ite if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = obj_name; - loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); - /* get the object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set the location access parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_DELETE_BY_IDX; + vol_cb_args.args.delete_by_idx.idx_type = idx_type; + vol_cb_args.args.delete_by_idx.order = order; + vol_cb_args.args.delete_by_idx.n = n; + /* Delete the attribute */ - if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - NULL) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -2233,7 +2327,8 @@ static herr_t H5A__exists_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const char *attr_name, hbool_t *attr_exists, void **token_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_attr_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2245,9 +2340,13 @@ H5A__exists_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_ATTR_EXISTS; + vol_cb_args.args.exists.name = attr_name; + vol_cb_args.args.exists.exists = attr_exists; + /* Check if the attribute exists */ - if (H5VL_attr_specific(vol_obj, loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, token_ptr, - attr_name, attr_exists) < 0) + if (H5VL_attr_specific(vol_obj, loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: @@ -2400,7 +2499,7 @@ H5A__exists_by_name_api_common(hid_t loc_id, const char *obj_name, const char *a /* obj_name is verified in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, obj_name, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, obj_name, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set object access arguments") /* Check if the attribute exists */ diff --git a/src/H5AC.c b/src/H5AC.c index 2eadd21..1c75aff 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -43,7 +43,6 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip Lists */ @@ -61,8 +60,8 @@ /********************/ static herr_t H5AC__check_if_write_permitted(const H5F_t *f, hbool_t *write_permitted_ptr); -static herr_t H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, - H5C_auto_size_ctl_t *int_conf_ptr); +static herr_t H5AC__ext_config_2_int_config(const H5AC_cache_config_t *ext_conf_ptr, + H5C_auto_size_ctl_t * int_conf_ptr); #if H5AC_DO_TAGGING_SANITY_CHECKS static herr_t H5AC__verify_tag(const H5AC_class_t *type); #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ @@ -1797,14 +1796,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, - uint32_t *cur_num_entries_ptr) +H5AC_get_cache_size(const H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (H5C_get_cache_size((H5C_t *)cache_ptr, max_size_ptr, min_clean_size_ptr, cur_size_ptr, + if (H5C_get_cache_size((const H5C_t *)cache_ptr, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_size() failed") @@ -1851,13 +1850,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr) +H5AC_get_cache_hit_rate(const H5AC_t *cache_ptr, double *hit_rate_ptr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr) < 0) + if (H5C_get_cache_hit_rate((const H5C_t *)cache_ptr, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_hit_rate() failed") done: @@ -1903,7 +1902,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) +H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, const H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; herr_t ret_value = SUCCEED; /* Return value */ @@ -2004,7 +2003,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_validate_config(H5AC_cache_config_t *config_ptr) +H5AC_validate_config(const H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; herr_t ret_value = SUCCEED; /* Return value */ @@ -2185,7 +2184,7 @@ H5AC__check_if_write_permitted(const H5F_t *------------------------------------------------------------------------- */ static herr_t -H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, H5C_auto_size_ctl_t *int_conf_ptr) +H5AC__ext_config_2_int_config(const H5AC_cache_config_t *ext_conf_ptr, H5C_auto_size_ctl_t *int_conf_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2746,13 +2745,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) +H5AC_get_mdc_image_info(const H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (H5C_get_mdc_image_info((H5C_t *)cache_ptr, image_addr, image_len) < 0) + if (H5C_get_mdc_image_info((const H5C_t *)cache_ptr, image_addr, image_len) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 283989d..b14194b 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -404,20 +404,20 @@ H5_DLL herr_t H5AC_evict(H5F_t *f); H5_DLL herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5AC_remove_entry(void *entry); H5_DLL herr_t H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr); -H5_DLL herr_t H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, +H5_DLL herr_t H5AC_get_cache_size(const H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); H5_DLL herr_t H5AC_get_cache_flush_in_progress(H5AC_t *cache_ptr, hbool_t *flush_in_progress_ptr); -H5_DLL herr_t H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr); +H5_DLL herr_t H5AC_get_cache_hit_rate(const H5AC_t *cache_ptr, double *hit_rate_ptr); H5_DLL herr_t H5AC_reset_cache_hit_rate_stats(H5AC_t *cache_ptr); -H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr); -H5_DLL herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, const H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5AC_validate_config(const H5AC_cache_config_t *config_ptr); /* Cache image routines */ H5_DLL herr_t H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); H5_DLL herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr); H5_DLL hbool_t H5AC_cache_image_pending(const H5F_t *f); H5_DLL herr_t H5AC_force_cache_image_load(H5F_t *f); -H5_DLL herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); +H5_DLL herr_t H5AC_get_mdc_image_info(const H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); /* Tag & Ring routines */ H5_DLL void H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag); diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 3d4e391..8ae4e41 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -309,10 +309,11 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_info2_t oinfo; - int ret_value = -1; + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5O_info2_t oinfo; + int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", loc_id); @@ -324,9 +325,13 @@ H5Aget_num_attrs(hid_t loc_id) if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; + vol_cb_args.args.get_info.oinfo = &oinfo; + vol_cb_args.args.get_info.fields = H5O_INFO_NUM_ATTRS; + /* Get the number of attributes for the object */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); @@ -375,8 +380,10 @@ done: herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num /*in,out*/, H5A_operator1_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_attr_optional_args_t attr_opt_args; /* Arguments for optional operation */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(H5_ITER_ERROR) H5TRACE4("e", "i*IuAo*x", loc_id, attr_num, op, op_data); @@ -389,9 +396,17 @@ H5Aiterate1(hid_t loc_id, unsigned *attr_num /*in,out*/, H5A_operator1_t op, voi if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") + /* Set up VOL callback arguments */ + attr_opt_args.iterate_old.loc_id = loc_id; + attr_opt_args.iterate_old.attr_num = attr_num; + attr_opt_args.iterate_old.op = op; + attr_opt_args.iterate_old.op_data = op_data; + vol_cb_args.op_type = H5VL_NATIVE_ATTR_ITERATE_OLD; + vol_cb_args.args = &attr_opt_args; + /* Call attribute iteration routine */ - if ((ret_value = H5VL_attr_optional(vol_obj, H5VL_NATIVE_ATTR_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, loc_id, attr_num, op, op_data)) < 0) + if ((ret_value = H5VL_attr_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < + 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: diff --git a/src/H5Aint.c b/src/H5Aint.c index 8ec5463..300d686 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -844,7 +844,6 @@ done: const void *buf; IN: Buffer of data to write RETURNS Non-negative on success/Negative on failure - DESCRIPTION This function writes a complete attribute to disk. --------------------------------------------------------------------------*/ @@ -949,31 +948,33 @@ done: NAME H5A__get_name PURPOSE - Private function for H5Aget_name. Gets a copy of the name for an - attribute + Gets a copy of the name for an attribute RETURNS - This function returns the length of the attribute's name (which may be - longer than 'buf_size') on success or negative for failure. + Non-negative on success/Negative on failure DESCRIPTION This function retrieves the name of an attribute for an attribute ID. Up to 'buf_size' characters are stored in 'buf' followed by a '\0' string terminator. If the name of the attribute is longer than 'buf_size'-1, the string terminator is stored in the last position of the buffer to properly terminate the string. + This function returns the length of the attribute's name (which may be + longer than 'buf_size') in the 'attr_name_len' parameter. --------------------------------------------------------------------------*/ -ssize_t -H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) +herr_t +H5A__get_name(H5A_t *attr, size_t buf_size, char *buf, size_t *attr_name_len) { - size_t copy_len, nbytes; - ssize_t ret_value = -1; /* Return value */ + size_t copy_len, nbytes; FUNC_ENTER_PACKAGE_NOERR - /* get the real attribute length */ + /* Sanity checks */ + HDassert(attr); + HDassert(attr_name_len); + + /* Get the real attribute length */ nbytes = HDstrlen(attr->shared->name); - HDassert((ssize_t)nbytes >= 0); /*overflow, pretty unlikely --rpm*/ - /* compute the string length which will fit into the user's buffer */ + /* Compute the string length which will fit into the user's buffer */ copy_len = MIN(buf_size - 1, nbytes); /* Copy all/some of the name */ @@ -984,10 +985,10 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) buf[copy_len] = '\0'; } /* end if */ - /* Set return value */ - ret_value = (ssize_t)nbytes; + /* Set actual attribute name length */ + *attr_name_len = nbytes; - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__get_name() */ /*------------------------------------------------------------------------- @@ -1091,13 +1092,10 @@ done: NAME H5A__get_create_plist PURPOSE - private version of H5Aget_create_plist + Private version of H5Aget_create_plist RETURNS This function returns the ID of a copy of the attribute's creation property list, or negative on failure. - - ERRORS - DESCRIPTION This function returns a copy of the creation property list for an attribute. The resulting ID must be closed with H5Pclose() or @@ -1304,7 +1302,7 @@ H5A__close_cb(H5VL_object_t *attr_vol_obj, void **request) HDassert(attr_vol_obj); /* Close the attribute */ - if ((ret_value = H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, request)) < 0) + if (H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute") /* Free the VOL object */ @@ -2768,7 +2766,7 @@ H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5 /* Call internal attribute iteration routine */ if ((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: /* Release resources */ diff --git a/src/H5Apkg.h b/src/H5Apkg.h index a349f9f..b50cbc4 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -200,14 +200,14 @@ H5_DLL herr_t H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_ #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL herr_t H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -H5_DLL herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name); -H5_DLL herr_t H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name, - hbool_t *attr_exists); -H5_DLL herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf); -H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf); -H5_DLL ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf); +H5_DLL herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name); +H5_DLL herr_t H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name, + hbool_t *attr_exists); +H5_DLL herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf); +H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf); +H5_DLL herr_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf, size_t *attr_name_len); /* Attribute "dense" storage routines */ H5_DLL herr_t H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo); diff --git a/src/H5CS.c b/src/H5CS.c index 6510c25..d7cb6f1 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -262,9 +262,9 @@ H5CS_copy_stack(void) if (NULL == (new_stack->rec = HDcalloc(old_stack->nused, sizeof(const char *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack records") - /* Copy old stack to new one, duplicating the strings */ - for (u = 0; u < old_stack->nused; u++) - new_stack->rec[u] = HDstrdup(old_stack->rec[u]); + /* Copy pointers on old stack to new one */ + /* (Strings don't need to be duplicated, they are statically allocated) */ + HDmemcpy(new_stack->rec, old_stack->rec, sizeof(char *) * old_stack->nused); new_stack->nused = new_stack->nalloc = old_stack->nused; /* Set the return value */ @@ -298,11 +298,9 @@ H5CS_close_stack(H5CS_t *stack) HDassert(stack); /* Free stack */ - for (u = 0; u < stack->nused; u++) { - if (stack->rec[u]) - HDfree((void *)stack->rec[u]); - stack->rec[u] = NULL; - } /* end for */ + /* The function name string are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ if (stack->rec) { HDfree(stack->rec); stack->rec = NULL; diff --git a/src/H5CX.c b/src/H5CX.c index c304548..ca30bdd 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -761,13 +761,14 @@ H5CX__get_context(void) static void H5CX__push_common(H5CX_node_t *cnode) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(cnode); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + HDassert(head); /* Set non-zero context info */ cnode->ctx.dxpl_id = H5P_DATASET_XFER_DEFAULT; @@ -834,7 +835,7 @@ done: void H5CX_push_special(void) { - H5CX_node_t *cnode; /* Context node */ + H5CX_node_t *cnode = NULL; /* Context node */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -868,13 +869,13 @@ H5CX_push_special(void) herr_t H5CX_retrieve_state(H5CX_state_t **api_state) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(api_state); @@ -975,6 +976,16 @@ H5CX_retrieve_state(H5CX_state_t **api_state) #endif /* H5_HAVE_PARALLEL */ done: + /* Cleanup on error */ + if (ret_value < 0) { + if (*api_state) { + /* Release the (possibly partially allocated) API state struct */ + if (H5CX_free_state(*api_state) < 0) + HDONE_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release API state") + *api_state = NULL; + } /* end if */ + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_retrieve_state() */ @@ -998,12 +1009,12 @@ done: herr_t H5CX_restore_state(const H5CX_state_t *api_state) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(api_state); @@ -1066,22 +1077,22 @@ H5CX_free_state(H5CX_state_t *api_state) HDassert(api_state); /* Release the DCPL */ - if (api_state->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + if (0 != api_state->dcpl_id && H5P_DATASET_CREATE_DEFAULT != api_state->dcpl_id) if (H5I_dec_ref(api_state->dcpl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DCPL") /* Release the DXPL */ - if (api_state->dxpl_id != H5P_DATASET_XFER_DEFAULT) + if (0 != api_state->dxpl_id && H5P_DATASET_XFER_DEFAULT != api_state->dxpl_id) if (H5I_dec_ref(api_state->dxpl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DXPL") /* Release the LAPL */ - if (api_state->lapl_id != H5P_LINK_ACCESS_DEFAULT) + if (0 != api_state->lapl_id && H5P_LINK_ACCESS_DEFAULT != api_state->lapl_id) if (H5I_dec_ref(api_state->lapl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LAPL") /* Release the LCPL */ - if (api_state->lcpl_id != H5P_LINK_CREATE_DEFAULT) + if (0 != api_state->lcpl_id && H5P_LINK_CREATE_DEFAULT != api_state->lcpl_id) if (H5I_dec_ref(api_state->lcpl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LCPL") @@ -1124,15 +1135,19 @@ done: hbool_t H5CX_is_def_dxpl(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + hbool_t is_def_dxpl = FALSE; /* Flag to indicate DXPL is default */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); - FUNC_LEAVE_NOAPI((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT); + /* Set return value */ + is_def_dxpl = ((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT); + + FUNC_LEAVE_NOAPI(is_def_dxpl) } /* end H5CX_is_def_dxpl() */ /*------------------------------------------------------------------------- @@ -1150,13 +1165,13 @@ H5CX_is_def_dxpl(void) void H5CX_set_dxpl(hid_t dxpl_id) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ - HDassert(*head); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + HDassert(head && *head); /* Set the API context's DXPL to a new value */ (*head)->ctx.dxpl_id = dxpl_id; @@ -1179,13 +1194,13 @@ H5CX_set_dxpl(hid_t dxpl_id) void H5CX_set_dcpl(hid_t dcpl_id) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ - HDassert(*head); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + HDassert(head && *head); /* Set the API context's DCPL to a new value */ (*head)->ctx.dcpl_id = dcpl_id; @@ -1209,13 +1224,13 @@ H5CX_set_dcpl(hid_t dcpl_id) herr_t H5CX_set_libver_bounds(H5F_t *f) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -1245,13 +1260,13 @@ done: void H5CX_set_lcpl(hid_t lcpl_id) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ - HDassert(*head); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + HDassert(head && *head); /* Set the API context's LCPL to a new value */ (*head)->ctx.lcpl_id = lcpl_id; @@ -1274,12 +1289,12 @@ H5CX_set_lcpl(hid_t lcpl_id) void H5CX_set_lapl(hid_t lapl_id) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context's LAPL to a new value */ @@ -1314,15 +1329,15 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, #endif /* H5_HAVE_PARALLEL */ is_collective) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(acspl_id); HDassert(libclass); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set access plist to the default property list of the appropriate class if it's the generic default */ @@ -1437,13 +1452,13 @@ H5CX_set_loc(hid_t loc_id) { #ifdef H5_HAVE_PARALLEL - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set collective metadata read flag */ @@ -1491,13 +1506,13 @@ done: herr_t H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -1525,13 +1540,13 @@ done: herr_t H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -1559,15 +1574,19 @@ done: hid_t H5CX_get_dxpl(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + hid_t dxpl_id = H5I_INVALID_HID; /* DXPL ID for API operation */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); - FUNC_LEAVE_NOAPI((*head)->ctx.dxpl_id) + /* Set return value */ + dxpl_id = (*head)->ctx.dxpl_id; + + FUNC_LEAVE_NOAPI(dxpl_id) } /* end H5CX_get_dxpl() */ /*------------------------------------------------------------------------- @@ -1585,15 +1604,19 @@ H5CX_get_dxpl(void) hid_t H5CX_get_lapl(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + hid_t lapl_id = H5I_INVALID_HID; /* LAPL ID for API operation */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); - FUNC_LEAVE_NOAPI((*head)->ctx.lapl_id) + /* Set return value */ + lapl_id = (*head)->ctx.lapl_id; + + FUNC_LEAVE_NOAPI(lapl_id) } /* end H5CX_get_lapl() */ /*------------------------------------------------------------------------- @@ -1611,14 +1634,14 @@ H5CX_get_lapl(void) herr_t H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_wrap_ctx); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Check for value that was set */ @@ -1647,14 +1670,14 @@ done: herr_t H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_connector_prop); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Check for value that was set */ @@ -1683,15 +1706,19 @@ done: haddr_t H5CX_get_tag(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + haddr_t tag = HADDR_UNDEF; /* Current object's tag (ohdr chunk #0 address) */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); - FUNC_LEAVE_NOAPI((*head)->ctx.tag) + /* Set return value */ + tag = (*head)->ctx.tag; + + FUNC_LEAVE_NOAPI(tag) } /* end H5CX_get_tag() */ /*------------------------------------------------------------------------- @@ -1709,15 +1736,19 @@ H5CX_get_tag(void) H5AC_ring_t H5CX_get_ring(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + H5AC_ring_t ring = H5AC_RING_INV; /* Current metadata cache ring for entries */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); - FUNC_LEAVE_NOAPI((*head)->ctx.ring) + /* Set return value */ + ring = (*head)->ctx.ring; + + FUNC_LEAVE_NOAPI(ring) } /* end H5CX_get_ring() */ #ifdef H5_HAVE_PARALLEL @@ -1737,12 +1768,12 @@ H5CX_get_ring(void) hbool_t H5CX_get_coll_metadata_read(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); FUNC_LEAVE_NOAPI((*head)->ctx.coll_metadata_read) @@ -1765,15 +1796,15 @@ H5CX_get_coll_metadata_read(void) herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(btype); HDassert(ftype); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context values */ @@ -1799,12 +1830,12 @@ done: hbool_t H5CX_get_mpi_file_flushing(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); FUNC_LEAVE_NOAPI((*head)->ctx.mpi_file_flushing) @@ -1826,12 +1857,12 @@ H5CX_get_mpi_file_flushing(void) hbool_t H5CX_get_mpio_rank0_bcast(void) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); FUNC_LEAVE_NOAPI((*head)->ctx.rank0_bcast) @@ -1853,14 +1884,14 @@ H5CX_get_mpio_rank0_bcast(void) herr_t H5CX_get_btree_split_ratios(double split_ratio[3]) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(split_ratio); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -1889,14 +1920,14 @@ done: herr_t H5CX_get_max_temp_buf(size_t *max_temp_buf) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(max_temp_buf); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -1924,14 +1955,14 @@ done: herr_t H5CX_get_tconv_buf(void **tconv_buf) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(tconv_buf); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -1959,14 +1990,14 @@ done: herr_t H5CX_get_bkgr_buf(void **bkgr_buf) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(bkgr_buf); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -1994,14 +2025,14 @@ done: herr_t H5CX_get_bkgr_buf_type(H5T_bkg_t *bkgr_buf_type) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(bkgr_buf_type); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2029,14 +2060,14 @@ done: herr_t H5CX_get_vec_size(size_t *vec_size) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vec_size); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2066,14 +2097,14 @@ done: herr_t H5CX_get_io_xfer_mode(H5FD_mpio_xfer_t *io_xfer_mode) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(io_xfer_mode); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2101,14 +2132,14 @@ done: herr_t H5CX_get_mpio_coll_opt(H5FD_mpio_collective_opt_t *mpio_coll_opt) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(mpio_coll_opt); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2136,14 +2167,14 @@ done: herr_t H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(mpio_local_no_coll_cause); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2172,14 +2203,14 @@ done: herr_t H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(mpio_global_no_coll_cause); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2208,14 +2239,14 @@ done: herr_t H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(mpio_chunk_opt_mode); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2244,14 +2275,14 @@ done: herr_t H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(mpio_chunk_opt_num); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2280,14 +2311,14 @@ done: herr_t H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(mpio_chunk_opt_ratio); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2317,14 +2348,14 @@ done: herr_t H5CX_get_err_detect(H5Z_EDC_t *err_detect) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(err_detect); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2352,14 +2383,14 @@ done: herr_t H5CX_get_filter_cb(H5Z_cb_t *filter_cb) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(filter_cb); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2387,14 +2418,14 @@ done: herr_t H5CX_get_data_transform(H5Z_data_xform_t **data_transform) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(data_transform); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2445,14 +2476,14 @@ done: herr_t H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vl_alloc_info); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2510,14 +2541,14 @@ done: herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *dt_conv_cb) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(dt_conv_cb); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2545,14 +2576,14 @@ done: herr_t H5CX_get_encoding(H5T_cset_t *encoding) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(encoding); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.lcpl_id); @@ -2580,14 +2611,14 @@ done: herr_t H5CX_get_intermediate_group(unsigned *crt_intermed_group) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(crt_intermed_group); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.lcpl_id); @@ -2616,14 +2647,14 @@ done: herr_t H5CX_get_nlinks(size_t *nlinks) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(nlinks); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); @@ -2651,15 +2682,15 @@ done: herr_t H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(low_bound); HDassert(high_bound); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.fapl_id); @@ -2690,14 +2721,14 @@ done: herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(dset_min_ohdr_flag); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); @@ -2726,14 +2757,14 @@ done: herr_t H5CX_get_ext_file_prefix(const char **extfile_prefix) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(extfile_prefix); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); @@ -2784,14 +2815,14 @@ done: herr_t H5CX_get_vds_prefix(const char **vds_prefix) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vds_prefix); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); @@ -2842,12 +2873,12 @@ done: void H5CX_set_tag(haddr_t tag) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); (*head)->ctx.tag = tag; @@ -2870,12 +2901,12 @@ H5CX_set_tag(haddr_t tag) void H5CX_set_ring(H5AC_ring_t ring) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); (*head)->ctx.ring = ring; @@ -2900,12 +2931,12 @@ H5CX_set_ring(H5AC_ring_t ring) void H5CX_set_coll_metadata_read(hbool_t cmdr) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); (*head)->ctx.coll_metadata_read = cmdr; @@ -2930,14 +2961,14 @@ H5CX_set_coll_metadata_read(hbool_t cmdr) herr_t H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context values */ @@ -2963,13 +2994,13 @@ done: herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -2997,13 +3028,13 @@ done: herr_t H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -3031,12 +3062,12 @@ done: void H5CX_set_mpi_file_flushing(hbool_t flushing) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); (*head)->ctx.mpi_file_flushing = flushing; @@ -3060,12 +3091,12 @@ H5CX_set_mpi_file_flushing(hbool_t flushing) void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); (*head)->ctx.rank0_bcast = rank0_bcast; @@ -3089,13 +3120,13 @@ H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -3126,13 +3157,13 @@ done: herr_t H5CX_set_nlinks(size_t nlinks) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Set the API context value */ @@ -3162,12 +3193,12 @@ done: void H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3193,12 +3224,12 @@ H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chun void H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t mpio_actual_io_mode) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3224,12 +3255,12 @@ H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t mpio_actual_io_mode) void H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert((*head)->ctx.dxpl_id != H5P_DEFAULT); @@ -3258,12 +3289,12 @@ H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) void H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert((*head)->ctx.dxpl_id != H5P_DEFAULT); @@ -3296,13 +3327,13 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) herr_t H5CX_test_set_mpio_coll_chunk_link_hard(int mpio_coll_chunk_link_hard) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3329,13 +3360,13 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_multi_hard(int mpio_coll_chunk_multi_hard) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3362,13 +3393,13 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_link_num_true(int mpio_coll_chunk_link_num_true) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3396,13 +3427,13 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_link_num_false(int mpio_coll_chunk_link_num_false) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3430,13 +3461,13 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(int mpio_coll_chunk_multi_ratio_coll) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3464,13 +3495,13 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(int mpio_coll_chunk_multi_ratio_ind) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3497,13 +3528,13 @@ done: herr_t H5CX_test_set_mpio_coll_rank0_bcast(hbool_t mpio_coll_rank0_bcast) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); @@ -3530,14 +3561,14 @@ done: herr_t H5CX_get_ohdr_flags(uint8_t *ohdr_flags) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(ohdr_flags); + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); @@ -3565,9 +3596,8 @@ done: static H5CX_node_t * H5CX__pop_common(hbool_t update_dxpl_props) { - H5CX_node_t **head = - H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - H5CX_node_t *ret_value = NULL; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + H5CX_node_t * ret_value = NULL; /* Return value */ #ifdef H5_HAVE_PARALLEL FUNC_ENTER_STATIC @@ -3576,6 +3606,7 @@ H5CX__pop_common(hbool_t update_dxpl_props) #endif /* Sanity check */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ HDassert(head && *head); /* Check for cached DXPL properties to return to application */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 66c6601..d6da9b7 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -919,7 +919,9 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) entry_ptr = prev_ptr; } /* end while */ +#ifdef H5C_DO_SANITY_CHECKS done: +#endif /* H5C_DO_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_clear_coll_entries */ diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 27a24c4..78d6f35 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -2242,10 +2242,10 @@ herr_t H5C_verify_tag(int id, haddr_t tag); H5_DLL herr_t H5C_flush_to_min_clean(H5F_t *f); H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); H5_DLL herr_t H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); -H5_DLL herr_t H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, +H5_DLL herr_t H5C_get_cache_size(const H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); -H5_DLL herr_t H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr); -H5_DLL herr_t H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr); +H5_DLL herr_t H5C_get_cache_flush_in_progress(const H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr); +H5_DLL herr_t H5C_get_cache_hit_rate(const H5C_t *cache_ptr, double *hit_rate_ptr); H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_ptr, hbool_t *in_cache_ptr, hbool_t *is_dirty_ptr, hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, hbool_t *is_corked_ptr, hbool_t *is_flush_dep_parent_ptr, @@ -2290,7 +2290,7 @@ H5_DLL herr_t H5C_unsettle_ring(H5F_t *f, H5C_ring_t ring); H5_DLL herr_t H5C_remove_entry(void *thing); H5_DLL herr_t H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr); H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); -H5_DLL herr_t H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); +H5_DLL herr_t H5C_get_mdc_image_info(const H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); /* Logging functions */ H5_DLL herr_t H5C_start_logging(H5C_t *cache); diff --git a/src/H5Cquery.c b/src/H5Cquery.c index d8e2a72..6cf8ffc 100644 --- a/src/H5Cquery.c +++ b/src/H5Cquery.c @@ -114,8 +114,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, - uint32_t *cur_num_entries_ptr) +H5C_get_cache_size(const H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -151,7 +151,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr) +H5C_get_cache_flush_in_progress(const H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -184,7 +184,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr) +H5C_get_cache_hit_rate(const H5C_t *cache_ptr, double *hit_rate_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -405,7 +405,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) +H5C_get_mdc_image_info(const H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5D.c b/src/H5D.c index aa09f5f..7d0e934 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -557,8 +557,9 @@ H5D__get_space_api_common(hid_t dset_id, void **token_ptr, H5VL_object_t **_vol_ { H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = - (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -566,11 +567,17 @@ H5D__get_space_api_common(hid_t dset_id, void **token_ptr, H5VL_object_t **_vol_ if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_SPACE; + vol_cb_args.args.get_space.space_id = H5I_INVALID_HID; + /* Get the dataspace */ - if (H5VL_dataset_get(*vol_obj_ptr, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, token_ptr, - &ret_value) < 0) + if (H5VL_dataset_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") + /* Set return value */ + ret_value = vol_cb_args.args.get_space.space_id; + done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_space_api_common() */ @@ -591,7 +598,7 @@ done: hid_t H5Dget_space(hid_t dset_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); @@ -664,8 +671,9 @@ done: herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation /*out*/) { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dset_id, allocation); @@ -674,9 +682,12 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_SPACE_STATUS; + vol_cb_args.args.get_space_status.status = allocation; + /* Get dataspace status */ - if ((ret_value = H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE_STATUS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, allocation)) < 0) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get space status") done: @@ -699,8 +710,9 @@ done: hid_t H5Dget_type(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); @@ -709,11 +721,17 @@ H5Dget_type(hid_t dset_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_TYPE; + vol_cb_args.args.get_type.type_id = H5I_INVALID_HID; + /* Get the datatype */ - if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + /* Set return value */ + ret_value = vol_cb_args.args.get_type.type_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_type() */ @@ -737,8 +755,9 @@ done: hid_t H5Dget_create_plist(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); @@ -747,11 +766,17 @@ H5Dget_create_plist(hid_t dset_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_DCPL; + vol_cb_args.args.get_dcpl.dcpl_id = H5I_INVALID_HID; + /* Get the dataset creation property list */ - if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties") + /* Set return value */ + ret_value = vol_cb_args.args.get_dcpl.dcpl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_create_plist() */ @@ -792,8 +817,9 @@ done: hid_t H5Dget_access_plist(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); @@ -802,11 +828,17 @@ H5Dget_access_plist(hid_t dset_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_DAPL; + vol_cb_args.args.get_dapl.dapl_id = H5I_INVALID_HID; + /* Get the dataset access property list */ - if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset access properties") + /* Set return value */ + ret_value = vol_cb_args.args.get_dapl.dapl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_access_plist() */ @@ -829,8 +861,10 @@ done: hsize_t H5Dget_storage_size(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - hsize_t ret_value = 0; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hsize_t storage_size = 0; /* Storage size of dataset */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", dset_id); @@ -839,11 +873,17 @@ H5Dget_storage_size(hid_t dset_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_STORAGE_SIZE; + vol_cb_args.args.get_storage_size.storage_size = &storage_size; + /* Get the storage size */ - if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "unable to get storage size") + /* Set return value */ + ret_value = storage_size; + done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_storage_size() */ @@ -862,8 +902,11 @@ done: haddr_t H5Dget_offset(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5VL_object_t * vol_obj; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + haddr_t dset_offset = HADDR_UNDEF; /* Dataset's offset */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_API(HADDR_UNDEF) H5TRACE1("a", "i", dset_id); @@ -872,11 +915,18 @@ H5Dget_offset(hid_t dset_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") + /* Set up VOL callback arguments */ + dset_opt_args.get_offset.offset = &dset_offset; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_OFFSET; + vol_cb_args.args = &dset_opt_args; + /* Get the offset */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") + /* Set return value */ + ret_value = dset_offset; + done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_offset() */ @@ -941,7 +991,11 @@ done: * * The MEM_SPACE_ID can be the constant H5S_ALL in which case * the memory dataspace is the same as the file dataspace - * defined when the dataset was created. + * defined when the dataset was created. The MEM_SPACE_ID can + * also be the constant H5S_BLOCK, which indicates that the + * buffer provided is a single contiguous block of memory, with + * the same # of elements as specified in the FILE_SPACE_ID + * selection. * * The number of elements in the memory dataspace must match * the number of elements in the file dataspace. @@ -1032,13 +1086,15 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) +H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf /*out*/) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "ii*h*Iu*x", dset_id, dxpl_id, offset, filters, buf); + H5TRACE5("e", "ii*h*Iux", dset_id, dxpl_id, offset, filters, buf); /* Check arguments */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) @@ -1056,11 +1112,20 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + /* Set up VOL callback arguments */ + dset_opt_args.chunk_read.offset = offset; + dset_opt_args.chunk_read.filters = 0; + dset_opt_args.chunk_read.buf = buf; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_CHUNK_READ; + vol_cb_args.args = &dset_opt_args; + /* Read the raw chunk */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_READ, dxpl_id, H5_REQUEST_NULL, offset, - filters, buf) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + /* Set return value */ + *filters = dset_opt_args.chunk_read.filters; + done: FUNC_LEAVE_API(ret_value) } /* end H5Dread_chunk() */ @@ -1126,7 +1191,11 @@ done: * * The MEM_SPACE_ID can be the constant H5S_ALL in which case * the memory dataspace is the same as the file dataspace - * defined when the dataset was created. + * defined when the dataset was created. The MEM_SPACE_ID can + * also be the constant H5S_BLOCK, which indicates that the + * buffer provided is a single contiguous block of memory, with + * the same # of elements as specified in the FILE_SPACE_ID + * selection. * * The number of elements in the memory dataspace must match * the number of elements in the file dataspace. @@ -1222,9 +1291,11 @@ herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, const void *buf) { - H5VL_object_t *vol_obj = NULL; - uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); @@ -1250,9 +1321,16 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + /* Set up VOL callback arguments */ + dset_opt_args.chunk_write.offset = offset; + dset_opt_args.chunk_write.filters = filters; + dset_opt_args.chunk_write.size = data_size_32; + dset_opt_args.chunk_write.buf = buf; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_CHUNK_WRITE; + vol_cb_args.args = &dset_opt_args; + /* Write chunk */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_WRITE, dxpl_id, H5_REQUEST_NULL, filters, - offset, data_size_32, buf) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: @@ -1348,7 +1426,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_ done: /* Release selection iterator */ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release selection iterator") if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); @@ -1447,7 +1525,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf done: /* Release selection iterator */ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release selection iterator") if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); @@ -1642,9 +1720,18 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *s &supported) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check for 'get vlen buf size' operation") if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + + /* Set up VOL callback arguments */ + dset_opt_args.get_vlen_buf_size.type_id = type_id; + dset_opt_args.get_vlen_buf_size.space_id = space_id; + dset_opt_args.get_vlen_buf_size.size = size; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE; + vol_cb_args.args = &dset_opt_args; + /* Make the 'get_vlen_buf_size' callback */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, type_id, space_id, size) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get vlen buf size") } /* end if */ else { @@ -1673,7 +1760,8 @@ H5D__set_extent_api_common(hid_t dset_id, const hsize_t size[], void **token_ptr H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_dataset_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1687,9 +1775,12 @@ H5D__set_extent_api_common(hid_t dset_id, const hsize_t size[], void **token_ptr if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_SET_EXTENT; + vol_cb_args.args.set_extent.size = size; + /* Set the extent */ - if ((ret_value = H5VL_dataset_specific(*vol_obj_ptr, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, - token_ptr, size)) < 0) + if (H5VL_dataset_specific(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set dataset extent") done: @@ -1775,8 +1866,9 @@ done: herr_t H5Dflush(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); @@ -1789,12 +1881,15 @@ H5Dflush(hid_t dset_id) if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_FLUSH; + vol_cb_args.args.flush.dset_id = dset_id; + /* Flush dataset information cached in memory * XXX: Note that we need to pass the ID to the VOL since the H5F_flush_cb_t * callback needs it and that's in the public API. */ - if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_FLUSH, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, dset_id)) < 0) + if (H5VL_dataset_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") done: @@ -1802,41 +1897,6 @@ done: } /* H5Dflush */ /*------------------------------------------------------------------------- - * Function: H5Dwait - * - * Purpose: Wait for all operations on a dataset. - * Tang: added for async - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5Dwait(hid_t dset_id) -{ - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", dset_id); - - /* Check args */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") - - /* Set up collective metadata if appropriate */ - if (H5CX_set_loc(dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") - - if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_WAIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, dset_id)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "unable to wait dataset") - -done: - FUNC_LEAVE_API(ret_value) -} /* H5Dwait*/ - -/*------------------------------------------------------------------------- * Function: H5Drefresh * * Purpose: Refreshes all buffers associated with a dataset. @@ -1848,8 +1908,9 @@ done: herr_t H5Drefresh(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); @@ -1862,9 +1923,12 @@ H5Drefresh(hid_t dset_id) if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_REFRESH; + vol_cb_args.args.refresh.dset_id = dset_id; + /* Refresh the dataset object */ - if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_REFRESH, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, dset_id)) < 0) + if (H5VL_dataset_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") done: @@ -1891,8 +1955,9 @@ done: herr_t H5Dformat_convert(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); @@ -1905,9 +1970,12 @@ H5Dformat_convert(hid_t dset_id) if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_DATASET_FORMAT_CONVERT; + vol_cb_args.args = NULL; + /* Convert the dataset */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format") done: @@ -1929,8 +1997,10 @@ done: herr_t H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type /*out*/) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dset_id, idx_type); @@ -1941,9 +2011,13 @@ H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type /*out*/) if (NULL == idx_type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL") + /* Set up VOL callback arguments */ + dset_opt_args.get_chunk_idx_type.idx_type = idx_type; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE; + vol_cb_args.args = &dset_opt_args; + /* Get the chunk indexing type */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, idx_type) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk index type") done: @@ -1968,8 +2042,10 @@ done: herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_nbytes /*out*/) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*hx", dset_id, offset, chunk_nbytes); @@ -1982,9 +2058,14 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n if (NULL == chunk_nbytes) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "chunk_nbytes parameter cannot be NULL") + /* Set up VOL callback arguments */ + dset_opt_args.get_chunk_storage_size.offset = offset; + dset_opt_args.get_chunk_storage_size.size = chunk_nbytes; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE; + vol_cb_args.args = &dset_opt_args; + /* Get the dataset creation property list */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, offset, chunk_nbytes) < 0) + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: @@ -2015,8 +2096,10 @@ done: herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks /*out*/) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj = NULL; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "iix", dset_id, fspace_id, nchunks); @@ -2027,10 +2110,15 @@ H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks /*out*/) if (NULL == nchunks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)") + /* Set up VOL callback arguments */ + dset_opt_args.get_num_chunks.space_id = fspace_id; + dset_opt_args.get_num_chunks.nchunks = nchunks; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_NUM_CHUNKS; + vol_cb_args.args = &dset_opt_args; + /* Get the number of written chunks */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, fspace_id, nchunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get number of chunks") + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") done: FUNC_LEAVE_API(ret_value); @@ -2062,9 +2150,11 @@ herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *offset /*out*/, unsigned *filter_mask /*out*/, haddr_t *addr /*out*/, hsize_t *size /*out*/) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - hsize_t nchunks = 0; - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj = NULL; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + hsize_t nchunks = 0; /* Number of chunks */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE7("e", "iihxxxx", dset_id, fspace_id, chk_index, offset, filter_mask, addr, size); @@ -2076,19 +2166,33 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *of if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") + /* Set up VOL callback arguments */ + dset_opt_args.get_num_chunks.space_id = fspace_id; + dset_opt_args.get_num_chunks.nchunks = &nchunks; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_NUM_CHUNKS; + vol_cb_args.args = &dset_opt_args; + /* Get the number of written chunks to check range */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, fspace_id, &nchunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get number of chunks") + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") /* Check range for chunk index */ if (chk_index >= nchunks) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk index is out of range") + /* Set up VOL callback arguments */ + dset_opt_args.get_chunk_info_by_idx.space_id = fspace_id; + dset_opt_args.get_chunk_info_by_idx.chk_index = chk_index; + dset_opt_args.get_chunk_info_by_idx.offset = offset; + dset_opt_args.get_chunk_info_by_idx.filter_mask = filter_mask; + dset_opt_args.get_chunk_info_by_idx.addr = addr; + dset_opt_args.get_chunk_info_by_idx.size = size; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX; + vol_cb_args.args = &dset_opt_args; + /* Call private function to get the chunk info given the chunk's index */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, fspace_id, chk_index, offset, filter_mask, addr, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get chunk info by index") + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index") done: FUNC_LEAVE_API(ret_value); @@ -2119,8 +2223,10 @@ herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filter_mask /*out*/, haddr_t *addr /*out*/, hsize_t *size /*out*/) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj = NULL; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*hxxx", dset_id, offset, filter_mask, addr, size); @@ -2134,10 +2240,17 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte if (NULL == offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)") + /* Set up VOL callback arguments */ + dset_opt_args.get_chunk_info_by_coord.offset = offset; + dset_opt_args.get_chunk_info_by_coord.filter_mask = filter_mask; + dset_opt_args.get_chunk_info_by_coord.addr = addr; + dset_opt_args.get_chunk_info_by_coord.size = size; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD; + vol_cb_args.args = &dset_opt_args; + /* Call private function to get the chunk info given the chunk's index */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, offset, filter_mask, addr, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get chunk info by its logical coordinates") + if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by its logical coordinates") done: FUNC_LEAVE_API(ret_value) @@ -2150,6 +2263,7 @@ done: * * Parameters: * hid_t dset_id; IN: Chunked dataset ID + * hid_t dxpl_id; IN: Dataset transfer property list ID * H5D_chunk_iter_op_t cb IN: User callback function, called for every chunk. * void *op_data IN/OUT: Optional user data passed on to user callback. * @@ -2187,22 +2301,37 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dchunk_iter(hid_t dset_id, H5D_chunk_iter_op_t cb, void *op_data) +H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj = NULL; /* Dataset for this operation */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_dataset_optional_args_t dset_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ix*x", dset_id, cb, op_data); + H5TRACE4("e", "iix*x", dset_id, dxpl_id, op, op_data); /* Check arguments */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") + if (NULL == op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback to chunk iteration") - /* Call private function to get the chunk info given the chunk's index */ - if (H5VL_dataset_specific(vol_obj, H5VL_DATASET_CHUNK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, cb, - op_data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't iterate over chunks") + /* 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, "dxpl_id is not a dataset transfer property list ID") + + /* Set up VOL callback arguments */ + dset_opt_args.chunk_iter.op = op; + dset_opt_args.chunk_iter.op_data = op_data; + vol_cb_args.op_type = H5VL_NATIVE_DATASET_CHUNK_ITER; + vol_cb_args.args = &dset_opt_args; + + /* Iterate over the chunks */ + if ((ret_value = H5VL_dataset_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL)) < 0) + HERROR(H5E_BADITER, H5E_BADITER, "error iterating over dataset chunks"); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 6be29fd..67ac99b 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -245,10 +245,10 @@ typedef struct H5D_chunk_coll_info_t { } H5D_chunk_coll_info_t; #endif /* H5_HAVE_PARALLEL */ -typedef struct H5D_chunk_iter_cb_data_t { - H5D_chunk_iter_op_t cb; /* User defined callback */ +typedef struct H5D_chunk_iter_ud_t { + H5D_chunk_iter_op_t op; /* User defined callback */ void * op_data; /* User data for user defined callback */ -} H5D_chunk_iter_cb_data_t; +} H5D_chunk_iter_ud_t; /********************/ /* Local Prototypes */ @@ -602,8 +602,6 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage HDassert(offset); HDassert(storage_size); - *storage_size = 0; - /* Allocate dataspace and initialize it if it hasn't been. */ if (!(*layout->ops->is_space_alloc)(&layout->storage)) HGOTO_DONE(SUCCEED) @@ -6026,6 +6024,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) if (udata->chunk_in_cache) { HDassert(H5F_addr_defined(chunk_rec->chunk_addr)); + HDassert(ent); HDassert(H5F_addr_defined(ent->chunk_block.offset)); H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t); @@ -7459,6 +7458,38 @@ done: } /* end H5D__get_chunk_info_by_coord() */ /*------------------------------------------------------------------------- + * Function: H5D__chunk_iter_cb + * + * Purpose: Call the user-defined function with the chunk data. The iterator continues if + * the user-defined function returns H5_ITER_CONT, and stops if H5_ITER_STOP is + * returned. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * Failure: Negative (H5_ITER_ERROR) + * + * Programmer: Gaute Hope + * August 2020 + * + *------------------------------------------------------------------------- + */ +static int +H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) +{ + const H5D_chunk_iter_ud_t *data = (H5D_chunk_iter_ud_t *)udata; + int ret_value = H5_ITER_CONT; + + FUNC_ENTER_STATIC + + /* Check for callback failure and pass along return value */ + if ((ret_value = (data->op)(chunk_rec->scaled, chunk_rec->filter_mask, chunk_rec->chunk_addr, + chunk_rec->nbytes, data->op_data)) < 0) + HERROR(H5E_DATASET, H5E_CANTNEXT, "iteration operator failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__chunk_iter_cb */ + +/*------------------------------------------------------------------------- * Function: H5D__chunk_iter * * Purpose: Iterate over all the chunks in the dataset with given callbak. @@ -7472,7 +7503,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data) +H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data) { const H5O_layout_t *layout = NULL; /* Dataset layout */ const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ @@ -7497,7 +7528,7 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data) for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "cannot flush indexed storage buffer") /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; @@ -7507,13 +7538,16 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data) /* If the dataset is not written, return without errors */ if (H5F_addr_defined(idx_info.storage->idx_addr)) { - H5D_chunk_iter_cb_data_t data; - data.cb = cb; - data.op_data = op_data; + H5D_chunk_iter_ud_t ud; + + /* Set up info for iteration callback */ + ud.op = op; + ud.op_data = op_data; /* Iterate over the allocated chunks calling the iterator callback */ - if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to iterate over chunks.") + if ((ret_value = + (dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0) + HERROR(H5E_DATASET, H5E_CANTNEXT, "chunk iteration failed"); } /* end if H5F_addr_defined */ done: @@ -7521,31 +7555,48 @@ done: } /* end H5D__chunk_iter() */ /*------------------------------------------------------------------------- - * Function: H5D__chunk_iter_cb + * Function: H5D__chunk_get_offset_copy * - * Purpose: Call the user-defined function with the chunk data. The iterator continues if - * the user-defined function returns H5_ITER_CONT, and stops if H5_ITER_STOP is - * returned. + * Purpose: Copies an offset buffer and performs bounds checks on the + * values. * - * Return: Success: H5_ITER_CONT or H5_ITER_STOP - * Failure: Negative (H5_ITER_ERROR) + * This helper function ensures that the offset buffer given + * by the user is suitable for use with the rest of the library. * - * Programmer: Gaute Hope - * August 2020 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ -static int -H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) +herr_t +H5D__chunk_get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy) { - int ret_value = 0; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_NOAPI(FAIL) - const H5D_chunk_iter_cb_data_t *data = (H5D_chunk_iter_cb_data_t *)udata; + HDassert(dset); + HDassert(offset); + HDassert(offset_copy); - ret_value = (data->cb)(chunk_rec->scaled, chunk_rec->filter_mask, chunk_rec->chunk_addr, - chunk_rec->nbytes, data->op_data); + /* The library's chunking code requires the offset to terminate with a zero. + * So transfer the offset array to an internal offset array that we + * can properly terminate (handled via the memset call). + */ + HDmemset(offset_copy, 0, H5O_LAYOUT_NDIMS * sizeof(hsize_t)); + for (u = 0; u < dset->shared->ndims; u++) { + /* Make sure the offset doesn't exceed the dataset's dimensions */ + if (offset[u] > dset->shared->curr_dims[u]) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "offset exceeds dimensions of dataset") + + /* Make sure the offset fall right on a chunk's boundary */ + if (offset[u] % dset->shared->layout.u.chunk.dim[u]) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "offset doesn't fall on chunks's boundary") + + offset_copy[u] = offset[u]; + } + +done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__chunk_iter_cb */ +} /* end H5D__chunk_get_offset_copy() */ diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 1c66f26..61ecab26 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -233,13 +233,15 @@ done: herr_t H5Dextend(hid_t dset_id, const hsize_t size[]) { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - H5S_t * ds = NULL; /* Dataspace struct */ - int ndims; /* Dataset/space rank */ - hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_dataset_get_args_t vol_get_cb_args; /* Arguments to VOL callback */ + H5VL_dataset_specific_args_t vol_spec_cb_args; /* Arguments to VOL callback */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + H5S_t * ds = NULL; /* Dataspace struct */ + int ndims; /* Dataset/space rank */ + hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); @@ -250,10 +252,14 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") + /* Set up VOL callback arguments */ + vol_get_cb_args.op_type = H5VL_DATASET_GET_SPACE; + vol_get_cb_args.args.get_space.space_id = H5I_INVALID_HID; + /* Get the dataspace pointer for the dataset */ - if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < - 0) + if (H5VL_dataset_get(vol_obj, &vol_get_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataspace") + sid = vol_get_cb_args.args.get_space.space_id; if (H5I_INVALID_HID == sid) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "received an invalid dataspace from the dataset") if (NULL == (ds = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) @@ -281,9 +287,12 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_spec_cb_args.op_type = H5VL_DATASET_SET_EXTENT; + vol_spec_cb_args.args.set_extent.size = dset_dims; + /* Increase size */ - if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, dset_dims)) < 0) + if (H5VL_dataset_specific(vol_obj, &vol_spec_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to extend dataset") done: diff --git a/src/H5Dint.c b/src/H5Dint.c index 207181a..6d3f4a3 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -2853,13 +2853,14 @@ H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id { H5D_vlen_bufsize_generic_t vlen_bufsize = { NULL, H5I_INVALID_HID, NULL, H5I_INVALID_HID, H5I_INVALID_HID, {NULL, NULL, 0, 0}}; - H5P_genplist_t * dxpl = NULL; /* DXPL for operation */ - H5S_t * mspace = NULL; /* Memory dataspace */ - char bogus; /* Bogus value to pass to H5Diterate() */ - H5S_t * space; /* Dataspace for iteration */ - H5T_t * type; /* Datatype */ - H5S_sel_iter_op_t dset_op; /* Operator for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * dxpl = NULL; /* DXPL for operation */ + H5S_t * mspace = NULL; /* Memory dataspace */ + char bogus; /* Bogus value to pass to H5Diterate() */ + H5S_t * space; /* Dataspace for iteration */ + H5T_t * type; /* Datatype */ + H5S_sel_iter_op_t dset_op; /* Operator for iteration */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2874,10 +2875,14 @@ H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id /* Save the dataset */ vlen_bufsize.dset_vol_obj = vol_obj; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_SPACE; + vol_cb_args.args.get_space.space_id = H5I_INVALID_HID; + /* Get a copy of the dataset's dataspace */ - if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &vlen_bufsize.fspace_id) < 0) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace") + vlen_bufsize.fspace_id = vol_cb_args.args.get_space.space_id; if (NULL == (vlen_bufsize.fspace = (H5S_t *)H5I_object(vlen_bufsize.fspace_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataspace") @@ -3943,7 +3948,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__refresh(hid_t dset_id, H5D_t *dset) +H5D__refresh(H5D_t *dset, hid_t dset_id) { H5D_virtual_held_file_t *head = NULL; /* Pointer to list of files held open */ hbool_t virt_dsets_held = FALSE; /* Whether virtual datasets' files are held open */ @@ -3968,7 +3973,7 @@ H5D__refresh(hid_t dset_id, H5D_t *dset) } /* end if */ /* Refresh dataset object */ - if ((H5O_refresh_metadata(dset_id, dset->oloc)) < 0) + if ((H5O_refresh_metadata(&dset->oloc, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh dataset") done: diff --git a/src/H5Dio.c b/src/H5Dio.c index 03400cf..600f08a 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -69,55 +69,6 @@ H5FL_BLK_DEFINE(type_conv); H5FL_DEFINE(H5D_chunk_map_t); /*------------------------------------------------------------------------- - * Function: H5D__get_offset_copy - * - * Purpose: Copies an offset buffer and performs bounds checks on the - * values. - * - * This helper function ensures that the offset buffer given - * by the user is suitable for use with the rest of the library. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy) -{ - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(dset); - HDassert(offset); - HDassert(offset_copy); - - /* The library's chunking code requires the offset to terminate with a zero. - * So transfer the offset array to an internal offset array that we - * can properly terminate (handled via the calloc call). - */ - - HDmemset(offset_copy, 0, H5O_LAYOUT_NDIMS * sizeof(hsize_t)); - - for (u = 0; u < dset->shared->ndims; u++) { - /* Make sure the offset doesn't exceed the dataset's dimensions */ - if (offset[u] > dset->shared->curr_dims[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") - - /* Make sure the offset fall right on a chunk's boundary */ - if (offset[u] % dset->shared->layout.u.chunk.dim[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") - - offset_copy[u] = offset[u]; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5D__get_offset_copy() */ - -/*------------------------------------------------------------------------- * Function: H5D__read * * Purpose: Reads (part of) a DATASET into application memory BUF. See @@ -161,12 +112,8 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t /* check args */ HDassert(dataset && dataset->oloc.file); - - if (!file_space) - file_space = dataset->shared->space; - if (!mem_space) - mem_space = file_space; - nelmts = H5S_GET_SELECT_NPOINTS(mem_space); + HDassert(file_space); + HDassert(mem_space); /* Set up datatype info for operation */ if (H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) @@ -189,11 +136,12 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ + nelmts = H5S_GET_SELECT_NPOINTS(mem_space); if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") - /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ + /* Check for a NULL buffer */ if (NULL == buf) { /* Check for any elements selected (which is invalid) */ if (nelmts > 0) @@ -225,7 +173,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t * Note that in general, this requires us to touch up the memory buffer as * well. */ - if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && + if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ /* to the beginning of the projected mem space. */ @@ -377,6 +325,8 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ /* check args */ HDassert(dataset && dataset->oloc.file); + HDassert(file_space); + HDassert(mem_space); /* All filters in the DCPL must have encoding enabled. */ if (!dataset->shared->checked_filters) { @@ -418,20 +368,13 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ } /* end else */ #endif /*H5_HAVE_PARALLEL*/ - /* Initialize dataspace information */ - if (!file_space) - file_space = dataset->shared->space; - if (!mem_space) - mem_space = file_space; - - nelmts = H5S_GET_SELECT_NPOINTS(mem_space); - /* Make certain that the number of elements in each selection is the same */ + nelmts = H5S_GET_SELECT_NPOINTS(mem_space); if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") - /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ + /* Check for a NULL buffer */ if (NULL == buf) { /* Check for any elements selected (which is invalid) */ if (nelmts > 0) @@ -463,7 +406,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ * Note that in general, this requires us to touch up the memory buffer * as well. */ - if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && + if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ /* to the beginning of the projected mem space. */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 28561c9..e07ba30 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -575,7 +575,7 @@ H5_DLL herr_t H5D__flush_sieve_buf(H5D_t *dataset); H5_DLL herr_t H5D__flush_real(H5D_t *dataset); H5_DLL herr_t H5D__flush(H5D_t *dset, hid_t dset_id); H5_DLL herr_t H5D__mark(const H5D_t *dataset, unsigned flags); -H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); +H5_DLL herr_t H5D__refresh(H5D_t *dataset, hid_t dset_id); /* To convert a dataset's chunk indexing type to v1 B-tree */ H5_DLL herr_t H5D__format_convert(H5D_t *dataset); @@ -650,7 +650,7 @@ H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5 H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, hsize_t *btree_size); H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, FILE *stream); H5_DLL herr_t H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *store); -H5_DLL herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy); +H5_DLL herr_t H5D__chunk_get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy); H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, uint32_t data_size, const void *buf); H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t *filters, void *buf); diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index f9ef772..ad9794d 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -79,11 +79,12 @@ #define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME \ "local_no_collective_cause" /* cause of broken collective I/O in each process */ #define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME \ - "global_no_collective_cause" /* cause of broken collective I/O in all processes */ -#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ -#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ -#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ -#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ + "global_no_collective_cause" /* cause of broken collective I/O in all processes */ +#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ +#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ +#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ +#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ +#define H5D_XFER_DSET_IO_SEL_NAME "dset_io_selection" /* Dataset I/O selection */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Collective chunk instrumentation properties */ #define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 0b5fac6..63cc61c 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -641,6 +641,7 @@ H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, u * \brief Iterate over all chunks * * \dset_id + * \param[in] dxpl_id Identifier of a transfer property list * \param[in] cb User callback function, called for every chunk. * \param[in] op_data User-defined pointer to data required by op * @@ -677,7 +678,7 @@ H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, u * indicating failure. * */ -H5_DLL herr_t H5Dchunk_iter(hid_t dset_id, H5D_chunk_iter_op_t cb, void *op_data); +H5_DLL herr_t H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t cb, void *op_data); /** * -------------------------------------------------------------------------- @@ -1339,8 +1340,6 @@ H5_DLL herr_t H5Dset_extent_async(const char *app_file, const char *app_func, un */ H5_DLL herr_t H5Dflush(hid_t dset_id); -H5_DLL herr_t H5Dwait(hid_t dset_id); - /** * -------------------------------------------------------------------------- * \ingroup H5D diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index f582ec5..4012188 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -3151,7 +3151,7 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register (temporary) source dataset ID") /* Refresh source dataset */ - if (H5D__refresh(temp_id, *dset) < 0) + if (H5D__refresh(*dset, temp_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") /* Discard the identifier & replace the dataset */ diff --git a/src/H5E.c b/src/H5E.c index b8e17a4..b132103 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -996,11 +996,12 @@ H5E__get_current_stack(void) if (H5I_inc_ref(current_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->min_num = current_error->min_num; - if (NULL == (new_error->func_name = H5MM_xstrdup(current_error->func_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if (NULL == (new_error->file_name = H5MM_xstrdup(current_error->file_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - new_error->line = current_error->line; + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + new_error->func_name = current_error->func_name; + new_error->file_name = current_error->file_name; + new_error->line = current_error->line; if (NULL == (new_error->desc = H5MM_xstrdup(current_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end for */ @@ -1116,11 +1117,12 @@ H5E__set_current_stack(H5E_t *estack) if (H5I_inc_ref(new_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->min_num = new_error->min_num; - if (NULL == (current_error->func_name = H5MM_xstrdup(new_error->func_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if (NULL == (current_error->file_name = H5MM_xstrdup(new_error->file_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - current_error->line = new_error->line; + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + current_error->func_name = new_error->func_name; + current_error->file_name = new_error->file_name; + current_error->line = new_error->line; if (NULL == (current_error->desc = H5MM_xstrdup(new_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end for */ @@ -1813,11 +1815,12 @@ H5E__append_stack(H5E_t *dst_stack, const H5E_t *src_stack) if (H5I_inc_ref(src_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error message") dst_error->min_num = src_error->min_num; - if (NULL == (dst_error->func_name = H5MM_xstrdup(src_error->func_name))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "memory allocation failed") - if (NULL == (dst_error->file_name = H5MM_xstrdup(src_error->file_name))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "memory allocation failed") - dst_error->line = src_error->line; + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + dst_error->func_name = src_error->func_name; + dst_error->file_name = src_error->file_name; + dst_error->line = src_error->line; if (NULL == (dst_error->desc = H5MM_xstrdup(src_error->desc))) HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "memory allocation failed") diff --git a/src/H5ES.c b/src/H5ES.c index 2ba8a72..ccc0dd8 100644 --- a/src/H5ES.c +++ b/src/H5ES.c @@ -34,11 +34,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ #include "H5ESpkg.h" /* Event Sets */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -103,10 +104,61 @@ done: } /* end H5EScreate() */ /*------------------------------------------------------------------------- + * Function: H5ESinsert_request + * + * Purpose: Insert a request from a VOL connector into an event set. + * + * Note: This function is primarily targeted at VOL connector + * authors and is _not_ designed for general-purpose application use. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, December 11, 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5ESinsert_request(hid_t es_id, hid_t connector_id, void *request) +{ + H5ES_t *es; /* Event set */ + H5VL_t *connector = NULL; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ii*x", es_id, connector_id, request); + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + if (NULL == request) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL request pointer") + + /* Create new VOL connector object, using the connector ID */ + if (NULL == (connector = H5VL_new_connector(connector_id))) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create VOL connector object") + + /* Insert request into event set */ + if (H5ES__insert_request(es, connector, request) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "can't insert request into event set") + +done: + /* Clean up on error */ + if (ret_value < 0) + /* Release newly created connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") + + FUNC_LEAVE_API(ret_value) +} /* end H5ESinsert_request() */ + +/*------------------------------------------------------------------------- * Function: H5ESget_count * * Purpose: Retrieve the # of events in an event set * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -117,19 +169,23 @@ done: herr_t H5ESget_count(hid_t es_id, size_t *count /*out*/) { - H5ES_t *es; /* Event set */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", es_id, count); - /* Check arguments */ - if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") - /* Retrieve the count, if non-NULL */ - if (count) - *count = H5ES__list_count(&es->active); + /* Retrieve the count, if non-NULL */ + if (count) + *count = H5ES__list_count(&es->active); + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -145,6 +201,8 @@ done: * mechanism for matching operations inserted into the event * set with [possible] errors that occur. * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -155,19 +213,23 @@ done: herr_t H5ESget_op_counter(hid_t es_id, uint64_t *op_counter /*out*/) { - H5ES_t *es; /* Event set */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", es_id, op_counter); - /* Check arguments */ - if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ - /* Retrieve the operation counter, if non-NULL */ - if (op_counter) - *op_counter = es->op_counter; + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + + /* Retrieve the operation counter, if non-NULL */ + if (op_counter) + *op_counter = es->op_counter; + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -192,6 +254,8 @@ done: * value returned for the # of operations in progress may be * inaccurate. * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -202,33 +266,82 @@ done: herr_t H5ESwait(hid_t es_id, uint64_t timeout, size_t *num_in_progress /*out*/, hbool_t *op_failed /*out*/) { - H5ES_t *es; /* Event set */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iULxx", es_id, timeout, num_in_progress, op_failed); - /* Check arguments */ - if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") - if (NULL == num_in_progress) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL num_in_progress pointer") - if (NULL == op_failed) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL op_failed pointer") - - /* Wait for operations */ - if (H5ES__wait(es, timeout, num_in_progress, op_failed) < 0) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTWAIT, FAIL, "can't wait on operations") + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + if (NULL == num_in_progress) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL num_in_progress pointer") + if (NULL == op_failed) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL op_failed pointer") + + /* Wait for operations */ + if (H5ES__wait(es, timeout, num_in_progress, op_failed) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTWAIT, FAIL, "can't wait on operations") + } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5ESwait() */ /*------------------------------------------------------------------------- + * Function: H5EScancel + * + * Purpose: Attempt to cancel operations in an event set + * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Thursday, December 10, 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5EScancel(hid_t es_id, size_t *num_not_canceled /*out*/, hbool_t *op_failed /*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ixx", es_id, num_not_canceled, op_failed); + + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + if (NULL == num_not_canceled) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL num_not_canceled pointer") + if (NULL == op_failed) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL op_failed pointer") + + /* Cancel operations */ + if (H5ES__cancel(es, num_not_canceled, op_failed) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCANCEL, FAIL, "can't cancel operations") + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5EScancel() */ + +/*------------------------------------------------------------------------- * Function: H5ESget_err_status * * Purpose: Check if event set has failed operations * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -239,19 +352,23 @@ done: herr_t H5ESget_err_status(hid_t es_id, hbool_t *err_status /*out*/) { - H5ES_t *es; /* Event set */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", es_id, err_status); - /* Check arguments */ - if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ - /* Retrieve the error flag, if non-NULL */ - if (err_status) - *err_status = es->err_occurred; + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + + /* Retrieve the error flag, if non-NULL */ + if (err_status) + *err_status = es->err_occurred; + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -265,6 +382,8 @@ done: * Note: Does not wait for active operations to complete, so count may * not include all failures. * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -275,23 +394,27 @@ done: herr_t H5ESget_err_count(hid_t es_id, size_t *num_errs /*out*/) { - H5ES_t *es; /* Event set */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", es_id, num_errs); - /* Check arguments */ - if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ - /* Retrieve the error flag, if non-NULL */ - if (num_errs) { - if (es->err_occurred) - *num_errs = H5ES__list_count(&es->failed); - else - *num_errs = 0; - } /* end if */ + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + + /* Retrieve the error flag, if non-NULL */ + if (num_errs) { + if (es->err_occurred) + *num_errs = H5ES__list_count(&es->failed); + else + *num_errs = 0; + } /* end if */ + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -305,6 +428,8 @@ done: * Note: The strings retrieved for each error info must be released * by calling H5free_memory(). * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -316,29 +441,164 @@ herr_t H5ESget_err_info(hid_t es_id, size_t num_err_info, H5ES_err_info_t err_info[] /*out*/, size_t *num_cleared /*out*/) { - H5ES_t *es; /* Event set */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "izxx", es_id, num_err_info, err_info, num_cleared); + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + if (0 == num_err_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "err_info array size is 0") + if (NULL == err_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL err_info array pointer") + if (NULL == num_cleared) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL errors cleared pointer") + + /* Retrieve the error information */ + if (H5ES__get_err_info(es, num_err_info, err_info, num_cleared) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, "can't retrieve error info for failed operation(s)") + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5ESget_err_info() */ + +/*------------------------------------------------------------------------- + * Function: H5ESfree_err_info + * + * Purpose: Convenience routine to free 1+ H5ES_err_info_t structs. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, March 5, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5ESfree_err_info(size_t num_err_info, H5ES_err_info_t err_info[]) +{ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "z*#", num_err_info, err_info); + /* Check arguments */ - if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") if (0 == num_err_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "err_info array size is 0") if (NULL == err_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL err_info array pointer") - if (NULL == num_cleared) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL errors cleared pointer") - /* Retrieve the error information */ - if (H5ES__get_err_info(es, num_err_info, err_info, num_cleared) < 0) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, "can't retrieve error info for failed operation(s)") + /* Iterate over array, releasing error information */ + for (u = 0; u < num_err_info; u++) { + H5MM_xfree(err_info[u].api_name); + H5MM_xfree(err_info[u].api_args); + H5MM_xfree(err_info[u].app_file_name); + H5MM_xfree(err_info[u].app_func_name); + if (H5I_dec_app_ref(err_info[u].err_stack_id) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "can't close error stack for err_info #%zu", u) + } /* end for */ done: FUNC_LEAVE_API(ret_value) -} /* end H5ESget_err_info() */ +} /* end H5ESfree_err_info() */ + +/*------------------------------------------------------------------------- + * Function: H5ESregister_insert_func + * + * Purpose: Registers a callback to invoke when a new operation is inserted + * into an event set. + * + * Note: Only one insert callback can be registered for each event set. + * Registering a new callback will replace the existing one. + * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, December 11, 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5ESregister_insert_func(hid_t es_id, H5ES_event_insert_func_t func, void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "iEI*x", es_id, func, ctx); + + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + if (NULL == func) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL function callback pointer") + + /* Set the event set's insert callback */ + es->ins_func = func; + es->ins_ctx = ctx; + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5ESregister_insert_func() */ + +/*------------------------------------------------------------------------- + * Function: H5ESregister_complete_func + * + * Purpose: Registers a callback to invoke when an operation completes + * within an event set. + * + * Note: Only one complete callback can be registered for each event set. + * Registering a new callback will replace the existing one. + * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, December 11, 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5ESregister_complete_func(hid_t es_id, H5ES_event_complete_func_t func, void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "iEC*x", es_id, func, ctx); + + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + H5ES_t *es; /* Event set */ + + /* Check arguments */ + if (NULL == (es = H5I_object_verify(es_id, H5I_EVENTSET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier") + if (NULL == func) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL function callback pointer") + + /* Set the event set's completion callback */ + es->comp_func = func; + es->comp_ctx = ctx; + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5ESregister_complete_func() */ /*------------------------------------------------------------------------- * Function: H5ESclose @@ -347,6 +607,8 @@ done: * * Note: Fails if active operations are present. * + * Note: H5ES_NONE is a valid value for 'es_id', but functions as a no-op + * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol @@ -362,16 +624,19 @@ H5ESclose(hid_t es_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", es_id); - /* Check arguments */ - if (H5I_EVENTSET != H5I_get_type(es_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an event set") - - /* - * Decrement the counter on the object. It will be freed if the count - * reaches zero. - */ - if (H5I_dec_app_ref(es_id) < 0) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on event set") + /* Passing H5ES_NONE is valid, but a no-op */ + if (H5ES_NONE != es_id) { + /* Check arguments */ + if (H5I_EVENTSET != H5I_get_type(es_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an event set") + + /* + * Decrement the counter on the object. It will be freed if the count + * reaches zero. + */ + if (H5I_dec_app_ref(es_id) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on event set") + } /* end if */ done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5ESdevelop.h b/src/H5ESdevelop.h new file mode 100644 index 0000000..5a0f2b4 --- /dev/null +++ b/src/H5ESdevelop.h @@ -0,0 +1,50 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5ES (event set) developer + * support routines. + */ + +#ifndef _H5ESdevelop_H +#define _H5ESdevelop_H + +/* Include package's public header */ +#include "H5ESpublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL herr_t H5ESinsert_request(hid_t es_id, hid_t connector_id, void *request); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5ESdevelop_H */ diff --git a/src/H5ESevent.c b/src/H5ESevent.c index b0c3578..aafc785 100644 --- a/src/H5ESevent.c +++ b/src/H5ESevent.c @@ -139,14 +139,14 @@ H5ES__event_free(H5ES_event_t *ev) /* Sanity check */ HDassert(ev); - if (ev->api_name) - H5MM_xfree_const(ev->api_name); - if (ev->api_args) - H5MM_xfree_const(ev->api_args); - if (ev->app_file) - H5MM_xfree_const(ev->app_file); - if (ev->app_func) - H5MM_xfree_const(ev->app_func); + /* The 'app_func_name', 'app_file_name', and 'api_name' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + ev->op_info.api_name = NULL; + if (ev->op_info.api_args) + H5MM_xfree_const(ev->op_info.api_args); + ev->op_info.app_file_name = NULL; + ev->op_info.app_func_name = NULL; if (ev->request) { /* Free the request */ if (H5VL_request_free(ev->request) < 0) diff --git a/src/H5ESint.c b/src/H5ESint.c index da3f779..6f9efe9 100644 --- a/src/H5ESint.c +++ b/src/H5ESint.c @@ -53,11 +53,18 @@ /* Callback context for wait operations */ typedef struct H5ES_wait_ctx_t { H5ES_t * es; /* Event set being operated on */ - uint64_t timeout; /* Timeout for wait operation */ + uint64_t timeout; /* Timeout for wait operation (in ns) */ size_t * num_in_progress; /* Count of # of operations that have not completed */ hbool_t *op_failed; /* Flag to indicate an operation failed */ } H5ES_wait_ctx_t; +/* Callback context for cancel operations */ +typedef struct H5ES_cancel_ctx_t { + H5ES_t * es; /* Event set being operated on */ + size_t * num_not_canceled; /* Count of # of operations were not canceled */ + hbool_t *op_failed; /* Flag to indicate an operation failed */ +} H5ES_cancel_ctx_t; + /* Callback context for get error info (gei) operations */ typedef struct H5ES_gei_ctx_t { H5ES_t * es; /* Event set being operated on */ @@ -73,9 +80,14 @@ typedef struct H5ES_gei_ctx_t { /********************/ /* Local Prototypes */ /********************/ +static herr_t H5ES__close(H5ES_t *es); static herr_t H5ES__close_cb(void *es, void **request_token); +static herr_t H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app_file, + const char *app_func, unsigned app_line, const char *caller, const char *api_args); static herr_t H5ES__handle_fail(H5ES_t *es, H5ES_event_t *ev); +static herr_t H5ES__op_complete(H5ES_t *es, H5ES_event_t *ev, H5VL_request_status_t ev_status); static int H5ES__wait_cb(H5ES_event_t *ev, void *_ctx); +static int H5ES__cancel_cb(H5ES_event_t *ev, void *_ctx); static int H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx); static int H5ES__close_failed_cb(H5ES_event_t *ev, void *_ctx); @@ -233,6 +245,81 @@ done: } /* end H5ES__create() */ /*------------------------------------------------------------------------- + * Function: H5ES__insert + * + * Purpose: Insert a request token into an event set + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, December 11, 2020 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app_file, const char *app_func, + unsigned app_line, const char *caller, const char *api_args) +{ + H5ES_event_t *ev = NULL; /* Event for request */ + hbool_t ev_inserted = FALSE; /* Flag to indicate that event is in active list */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(es); + + /* Create new event */ + if (NULL == (ev = H5ES__event_new(connector, request_token))) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create event object") + + /* Copy the app source information */ + /* The 'app_func' & 'app_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ev->op_info.app_file_name = app_file; + ev->op_info.app_func_name = app_func; + ev->op_info.app_line_num = app_line; + + /* Set the event's operation counter */ + ev->op_info.op_ins_count = es->op_counter++; + + /* Set the event's timestamp & execution time */ + ev->op_info.op_ins_ts = H5_now_usec(); + ev->op_info.op_exec_ts = UINT64_MAX; + ev->op_info.op_exec_time = UINT64_MAX; + + /* Copy the API routine's name & arguments */ + /* The 'caller' string is also statically allocated (by the compiler) + * there's no need to duplicate it. + */ + ev->op_info.api_name = caller; + if (NULL == (ev->op_info.api_args = H5MM_xstrdup(api_args))) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine arguments") + + /* Append fully initialized event onto the event set's 'active' list */ + H5ES__list_append(&es->active, ev); + ev_inserted = TRUE; + + /* Invoke the event set's 'insert' callback, if present */ + if (es->ins_func) + if ((es->ins_func)(&ev->op_info, es->ins_ctx) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CALLBACK, FAIL, "'insert' callback for event set failed") + +done: + /* Release resources on error */ + if (ret_value < 0) + if (ev) { + if (ev_inserted) + H5ES__list_remove(&es->active, ev); + if (H5ES__event_free(ev) < 0) + HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release event") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5ES__insert() */ + +/*------------------------------------------------------------------------- * Function: H5ES_insert * * Purpose: Insert a request token into an event set @@ -247,15 +334,15 @@ done: herr_t H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, const char *caller_args, ...) { - H5ES_t * es = NULL; /* Event set for the operation */ - H5ES_event_t *ev = NULL; /* Event for request */ - H5RS_str_t * rs = NULL; /* Ref-counted string to compose formatted argument string in */ - const char * app_file; /* Application source file name */ - const char * app_func; /* Application source function name */ - const char * s; /* Pointer to internal string from ref-counted string */ - va_list ap; /* Varargs for caller */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - herr_t ret_value = SUCCEED; /* Return value */ + H5ES_t * es = NULL; /* Event set for the operation */ + const char *app_file; /* Application source file name */ + const char *app_func; /* Application source function name */ + unsigned app_line; /* Application source line number */ + H5RS_str_t *rs = NULL; /* Ref-counted string to compose formatted argument string in */ + const char *api_args; /* Pointer to api_args string from ref-counted string */ + va_list ap; /* Varargs for caller */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -273,10 +360,6 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con if (es->err_occurred) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations") - /* Create new event */ - if (NULL == (ev = H5ES__event_new(connector, token))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create event object") - /* Start working on the API routines arguments */ HDva_start(ap, caller_args); arg_started = TRUE; @@ -284,24 +367,10 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con /* Copy the app source information */ (void)HDva_arg(ap, char *); /* Toss the 'app_file' parameter name */ app_file = HDva_arg(ap, char *); - if (NULL == (ev->app_file = H5MM_strdup(app_file))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy app source file name") (void)HDva_arg(ap, char *); /* Toss the 'app_func' parameter name */ app_func = HDva_arg(ap, char *); - if (NULL == (ev->app_func = H5MM_strdup(app_func))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy app source function name") (void)HDva_arg(ap, char *); /* Toss the 'app_line' parameter name */ - ev->app_line = HDva_arg(ap, unsigned); - - /* Set the event's operation counter */ - ev->ev_count = es->op_counter++; - - /* Set the event's timestamp */ - ev->ev_time = H5_now_usec(); - - /* Copy the API routine's name */ - if (NULL == (ev->api_name = H5MM_strdup(caller))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine name") + app_line = HDva_arg(ap, unsigned); /* Create the string for the API routine's arguments */ if (NULL == (rs = H5RS_create(NULL))) @@ -312,13 +381,12 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con HDassert(0 == HDstrncmp(caller_args, "*s*sIu", 6)); if (H5_trace_args(rs, caller_args + 6, ap) < 0) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, FAIL, "can't create formatted API arguments") - if (NULL == (s = H5RS_get_str(rs))) + if (NULL == (api_args = H5RS_get_str(rs))) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, "can't get pointer to formatted API arguments") - if (NULL == (ev->api_args = H5MM_strdup(s))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine arguments") - /* Append fully initialized event onto the event set's 'active' list */ - H5ES__list_append(&es->active, ev); + /* Insert the operation into the event set */ + if (H5ES__insert(es, connector, token, app_file, app_func, app_line, caller, api_args) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations") done: /* Clean up */ @@ -327,15 +395,42 @@ done: if (rs) H5RS_decr(rs); - /* Release resources on error */ - if (ret_value < 0) - if (ev && H5ES__event_free(ev) < 0) - HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release event") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5ES_insert() */ /*------------------------------------------------------------------------- + * Function: H5ES__insert_request + * + * Purpose: Directly insert a request token into an event set + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, December 11, 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5ES__insert_request(H5ES_t *es, H5VL_t *connector, void *token) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(es); + HDassert(connector); + HDassert(token); + + /* Insert an 'anonymous' operation into the event set */ + if (H5ES__insert(es, connector, token, NULL, NULL, 0, NULL, NULL) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5ES__insert_request() */ + +/*------------------------------------------------------------------------- * Function: H5ES__handle_fail * * Purpose: Handle a failed event @@ -370,6 +465,101 @@ H5ES__handle_fail(H5ES_t *es, H5ES_event_t *ev) } /* end H5ES__handle_fail() */ /*------------------------------------------------------------------------- + * Function: H5ES__op_complete + * + * Purpose: Handle an operation completing + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, December 11, 2020 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5ES__op_complete(H5ES_t *es, H5ES_event_t *ev, H5VL_request_status_t ev_status) +{ + H5VL_request_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t err_stack_id = H5I_INVALID_HID; /* Error stack for failed operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(es); + HDassert(ev); + HDassert(H5VL_REQUEST_STATUS_SUCCEED == ev_status || H5VL_REQUEST_STATUS_FAIL == ev_status || + H5VL_REQUEST_STATUS_CANCELED == ev_status); + + /* Handle each form of event completion */ + if (H5VL_REQUEST_STATUS_SUCCEED == ev_status || H5VL_REQUEST_STATUS_CANCELED == ev_status) { + /* Invoke the event set's 'complete' callback, if present */ + if (es->comp_func) { + H5ES_status_t op_status; /* Status for complete callback */ + + /* Set appropriate info for callback */ + if (H5VL_REQUEST_STATUS_SUCCEED == ev_status) { + /* Translate status */ + op_status = H5ES_STATUS_SUCCEED; + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_REQUEST_GET_EXEC_TIME; + vol_cb_args.args.get_exec_time.exec_ts = &ev->op_info.op_exec_ts; + vol_cb_args.args.get_exec_time.exec_time = &ev->op_info.op_exec_time; + + /* Retrieve the execution time info */ + if (H5VL_request_specific(ev->request, &vol_cb_args) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, + "unable to retrieve execution time info for operation") + } + else + /* Translate status */ + op_status = H5ES_STATUS_CANCELED; + + if ((es->comp_func)(&ev->op_info, op_status, H5I_INVALID_HID, es->comp_ctx) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CALLBACK, FAIL, "'complete' callback for event set failed") + } /* end if */ + + /* Event success or cancellation */ + if (H5ES__event_completed(ev, &es->active) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release completed event") + } /* end if */ + else if (H5VL_REQUEST_STATUS_FAIL == ev_status) { + /* Invoke the event set's 'complete' callback, if present */ + if (es->comp_func) { + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_REQUEST_GET_ERR_STACK; + vol_cb_args.args.get_err_stack.err_stack_id = H5I_INVALID_HID; + + /* Retrieve the error stack for the operation */ + if (H5VL_request_specific(ev->request, &vol_cb_args) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, "unable to retrieve error stack for operation") + + /* Set values */ + err_stack_id = vol_cb_args.args.get_err_stack.err_stack_id; + + if ((es->comp_func)(&ev->op_info, H5ES_STATUS_FAIL, err_stack_id, es->comp_ctx) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CALLBACK, FAIL, "'complete' callback for event set failed") + } /* end if */ + + /* Handle failure */ + if (H5ES__handle_fail(es, ev) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, FAIL, "unable to handle failed event") + } /* end else-if */ + else + HGOTO_ERROR(H5E_EVENTSET, H5E_BADVALUE, FAIL, "unknown event status?!?") + +done: + /* Clean up */ + if (H5I_INVALID_HID != err_stack_id) + if (H5I_dec_ref(err_stack_id) < 0) + HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, + "unable to decrement ref count on error stack for failed operation") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5ES__op_complete() */ + +/*------------------------------------------------------------------------- * Function: H5ES__wait_cb * * Purpose: Common routine for testing / waiting on an operation @@ -405,9 +595,9 @@ H5ES__wait_cb(H5ES_event_t *ev, void *_ctx) /* Check for status values that indicate we should break out of the loop */ if (ev_status == H5VL_REQUEST_STATUS_FAIL) { - /* Handle failure */ - if (H5ES__handle_fail(ctx->es, ev) < 0) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, H5_ITER_ERROR, "unable to handle failed event") + /* Handle event completion */ + if (H5ES__op_complete(ctx->es, ev, ev_status) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event") /* Record the error */ *ctx->op_failed = TRUE; @@ -415,13 +605,15 @@ H5ES__wait_cb(H5ES_event_t *ev, void *_ctx) /* Exit from the iteration */ ret_value = H5_ITER_STOP; } /* end if */ - else if (ev_status == H5VL_REQUEST_STATUS_SUCCEED) { - if (H5ES__event_completed(ev, &ctx->es->active) < 0) + else if (ev_status == H5VL_REQUEST_STATUS_SUCCEED || ev_status == H5VL_REQUEST_STATUS_CANCELED) { + /* Handle event completion */ + if (H5ES__op_complete(ctx->es, ev, ev_status) < 0) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event") } /* end else-if */ - else if (ev_status == H5VL_REQUEST_STATUS_CANCELED) - /* Should never get a status of 'cancel' back from test / wait operation */ - HGOTO_ERROR(H5E_EVENTSET, H5E_BADVALUE, H5_ITER_ERROR, "received 'cancel' status for operation") + else if (ev_status == H5VL_REQUEST_STATUS_CANT_CANCEL) + /* Should never get a status of 'can't cancel' back from test / wait operation */ + HGOTO_ERROR(H5E_EVENTSET, H5E_BADVALUE, H5_ITER_ERROR, + "received \"can't cancel\" status for operation") else { /* Sanity check */ HDassert(ev_status == H5VL_REQUEST_STATUS_IN_PROGRESS); @@ -489,6 +681,114 @@ done: } /* end H5ES__wait() */ /*------------------------------------------------------------------------- + * Function: H5ES__cancel_cb + * + * Purpose: Callback for canceling operations + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Thursday, December 10, 2020 + * + *------------------------------------------------------------------------- + */ +static int +H5ES__cancel_cb(H5ES_event_t *ev, void *_ctx) +{ + H5ES_cancel_ctx_t * ctx = (H5ES_cancel_ctx_t *)_ctx; /* Callback context */ + H5VL_request_status_t ev_status = H5VL_REQUEST_STATUS_SUCCEED; /* Status from event's operation */ + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(ev); + HDassert(ctx); + + /* Attempt to cancel the request */ + if (H5VL_request_cancel(ev->request, &ev_status) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCANCEL, H5_ITER_ERROR, "unable to cancel operation") + + /* Check for status values that indicate we should break out of the loop */ + if (ev_status == H5VL_REQUEST_STATUS_FAIL) { + /* Handle event completion */ + if (H5ES__op_complete(ctx->es, ev, ev_status) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, H5_ITER_ERROR, "unable to handle failed event") + + /* Record the error */ + *ctx->op_failed = TRUE; + + /* Exit from the iteration */ + ret_value = H5_ITER_STOP; + } /* end if */ + else if (ev_status == H5VL_REQUEST_STATUS_SUCCEED) { + /* Increment "not canceled" counter */ + (*ctx->num_not_canceled)++; + + /* Handle event completion */ + if (H5ES__op_complete(ctx->es, ev, ev_status) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event") + } /* end else-if */ + else if (ev_status == H5VL_REQUEST_STATUS_CANT_CANCEL || ev_status == H5VL_REQUEST_STATUS_IN_PROGRESS) { + /* Increment "not canceled" counter */ + (*ctx->num_not_canceled)++; + } /* end else-if */ + else { + /* Sanity check */ + HDassert(ev_status == H5VL_REQUEST_STATUS_CANCELED); + + /* Handle event completion */ + if (H5ES__op_complete(ctx->es, ev, ev_status) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5ES__cancel_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5ES__cancel + * + * Purpose: Cancel operations in event set + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Thursday, December 10, 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5ES__cancel(H5ES_t *es, size_t *num_not_canceled, hbool_t *op_failed) +{ + H5ES_cancel_ctx_t ctx; /* Iterator callback context info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(es); + HDassert(num_not_canceled); + HDassert(op_failed); + + /* Set user's parameters to known values */ + *num_not_canceled = 0; + *op_failed = FALSE; + + /* Set up context for iterator callbacks */ + ctx.es = es; + ctx.num_not_canceled = num_not_canceled; + ctx.op_failed = op_failed; + + /* Iterate over the events in the set, attempting to cancel them */ + if (H5ES__list_iterate(&es->active, H5ES__cancel_cb, &ctx) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_BADITER, FAIL, "iteration failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5ES__cancel() */ + +/*------------------------------------------------------------------------- * Function: H5ES__get_err_info_cb * * Purpose: Retrieve information about a failed operation @@ -503,8 +803,9 @@ done: static int H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx) { - H5ES_gei_ctx_t *ctx = (H5ES_gei_ctx_t *)_ctx; /* Callback context */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5VL_request_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5ES_gei_ctx_t * ctx = (H5ES_gei_ctx_t *)_ctx; /* Callback context */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -513,22 +814,35 @@ H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx) HDassert(ctx); /* Copy operation info for event */ - if (NULL == (ctx->curr_err_info->api_name = H5MM_strdup(ev->api_name))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API name") - if (NULL == (ctx->curr_err_info->api_args = H5MM_strdup(ev->api_args))) + /* The 'app_func_name', 'app_file_name', and 'api_name' strings are statically allocated (by the compiler) + * so there's no need to duplicate them internally, but they are duplicated + * here, when they are given back to the user. + */ + if (NULL == (ctx->curr_err_info->api_name = H5MM_strdup(ev->op_info.api_name))) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API routine name") + if (NULL == (ctx->curr_err_info->api_args = H5MM_strdup(ev->op_info.api_args))) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API routine arguments") - if (NULL == (ctx->curr_err_info->app_file_name = H5MM_strdup(ev->app_file))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy app source file name") - if (NULL == (ctx->curr_err_info->app_func_name = H5MM_strdup(ev->app_func))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy app function name") - ctx->curr_err_info->app_line_num = ev->app_line; - ctx->curr_err_info->op_ins_count = ev->ev_count; - ctx->curr_err_info->op_ins_ts = ev->ev_time; + if (NULL == (ctx->curr_err_info->app_file_name = H5MM_strdup(ev->op_info.app_file_name))) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 application file name") + if (NULL == (ctx->curr_err_info->app_func_name = H5MM_strdup(ev->op_info.app_func_name))) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 application function name") + ctx->curr_err_info->app_line_num = ev->op_info.app_line_num; + ctx->curr_err_info->op_ins_count = ev->op_info.op_ins_count; + ctx->curr_err_info->op_ins_ts = ev->op_info.op_ins_ts; + ctx->curr_err_info->op_exec_ts = ev->op_info.op_exec_ts; + ctx->curr_err_info->op_exec_time = ev->op_info.op_exec_time; + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_REQUEST_GET_ERR_STACK; + vol_cb_args.args.get_err_stack.err_stack_id = H5I_INVALID_HID; /* Get error stack for event */ - if (H5VL_request_specific(ev->request, H5VL_REQUEST_GET_ERR_STACK, &ctx->curr_err_info->err_stack_id) < 0) + if (H5VL_request_specific(ev->request, &vol_cb_args) < 0) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, H5_ITER_ERROR, "unable to retrieve error stack for operation") + /* Set value */ + ctx->curr_err_info->err_stack_id = vol_cb_args.args.get_err_stack.err_stack_id; + /* Remove event from event set's failed list */ H5ES__list_remove(&ctx->es->failed, ev); diff --git a/src/H5ESpkg.h b/src/H5ESpkg.h index 339ce1d..a7a8e20 100644 --- a/src/H5ESpkg.h +++ b/src/H5ESpkg.h @@ -43,14 +43,7 @@ typedef struct H5ES_event_t { H5VL_object_t * request; /* Request token for event */ struct H5ES_event_t *prev, *next; /* Previous and next event nodes */ - /* Useful info for debugging and error reporting */ - const char *api_name; /* Name of API routine for event */ - const char *api_args; /* Arguments to API routine */ - const char *app_file; /* Name of source file from application */ - const char *app_func; /* Name of source function from application */ - unsigned app_line; /* Line # of source file from application */ - uint64_t ev_count; /* This event is the n'th operation in the event set */ - uint64_t ev_time; /* Timestamp for this event (in ms from UNIX epoch) */ + H5ES_op_info_t op_info; /* Useful info about operation */ } H5ES_event_t; /* Typedef for lists of event set operations */ @@ -61,7 +54,11 @@ typedef struct H5ES_event_list_t { /* Typedef for event set objects */ struct H5ES_t { - uint64_t op_counter; /* Count of operations inserted into this set */ + uint64_t op_counter; /* Count of operations inserted into this set */ + H5ES_event_insert_func_t ins_func; /* Callback to invoke for operation inserts */ + void * ins_ctx; /* Context for callback to invoke for operation inserts */ + H5ES_event_complete_func_t comp_func; /* Callback to invoke for operation completions */ + void * comp_ctx; /* Context for callback to invoke for operation inserts */ /* Active events */ H5ES_event_list_t active; /* List of active events in set */ @@ -82,10 +79,11 @@ typedef int (*H5ES_list_iter_func_t)(H5ES_event_t *ev, void *ctx); /* Package Private Prototypes */ /******************************/ H5_DLL H5ES_t *H5ES__create(void); +H5_DLL herr_t H5ES__insert_request(H5ES_t *es, H5VL_t *connector, void *token); H5_DLL herr_t H5ES__wait(H5ES_t *es, uint64_t timeout, size_t *num_in_progress, hbool_t *op_failed); +H5_DLL herr_t H5ES__cancel(H5ES_t *es, size_t *num_not_canceled, hbool_t *op_failed); H5_DLL herr_t H5ES__get_err_info(H5ES_t *es, size_t num_err_info, H5ES_err_info_t err_info[], size_t *num_cleared); -H5_DLL herr_t H5ES__close(H5ES_t *es); /* Event list operations */ H5_DLL void H5ES__list_append(H5ES_event_list_t *el, H5ES_event_t *ev); diff --git a/src/H5ESprivate.h b/src/H5ESprivate.h index 4f843ba..3d9ce9f 100644 --- a/src/H5ESprivate.h +++ b/src/H5ESprivate.h @@ -24,8 +24,9 @@ #ifndef H5ESprivate_H #define H5ESprivate_H -/* Include package's public header */ -#include "H5ESpublic.h" /* Event Sets */ +/* Include package's public headers */ +#include "H5ESpublic.h" +#include "H5ESdevelop.h" /* Private headers needed by this file */ #include "H5VLprivate.h" /* Virtual Object Layer */ diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h index 409282c..4cf71c5 100644 --- a/src/H5ESpublic.h +++ b/src/H5ESpublic.h @@ -42,24 +42,49 @@ /* Asynchronous operation status */ typedef enum H5ES_status_t { - H5ES_STATUS_IN_PROGRESS, /* Operation(s) have not yet completed */ - H5ES_STATUS_SUCCEED, /* Operation(s) have completed, successfully */ - H5ES_STATUS_FAIL /* An operation has completed, but failed */ + H5ES_STATUS_IN_PROGRESS, /* Operation(s) have not yet completed */ + H5ES_STATUS_SUCCEED, /* Operation(s) have completed, successfully */ + H5ES_STATUS_CANCELED, /* Operation(s) has been canceled */ + H5ES_STATUS_FAIL /* An operation has completed, but failed */ } H5ES_status_t; +/* Information about operations in an event set */ +typedef struct H5ES_op_info_t { + /* API call info */ + char *api_name; /* Name of HDF5 API routine called */ + char *api_args; /* "Argument string" for arguments to HDF5 API routine called */ + + /* Application info */ + char * app_file_name; /* Name of source file where the HDF5 API routine was called */ + char * app_func_name; /* Name of function where the HDF5 API routine was called */ + unsigned app_line_num; /* Line # of source file where the HDF5 API routine was called */ + + /* Operation info */ + uint64_t op_ins_count; /* Counter of operation's insertion into event set */ + uint64_t op_ins_ts; /* Timestamp for when the operation was inserted into the event set */ + uint64_t op_exec_ts; /* Timestamp for when the operation began execution */ + uint64_t op_exec_time; /* Execution time for operation (in ns) */ +} H5ES_op_info_t; + //! /** * Information about failed operations in event set */ typedef struct H5ES_err_info_t { - /* Operation info */ - char * api_name; /**< Name of HDF5 API routine called */ - char * api_args; /**< "Argument string" for arguments to HDF5 API routine called */ + /* API call info */ + char *api_name; /**< Name of HDF5 API routine called */ + char *api_args; /**< "Argument string" for arguments to HDF5 API routine called */ + + /* Application info */ char * app_file_name; /**< Name of source file where the HDF5 API routine was called */ char * app_func_name; /**< Name of function where the HDF5 API routine was called */ unsigned app_line_num; /**< Line # of source file where the HDF5 API routine was called */ - uint64_t op_ins_count; /**< Counter of operation's insertion into event set */ - uint64_t op_ins_ts; /**< Timestamp for when the operation was inserted into the event set */ + + /* Operation info */ + uint64_t op_ins_count; /**< Counter of operation's insertion into event set */ + uint64_t op_ins_ts; /**< Timestamp for when the operation was inserted into the event set */ + uint64_t op_exec_ts; /**< Timestamp for when the operation began execution */ + uint64_t op_exec_time; /**< Execution time for operation (in ns) */ /* Error info */ hid_t err_stack_id; /**< ID for error stack from failed operation */ @@ -67,25 +92,11 @@ typedef struct H5ES_err_info_t { //! /* -H5ES_op_info_t: - const char *: API name (H5Dwrite_async, ...) - const char *: Arg string - const char *: Appl. source file name - const char *: Appl. source function - unsigned: Appl. source file line - uint64_t: Insert Time Timestamp - uint64_t: "event count" - n'th event inserted into event set - uint64_t: Execution Time timestamp (*) - More Possible Info for H5ES_op_info_t: Parent Operation's request token (*) -> "parent event count"? -- Could be used to "prune" child operations from reported errors, with flag to H5ESget_err_info? -H5ES_err_info_t: - H5ES_op_info_t: (above) - hid_t: Error stack (*) - Possible debugging routines: (Should also be configured from Env Var) H5ESdebug_signal(hid_t es_id, signal_t sig, uint64_t ); H5ESdebug_err_trace_log(hid_t es_id, const char *filename); @@ -102,15 +113,12 @@ Possible debugging routines: (Should also be configured from Env Var) How to Trace Async Operations? -"Library / wrapper developer" version of API routines: (Auto-generated) - H5Dwrite_async_wrap(const char *app_file, const char *app_func, - unsigned app_line_num, dset_id, mem_type_id, mem_space_id, ..., es_id); - - vs. - - H5Dwrite_async(dset_id, mem_type_id, mem_space_id, ..., es_id); */ +typedef int (*H5ES_event_insert_func_t)(const H5ES_op_info_t *op_info, void *ctx); +typedef int (*H5ES_event_complete_func_t)(const H5ES_op_info_t *op_info, H5ES_status_t status, + hid_t err_stack, void *ctx); + /********************/ /* Public Variables */ /********************/ @@ -170,6 +178,7 @@ H5_DLL hid_t H5EScreate(void); * */ H5_DLL herr_t H5ESwait(hid_t es_id, uint64_t timeout, size_t *num_in_progress, hbool_t *err_occurred); +H5_DLL herr_t H5EScancel(hid_t es_id, size_t *num_not_canceled, hbool_t *err_occurred); /** * \ingroup H5ES @@ -260,6 +269,9 @@ H5_DLL herr_t H5ESget_err_count(hid_t es_id, size_t *num_errs); */ H5_DLL herr_t H5ESget_err_info(hid_t es_id, size_t num_err_info, H5ES_err_info_t err_info[], size_t *err_cleared); +H5_DLL herr_t H5ESfree_err_info(size_t num_err_info, H5ES_err_info_t err_info[]); +H5_DLL herr_t H5ESregister_insert_func(hid_t es_id, H5ES_event_insert_func_t func, void *ctx); +H5_DLL herr_t H5ESregister_complete_func(hid_t es_id, H5ES_event_complete_func_t func, void *ctx); /** * \ingroup H5ES diff --git a/src/H5Eint.c b/src/H5Eint.c index 3fd4099..b38833f 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -772,11 +772,12 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line if (H5I_inc_ref(min_id, FALSE) < 0) HGOTO_DONE(FAIL) estack->slot[estack->nused].min_num = min_id; - if (NULL == (estack->slot[estack->nused].func_name = H5MM_xstrdup(func))) - HGOTO_DONE(FAIL) - if (NULL == (estack->slot[estack->nused].file_name = H5MM_xstrdup(file))) - HGOTO_DONE(FAIL) - estack->slot[estack->nused].line = line; + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + estack->slot[estack->nused].func_name = func; + estack->slot[estack->nused].file_name = file; + estack->slot[estack->nused].line = line; if (NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) HGOTO_DONE(FAIL) estack->nused++; @@ -826,10 +827,11 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") /* Release strings */ - if (error->func_name) - error->func_name = (const char *)H5MM_xfree_const(error->func_name); - if (error->file_name) - error->file_name = (const char *)H5MM_xfree_const(error->file_name); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + error->func_name = NULL; + error->file_name = NULL; if (error->desc) error->desc = (const char *)H5MM_xfree_const(error->desc); } diff --git a/src/H5F.c b/src/H5F.c index 8618851..5950d9e 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -112,8 +112,9 @@ H5FL_EXTERN(H5VL_object_t); hid_t H5Fget_create_plist(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* File for file_id */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); @@ -122,10 +123,17 @@ H5Fget_create_plist(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_FCPL; + vol_cb_args.args.get_fcpl.fcpl_id = H5I_INVALID_HID; + /* Retrieve the file creation property list */ - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_FCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") + /* Set return value */ + ret_value = vol_cb_args.args.get_fcpl.fcpl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_create_plist() */ @@ -151,8 +159,9 @@ done: hid_t H5Fget_access_plist(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* File for file_id */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); @@ -161,10 +170,17 @@ H5Fget_access_plist(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_FAPL; + vol_cb_args.args.get_fapl.fapl_id = H5I_INVALID_HID; + /* Retrieve the file's access property list */ - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_FAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") + /* Set return value */ + ret_value = vol_cb_args.args.get_fapl.fapl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_access_plist() */ @@ -222,16 +238,25 @@ H5Fget_obj_count(hid_t file_id, unsigned types) * count the IDs in the file. */ if (file_id != (hid_t)H5F_OBJ_ALL) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; /* File for file_id */ + size_t count = 0; /* Object count */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ /* Get the file object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file id") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_OBJ_COUNT; + vol_cb_args.args.get_obj_count.types = types; + vol_cb_args.args.get_obj_count.count = &count; + /* Get the count */ - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, - &ret_value) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object count in file(s)") + + /* Set return value */ + ret_value = (ssize_t)count; } /* If we passed in the 'special' ID, get the count for everything open in the * library, iterating over all open files and getting the object count for each. @@ -333,16 +358,27 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list / * get the IDs from the file. */ if (file_id != (hid_t)H5F_OBJ_ALL) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; /* File for file_id */ + size_t count = 0; /* Object count */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ /* get the file object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_OBJ_IDS; + vol_cb_args.args.get_obj_ids.types = types; + vol_cb_args.args.get_obj_ids.max_objs = max_objs; + vol_cb_args.args.get_obj_ids.oid_list = oid_list; + vol_cb_args.args.get_obj_ids.count = &count; + /* Get the IDs */ - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_IDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, - max_objs, oid_list, &ret_value) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object ids in file(s)") + + /* Set return value */ + ret_value = (ssize_t)count; } /* end if */ /* If we passed in the 'special' ID, get the count for everything open in the * library, iterating over all open files and getting the object count for each. @@ -396,8 +432,10 @@ done: herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle /*out*/) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iix", file_id, fapl_id, file_handle); @@ -410,9 +448,14 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Set up VOL callback arguments */ + file_opt_args.get_vfd_handle.fapl_id = fapl_id; + file_opt_args.get_vfd_handle.file_handle = file_handle; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_VFD_HANDLE; + vol_cb_args.args = &file_opt_args; + /* Retrieve the VFD handle for the file */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_VFD_HANDLE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, file_handle, fapl_id) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: @@ -432,7 +475,9 @@ done: htri_t H5Fis_accessible(const char *filename, hid_t fapl_id) { - htri_t ret_value; /* Return value */ + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + hbool_t is_accessible = FALSE; /* Whether file is accessible */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "*si", filename, fapl_id); @@ -447,11 +492,19 @@ H5Fis_accessible(const char *filename, hid_t fapl_id) else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_IS_ACCESSIBLE; + vol_cb_args.args.is_accessible.filename = filename; + vol_cb_args.args.is_accessible.fapl_id = fapl_id; + vol_cb_args.args.is_accessible.accessible = &is_accessible; + /* Check if file is accessible */ - if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, - filename, &ret_value) < 0) + if (H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") + /* Set return value */ + ret_value = (htri_t)is_accessible; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fis_accessible() */ @@ -477,10 +530,17 @@ H5F__post_open_api_common(H5VL_object_t *vol_obj, void **token_ptr) supported = 0; if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't check for 'post open' operation") - if (supported & H5VL_OPT_QUERY_SUPPORTED) + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = NULL; + /* Make the 'post open' callback */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to make file 'post open' callback") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -870,8 +930,9 @@ H5F__flush_api_common(hid_t object_id, H5F_scope_t scope, void **token_ptr, H5VL H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5I_type_t obj_type; /* Type of object to use */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_type_t obj_type; /* Type of object to use */ + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -885,9 +946,13 @@ H5F__flush_api_common(hid_t object_id, H5F_scope_t scope, void **token_ptr, H5VL if (NULL == (*vol_obj_ptr = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_FLUSH; + vol_cb_args.args.flush.obj_type = obj_type; + vol_cb_args.args.flush.scope = scope; + /* Flush the object */ - if (H5VL_file_specific(*vol_obj_ptr, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, token_ptr, (int)obj_type, - (int)scope) < 0) + if (H5VL_file_specific(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: @@ -1072,10 +1137,11 @@ done: herr_t H5Fdelete(const char *filename, hid_t fapl_id) { - H5P_genplist_t * plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - htri_t is_hdf5 = FAIL; - herr_t ret_value = SUCCEED; + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + hbool_t is_accessible = FALSE; /* Whether file is accessible */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "*si", filename, fapl_id); @@ -1100,16 +1166,25 @@ H5Fdelete(const char *filename, hid_t fapl_id) if (H5CX_set_vol_connector_prop(&connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set VOL connector info in API context") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_IS_ACCESSIBLE; + vol_cb_args.args.is_accessible.filename = filename; + vol_cb_args.args.is_accessible.fapl_id = fapl_id; + vol_cb_args.args.is_accessible.accessible = &is_accessible; + /* Make sure this is HDF5 storage for this VOL connector */ - if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, - filename, &is_hdf5) < 0) + if (H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") - if (!is_hdf5) + if (!is_accessible) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "not an HDF5 file") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_DELETE; + vol_cb_args.args.del.filename = filename; + vol_cb_args.args.del.fapl_id = fapl_id; + /* Delete the file */ - if (H5VL_file_specific(NULL, H5VL_FILE_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, - filename, &ret_value) < 0) + if (H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "unable to delete the file") done: @@ -1129,11 +1204,13 @@ done: herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5VL_object_t *loc_vol_obj = NULL; /* Parent object */ - H5VL_object_t *child_vol_obj = NULL; /* Child object */ - H5I_type_t loc_type; /* ID type of location */ - H5I_type_t child_type; /* ID type of child */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * loc_vol_obj = NULL; /* Parent object */ + H5VL_object_t * child_vol_obj = NULL; /* Child object */ + H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + void * grp = NULL; /* Root group opened */ + H5I_type_t loc_type; /* ID type of location */ + int same_connector = 0; /* Whether parent and child files use the same connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); @@ -1146,8 +1223,7 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") - child_type = H5I_get_type(child_id); - if (H5I_FILE != child_type) + if (H5I_FILE != H5I_get_type(child_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") if (H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; @@ -1159,23 +1235,71 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if (NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + /* Need to open the root group of a file, if a file ID was given as the + * 'loc_id', because the 'mount' operation is a group specific operation. + */ + if (H5I_FILE == loc_type) { + H5VL_object_t * vol_obj; /* Object for loc_id (file) */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = loc_type; + + /* Open the root group object */ + if (NULL == (grp = H5VL_group_open(vol_obj, &loc_params, "/", H5P_GROUP_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, NULL))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open group") + + /* Create a VOL object for the root group */ + if (NULL == (loc_vol_obj = H5VL_create_object(grp, vol_obj->connector))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "can't create VOL object for root group") + } /* end if */ + else { + HDassert(H5I_GROUP == loc_type); + if (NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + } /* end else */ /* Get the child object */ if (NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") /* Check if both objects are associated with the same VOL connector */ - if (loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") + if (H5VL_cmp_connector_cls(&same_connector, loc_vol_obj->connector->cls, child_vol_obj->connector->cls) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + if (same_connector) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't mount file onto object from different VOL connector") + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_GROUP_MOUNT; + vol_cb_args.args.mount.name = name; + vol_cb_args.args.mount.child_file = + child_vol_obj->data; /* Don't unwrap fully, so each connector can see its object */ + vol_cb_args.args.mount.fmpl_id = plist_id; /* Perform the mount operation */ - if (H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - (int)loc_type, name, child_vol_obj->data, plist_id) < 0) + /* (This is on a group, so that the VOL framework always sees groups for + * the 'mount' operation, instead of mixing files and groups) + */ + if (H5VL_group_specific(loc_vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: + /* Clean up if we temporarily opened the root group for a file */ + if (grp) { + HDassert(loc_vol_obj); + if (H5VL_group_close(loc_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to release group") + if (H5VL_free_object(loc_vol_obj) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + } /* end if */ + FUNC_LEAVE_API(ret_value) } /* end H5Fmount() */ @@ -1198,9 +1322,11 @@ done: herr_t H5Funmount(hid_t loc_id, const char *name) { - H5VL_object_t *vol_obj = NULL; /* Parent object */ - H5I_type_t loc_type; /* ID type of location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * loc_vol_obj = NULL; /* Parent object */ + H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + void * grp = NULL; /* Root group opened */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); @@ -1219,15 +1345,57 @@ H5Funmount(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + /* Need to open the root group of a file, if a file ID was given as the + * 'loc_id', because the 'mount' operation is a group specific operation. + */ + if (H5I_FILE == loc_type) { + H5VL_object_t * vol_obj; /* Object for loc_id (file) */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = loc_type; + + /* Open the root group object */ + if (NULL == (grp = H5VL_group_open(vol_obj, &loc_params, "/", H5P_GROUP_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, NULL))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open group") + + /* Create a VOL object for the root group */ + if (NULL == (loc_vol_obj = H5VL_create_object(grp, vol_obj->connector))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "can't create VOL object for root group") + } /* end if */ + else { + HDassert(H5I_GROUP == loc_type); + if (NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + } /* end else */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_GROUP_UNMOUNT; + vol_cb_args.args.unmount.name = name; /* Perform the unmount operation */ - if (H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - (int)loc_type, name) < 0) + /* (This is on a group, so that the VOL framework always sees groups for + * the 'unmount' operation, instead of mixing files and groups) + */ + if (H5VL_group_specific(loc_vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: + /* Clean up if we temporarily opened the root group for a file */ + if (grp) { + HDassert(loc_vol_obj); + if (H5VL_group_close(loc_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to release group") + if (H5VL_free_object(loc_vol_obj) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + } /* end if */ + FUNC_LEAVE_API(ret_value) } /* end H5Funmount() */ @@ -1245,9 +1413,10 @@ done: static hid_t H5F__reopen_api_common(hid_t file_id, void **token_ptr) { - void * file = NULL; /* File struct for new file */ - H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + void * reopen_file = NULL; /* Pointer to the re-opened file object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -1255,16 +1424,20 @@ H5F__reopen_api_common(hid_t file_id, void **token_ptr) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_REOPEN; + vol_cb_args.args.reopen.file = &reopen_file; + /* Reopen the file */ - if (H5VL_file_specific(vol_obj, H5VL_FILE_REOPEN, H5P_DATASET_XFER_DEFAULT, token_ptr, &file) < 0) + if (H5VL_file_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file via the VOL connector") /* Make sure that worked */ - if (NULL == file) + if (NULL == reopen_file) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") /* Get an ID for the file */ - if ((ret_value = H5VL_register(H5I_FILE, file, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_FILE, reopen_file, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle") done: @@ -1398,15 +1571,19 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags /*out*/) /* If no intent flags were passed in, exit quietly */ if (intent_flags) { - H5VL_object_t *vol_obj; /* File info */ + H5VL_object_t * vol_obj; /* File for file_id */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ /* Get the internal file structure */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_INTENT; + vol_cb_args.args.get_intent.flags = intent_flags; + /* Get the flags */ - if ((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_INTENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, intent_flags)) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's intent flags") } /* end if */ @@ -1434,15 +1611,19 @@ H5Fget_fileno(hid_t file_id, unsigned long *fnumber /*out*/) /* If no fnumber pointer was passed in, exit quietly */ if (fnumber) { - H5VL_object_t *vol_obj; /* File info */ + H5VL_object_t * vol_obj; /* File for file_id */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ /* Get the internal file structure */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Get the flags */ - if ((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_FILENO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, fnumber)) < 0) + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_FILENO; + vol_cb_args.args.get_fileno.fileno = fnumber; + + /* Get the 'file number' */ + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's 'file number'") } /* end if */ @@ -1462,8 +1643,11 @@ done: hssize_t H5Fget_freespace(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; - hssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + hsize_t file_freespace = 0; /* Size of freespace in the file */ + hssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Hs", "i", file_id); @@ -1472,11 +1656,18 @@ H5Fget_freespace(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") + /* Set up VOL callback arguments */ + file_opt_args.get_freespace.size = &file_freespace; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_FREE_SPACE; + vol_cb_args.args = &file_opt_args; + /* Get the amount of free space in the file */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SPACE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free space") + /* Set return value */ + ret_value = (hssize_t)file_freespace; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_freespace() */ @@ -1495,8 +1686,10 @@ done: herr_t H5Fget_filesize(hid_t file_id, hsize_t *size /*out*/) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", file_id, size); @@ -1507,9 +1700,13 @@ H5Fget_filesize(hid_t file_id, hsize_t *size /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_size.size = size; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_SIZE; + vol_cb_args.args = &file_opt_args; + /* Get the file size */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - size) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") done: @@ -1556,8 +1753,11 @@ done: ssize_t H5Fget_file_image(hid_t file_id, void *buf /*out*/, size_t buf_len) { - H5VL_object_t *vol_obj; /* File object for file ID */ - ssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* File object for file ID */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + size_t image_len = 0; /* Size of image buffer */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", file_id, buf, buf_len); @@ -1566,11 +1766,20 @@ H5Fget_file_image(hid_t file_id, void *buf /*out*/, size_t buf_len) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_file_image.buf_size = buf_len; + file_opt_args.get_file_image.buf = buf; + file_opt_args.get_file_image.image_len = &image_len; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_FILE_IMAGE; + vol_cb_args.args = &file_opt_args; + /* Get the file image */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FILE_IMAGE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, buf, &ret_value, buf_len) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") + /* Set return value */ + ret_value = (ssize_t)image_len; + done: FUNC_LEAVE_API(ret_value) } /* H5Fget_file_image() */ @@ -1592,8 +1801,10 @@ done: herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config /*out*/) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", file_id, config); @@ -1606,9 +1817,13 @@ H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Set up VOL callback arguments */ + file_opt_args.get_mdc_config.config = config; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MDC_CONF; + vol_cb_args.args = &file_opt_args; + /* Get the metadata cache configuration */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_CONF, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - config) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache configuration") done: @@ -1627,10 +1842,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) +H5Fset_mdc_config(hid_t file_id, const H5AC_cache_config_t *config_ptr) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Cc", file_id, config_ptr); @@ -1639,9 +1856,13 @@ H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Set up VOL callback arguments */ + file_opt_args.set_mdc_config.config = config_ptr; + vol_cb_args.op_type = H5VL_NATIVE_FILE_SET_MDC_CONFIG; + vol_cb_args.args = &file_opt_args; + /* Set the metadata cache configuration */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MDC_CONFIG, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, config_ptr) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set metadata cache configuration") done: @@ -1663,8 +1884,10 @@ done: herr_t H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate /*out*/) { - H5VL_object_t *vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", file_id, hit_rate); @@ -1675,9 +1898,13 @@ H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_mdc_hit_rate.hit_rate = hit_rate; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MDC_HR; + vol_cb_args.args = &file_opt_args; + /* Get the current hit rate */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_HR, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - hit_rate) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -1701,8 +1928,11 @@ herr_t H5Fget_mdc_size(hid_t file_id, size_t *max_size /*out*/, size_t *min_clean_size /*out*/, size_t *cur_size /*out*/, int *cur_num_entries /*out*/) { - H5VL_object_t *vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + uint32_t index_len = 0; /* Size of cache index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ixxxx", file_id, max_size, min_clean_size, cur_size, cur_num_entries); @@ -1711,11 +1941,22 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size /*out*/, size_t *min_clean_size if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_mdc_size.max_size = max_size; + file_opt_args.get_mdc_size.min_clean_size = min_clean_size; + file_opt_args.get_mdc_size.cur_size = cur_size; + file_opt_args.get_mdc_size.cur_num_entries = &index_len; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MDC_SIZE; + vol_cb_args.args = &file_opt_args; + /* Get the size data */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - max_size, min_clean_size, cur_size, cur_num_entries) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC size") + /* Set mis-matched return value */ + if (cur_num_entries) + *cur_num_entries = (int)index_len; + done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_size() */ @@ -1739,8 +1980,9 @@ done: herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -1749,9 +1991,12 @@ H5Freset_mdc_hit_rate_stats(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE; + vol_cb_args.args = NULL; + /* Reset the hit rate statistic */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") done: @@ -1780,9 +2025,11 @@ done: ssize_t H5Fget_name(hid_t obj_id, char *name /*out*/, size_t size) { - H5VL_object_t *vol_obj = NULL; - H5I_type_t type; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj; /* File for file_id */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5I_type_t type; + size_t file_name_len = 0; /* Length of file name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, name, size); @@ -1797,11 +2044,20 @@ H5Fget_name(hid_t obj_id, char *name /*out*/, size_t size) if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_NAME; + vol_cb_args.args.get_name.type = type; + vol_cb_args.args.get_name.buf_size = size; + vol_cb_args.args.get_name.buf = name; + vol_cb_args.args.get_name.file_name_len = &file_name_len; + /* Get the filename via the VOL */ - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, size, - name, &ret_value) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file name") + /* Set the return value */ + ret_value = (ssize_t)file_name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ @@ -1822,9 +2078,11 @@ done: herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo /*out*/) { - H5VL_object_t *vol_obj = NULL; - H5I_type_t type; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + H5I_type_t type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", obj_id, finfo); @@ -1843,9 +2101,14 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo /*out*/) if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + file_opt_args.get_info.type = type; + file_opt_args.get_info.finfo = finfo; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_INFO; + vol_cb_args.args = &file_opt_args; + /* Get the file information */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - (int)type, finfo) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") done: @@ -1865,8 +2128,10 @@ done: herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info /*out*/) { - H5VL_object_t *vol_obj = NULL; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* File object for file ID */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", file_id, info); @@ -1879,10 +2144,14 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_metadata_read_retry_info.info = info; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO; + vol_cb_args.args = &file_opt_args; + /* Get the retry info */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info") + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get metadata read retry info") done: FUNC_LEAVE_API(ret_value) @@ -1903,8 +2172,11 @@ done: ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info /*out*/) { - H5VL_object_t *vol_obj = NULL; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + size_t sect_count = 0; /* Number of sections */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info); @@ -1915,11 +2187,21 @@ H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info if (sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "nsects must be > 0") + /* Set up VOL callback arguments */ + file_opt_args.get_free_sections.type = type; + file_opt_args.get_free_sections.sect_info = sect_info; + file_opt_args.get_free_sections.nsects = nsects; + file_opt_args.get_free_sections.sect_count = §_count; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_FREE_SECTIONS; + vol_cb_args.args = &file_opt_args; + /* Get the free-space section information in the file */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SECTIONS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, sect_info, &ret_value, (int)type, nsects) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free sections") + /* Set return value */ + ret_value = (ssize_t)sect_count; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_free_sections() */ @@ -1938,8 +2220,9 @@ done: herr_t H5Fclear_elink_file_cache(hid_t file_id) { - H5VL_object_t *vol_obj; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -1948,9 +2231,12 @@ H5Fclear_elink_file_cache(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE; + vol_cb_args.args = NULL; + /* Release the EFC */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: @@ -1994,8 +2280,9 @@ done: herr_t H5Fstart_swmr_write(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -2008,9 +2295,12 @@ H5Fstart_swmr_write(hid_t file_id) if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_START_SWMR_WRITE; + vol_cb_args.args = NULL; + /* Start SWMR writing */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_SWMR_WRITE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to start SWMR writing") done: @@ -2030,8 +2320,9 @@ done: herr_t H5Fstart_mdc_logging(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -2040,9 +2331,12 @@ H5Fstart_mdc_logging(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_START_MDC_LOGGING; + vol_cb_args.args = NULL; + /* Call mdc logging function */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") done: @@ -2063,8 +2357,9 @@ done: herr_t H5Fstop_mdc_logging(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -2073,9 +2368,12 @@ H5Fstop_mdc_logging(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_STOP_MDC_LOGGING; + vol_cb_args.args = NULL; + /* Call mdc logging function */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_STOP_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") done: @@ -2096,8 +2394,10 @@ done: herr_t H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled /*out*/, hbool_t *is_currently_logging /*out*/) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", file_id, is_enabled, is_currently_logging); @@ -2106,9 +2406,14 @@ H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled /*out*/, hbool_t *i if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_mdc_logging_status.is_enabled = is_enabled; + file_opt_args.get_mdc_logging_status.is_currently_logging = is_currently_logging; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS; + vol_cb_args.args = &file_opt_args; + /* Call mdc logging function */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, is_enabled, is_currently_logging) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") done: @@ -2130,8 +2435,10 @@ done: herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) { - H5VL_object_t *vol_obj; /* File as VOL object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File as VOL object */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFvFv", file_id, low, high); @@ -2144,9 +2451,14 @@ H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + file_opt_args.set_libver_bounds.low = low; + file_opt_args.set_libver_bounds.high = high; + vol_cb_args.op_type = H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS; + vol_cb_args.args = &file_opt_args; + /* Set the library's version bounds */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, low, high) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: @@ -2167,8 +2479,9 @@ done: herr_t H5Fformat_convert(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* File */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -2181,9 +2494,12 @@ H5Fformat_convert(hid_t file_id) if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_FORMAT_CONVERT; + vol_cb_args.args = NULL; + /* Convert the format */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") done: @@ -2202,8 +2518,9 @@ done: herr_t H5Freset_page_buffering_stats(hid_t file_id) { - H5VL_object_t *vol_obj; /* File to reset stats on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File to reset stats on */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -2212,9 +2529,12 @@ H5Freset_page_buffering_stats(hid_t file_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS; + vol_cb_args.args = NULL; + /* Reset the statistics */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset stats for page buffering") done: @@ -2235,8 +2555,10 @@ H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2] /*out*/, unsigne unsigned misses[2] /*out*/, unsigned evictions[2] /*out*/, unsigned bypasses[2] /*out*/) { - H5VL_object_t *vol_obj; /* File object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File object */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "ixxxxx", file_id, accesses, hits, misses, evictions, bypasses); @@ -2247,9 +2569,17 @@ H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2] /*out*/, unsigne if (NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") + /* Set up VOL callback arguments */ + file_opt_args.get_page_buffering_stats.accesses = accesses; + file_opt_args.get_page_buffering_stats.hits = hits; + file_opt_args.get_page_buffering_stats.misses = misses; + file_opt_args.get_page_buffering_stats.evictions = evictions; + file_opt_args.get_page_buffering_stats.bypasses = bypasses; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS; + vol_cb_args.args = &file_opt_args; + /* Get the statistics */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, accesses, hits, misses, evictions, bypasses) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") done: @@ -2272,8 +2602,10 @@ done: herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr /*out*/, hsize_t *image_len /*out*/) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", file_id, image_addr, image_len); @@ -2282,9 +2614,14 @@ H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr /*out*/, hsize_t *image if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.get_mdc_image_info.addr = image_addr; + file_opt_args.get_mdc_image_info.len = image_len; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO; + vol_cb_args.args = &file_opt_args; + /* Go get the address and size of the cache image */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, image_addr, image_len) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: @@ -2317,9 +2654,16 @@ H5Fget_eoa(hid_t file_id, haddr_t *eoa /*out*/) /* Only do work if valid pointer to fill in */ if (eoa) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + + /* Set up VOL callback arguments */ + file_opt_args.get_eoa.eoa = eoa; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_EOA; + vol_cb_args.args = &file_opt_args; + /* Retrieve the EOA for the file */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_EOA, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - eoa) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") } /* end if */ @@ -2339,8 +2683,10 @@ done: herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", file_id, increment); @@ -2349,9 +2695,13 @@ H5Fincrement_filesize(hid_t file_id, hsize_t increment) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") + /* Set up VOL callback arguments */ + file_opt_args.increment_filesize.increment = increment; + vol_cb_args.op_type = H5VL_NATIVE_FILE_INCR_FILESIZE; + vol_cb_args.args = &file_opt_args; + /* Increment the file size */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_INCR_FILESIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - increment) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to increment file size") done: @@ -2371,21 +2721,27 @@ done: herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize /*out*/) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", file_id, minimize); + /* Check args */ if (NULL == minimize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "out pointer 'minimize' cannot be NULL") - - vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if (NULL == vol_obj) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, minimize) < 0) + /* Set up VOL callback arguments */ + file_opt_args.get_min_dset_ohdr_flag.minimize = minimize; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG; + vol_cb_args.args = &file_opt_args; + + /* Get the dataset object header minimum size flag */ + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") done: @@ -2405,57 +2761,27 @@ done: herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, minimize); - vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if (NULL == vol_obj) + /* Check args */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, minimize) < 0) + /* Set up VOL callback arguments */ + file_opt_args.set_min_dset_ohdr_flag.minimize = minimize; + vol_cb_args.op_type = H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG; + vol_cb_args.args = &file_opt_args; + + /* Set the 'minimize dataset object headers flag' */ + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") done: FUNC_LEAVE_API(ret_value) } /* H5Fset_dset_no_attrs_hint */ - -/*------------------------------------------------------------------------- - * Function: H5Fwait - * - * Purpose: Wait for all operations on a dataset. - * Tang: added for async - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5Fwait(hid_t file_id) -{ - H5VL_object_t *vol_obj; /* File for this operation */ - H5I_type_t obj_type; /* Type of object */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", file_id); - - /* Get the type of object we're flushing + sanity check */ - obj_type = H5I_get_type(file_id); - if (H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type && - H5I_DATASET != obj_type && H5I_ATTR != obj_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "file_id parameter is not a valid file identifier") - - if ((ret_value = H5VL_file_specific(vol_obj, H5VL_FILE_WAIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - file_id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPERATE, FAIL, "unable to wait file") - -done: - FUNC_LEAVE_API(ret_value) -} /* H5Fwait() */ diff --git a/src/H5FDdevelop.h b/src/H5FDdevelop.h new file mode 100644 index 0000000..57f0a42 --- /dev/null +++ b/src/H5FDdevelop.h @@ -0,0 +1,262 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5FD (file drivers) developer + * support routines. + */ + +#ifndef _H5FDdevelop_H +#define _H5FDdevelop_H + +/* Include package's public header */ +#include "H5FDpublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/* Map "fractal heap" header blocks to 'ohdr' type file memory, since its + * a fair amount of work to add a new kind of file memory and they are similar + * enough to object headers and probably too minor to deserve their own type. + * + * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they + * are similar to fractal heap header blocks. + * + * Map "fractal heap" direct blocks to 'lheap' type file memory, since they + * will be replacing local heaps. + * + * Map "fractal heap" 'huge' objects to 'draw' type file memory, since they + * represent large objects that are directly stored in the file. + * + * -QAK + */ +#define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR +#define H5FD_MEM_FHEAP_IBLOCK H5FD_MEM_OHDR +#define H5FD_MEM_FHEAP_DBLOCK H5FD_MEM_LHEAP +#define H5FD_MEM_FHEAP_HUGE_OBJ H5FD_MEM_DRAW + +/* Map "free space" header blocks to 'ohdr' type file memory, since its + * a fair amount of work to add a new kind of file memory and they are similar + * enough to object headers and probably too minor to deserve their own type. + * + * Map "free space" serialized sections to 'lheap' type file memory, since they + * are similar enough to local heap info. + * + * -QAK + */ +#define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR +#define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP + +/* Map "shared object header message" master table to 'ohdr' type file memory, + * since its a fair amount of work to add a new kind of file memory and they are + * similar enough to object headers and probably too minor to deserve their own + * type. + * + * Map "shared object header message" indices to 'btree' type file memory, + * since they are similar enough to B-tree nodes. + * + * -QAK + */ +#define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR +#define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE + +/* Map "extensible array" header blocks to 'ohdr' type file memory, since its + * a fair amount of work to add a new kind of file memory and they are similar + * enough to object headers and probably too minor to deserve their own type. + * + * Map "extensible array" index blocks to 'ohdr' type file memory, since they + * are similar to extensible array header blocks. + * + * Map "extensible array" super blocks to 'btree' type file memory, since they + * are similar enough to B-tree nodes. + * + * Map "extensible array" data blocks & pages to 'lheap' type file memory, since + * they are similar enough to local heap info. + * + * -QAK + */ +#define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR +#define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR +#define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE +#define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP +#define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP + +/* Map "fixed array" header blocks to 'ohdr' type file memory, since its + * a fair amount of work to add a new kind of file memory and they are similar + * enough to object headers and probably too minor to deserve their own type. + * + * Map "fixed array" data blocks & pages to 'lheap' type file memory, since + * they are similar enough to local heap info. + * + */ +#define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR +#define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP +#define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP + +/* + * A free-list map which maps all types of allocation requests to a single + * free list. This is useful for drivers that don't really care about + * keeping different requests segregated in the underlying file and which + * want to make most efficient reuse of freed memory. The use of the + * H5FD_MEM_SUPER free list is arbitrary. + */ +#define H5FD_FLMAP_SINGLE \ + { \ + H5FD_MEM_SUPER, /*default*/ \ + H5FD_MEM_SUPER, /*super*/ \ + H5FD_MEM_SUPER, /*btree*/ \ + H5FD_MEM_SUPER, /*draw*/ \ + H5FD_MEM_SUPER, /*gheap*/ \ + H5FD_MEM_SUPER, /*lheap*/ \ + H5FD_MEM_SUPER /*ohdr*/ \ + } + +/* + * A free-list map which segregates requests into `raw' or `meta' data + * pools. + */ +#define H5FD_FLMAP_DICHOTOMY \ + { \ + H5FD_MEM_SUPER, /*default*/ \ + H5FD_MEM_SUPER, /*super*/ \ + H5FD_MEM_SUPER, /*btree*/ \ + H5FD_MEM_DRAW, /*draw*/ \ + H5FD_MEM_DRAW, /*gheap*/ \ + H5FD_MEM_SUPER, /*lheap*/ \ + H5FD_MEM_SUPER /*ohdr*/ \ + } + +/* + * The default free list map which causes each request type to use it's own + * free-list. + */ +#define H5FD_FLMAP_DEFAULT \ + { \ + H5FD_MEM_DEFAULT, /*default*/ \ + H5FD_MEM_DEFAULT, /*super*/ \ + H5FD_MEM_DEFAULT, /*btree*/ \ + H5FD_MEM_DEFAULT, /*draw*/ \ + H5FD_MEM_DEFAULT, /*gheap*/ \ + H5FD_MEM_DEFAULT, /*lheap*/ \ + H5FD_MEM_DEFAULT /*ohdr*/ \ + } + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* Forward declaration */ +typedef struct H5FD_t H5FD_t; + +/* Class information for each file driver */ +typedef struct H5FD_class_t { + const char * name; + haddr_t maxaddr; + H5F_close_degree_t fc_degree; + herr_t (*terminate)(void); + hsize_t (*sb_size)(H5FD_t *file); + herr_t (*sb_encode)(H5FD_t *file, char *name /*out*/, unsigned char *p /*out*/); + herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); + size_t fapl_size; + void *(*fapl_get)(H5FD_t *file); + void *(*fapl_copy)(const void *fapl); + herr_t (*fapl_free)(void *fapl); + size_t dxpl_size; + void *(*dxpl_copy)(const void *dxpl); + herr_t (*dxpl_free)(void *dxpl); + H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr); + herr_t (*close)(H5FD_t *file); + int (*cmp)(const H5FD_t *f1, const H5FD_t *f2); + herr_t (*query)(const H5FD_t *f1, unsigned long *flags); + herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map); + haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); + herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); + haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type); + herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr); + haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type); + herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void **file_handle); + herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer); + herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer); + herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + herr_t (*lock)(H5FD_t *file, hbool_t rw); + herr_t (*unlock)(H5FD_t *file); + herr_t (*del)(const char *name, hid_t fapl); + H5FD_mem_t fl_map[H5FD_MEM_NTYPES]; +} H5FD_class_t; + +/* A free list is a singly-linked list of address/size pairs. */ +typedef struct H5FD_free_t { + haddr_t addr; + hsize_t size; + struct H5FD_free_t *next; +} H5FD_free_t; + +/* + * The main datatype for each driver. Public fields common to all drivers + * are declared here and the driver appends private fields in memory. + */ +struct H5FD_t { + hid_t driver_id; /*driver ID for this file */ + const H5FD_class_t *cls; /*constant class info */ + unsigned long fileno; /* File 'serial' number */ + unsigned access_flags; /* File access flags (from create or open) */ + unsigned long feature_flags; /* VFL Driver feature Flags */ + haddr_t maxaddr; /* For this file, overrides class */ + haddr_t base_addr; /* Base address for HDF5 data w/in file */ + + /* Space allocation management fields */ + hsize_t threshold; /* Threshold for alignment */ + hsize_t alignment; /* Allocation alignment */ + hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ +}; + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); +H5_DLL herr_t H5FDunregister(hid_t driver_id); +H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +H5_DLL herr_t H5FDclose(H5FD_t *file); +H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); +H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); +H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); +H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); +H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); +H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); +H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); +H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle); +H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf /*out*/); +H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); +H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); +H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); +H5_DLL herr_t H5FDunlock(H5FD_t *file); +H5_DLL herr_t H5FDdelete(const char *name, hid_t fapl_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5FDdevelop_H */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 707c97b..f996b9e 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -1218,7 +1218,6 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ if (addr != file->pos || OP_READ != file->op) { - H5_timer_t seek_timer; /* Timer for seek operation */ H5_timevals_t seek_times; /* Elapsed time for seek operation */ @@ -1441,7 +1440,6 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ if (addr != file->pos || OP_WRITE != file->op) { - H5_timer_t seek_timer; /* Timer for seek operation */ H5_timevals_t seek_times; /* Elapsed time for seek operation */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 9347eab..97d1d7a 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -27,6 +27,7 @@ #include #include "hdf5.h" +#include "hdf5dev.h" #ifndef FALSE #define FALSE 0 diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 6dfb7b4..c00c123 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -18,8 +18,9 @@ #ifndef H5FDprivate_H #define H5FDprivate_H -/* Include package's public header */ +/* Include package's public headers */ #include "H5FDpublic.h" +#include "H5FDdevelop.h" /* Private headers needed by this file */ #include "H5Pprivate.h" /* Property lists */ diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 7794f24..0cfb072 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -18,140 +18,15 @@ #ifndef H5FDpublic_H #define H5FDpublic_H -#include "H5public.h" -#include "H5Fpublic.h" /*for H5F_close_degree_t */ +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ +#include "H5Fpublic.h" /* Files */ -#define H5_HAVE_VFL 1 /*define a convenient app feature test*/ -#define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ - -/* Types of allocation requests: see H5Fpublic.h */ -typedef enum H5F_mem_t H5FD_mem_t; - -/* Map "fractal heap" header blocks to 'ohdr' type file memory, since its - * a fair amount of work to add a new kind of file memory and they are similar - * enough to object headers and probably too minor to deserve their own type. - * - * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they - * are similar to fractal heap header blocks. - * - * Map "fractal heap" direct blocks to 'lheap' type file memory, since they - * will be replacing local heaps. - * - * Map "fractal heap" 'huge' objects to 'draw' type file memory, since they - * represent large objects that are directly stored in the file. - * - * -QAK - */ -#define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR -#define H5FD_MEM_FHEAP_IBLOCK H5FD_MEM_OHDR -#define H5FD_MEM_FHEAP_DBLOCK H5FD_MEM_LHEAP -#define H5FD_MEM_FHEAP_HUGE_OBJ H5FD_MEM_DRAW - -/* Map "free space" header blocks to 'ohdr' type file memory, since its - * a fair amount of work to add a new kind of file memory and they are similar - * enough to object headers and probably too minor to deserve their own type. - * - * Map "free space" serialized sections to 'lheap' type file memory, since they - * are similar enough to local heap info. - * - * -QAK - */ -#define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR -#define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP - -/* Map "shared object header message" master table to 'ohdr' type file memory, - * since its a fair amount of work to add a new kind of file memory and they are - * similar enough to object headers and probably too minor to deserve their own - * type. - * - * Map "shared object header message" indices to 'btree' type file memory, - * since they are similar enough to B-tree nodes. - * - * -QAK - */ -#define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR -#define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE - -/* Map "extensible array" header blocks to 'ohdr' type file memory, since its - * a fair amount of work to add a new kind of file memory and they are similar - * enough to object headers and probably too minor to deserve their own type. - * - * Map "extensible array" index blocks to 'ohdr' type file memory, since they - * are similar to extensible array header blocks. - * - * Map "extensible array" super blocks to 'btree' type file memory, since they - * are similar enough to B-tree nodes. - * - * Map "extensible array" data blocks & pages to 'lheap' type file memory, since - * they are similar enough to local heap info. - * - * -QAK - */ -#define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR -#define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR -#define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE -#define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP -#define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP +/*****************/ +/* Public Macros */ +/*****************/ -/* Map "fixed array" header blocks to 'ohdr' type file memory, since its - * a fair amount of work to add a new kind of file memory and they are similar - * enough to object headers and probably too minor to deserve their own type. - * - * Map "fixed array" data blocks & pages to 'lheap' type file memory, since - * they are similar enough to local heap info. - * - */ -#define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR -#define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP -#define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP - -/* - * A free-list map which maps all types of allocation requests to a single - * free list. This is useful for drivers that don't really care about - * keeping different requests segregated in the underlying file and which - * want to make most efficient reuse of freed memory. The use of the - * H5FD_MEM_SUPER free list is arbitrary. - */ -#define H5FD_FLMAP_SINGLE \ - { \ - H5FD_MEM_SUPER, /*default*/ \ - H5FD_MEM_SUPER, /*super*/ \ - H5FD_MEM_SUPER, /*btree*/ \ - H5FD_MEM_SUPER, /*draw*/ \ - H5FD_MEM_SUPER, /*gheap*/ \ - H5FD_MEM_SUPER, /*lheap*/ \ - H5FD_MEM_SUPER /*ohdr*/ \ - } - -/* - * A free-list map which segregates requests into `raw' or `meta' data - * pools. - */ -#define H5FD_FLMAP_DICHOTOMY \ - { \ - H5FD_MEM_SUPER, /*default*/ \ - H5FD_MEM_SUPER, /*super*/ \ - H5FD_MEM_SUPER, /*btree*/ \ - H5FD_MEM_DRAW, /*draw*/ \ - H5FD_MEM_DRAW, /*gheap*/ \ - H5FD_MEM_SUPER, /*lheap*/ \ - H5FD_MEM_SUPER /*ohdr*/ \ - } - -/* - * The default free list map which causes each request type to use it's own - * free-list. - */ -#define H5FD_FLMAP_DEFAULT \ - { \ - H5FD_MEM_DEFAULT, /*default*/ \ - H5FD_MEM_DEFAULT, /*super*/ \ - H5FD_MEM_DEFAULT, /*btree*/ \ - H5FD_MEM_DEFAULT, /*draw*/ \ - H5FD_MEM_DEFAULT, /*gheap*/ \ - H5FD_MEM_DEFAULT, /*lheap*/ \ - H5FD_MEM_DEFAULT /*ohdr*/ \ - } +#define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ /* Define VFL driver features that can be enabled on a per-driver basis */ /* These are returned with the 'query' function pointer in H5FD_class_t */ @@ -263,71 +138,12 @@ typedef enum H5F_mem_t H5FD_mem_t; */ #define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000 -/* Forward declaration */ -typedef struct H5FD_t H5FD_t; - -/* Class information for each file driver */ -typedef struct H5FD_class_t { - const char * name; - haddr_t maxaddr; - H5F_close_degree_t fc_degree; - herr_t (*terminate)(void); - hsize_t (*sb_size)(H5FD_t *file); - herr_t (*sb_encode)(H5FD_t *file, char *name /*out*/, unsigned char *p /*out*/); - herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); - size_t fapl_size; - void *(*fapl_get)(H5FD_t *file); - void *(*fapl_copy)(const void *fapl); - herr_t (*fapl_free)(void *fapl); - size_t dxpl_size; - void *(*dxpl_copy)(const void *dxpl); - herr_t (*dxpl_free)(void *dxpl); - H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr); - herr_t (*close)(H5FD_t *file); - int (*cmp)(const H5FD_t *f1, const H5FD_t *f2); - herr_t (*query)(const H5FD_t *f1, unsigned long *flags); - herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map); - haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); - herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); - haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type); - herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr); - haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type); - herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void **file_handle); - herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer); - herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer); - herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - herr_t (*lock)(H5FD_t *file, hbool_t rw); - herr_t (*unlock)(H5FD_t *file); - herr_t (*del)(const char *name, hid_t fapl); - H5FD_mem_t fl_map[H5FD_MEM_NTYPES]; -} H5FD_class_t; - -/* A free list is a singly-linked list of address/size pairs. */ -typedef struct H5FD_free_t { - haddr_t addr; - hsize_t size; - struct H5FD_free_t *next; -} H5FD_free_t; - -/* - * The main datatype for each driver. Public fields common to all drivers - * are declared here and the driver appends private fields in memory. - */ -struct H5FD_t { - hid_t driver_id; /*driver ID for this file */ - const H5FD_class_t *cls; /*constant class info */ - unsigned long fileno; /* File 'serial' number */ - unsigned access_flags; /* File access flags (from create or open) */ - unsigned long feature_flags; /* VFL Driver feature Flags */ - haddr_t maxaddr; /* For this file, overrides class */ - haddr_t base_addr; /* Base address for HDF5 data w/in file */ +/*******************/ +/* Public Typedefs */ +/*******************/ - /* Space allocation management fields */ - hsize_t threshold; /* Threshold for alignment */ - hsize_t alignment; /* Allocation alignment */ - hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ -}; +/* Types of allocation requests: see H5Fpublic.h */ +typedef enum H5F_mem_t H5FD_mem_t; /** * Define enum for the source of file image callbacks @@ -437,33 +253,19 @@ typedef struct { } H5FD_file_image_callbacks_t; //! +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ -H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); -H5_DLL herr_t H5FDunregister(hid_t driver_id); -H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -H5_DLL herr_t H5FDclose(H5FD_t *file); -H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); -H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); -H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); -H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); -H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle); -H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - void *buf /*out*/); -H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *buf); -H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); -H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); -H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); -H5_DLL herr_t H5FDunlock(H5FD_t *file); -H5_DLL herr_t H5FDdelete(const char *name, hid_t fapl_id); - /* Allows querying a VFD ID for features before the file is opened */ H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/); diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 6631325..e23aca8 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -29,6 +29,7 @@ #include #include "hdf5.h" +#include "hdf5dev.h" #ifdef H5_HAVE_FLOCK /* Needed for lock type definitions (e.g., LOCK_EX) */ diff --git a/src/H5FL.c b/src/H5FL.c index 95188d5..0aca4b7 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -337,8 +337,11 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk->file = NULL; + trk->func = NULL; /* Remove from "outstanding allocations" list */ if (trk == H5FL_out_head_g) { @@ -443,8 +446,11 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) /* Copy allocation location information */ ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); HDassert(((H5FL_track_t *)ret_value)->stack); - ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); - ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; ((H5FL_track_t *)ret_value)->line = call_line; /* Add to "outstanding allocations" list */ @@ -908,8 +914,11 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) /* Copy allocation location information */ ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); HDassert(((H5FL_track_t *)ret_value)->stack); - ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); - ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; ((H5FL_track_t *)ret_value)->line = call_line; /* Add to "outstanding allocations" list */ @@ -1004,8 +1013,11 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk->file = NULL; + trk->func = NULL; /* Remove from "outstanding allocations" list */ if (trk == H5FL_out_head_g) { @@ -1120,14 +1132,20 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ /* Release previous tracking information */ H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk->file = NULL; + trk->func = NULL; /* Store new tracking information */ trk->stack = H5CS_copy_stack(); HDassert(trk->stack); - trk->file = H5MM_strdup(call_file); - trk->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + trk->file = call_file; + trk->func = call_func; trk->line = call_line; } #endif /* H5FL_TRACK */ @@ -2017,8 +2035,11 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk->file = NULL; + trk->func = NULL; /* Remove from "outstanding allocations" list */ if (trk == H5FL_out_head_g) { @@ -2120,8 +2141,11 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) /* Copy allocation location information */ ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); HDassert(((H5FL_track_t *)ret_value)->stack); - ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); - ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; ((H5FL_track_t *)ret_value)->line = call_line; /* Add to "outstanding allocations" list */ diff --git a/src/H5Faccum.c b/src/H5Faccum.c index aed5812..4821272 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -36,7 +36,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ +#include "H5FDprivate.h" /* File drivers */ #include "H5MMprivate.h" /* Memory management */ #include "H5VMprivate.h" /* Vectors and arrays */ diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index b482961..ff6b4a0 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -89,10 +89,12 @@ herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo /*out*/) { - H5VL_object_t *vol_obj = NULL; - H5I_type_t type; - H5F_info2_t finfo2; /* Current file info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + H5I_type_t type; + H5F_info2_t finfo2; /* Current file info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", obj_id, finfo); @@ -111,9 +113,14 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo /*out*/) if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + file_opt_args.get_info.type = type; + file_opt_args.get_info.finfo = &finfo2; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_INFO; + vol_cb_args.args = &file_opt_args; + /* Get the file information */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - type, &finfo2) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") /* Copy the compatible fields into the older struct */ @@ -141,7 +148,9 @@ done: htri_t H5Fis_hdf5(const char *name) { - htri_t ret_value; /* Return value */ + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + hbool_t is_accessible = FALSE; /* Whether file is accessible */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("t", "*s", name); @@ -150,11 +159,19 @@ H5Fis_hdf5(const char *name) if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "no file name specified") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_IS_ACCESSIBLE; + vol_cb_args.args.is_accessible.filename = name; + vol_cb_args.args.is_accessible.fapl_id = H5P_FILE_ACCESS_DEFAULT; + vol_cb_args.args.is_accessible.accessible = &is_accessible; + /* Check if file is accessible */ - if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5P_FILE_ACCESS_DEFAULT, name, &ret_value) < 0) + if (H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable to determine if file is accessible as HDF5") + /* Set return value */ + ret_value = (htri_t)is_accessible; + done: FUNC_LEAVE_API(ret_value) } /* end H5Fis_hdf5() */ @@ -196,10 +213,11 @@ done: herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format) { - H5VL_object_t *vol_obj; /* File as VOL object */ - H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ - H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* File as VOL object */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, latest_format); @@ -218,9 +236,14 @@ H5Fset_latest_format(hid_t file_id, hbool_t latest_format) if (!latest_format) low = H5F_LIBVER_EARLIEST; + /* Set up VOL callback arguments */ + file_opt_args.set_libver_bounds.low = low; + file_opt_args.set_libver_bounds.high = H5F_LIBVER_LATEST; + vol_cb_args.op_type = H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS; + vol_cb_args.args = &file_opt_args; + /* Set the library's version bounds */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)low, (int)high) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: diff --git a/src/H5Fint.c b/src/H5Fint.c index e1be2b6..c2d3e77 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -2360,11 +2360,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_delete(const char *filename, hid_t fapl_id) +H5F__delete(const char *filename, hid_t fapl_id) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(filename); @@ -2374,7 +2374,7 @@ H5F_delete(const char *filename, hid_t fapl_id) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_delete() */ +} /* end H5F__delete() */ /*------------------------------------------------------------------------- * Function: H5F_try_close @@ -3109,27 +3109,28 @@ done: /*------------------------------------------------------------------------- * Function: H5F__get_file_image * - * Purpose: Private version of H5Fget_file_image + * Purpose: Private version of H5Fget_file_image, returns bytes copied/ + * number of bytes needed in *image_len. + * + * Return: SUCCEED/FAIL * - * Return: Success: Bytes copied / number of bytes needed. - * Failure: -1 *------------------------------------------------------------------------- */ -ssize_t -H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) +herr_t +H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, size_t *image_len) { - H5FD_t *fd_ptr; /* file driver */ - haddr_t eoa; /* End of file address */ - ssize_t ret_value = -1; /* Return value */ + H5FD_t *fd_ptr; /* file driver */ + haddr_t eoa; /* End of file address */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ if (!file || !file->shared || !file->shared->lf) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "file_id yields invalid file pointer") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file_id yields invalid file pointer") fd_ptr = file->shared->lf; if (!fd_ptr->cls) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "fd_ptr yields invalid class pointer") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "fd_ptr yields invalid class pointer") /* the address space used by the split and multi file drivers is not * a good fit for this call. Since the plan is to depreciate these @@ -3150,7 +3151,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * JRM -- 11/11/22 */ if (HDstrcmp(fd_ptr->cls->name, "multi") == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "Not supported for multi file driver.") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not supported for multi file driver.") /* While the family file driver is conceptually fully compatible * with the get file image operation, it sets a file driver message @@ -3158,7 +3159,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * driver other than the family file driver. Needless to say, this * rather defeats the purpose of the get file image operation. * - * While this problem is quire solvable, the required time and + * While this problem is quite solvable, the required time and * resources are lacking at present. Hence, for now, we don't * allow the get file image operation to be perfomed on files * opened with the family file driver. @@ -3172,30 +3173,24 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * JRM -- 12/21/11 */ if (HDstrcmp(fd_ptr->cls->name, "family") == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "Not supported for family file driver.") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Not supported for family file driver.") /* Go get the actual file size */ if (HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file size") - - /* set ret_value = to eoa -- will overwrite this if appropriate */ - ret_value = (ssize_t)eoa; + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") - /* test to see if a buffer was provided -- if not, we are done */ + /* Test to see if a buffer was provided */ if (buf_ptr != NULL) { - size_t space_needed; /* size of file image */ unsigned tmp, tmp_size; /* Check for buffer too small */ if ((haddr_t)buf_len < eoa) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "supplied buffer too small") - - space_needed = (size_t)eoa; + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "supplied buffer too small") - /* read in the file image */ + /* Read in the file image */ /* (Note compensation for base address addition in internal routine) */ - if (H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_READERROR, (-1), "file image read request failed") + if (H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, (size_t)eoa, buf_ptr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "file image read request failed") /* Offset to "status_flags" in the superblock */ tmp = H5F_SUPER_STATUS_FLAGS_OFF(file->shared->sblock->super_vers); @@ -3207,6 +3202,9 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) HDmemset((uint8_t *)buf_ptr + tmp, 0, tmp_size); } /* end if */ + /* Set *image_len = to EOA */ + *image_len = (size_t)eoa; + done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__get_file_image() */ @@ -3902,11 +3900,12 @@ done: hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref) { - void * vol_obj_file = NULL; /* File object pointer */ - H5VL_loc_params_t loc_params; /* Location parameters */ - hid_t file_id = H5I_INVALID_HID; /* File ID for object */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * vol_obj_file = NULL; /* File object pointer */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + hid_t file_id = H5I_INVALID_HID; /* File ID for object */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -3914,9 +3913,12 @@ H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = obj_type; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_FILE; + vol_cb_args.args.get_file.file = &vol_obj_file; + /* Retrieve VOL file from object */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &vol_obj_file) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file from object") /* Check if the file's ID already exists */ diff --git a/src/H5Fmount.c b/src/H5Fmount.c index f107c98..4b90ea3 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -83,7 +83,7 @@ done: } /* end H5F__close_mounts() */ /*------------------------------------------------------------------------- - * Function: H5F__mount + * Function: H5F_mount * * Purpose: Mount file CHILD onto the group specified by LOC and NAME, * using mount properties in PLIST. CHILD must not already be @@ -97,7 +97,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) +H5F_mount(const H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) { H5G_t * mount_point = NULL; /*mount point group */ H5F_t * ancestor = NULL; /*ancestor files */ @@ -110,7 +110,7 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED H5G_loc_t root_loc; /* Group location of root of file to mount */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) HDassert(loc); HDassert(name && *name); @@ -157,10 +157,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED HDassert(mp_loc.oloc); mp_loc.path = H5G_nameof(mount_point); HDassert(mp_loc.path); - for (ancestor = parent; ancestor; ancestor = ancestor->parent) { + for (ancestor = parent; ancestor; ancestor = ancestor->parent) if (ancestor->shared == child->shared) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") - } /* Make certain that the parent & child files have the same "file close degree" */ if (parent->shared->fc_degree != child->shared->fc_degree) @@ -240,10 +239,10 @@ done: } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F__mount() */ +} /* end H5F_mount() */ /*------------------------------------------------------------------------- - * Function: H5F__unmount + * Function: H5F_unmount * * Purpose: Unmount the child which is mounted at the group specified by * LOC and NAME or fail if nothing is mounted there. Neither @@ -261,7 +260,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__unmount(H5G_loc_t *loc, const char *name) +H5F_unmount(const H5G_loc_t *loc, const char *name) { H5G_t * child_group = NULL; /* Child's group in parent mtab */ H5F_t * child = NULL; /*mounted file */ @@ -275,7 +274,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) int child_idx; /* Index of child in parent's mtab */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) HDassert(loc); HDassert(name && *name); @@ -291,7 +290,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) * then we must have found the mount point. */ if (H5G_loc_find(loc, name, &mp_loc /*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + HGOTO_ERROR(H5E_FILE, H5E_NOTFOUND, FAIL, "group not found") mp_loc_setup = TRUE; child = mp_loc.oloc->file; mnt_oloc = H5G_oloc(child->shared->root_grp); @@ -364,7 +363,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) /* Search the open IDs replace names to reflect unmount operation */ if (H5G_name_replace(NULL, H5G_NAME_UNMOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, @@ -376,7 +375,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) /* Unmount the child file from the parent file */ if (H5G_unmount(child_group) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to reset group mounted flag") + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to reset group mounted flag") if (H5G_close(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close unmounted group") @@ -391,7 +390,7 @@ done: H5G_loc_free(&mp_loc); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F__unmount() */ +} /* end H5F_unmount() */ /*------------------------------------------------------------------------- * Function: H5F_is_mount diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 4b5283e..53d2d78 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -193,7 +193,7 @@ done: } /* end H5F_mpi_get_size() */ /*------------------------------------------------------------------------- - * Function: H5F_set_mpi_atomicity + * Function: H5F__set_mpi_atomicity * * Purpose: Private call to set the atomicity mode * @@ -202,11 +202,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) +H5F__set_mpi_atomicity(H5F_t *file, hbool_t flag) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_PACKAGE /* Check args */ HDassert(file); @@ -222,7 +222,7 @@ H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) done: FUNC_LEAVE_NOAPI(ret_value); -} /* end H5F_set_mpi_atomicity() */ +} /* end H5F__set_mpi_atomicity() */ /*------------------------------------------------------------------------- * Function: H5Fset_mpi_atomicity @@ -240,9 +240,10 @@ done: herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) { - H5VL_object_t *vol_obj = NULL; - int va_flag = (int)flag; /* C is grumpy about passing hbool_t via va_arg */ - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE2("e", "ib", file_id, flag); @@ -251,9 +252,13 @@ H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + /* Set up VOL callback arguments */ + file_opt_args.set_mpi_atomicity.flag = flag; + vol_cb_args.op_type = H5VL_NATIVE_FILE_SET_MPI_ATOMICITY; + vol_cb_args.args = &file_opt_args; + /* Set atomicity value */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, va_flag) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set MPI atomicity"); done: @@ -261,7 +266,7 @@ done: } /* end H5Fset_mpi_atomicity() */ /*------------------------------------------------------------------------- - * Function: H5F_get_mpi_atomicity + * Function: H5F__get_mpi_atomicity * * Purpose: Private call to get the atomicity mode * @@ -270,11 +275,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) +H5F__get_mpi_atomicity(const H5F_t *file, hbool_t *flag) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_PACKAGE /* Check args */ HDassert(file); @@ -291,7 +296,7 @@ H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) done: FUNC_LEAVE_NOAPI(ret_value); -} /* end H5F_get_mpi_atomicity() */ +} /* end H5F__get_mpi_atomicity() */ /*------------------------------------------------------------------------- * Function: H5Fget_mpi_atomicity @@ -309,8 +314,10 @@ done: herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag /*out*/) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj; /* File info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE2("e", "ix", file_id, flag); @@ -319,9 +326,13 @@ H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + /* Set up VOL callback arguments */ + file_opt_args.get_mpi_atomicity.flag = flag; + vol_cb_args.op_type = H5VL_NATIVE_FILE_GET_MPI_ATOMICITY; + vol_cb_args.args = &file_opt_args; + /* Get atomicity value */ - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, flag) < 0) + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MPI atomicity"); done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 087c9c9..b016696 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -33,6 +33,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Bprivate.h" /* B-trees */ +#include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ #include "H5FSprivate.h" /* File free space */ @@ -404,21 +405,20 @@ H5_DLLVAR htri_t use_locks_env_g; /* General routines */ H5_DLL herr_t H5F__post_open(H5F_t *f); -H5_DLL H5F_t * H5F__reopen(H5F_t *f); -H5_DLL herr_t H5F__flush(H5F_t *f); -H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); -H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); -H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); -H5_DLL herr_t H5F__format_convert(H5F_t *f); -H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); -H5_DLL herr_t H5F__close(H5F_t *f); -H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); -H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); -H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks); +H5_DLL H5F_t *H5F__reopen(H5F_t *f); +H5_DLL herr_t H5F__flush(H5F_t *f); +H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); +H5_DLL herr_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len, size_t *image_len); +H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); +H5_DLL herr_t H5F__format_convert(H5F_t *f); +H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); +H5_DLL herr_t H5F__close(H5F_t *f); +H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); +H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); +H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks); +H5_DLL herr_t H5F__delete(const char *filename, hid_t fapl_id); /* File mount related routines */ -H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); -H5_DLL herr_t H5F__unmount(H5G_loc_t *loc, const char *name); H5_DLL herr_t H5F__close_mounts(H5F_t *f); H5_DLL herr_t H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); @@ -448,6 +448,12 @@ H5_DLL herr_t H5F__sfile_add(H5F_shared_t *shared); H5_DLL H5F_shared_t *H5F__sfile_search(H5FD_t *lf); H5_DLL herr_t H5F__sfile_remove(H5F_shared_t *shared); +/* Parallel I/O (i.e. MPI) related routines */ +#ifdef H5_HAVE_PARALLEL +H5_DLL herr_t H5F__get_mpi_atomicity(const H5F_t *file, hbool_t *flag); +H5_DLL herr_t H5F__set_mpi_atomicity(H5F_t *file, hbool_t flag); +#endif /* H5_HAVE_PARALLEL */ + /* External file cache routines */ H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); H5_DLL H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 7044835..051abd9 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -755,6 +755,7 @@ typedef struct H5F_t H5F_t; /* Forward declarations (for prototypes & type definitions) */ struct H5B_class_t; struct H5UC_t; +struct H5G_loc_t; struct H5O_loc_t; struct H5HG_heap_t; struct H5VL_class_t; @@ -830,7 +831,6 @@ H5_DLL herr_t H5F_init(void); H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/); H5_DLL hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref); -H5_DLL herr_t H5F_delete(const char *filename, hid_t fapl_id); /* Functions that retrieve values from the file struct */ H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); @@ -908,7 +908,9 @@ H5_DLL haddr_t H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type); H5_DLL haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type); H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); -/* Functions that check file mounting information */ +/* File mounting routines */ +H5_DLL herr_t H5F_mount(const struct H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); +H5_DLL herr_t H5F_unmount(const struct H5G_loc_t *loc, const char *name); H5_DLL hbool_t H5F_is_mount(const H5F_t *file); H5_DLL hbool_t H5F_has_mount(const H5F_t *file); H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc /*in,out*/); @@ -961,8 +963,6 @@ H5_DLL MPI_Comm H5F_mpi_get_comm(const H5F_t *f); H5_DLL int H5F_shared_mpi_get_size(const H5F_shared_t *f_sh); H5_DLL int H5F_mpi_get_size(const H5F_t *f); H5_DLL herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm); -H5_DLL herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag); -H5_DLL herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag); #endif /* H5_HAVE_PARALLEL */ /* External file cache routines */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 51c06f4..98d2a9f 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -1026,7 +1026,7 @@ H5_DLL herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr); * \since 1.8.0 * */ -H5_DLL herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5Fset_mdc_config(hid_t file_id, const H5AC_cache_config_t *config_ptr); /** * \ingroup MDC * @@ -1685,7 +1685,6 @@ H5_DLL herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize); * */ H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize); -H5_DLL herr_t H5Fwait(hid_t file_id); #ifdef H5_HAVE_PARALLEL /** diff --git a/src/H5G.c b/src/H5G.c index 0163d65..d7e4da9 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -502,8 +502,9 @@ done: hid_t H5Gget_create_plist(hid_t group_id) { - H5VL_object_t *vol_obj = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5VL_object_t * vol_obj; /* Object for loc_id */ + H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", group_id); @@ -512,11 +513,17 @@ H5Gget_create_plist(hid_t group_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_GROUP_GET_GCPL; + vol_cb_args.args.get_gcpl.gcpl_id = H5I_INVALID_HID; + /* Get the group creation property list for the group */ - if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_GCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < - 0) + if (H5VL_group_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get group's creation property list") + /* Set the return value */ + ret_value = vol_cb_args.args.get_gcpl.gcpl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_create_plist() */ @@ -538,9 +545,9 @@ H5G__get_info_api_common(hid_t loc_id, H5G_info_t *group_info /*out*/, void **to H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5I_type_t id_type; /* Type of ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -551,13 +558,14 @@ H5G__get_info_api_common(hid_t loc_id, H5G_info_t *group_info /*out*/, void **to if (!group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") - /* Set up object access arguments */ - if (H5VL_setup_self_args(loc_id, vol_obj_ptr, &loc_params) < 0) + /* Set up VOL callback & object access arguments */ + vol_cb_args.op_type = H5VL_GROUP_GET_INFO; + if (H5VL_setup_self_args(loc_id, vol_obj_ptr, &vol_cb_args.args.get_info.loc_params) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments") + vol_cb_args.args.get_info.ginfo = group_info; /* Retrieve group information */ - if (H5VL_group_get(*vol_obj_ptr, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, token_ptr, &loc_params, - group_info) < 0) + if (H5VL_group_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -647,8 +655,8 @@ H5G__get_info_by_name_api_common(hid_t loc_id, const char *name, H5G_info_t *gro H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -656,13 +664,15 @@ H5G__get_info_by_name_api_common(hid_t loc_id, const char *name, H5G_info_t *gro if (!group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") - /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, name, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) + /* Set up VOL callback & object access arguments */ + vol_cb_args.op_type = H5VL_GROUP_GET_INFO; + if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, vol_obj_ptr, + &vol_cb_args.args.get_info.loc_params) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments") + vol_cb_args.args.get_info.ginfo = group_info; /* Retrieve group information */ - if (H5VL_group_get(*vol_obj_ptr, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, token_ptr, &loc_params, - group_info) < 0) + if (H5VL_group_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -754,8 +764,8 @@ H5G__get_info_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -763,14 +773,15 @@ H5G__get_info_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t if (!group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") - /* Set up object access arguments */ - if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, - &loc_params) < 0) + /* Set up VOL callback & object access arguments */ + vol_cb_args.op_type = H5VL_GROUP_GET_INFO; + if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, FALSE, lapl_id, vol_obj_ptr, + &vol_cb_args.args.get_info.loc_params) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments") + vol_cb_args.args.get_info.ginfo = group_info; /* Retrieve group information */ - if (H5VL_group_get(*vol_obj_ptr, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, token_ptr, &loc_params, - group_info) < 0) + if (H5VL_group_get(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -957,8 +968,9 @@ done: herr_t H5Gflush(hid_t group_id) { - H5VL_object_t *vol_obj; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); @@ -971,9 +983,12 @@ H5Gflush(hid_t group_id) if (H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_GROUP_FLUSH; + vol_cb_args.args.flush.grp_id = group_id; + /* Flush group's metadata to file */ - if (H5VL_group_specific(vol_obj, H5VL_GROUP_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < - 0) + if (H5VL_group_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") done: @@ -995,8 +1010,9 @@ done: herr_t H5Grefresh(hid_t group_id) { - H5VL_object_t *vol_obj; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); @@ -1009,9 +1025,12 @@ H5Grefresh(hid_t group_id) if (H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_GROUP_REFRESH; + vol_cb_args.args.refresh.grp_id = group_id; + /* Refresh group's metadata */ - if (H5VL_group_specific(vol_obj, H5VL_GROUP_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - group_id) < 0) + if (H5VL_group_specific(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") done: diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index a621f6e..0c0b5db 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -200,20 +200,20 @@ done: * * Purpose: Returns the name of objects in the group by giving index. * - * Return: Success: Non-negative, length of name - * Failure: Negative + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Sep 6, 2005 * *------------------------------------------------------------------------- */ -ssize_t +herr_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, char *name, size_t size) + H5_iter_order_t order, hsize_t idx, char *name, size_t name_size, + size_t *name_len) { H5G_link_table_t ltable = {0, NULL}; /* Link table */ - ssize_t ret_value = -1; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -229,13 +229,13 @@ H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(ltable.lnks[idx].name); + *name_len = HDstrlen(ltable.lnks[idx].name); /* Copy the name into the user's buffer, if given */ if (name) { - HDstrncpy(name, ltable.lnks[idx].name, MIN((size_t)(ret_value + 1), size)); - if ((size_t)ret_value >= size) - name[size - 1] = '\0'; + HDstrncpy(name, ltable.lnks[idx].name, MIN((*name_len + 1), name_size)); + if (*name_len >= name_size) + name[name_size - 1] = '\0'; } /* end if */ done: diff --git a/src/H5Gdense.c b/src/H5Gdense.c index ec5cb71..753936b 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -169,7 +169,7 @@ typedef struct { size_t name_size; /* Size of name buffer to fill */ /* upward */ - ssize_t name_len; /* Full length of name */ + size_t name_len; /* Full length of name */ } H5G_bt2_ud_gnbi_t; /* @@ -185,7 +185,7 @@ typedef struct { size_t name_size; /* Size of name buffer to fill */ /* upward */ - ssize_t name_len; /* Full length of name */ + size_t name_len; /* Full length of name */ } H5G_fh_ud_gnbi_t; /* @@ -1046,12 +1046,12 @@ H5G__dense_get_name_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Get the length of the name */ - udata->name_len = (ssize_t)HDstrlen(lnk->name); + udata->name_len = HDstrlen(lnk->name); /* Copy the name into the user's buffer, if given */ if (udata->name) { - HDstrncpy(udata->name, lnk->name, MIN((size_t)(udata->name_len + 1), udata->name_size)); - if ((size_t)udata->name_len >= udata->name_size) + HDstrncpy(udata->name, lnk->name, MIN((udata->name_len + 1), udata->name_size)); + if (udata->name_len >= udata->name_size) udata->name[udata->name_size - 1] = '\0'; } /* end if */ @@ -1106,23 +1106,22 @@ done: * * Purpose: Returns the name of objects in the group by giving index. * - * Return: Success: Non-negative, length of name - * Failure: Negative + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Sep 19 2006 * *------------------------------------------------------------------------- */ -ssize_t +herr_t H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, char *name, size_t size) + hsize_t n, char *name, size_t name_size, size_t *name_len) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - ssize_t ret_value = -1; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1176,14 +1175,14 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, H5 udata.f = f; udata.fheap = fheap; udata.name = name; - udata.name_size = size; + udata.name_size = name_size; /* Retrieve the name according to the v2 B-tree's index order */ if (H5B2_index(bt2, order, n, H5G__dense_get_name_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "can't locate object in v2 B-tree") /* Set return value */ - ret_value = udata.name_len; + *name_len = udata.name_len; } /* end if */ else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ @@ -1195,13 +1194,13 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, H5 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(ltable.lnks[n].name); + *name_len = HDstrlen(ltable.lnks[n].name); /* Copy the name into the user's buffer, if given */ if (name) { - HDstrncpy(name, ltable.lnks[n].name, MIN((size_t)(ret_value + 1), size)); - if ((size_t)ret_value >= size) - name[size - 1] = '\0'; + HDstrncpy(name, ltable.lnks[n].name, MIN((*name_len + 1), name_size)); + if (*name_len >= name_size) + name[name_size - 1] = '\0'; } /* end if */ } /* end else */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 45065e8..7c0404f 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -308,7 +308,8 @@ done: herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iLl*s*s", cur_loc_id, type, cur_name, new_name); @@ -326,20 +327,15 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new /* Create link */ if (type == H5L_TYPE_HARD) { H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params1; - H5VL_loc_params_t loc_params2; + H5VL_loc_params_t new_loc_params; H5VL_object_t tmp_vol_obj; /* Temporary object */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(cur_loc_id); - loc_params1.loc_data.loc_by_name.name = cur_name; - loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + /* Set up new location struct */ + new_loc_params.type = H5VL_OBJECT_BY_NAME; + new_loc_params.loc_data.loc_by_name.name = new_name; + new_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.loc_data.loc_by_name.name = new_name; - loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - - /* get the location object */ + /* Get the location object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") @@ -347,16 +343,24 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new tmp_vol_obj.data = NULL; tmp_vol_obj.connector = vol_obj->connector; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; + vol_cb_args.args.hard.curr_obj = vol_obj->data; + vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME; + vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(cur_loc_id); + vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.name = cur_name; + vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + /* Create the link through the VOL */ - if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - vol_obj->data, &loc_params1) < 0) + if (H5VL_link_create(&vol_cb_args, &tmp_vol_obj, &new_loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if (type == H5L_TYPE_SOFT) { H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.loc_data.loc_by_name.name = new_name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; @@ -366,10 +370,13 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_SOFT; + vol_cb_args.args.soft.target = cur_name; + /* Create the link through the VOL */ - if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - cur_name) < 0) + if (H5VL_link_create(&vol_cb_args, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else-if */ else @@ -390,7 +397,8 @@ done: herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sLli*s", cur_loc_id, cur_name, type, new_loc_id, new_name); @@ -409,29 +417,31 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ if (type == H5L_TYPE_HARD) { H5VL_object_t * vol_obj1; /* Object of loc_id */ H5VL_object_t * vol_obj2; /* Object of loc_id */ - H5VL_loc_params_t loc_params1; - H5VL_loc_params_t loc_params2; + H5VL_loc_params_t new_loc_params; - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(cur_loc_id); - loc_params1.loc_data.loc_by_name.name = cur_name; - loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + /* Set up new location struct */ + new_loc_params.type = H5VL_OBJECT_BY_NAME; + new_loc_params.obj_type = H5I_get_type(new_loc_id); + new_loc_params.loc_data.loc_by_name.name = new_name; + new_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.obj_type = H5I_get_type(new_loc_id); - loc_params2.loc_data.loc_by_name.name = new_name; - loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - - /* get the location object */ + /* Get the location objects */ if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; + vol_cb_args.args.hard.curr_obj = vol_obj1->data; + vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME; + vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(cur_loc_id); + vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.name = cur_name; + vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + /* Create the link through the VOL */ - if (H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - vol_obj1->data, &loc_params1) < 0) + if (H5VL_link_create(&vol_cb_args, vol_obj2, &new_loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if (type == H5L_TYPE_SOFT) { @@ -443,6 +453,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ if (new_loc_id == H5L_SAME_LOC) new_loc_id = cur_loc_id; + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.loc_data.loc_by_name.name = new_name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; @@ -452,10 +463,13 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_SOFT; + vol_cb_args.args.soft.target = cur_name; + /* Create the link through the VOL */ - if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - cur_name) < 0) + if (H5VL_link_create(&vol_cb_args, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else-if */ else @@ -572,9 +586,10 @@ done: herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); @@ -596,9 +611,11 @@ H5Gunlink(hid_t loc_id, const char *name) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_DELETE; + /* Delete the link */ - if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "couldn't delete link") done: @@ -616,9 +633,10 @@ done: herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szx", loc_id, name, size, buf); @@ -631,6 +649,7 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.obj_type = H5I_get_type(loc_id); loc_params.loc_data.loc_by_name.name = name; @@ -640,9 +659,13 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_VAL; + vol_cb_args.args.get_val.buf = buf; + vol_cb_args.args.get_val.buf_size = size; + /* Get the link value */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, - size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link value") done: @@ -669,9 +692,11 @@ done: herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, name, comment); @@ -693,9 +718,14 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.set_comment.comment = comment; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_SET_COMMENT; + vol_cb_args.args = &obj_opt_args; + /* Set the comment */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, comment) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "unable to set comment value") done: @@ -728,10 +758,12 @@ done: int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf /*out*/) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - ssize_t op_ret; /* Return value from operation */ - int ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + size_t comment_len = 0; /* Length of comment */ + int ret_value; /* Return value */ FUNC_ENTER_API(-1) H5TRACE4("Is", "i*szx", loc_id, name, bufsize, buf); @@ -755,13 +787,20 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf /*out*/ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.get_comment.buf = buf; + obj_opt_args.get_comment.buf_size = bufsize; + obj_opt_args.get_comment.comment_len = &comment_len; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_COMMENT; + vol_cb_args.args = &obj_opt_args; + /* Get the comment */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, buf, bufsize, &op_ret) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, -1, "unable to get comment value") /* Set return value */ - ret_value = (int)op_ret; + ret_value = (int)comment_len; done: FUNC_LEAVE_API(ret_value) @@ -794,12 +833,11 @@ done: herr_t H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_obj; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_group_optional_args_t grp_opt_args; /* Arguments for optional operation */ + hsize_t last_obj = 0; /* Pointer to index value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*IsGi*x", loc_id, name, idx_p, op, op_data); @@ -812,30 +850,28 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *o if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") - /* Set number of objects looked at to zero */ - last_obj = 0; - idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p); - - /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_OLD; - lnk_op.op_func.op_old = op; - - /* Fill out location struct */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; - loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(loc_id); - /* Get the object pointer */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ID, H5E_BADTYPE, (-1), "invalid identifier") + /* Set up VOL callback arguments */ + grp_opt_args.iterate_old.loc_params.type = H5VL_OBJECT_BY_NAME; + grp_opt_args.iterate_old.loc_params.loc_data.loc_by_name.name = name; + grp_opt_args.iterate_old.loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + grp_opt_args.iterate_old.loc_params.obj_type = H5I_get_type(loc_id); + grp_opt_args.iterate_old.idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p); + grp_opt_args.iterate_old.last_obj = &last_obj; + grp_opt_args.iterate_old.op = op; + grp_opt_args.iterate_old.op_data = op_data; + vol_cb_args.op_type = H5VL_NATIVE_GROUP_ITERATE_OLD; + vol_cb_args.args = &grp_opt_args; + /* Call private iteration function, through VOL callback */ - if ((ret_value = H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) + if ((ret_value = H5VL_group_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < + 0) HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links"); - /* Set the index we stopped at */ + /* Set value to return */ if (idx_p) *idx_p = (int)last_obj; @@ -862,11 +898,11 @@ done: herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs /*out*/) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5I_type_t id_type; /* Type of ID */ - H5VL_loc_params_t loc_params; - H5G_info_t grp_info; /* Group information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5I_type_t id_type; /* Type of ID */ + H5G_info_t grp_info; /* Group information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", loc_id, num_objs); @@ -878,17 +914,14 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs /*out*/) if (!num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") - /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = id_type; - - /* Get group location */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback & object access arguments */ + vol_cb_args.op_type = H5VL_GROUP_GET_INFO; + if (H5VL_setup_self_args(loc_id, &vol_obj, &vol_cb_args.args.get_info.loc_params) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set object access arguments") + vol_cb_args.args.get_info.ginfo = &grp_info; /* Retrieve the group's information */ - if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, - &grp_info) < 0) + if (H5VL_group_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") /* Set the number of objects [i.e. links] in the group */ @@ -918,9 +951,10 @@ done: herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_group_optional_args_t grp_opt_args; /* Arguments for optional operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf); @@ -933,20 +967,22 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t * if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info"); - /* Retrieve object info */ - /* Fill out location struct */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; - loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(loc_id); - /* Get the location object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); + /* Set up VOL callback arguments */ + grp_opt_args.get_objinfo.loc_params.type = H5VL_OBJECT_BY_NAME; + grp_opt_args.get_objinfo.loc_params.loc_data.loc_by_name.name = name; + grp_opt_args.get_objinfo.loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + grp_opt_args.get_objinfo.loc_params.obj_type = H5I_get_type(loc_id); + grp_opt_args.get_objinfo.follow_link = follow_link; + grp_opt_args.get_objinfo.statbuf = statbuf; + vol_cb_args.op_type = H5VL_NATIVE_GROUP_GET_OBJINFO; + vol_cb_args.args = &grp_opt_args; + /* Retrieve the object's information */ - if (H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_GET_OBJINFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &loc_params, (unsigned)follow_link, statbuf) < 0) + if (H5VL_group_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name); done: @@ -1138,9 +1174,11 @@ done: ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name /*out*/, size_t size) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - ssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + size_t name_len = 0; /* Length of object name */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "ihxz", loc_id, idx, name, size); @@ -1149,7 +1187,7 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name /*out*/, size_t size if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set collective metadata read info") - /* Fill in location struct fields */ + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = "."; loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_NAME; @@ -1162,11 +1200,19 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name /*out*/, size_t size if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_NAME; + vol_cb_args.args.get_name.name_size = size; + vol_cb_args.args.get_name.name = name; + vol_cb_args.args.get_name.name_len = &name_len; + /* Call internal function */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - name, size, &ret_value) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get object name") + /* Set the return value */ + ret_value = (ssize_t)name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_objname_by_idx() */ @@ -1189,10 +1235,11 @@ done: H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_info2_t oinfo; /* Object info (contains object type) */ - H5G_obj_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5O_info2_t oinfo; /* Object info (contains object type) */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE2("Go", "ih", loc_id, idx); @@ -1210,9 +1257,13 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; + vol_cb_args.args.get_info.oinfo = &oinfo; + vol_cb_args.args.get_info.fields = H5O_INFO_BASIC; + /* Retrieve the object's basic information (which includes its type) */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &oinfo, H5O_INFO_BASIC) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info") /* Map to group object type */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 7d08b54..2844c66 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -53,12 +53,6 @@ typedef struct { H5G_loc_t *loc; /* Group location to set */ } H5G_loc_fnd_t; -/* User data for checking if an object exists */ -typedef struct { - /* upward */ - htri_t exists; /* Whether the object exists */ -} H5G_loc_exists_t; - /* User data for looking up an object in a group by index */ typedef struct { /* downward */ @@ -103,7 +97,7 @@ typedef struct { size_t bufsize; /* Size of object comment buffer */ /* upward */ - ssize_t comment_size; /* Actual size of object comment */ + size_t comment_size; /* Actual size of object comment */ } H5G_loc_gc_t; /********************/ @@ -616,24 +610,26 @@ H5G__loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_ const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_exists_t *udata = (H5G_loc_exists_t *)_udata; /* User data passed in */ + hbool_t *exists = (hbool_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid object */ if (obj_loc == NULL) if (lnk) - udata->exists = FALSE; + *exists = FALSE; else - udata->exists = FAIL; + HGOTO_ERROR(H5E_SYM, H5E_INTERNAL, FAIL, "no object or link info?") else - udata->exists = TRUE; + *exists = TRUE; /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_exists_cb() */ /*------------------------------------------------------------------------- @@ -649,28 +645,22 @@ H5G__loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_ * *------------------------------------------------------------------------- */ -htri_t -H5G_loc_exists(const H5G_loc_t *loc, const char *name) +herr_t +H5G_loc_exists(const H5G_loc_t *loc, const char *name, hbool_t *exists) { - H5G_loc_exists_t udata; /* User data for traversal callback */ - htri_t ret_value = FAIL; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args. */ HDassert(loc); HDassert(name && *name); - - /* Set up user data for locating object */ - udata.exists = FALSE; + HDassert(exists); /* Traverse group hierarchy to locate object */ - if (H5G_traverse(loc, name, H5G_TARGET_EXISTS, H5G__loc_exists_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_EXISTS, H5G__loc_exists_cb, exists) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't check if object exists") - /* Set return value */ - ret_value = udata.exists; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_exists() */ @@ -1024,7 +1014,7 @@ H5G__loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ else { if (udata->comment && udata->bufsize) HDstrncpy(udata->comment, comment.s, udata->bufsize); - udata->comment_size = (ssize_t)HDstrlen(comment.s); + udata->comment_size = HDstrlen(comment.s); H5O_msg_reset(H5O_NAME_ID, &comment); } @@ -1043,22 +1033,19 @@ done: * Purpose: Retrieve the information for an object from a group location * and path to that object * - * Return: Success: Number of bytes in the comment excluding the - * null terminator. Zero if the object has no - * comment. - * - * Failure: Negative + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, August 30, 2007 * *------------------------------------------------------------------------- */ -ssize_t -H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, size_t bufsize) +herr_t +H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, size_t bufsize, + size_t *comment_len) { - H5G_loc_gc_t udata; /* User data for traversal callback */ - ssize_t ret_value = -1; /* Return value */ + H5G_loc_gc_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1069,14 +1056,15 @@ H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out* /* Set up user data for locating object */ udata.comment = comment; udata.bufsize = bufsize; - udata.comment_size = (-1); + udata.comment_size = 0; /* Traverse group hierarchy to locate object */ if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_get_comment_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") - /* Set the return value */ - ret_value = udata.comment_size; + /* Set value to return */ + if (comment_len) + *comment_len = udata.comment_size; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Gname.c b/src/H5Gname.c index 2465f01..c139a4e 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -468,11 +468,10 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) * *------------------------------------------------------------------------- */ -ssize_t -H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached) +herr_t +H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, size_t *name_len, hbool_t *cached) { - ssize_t len = 0; /* Length of object's name */ - ssize_t ret_value = -1; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -481,14 +480,20 @@ H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cac /* If the user path is available and it's not "hidden", use it */ if (loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) { + size_t len; /* Length of object's name */ + len = H5RS_len(loc->path->user_path_r); if (name) { - HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((size_t)(len + 1), size)); - if ((size_t)len >= size) + HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((len + 1), size)); + if (len >= size) name[size - 1] = '\0'; } /* end if */ + /* Set name length, if requested */ + if (name_len) + *name_len = len; + /* Indicate that the name is cached, if requested */ /* (Currently only used for testing - QAK, 2010/07/26) */ if (cached) @@ -496,7 +501,7 @@ H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cac } /* end if */ else if (!loc->path->obj_hidden) { /* Search for name of object */ - if ((len = H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size)) < 0) + if (H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size, name_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") /* Indicate that the name is _not_ cached, if requested */ @@ -505,9 +510,6 @@ H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cac *cached = FALSE; } /* end else */ - /* Set return value */ - ret_value = len; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name() */ @@ -1152,28 +1154,29 @@ done: * *------------------------------------------------------------------------- */ -ssize_t -H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) +herr_t +H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size, size_t *name_len) { - H5G_gnba_iter_t udata; /* User data for iteration */ - H5G_loc_t root_loc; /* Root group's location */ - hbool_t found_obj = FALSE; /* If we found the object */ - herr_t status; /* Status from iteration */ - ssize_t ret_value = -1; /* Return value */ + H5G_gnba_iter_t udata; /* User data for iteration */ + size_t len; /* Length of path name */ + H5G_loc_t root_loc; /* Root group's location */ + hbool_t found_obj = FALSE; /* If we found the object */ + herr_t status; /* Status from iteration */ + herr_t ret_value = SUCCEED; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); - FUNC_ENTER_NOAPI((-1)) + FUNC_ENTER_NOAPI(FAIL) /* Construct a group location for root group of the file */ if (H5G_root_loc(f, &root_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get root group's location") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get root group's location") /* Check for root group being the object looked for */ if (root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { if (NULL == (udata.path = H5MM_strdup(""))) - HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, (-1), "can't duplicate path string") + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, FAIL, "can't duplicate path string") found_obj = TRUE; } /* end if */ else { @@ -1184,7 +1187,7 @@ H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) /* Visit all the links in the file */ if ((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G__get_name_by_addr_cb, &udata)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, (-1), "group traversal failed while looking for object name") + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group traversal failed while looking for object name") else if (status > 0) found_obj = TRUE; } /* end else */ @@ -1192,7 +1195,7 @@ H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) /* Check for finding the object */ if (found_obj) { /* Set the length of the full path */ - ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ + len = HDstrlen(udata.path) + 1; /* Length of path + 1 (for "/") */ /* If there's a buffer provided, copy into it, up to the limit of its size */ if (name) { @@ -1202,12 +1205,16 @@ H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) /* Append the rest of the path */ /* (less one character, for the initial path separator) */ HDstrncat(name, udata.path, (size - 2)); - if ((size_t)ret_value >= size) + if (len >= size) name[size - 1] = '\0'; } /* end if */ } /* end if */ else - ret_value = 0; + len = 0; + + /* Set path name length, if given */ + if (name_len) + *name_len = len; done: /* Release resources */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 1ca6b14..66917c2 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -767,13 +767,13 @@ done: * *------------------------------------------------------------------------- */ -ssize_t +herr_t H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - char *name, size_t size) + char *name, size_t name_size, size_t *name_len) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - ssize_t ret_value = -1; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(oloc->addr, FAIL) @@ -785,22 +785,21 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_orde HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if (idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) /* Check if creation order is tracked */ if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") - } /* end if */ /* Check for dense link storage */ if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the object's name from the dense link storage */ - if ((ret_value = H5G__dense_get_name_by_idx(oloc->file, &linfo, idx_type, order, n, name, size)) < - 0) + if (H5G__dense_get_name_by_idx(oloc->file, &linfo, idx_type, order, n, name, name_size, + name_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end if */ else { /* Get the object's name from the link messages */ - if ((ret_value = H5G__compact_get_name_by_idx(oloc, &linfo, idx_type, order, n, name, size)) < 0) + if (H5G__compact_get_name_by_idx(oloc, &linfo, idx_type, order, n, name, name_size, name_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ } /* end if */ @@ -810,7 +809,7 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_orde HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's name from the symbol table */ - if ((ret_value = H5G__stab_get_name_by_idx(oloc, order, n, name, size)) < 0) + if (H5G__stab_get_name_by_idx(oloc, order, n, name, name_size, name_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 86b6e1b..da565af 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -359,14 +359,14 @@ H5_DLL herr_t H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, hs H5G_lib_iterate_t op, void *op_data); H5_DLL herr_t H5G__stab_count(const struct H5O_loc_t *oloc, hsize_t *num_objs); H5_DLL herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info); -H5_DLL ssize_t H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, - size_t size); -H5_DLL herr_t H5G__stab_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); -H5_DLL herr_t H5G__stab_remove_by_idx(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, hbool_t *found, H5O_link_t *lnk); -H5_DLL herr_t H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, - H5O_link_t *lnk); +H5_DLL herr_t H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, + size_t name_size, size_t *name_len); +H5_DLL herr_t H5G__stab_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G__stab_remove_by_idx(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, hbool_t *found, H5O_link_t *lnk); +H5_DLL herr_t H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, + H5O_link_t *lnk); #ifndef H5_STRICT_FORMAT_CHECKS H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab); #endif /* H5_STRICT_FORMAT_CHECKS */ @@ -406,41 +406,42 @@ H5_DLL herr_t H5G__link_release_table(H5G_link_table_t *ltable); H5_DLL herr_t H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_t *lnk); /* Functions that understand "compact" link storage */ -H5_DLL herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk); -H5_DLL ssize_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, - char *name, size_t size); -H5_DLL herr_t H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); -H5_DLL herr_t H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5RS_str_t *grp_full_path_r, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - H5G_lib_iterate_t op, void *op_data); -H5_DLL herr_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, hbool_t *found, - H5O_link_t *lnk); +H5_DLL herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk); +H5_DLL herr_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, + H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + char *name, size_t name_size, size_t *name_len); +H5_DLL herr_t H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, + H5RS_str_t *grp_full_path_r, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5G_lib_iterate_t op, void *op_data); +H5_DLL herr_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, hbool_t *found, + H5O_link_t *lnk); H5_DLL herr_t H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); /* Functions that understand "dense" link storage */ -H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, H5G_link_table_t *ltable); -H5_DLL herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline); -H5_DLL herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk); -H5_DLL herr_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, hbool_t *found, - H5O_link_t *lnk); -H5_DLL herr_t H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); -H5_DLL herr_t H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, - void *op_data); -H5_DLL ssize_t H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char *name, size_t size); -H5_DLL herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); +H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable); +H5_DLL herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline); +H5_DLL herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk); +H5_DLL herr_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, hbool_t *found, + H5O_link_t *lnk); +H5_DLL herr_t H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); +H5_DLL herr_t H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, + void *op_data); +H5_DLL herr_t H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name, size_t name_size, + size_t *name_len); +H5_DLL herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, + const char *name); +H5_DLL herr_t H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); /* Functions that understand group objects */ H5_DLL herr_t H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 409d790..4cf4623 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -144,7 +144,7 @@ struct H5O_link_t; * The "location" of an object in a group hierarchy. This points to an object * location and a group hierarchy path for the object. */ -typedef struct { +typedef struct H5G_loc_t { struct H5O_loc_t *oloc; /* Object header location */ H5G_name_t * path; /* Group hierarchy path */ } H5G_loc_t; @@ -227,16 +227,17 @@ H5_DLL herr_t H5G_link_to_info(const struct H5O_loc_t *link_loc, const struct H5 /* * Functions that understand group objects */ -H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name, struct H5O_link_t *obj_lnk, - hbool_t adj_link, H5O_type_t obj_type, const void *crt_info); -H5_DLL ssize_t H5G_obj_get_name_by_idx(const struct H5O_loc_t *oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char *name, size_t size); -H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); -H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk); -H5_DLL hid_t H5G_get_create_plist(const H5G_t *grp); +H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name, struct H5O_link_t *obj_lnk, + hbool_t adj_link, H5O_type_t obj_type, const void *crt_info); +H5_DLL herr_t H5G_obj_get_name_by_idx(const struct H5O_loc_t *oloc, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name, size_t name_size, + size_t *name_len); +H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk); +H5_DLL hid_t H5G_get_create_plist(const H5G_t *grp); /* * These functions operate on symbol table nodes. @@ -253,35 +254,37 @@ H5_DLL herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *en /* * These functions operate on group hierarchy names. */ -H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name); -H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, - H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r); -H5_DLL herr_t H5G_name_reset(H5G_name_t *name); -H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5G_name_free(H5G_name_t *name); -H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached); -H5_DLL ssize_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, char *name, size_t size); +H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name); +H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, + H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r); +H5_DLL herr_t H5G_name_reset(H5G_name_t *name); +H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5G_name_free(H5G_name_t *name); +H5_DLL herr_t H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, size_t *name_len, + hbool_t *cached); +H5_DLL herr_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, char *name, size_t size, + size_t *name_len); H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name); /* * These functions operate on group "locations" */ -H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); -H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); -H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc /*out*/); -H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc /*out*/); -H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo /*out*/, - unsigned fields); -H5_DLL herr_t H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo /*out*/, - unsigned fields); -H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment); -H5_DLL ssize_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, - size_t bufsize); -H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc); -H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); +H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc /*out*/); +H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc /*out*/); +H5_DLL herr_t H5G_loc_exists(const H5G_loc_t *loc, const char *name, hbool_t *exists); +H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo /*out*/, + unsigned fields); +H5_DLL herr_t H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo /*out*/, + unsigned fields); +H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment); +H5_DLL herr_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, + size_t bufsize, size_t *comment_len); +H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc); /* * These functions operate on the root group diff --git a/src/H5Gstab.c b/src/H5Gstab.c index bf4b417..ca74aa5 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -705,22 +705,22 @@ done: * * Purpose: Returns the name of objects in the group by giving index. * - * Return: Success: Non-negative, length of name - * Failure: Negative + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Nov 20, 2002 * *------------------------------------------------------------------------- */ -ssize_t -H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, size_t size) +herr_t +H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, + size_t name_size, size_t *name_len) { - H5HL_t * heap = NULL; /* Pointer to local heap */ - H5O_stab_t stab; /* Info about local heap & B-tree */ - H5G_bt_it_gnbi_t udata; /* Iteration information */ - hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ - ssize_t ret_value = -1; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5O_stab_t stab; /* Info about local heap & B-tree */ + H5G_bt_it_gnbi_t udata; /* Iteration information */ + hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ + herr_t ret_value = SUCCEED; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -767,13 +767,13 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound") /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(udata.name); + *name_len = HDstrlen(udata.name); /* Copy the name into the user's buffer, if given */ if (name) { - HDstrncpy(name, udata.name, MIN((size_t)(ret_value + 1), size)); - if ((size_t)ret_value >= size) - name[size - 1] = '\0'; + HDstrncpy(name, udata.name, MIN((*name_len + 1), name_size)); + if (*name_len >= name_size) + name[name_size - 1] = '\0'; } /* end if */ done: diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 9f0dca2..7ae41ed 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -616,14 +616,14 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign /* Retrieve a copy of the user path and put it into the buffer */ if (obj_path->user_path_r) { - ssize_t len = H5RS_len(obj_path->user_path_r); + size_t len = H5RS_len(obj_path->user_path_r); /* Set the user path, if given */ if (user_path) - HDstrncpy(user_path, H5RS_get_str(obj_path->user_path_r), (size_t)(len + 1)); + HDstrncpy(user_path, H5RS_get_str(obj_path->user_path_r), (len + 1)); /* Set the length of the path */ - *user_path_len = (size_t)len; + *user_path_len = len; /* Set the user path hidden flag */ *obj_hidden = obj_path->obj_hidden; diff --git a/src/H5I.c b/src/H5I.c index 1973354..954a86b 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -925,9 +925,11 @@ done: ssize_t H5Iget_name(hid_t id, char *name /*out*/, size_t size) { - H5VL_object_t * vol_obj = NULL; /* Object stored in ID */ - H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object stored in ID */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + size_t obj_name_len = 0; /* Length of object's name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", id, name, size); @@ -940,11 +942,19 @@ H5Iget_name(hid_t id, char *name /*out*/, size_t size) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_NAME; + vol_cb_args.args.get_name.buf_size = size; + vol_cb_args.args.get_name.buf = name; + vol_cb_args.args.get_name.name_len = &obj_name_len; + /* Retrieve object's name */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value, name, size) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_ID, H5E_CANTGET, (-1), "can't retrieve object name") + /* Set return value */ + ret_value = (ssize_t)obj_name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_name() */ diff --git a/src/H5Idevelop.h b/src/H5Idevelop.h new file mode 100644 index 0000000..3cd951e --- /dev/null +++ b/src/H5Idevelop.h @@ -0,0 +1,139 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5I (ID management) developer + * support routines. + */ + +#ifndef _H5Idevelop_H +#define _H5Idevelop_H + +/* Include package's public header */ +#include "H5Ipublic.h" /* ID management */ + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/** + * The type of the realize_cb callback for H5Iregister_future + */ +//! +typedef herr_t (*H5I_future_realize_func_t)(void *future_object, hid_t *actual_object_id); +//! + +/** + * The type of the discard_cb callback for H5Iregister_future + */ +//! +typedef herr_t (*H5I_future_discard_func_t)(void *future_object); +//! + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup H5I + * + * \brief Registers a "future" object under a type and returns an ID for it + * + * \param[in] type The identifier of the type of the new ID + * \param[in] object Pointer to "future" object for which a new ID is created + * \param[in] realize_cb Function pointer to realize a future object + * \param[in] discard_cb Function pointer to destroy a future object + * + * \return \hid_t{object} + * + * \details H5Iregister_future() creates and returns a new ID for a "future" object. + * Future objects are a special kind of object and represent a + * placeholder for an object that has not yet been created or opened. + * The \p realize_cb will be invoked by the HDF5 library to 'realize' + * the future object as an actual object. A call to H5Iobject_verify() + * will invoke the \p realize_cb callback and if it successfully + * returns, will return the actual object, not the future object. + * + * \details The \p type parameter is the identifier for the ID type to which + * this new future ID will belong. This identifier may have been created + * by a call to H5Iregister_type() or may be one of the HDF5 pre-defined + * ID classes (e.g. H5I_FILE, H5I_GROUP, H5I_DATASPACE, etc). + * + * \details The \p object parameter is a pointer to the memory which the new ID + * will be a reference to. This pointer will be stored by the library, + * but will not be returned to a call to H5Iobject_verify() until the + * \p realize_cb callback has returned the actual pointer for the object. + * + * A NULL value for \p object is allowed. + * + * \details The \p realize_cb parameter is a function pointer that will be + * invoked by the HDF5 library to convert a future object into an + * actual object. The \p realize_cb function may be invoked by + * H5Iobject_verify() to return the actual object for a user-defined + * ID class (i.e. an ID class registered with H5Iregister_type()) or + * internally by the HDF5 library in order to use or get information + * from an HDF5 pre-defined ID type. For example, the \p realize_cb + * for a future dataspace object will be called during the process + * of returning information from H5Sget_simple_extent_dims(). + * + * Note that although the \p realize_cb routine returns + * an ID (as a parameter) for the actual object, the HDF5 library + * will swap the actual object in that ID for the future object in + * the future ID. This ensures that the ID value for the object + * doesn't change for the user when the object is realized. + * + * Note that the \p realize_cb callback could receive a NULL value + * for a future object pointer, if one was used when H5Iregister_future() + * was initially called. This is permitted as a means of allowing + * the \p realize_cb to act as a generator of new objects, without + * requiring creation of unnecessary future objects. + * + * It is an error to pass NULL for \p realize_cb. + * + * \details The \p discard_cb parameter is a function pointer that will be + * invoked by the HDF5 library to destroy a future object. This + * callback will always be invoked for _every_ future object, whether + * the \p realize_cb is invoked on it or not. It's possible that + * the \p discard_cb is invoked on a future object without the + * \p realize_cb being invoked, e.g. when a future ID is closed without + * requiring the future object to be realized into an actual one. + * + * Note that the \p discard_cb callback could receive a NULL value + * for a future object pointer, if one was used when H5Iregister_future() + * was initially called. + * + * It is an error to pass NULL for \p discard_cb. + * + * \note The H5Iregister_future() function is primarily targeted at VOL connector + * authors and is _not_ designed for general-purpose application use. + * + */ +H5_DLL hid_t H5Iregister_future(H5I_type_t type, const void *object, H5I_future_realize_func_t realize_cb, + H5I_future_discard_func_t discard_cb); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5Idevelop_H */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index d1b6248..831ff76 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -20,8 +20,9 @@ #ifndef H5Iprivate_H #define H5Iprivate_H -/* Include package's public header */ +/* Include package's public headers */ #include "H5Ipublic.h" +#include "H5Idevelop.h" /* Private headers needed by this file */ #include "H5private.h" diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 8e5e167..a5f830b 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -99,20 +99,6 @@ typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); typedef herr_t (*H5I_iterate_func_t)(hid_t id, void *udata); //! -/** - * The type of the realize_cb callback for H5Iregister_future - */ -//! -typedef herr_t (*H5I_future_realize_func_t)(void *future_object, hid_t *actual_object_id); -//! - -/** - * The type of the discard_cb callback for H5Iregister_future - */ -//! -typedef herr_t (*H5I_future_discard_func_t)(void *future_object); -//! - #ifdef __cplusplus extern "C" { #endif @@ -144,82 +130,6 @@ H5_DLL hid_t H5Iregister(H5I_type_t type, const void *object); /** * \ingroup H5I * - * \brief Registers a "future" object under a type and returns an ID for it - * - * \param[in] type The identifier of the type of the new ID - * \param[in] object Pointer to "future" object for which a new ID is created - * \param[in] realize_cb Function pointer to realize a future object - * \param[in] discard_cb Function pointer to destroy a future object - * - * \return \hid_t{object} - * - * \details H5Iregister_future() creates and returns a new ID for a "future" object. - * Future objects are a special kind of object and represent a - * placeholder for an object that has not yet been created or opened. - * The \p realize_cb will be invoked by the HDF5 library to 'realize' - * the future object as an actual object. A call to H5Iobject_verify() - * will invoke the \p realize_cb callback and if it successfully - * returns, will return the actual object, not the future object. - * - * \details The \p type parameter is the identifier for the ID type to which - * this new future ID will belong. This identifier may have been created - * by a call to H5Iregister_type() or may be one of the HDF5 pre-defined - * ID classes (e.g. H5I_FILE, H5I_GROUP, H5I_DATASPACE, etc). - * - * \details The \p object parameter is a pointer to the memory which the new ID - * will be a reference to. This pointer will be stored by the library, - * but will not be returned to a call to H5Iobject_verify() until the - * \p realize_cb callback has returned the actual pointer for the object. - * - * A NULL value for \p object is allowed. - * - * \details The \p realize_cb parameter is a function pointer that will be - * invoked by the HDF5 library to convert a future object into an - * actual object. The \p realize_cb function may be invoked by - * H5Iobject_verify() to return the actual object for a user-defined - * ID class (i.e. an ID class registered with H5Iregister_type()) or - * internally by the HDF5 library in order to use or get information - * from an HDF5 pre-defined ID type. For example, the \p realize_cb - * for a future dataspace object will be called during the process - * of returning information from H5Sget_simple_extent_dims(). - * - * Note that although the \p realize_cb routine returns - * an ID (as a parameter) for the actual object, the HDF5 library - * will swap the actual object in that ID for the future object in - * the future ID. This ensures that the ID value for the object - * doesn't change for the user when the object is realized. - * - * Note that the \p realize_cb callback could receive a NULL value - * for a future object pointer, if one was used when H5Iregister_future() - * was initially called. This is permitted as a means of allowing - * the \p realize_cb to act as a generator of new objects, without - * requiring creation of unnecessary future objects. - * - * It is an error to pass NULL for \p realize_cb. - * - * \details The \p discard_cb parameter is a function pointer that will be - * invoked by the HDF5 library to destroy a future object. This - * callback will always be invoked for _every_ future object, whether - * the \p realize_cb is invoked on it or not. It's possible that - * the \p discard_cb is invoked on a future object without the - * \p realize_cb being invoked, e.g. when a future ID is closed without - * requiring the future object to be realized into an actual one. - * - * Note that the \p discard_cb callback could receive a NULL value - * for a future object pointer, if one was used when H5Iregister_future() - * was initially called. - * - * It is an error to pass NULL for \p discard_cb. - * - * \note The H5Iregister_future() function is primarily targeted at VOL connector - * authors and is _not_ designed for general-purpose application use. - * - */ -H5_DLL hid_t H5Iregister_future(H5I_type_t type, const void *object, H5I_future_realize_func_t realize_cb, - H5I_future_discard_func_t discard_cb); -/** - * \ingroup H5I - * * \brief Returns the object referenced by an ID * * \param[in] id ID to be dereferenced diff --git a/src/H5Itest.c b/src/H5Itest.c index 71ef3f8..80738a9 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -71,6 +71,7 @@ H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) H5G_loc_t loc; /* Object location */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + size_t name_len = 0; /* Length of name */ ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -86,7 +87,7 @@ H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) /* Set wrapper info in API context */ if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_ID, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + HGOTO_ERROR(H5E_ID, H5E_CANTSET, (-1), "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Get object location */ @@ -94,13 +95,16 @@ H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) HGOTO_ERROR(H5E_ID, H5E_CANTGET, (-1), "can't retrieve object location") /* Call internal group routine to retrieve object's name */ - if ((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) + if (H5G_get_name(&loc, name, size, &name_len, cached) < 0) HGOTO_ERROR(H5E_ID, H5E_CANTGET, (-1), "can't retrieve object name") + /* Set return value */ + ret_value = (ssize_t)name_len; + done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_ID, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_ID, H5E_CANTRESET, (-1), "can't reset VOL wrapper info") if (api_ctx_pushed && H5CX_pop(FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context") diff --git a/src/H5L.c b/src/H5L.c index d3c0fe3..487599b 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -148,14 +148,28 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *ds HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if (vol_obj1 && vol_obj2) - if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + if (vol_obj1 && vol_obj2) { + int same_connector = 0; + + /* Check if both objects are associated with the same VOL connector */ + if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + if (same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + } /* end if */ /* Construct a temporary source VOL object */ - tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); - tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); + if (vol_obj1) { + tmp_vol_obj.connector = vol_obj1->connector; + tmp_vol_obj.data = vol_obj1->data; + } /* end if */ + else { + HDassert(vol_obj2); + + tmp_vol_obj.connector = vol_obj2->connector; + tmp_vol_obj.data = NULL; + } /* end else */ /* Move the link */ if (H5VL_link_move(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, @@ -238,14 +252,28 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *ds HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if (vol_obj1 && vol_obj2) - if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + if (vol_obj1 && vol_obj2) { + int same_connector = 0; + + /* Check if both objects are associated with the same VOL connector */ + if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + if (same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + } /* end if */ /* Construct a temporary source VOL object */ - tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); - tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); + if (vol_obj1) { + tmp_vol_obj.connector = vol_obj1->connector; + tmp_vol_obj.data = vol_obj1->data; + } /* end if */ + else { + HDassert(vol_obj2); + + tmp_vol_obj.connector = vol_obj2->connector; + tmp_vol_obj.data = NULL; + } /* end else */ /* Copy the link */ if (H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, @@ -272,8 +300,9 @@ H5L__create_soft_api_common(const char *link_target, hid_t link_loc_id, const ch H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -286,6 +315,7 @@ H5L__create_soft_api_common(const char *link_target, hid_t link_loc_id, const ch HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be an empty string") if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + /* link_name is verified in H5VL_setup_name_args() */ /* Get the link creation property list */ if (H5P_DEFAULT == lcpl_id) @@ -298,15 +328,17 @@ H5L__create_soft_api_common(const char *link_target, hid_t link_loc_id, const ch if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* link_name is verified in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(link_loc_id, link_name, H5P_CLS_LACC, TRUE, lapl_id, vol_obj_ptr, &loc_params) < - 0) + if (H5VL_setup_name_args(link_loc_id, link_name, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_SOFT; + vol_cb_args.args.soft.target = link_target; + /* Create the link */ - if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, *vol_obj_ptr, &loc_params, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, token_ptr, link_target) < 0) + if (H5VL_link_create(&vol_cb_args, *vol_obj_ptr, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, + token_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link") done: @@ -401,31 +433,31 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, +H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) { - H5VL_object_t * vol_obj1 = NULL; /* Object of cur_loc_id */ - H5VL_object_t * vol_obj2 = NULL; /* Object of new_loc_id */ + H5VL_object_t * curr_vol_obj = NULL; /* Object of cur_loc_id */ + H5VL_object_t * link_vol_obj = NULL; /* Object of link_loc_id */ H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_object_t * tmp_vol_obj_ptr = &tmp_vol_obj; /* Ptr to temporary object */ H5VL_object_t **tmp_vol_obj_ptr_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj_ptr); /* Ptr to ptr to temporary object */ - H5VL_loc_params_t loc_params1; /* Location parameters for cur_loc_id object access */ - H5VL_loc_params_t loc_params2; /* Location parameters for new_loc_id object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t link_loc_params; /* Location parameters for link_loc_id object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check arguments */ - if (cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) + if (cur_loc_id == H5L_SAME_LOC && link_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") if (!cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be NULL") if (!*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be an empty string") - if (!new_name) + if (!link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be NULL") - if (!*new_name) + if (!*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be an empty string") if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") @@ -441,40 +473,59 @@ H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t new_lo if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* Set up current & new location structs */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(cur_loc_id); - loc_params1.loc_data.loc_by_name.name = cur_name; - loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; - - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.obj_type = H5I_get_type(new_loc_id); - loc_params2.loc_data.loc_by_name.name = new_name; - loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + /* Set up new location struct */ + link_loc_params.type = H5VL_OBJECT_BY_NAME; + link_loc_params.obj_type = H5I_get_type(link_loc_id); + link_loc_params.loc_data.loc_by_name.name = link_name; + link_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; if (H5L_SAME_LOC != cur_loc_id) /* Get the current location object */ - if (NULL == (vol_obj1 = (H5VL_object_t *)H5VL_vol_object(cur_loc_id))) + if (NULL == (curr_vol_obj = (H5VL_object_t *)H5VL_vol_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if (H5L_SAME_LOC != new_loc_id) + if (H5L_SAME_LOC != link_loc_id) /* Get the new location object */ - if (NULL == (vol_obj2 = (H5VL_object_t *)H5VL_vol_object(new_loc_id))) + if (NULL == (link_vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if (vol_obj1 && vol_obj2) - if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + if (curr_vol_obj && link_vol_obj) { + int same_connector = 0; + + /* Check if both objects are associated with the same VOL connector */ + if (H5VL_cmp_connector_cls(&same_connector, curr_vol_obj->connector->cls, + link_vol_obj->connector->cls) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + if (same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + } /* end if */ /* Construct a temporary VOL object */ - (*tmp_vol_obj_ptr_ptr)->data = (vol_obj2 ? (vol_obj2->data) : NULL); - (*tmp_vol_obj_ptr_ptr)->connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); + if (curr_vol_obj) + (*tmp_vol_obj_ptr_ptr)->connector = curr_vol_obj->connector; + else { + HDassert(link_vol_obj); + + (*tmp_vol_obj_ptr_ptr)->connector = link_vol_obj->connector; + } /* end else */ + if (link_vol_obj) + (*tmp_vol_obj_ptr_ptr)->data = link_vol_obj->data; + else + (*tmp_vol_obj_ptr_ptr)->data = NULL; + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; + vol_cb_args.args.hard.curr_obj = (curr_vol_obj ? curr_vol_obj->data : NULL); + vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME; + vol_cb_args.args.hard.curr_loc_params.obj_type = + (H5L_SAME_LOC != cur_loc_id ? H5I_get_type(cur_loc_id) : H5I_BADID); + vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.name = cur_name; + vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Create the link */ - if (H5VL_link_create(H5VL_LINK_CREATE_HARD, *tmp_vol_obj_ptr_ptr, &loc_params2, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, token_ptr, (vol_obj1 ? vol_obj1->data : NULL), - &loc_params1) < 0) + if (H5VL_link_create(&vol_cb_args, *tmp_vol_obj_ptr_ptr, &link_loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link") done: @@ -534,12 +585,11 @@ H5Lcreate_hard_async(const char *app_file, const char *app_func, unsigned app_li const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id, hid_t es_id) { - H5VL_object_t vol_obj; /* Object for loc_id */ - H5VL_object_t * vol_obj_ptr = &vol_obj; /* Pointer to object for loc_id */ - H5VL_object_t **vol_obj_ptr_ptr = &vol_obj_ptr; /* Pointer to object pointer */ - void * token = NULL; /* Request token for async operation */ - void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t vol_obj; /* Object for loc_id */ + H5VL_object_t *vol_obj_ptr = &vol_obj; /* Pointer to object for loc_id */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE10("e", "*s*sIui*si*siii", app_file, app_func, app_line, cur_loc_id, cur_name, new_loc_id, @@ -551,7 +601,7 @@ H5Lcreate_hard_async(const char *app_file, const char *app_func, unsigned app_li /* Creates a hard link asynchronously */ if (H5L__create_hard_api_common(cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id, token_ptr, - vol_obj_ptr_ptr) < 0) + &vol_obj_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to asynchronously create hard link") /* If a token was created, add the token to the event set */ @@ -590,16 +640,16 @@ herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - char * norm_obj_name = NULL; /* Pointer to normalized current name */ - void * ext_link_buf = NULL; /* Buffer to contain external link */ - size_t buf_size; /* Size of buffer to hold external link */ - size_t file_name_len; /* Length of file name string */ - size_t norm_obj_name_len; /* Length of normalized object name string */ - uint8_t * p; /* Pointer into external link buffer */ - H5L_type_t link_type = H5L_TYPE_EXTERNAL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + char * norm_obj_name = NULL; /* Pointer to normalized current name */ + void * ext_link_buf = NULL; /* Buffer to contain external link */ + size_t buf_size; /* Size of buffer to hold external link */ + size_t file_name_len; /* Length of file name string */ + size_t norm_obj_name_len; /* Length of normalized object name string */ + uint8_t * p; /* Pointer into external link buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id); @@ -650,10 +700,15 @@ H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_i if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_UD; + vol_cb_args.args.ud.type = H5L_TYPE_EXTERNAL; + vol_cb_args.args.ud.buf = ext_link_buf; + vol_cb_args.args.ud.buf_size = buf_size; + /* Create an external link */ - if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, - buf_size) < 0) + if (H5VL_link_create(&vol_cb_args, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") done: @@ -691,9 +746,10 @@ herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sLl*xzii", link_loc_id, link_name, link_type, udata, udata_size, lcpl_id, lapl_id); @@ -726,9 +782,15 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, con if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Create external link */ - if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, udata, udata_size) < 0) + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_UD; + vol_cb_args.args.ud.type = link_type; + vol_cb_args.args.ud.buf = udata; + vol_cb_args.args.ud.buf_size = udata_size; + + /* Create user-defined link */ + if (H5VL_link_create(&vol_cb_args, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -751,8 +813,9 @@ H5L__delete_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **tok H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -760,12 +823,14 @@ H5L__delete_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **tok /* name is verified in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, name, H5P_CLS_LACC, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, name, TRUE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments") - /* Unlink */ - if (H5VL_link_specific(*vol_obj_ptr, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, token_ptr) < - 0) + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_DELETE; + + /* Delete link */ + if (H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -864,8 +929,9 @@ H5L__delete_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t i H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -878,13 +944,15 @@ H5L__delete_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t i HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Set up object access arguments */ - if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, H5P_CLS_LACC, TRUE, lapl_id, vol_obj_ptr, - &loc_params) < 0) + if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, TRUE, lapl_id, vol_obj_ptr, &loc_params) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_DELETE; + /* Delete the link */ - if (H5VL_link_specific(*vol_obj_ptr, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, token_ptr) < - 0) + if (H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -993,9 +1061,10 @@ done: herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sxzi", loc_id, name, buf, size, lapl_id); @@ -1008,18 +1077,23 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.obj_type = H5I_get_type(loc_id); loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - /* Get the location object */ + /* Get the VOL object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_VAL; + vol_cb_args.args.get_val.buf = buf; + vol_cb_args.args.get_val.buf_size = size; + /* Get the link value */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, - size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for '%s'", name) done: @@ -1048,9 +1122,10 @@ herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, buf, size, lapl_id); @@ -1067,6 +1142,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; @@ -1075,13 +1151,17 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* get the location object */ + /* Get the VOL object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_VAL; + vol_cb_args.args.get_val.buf = buf; + vol_cb_args.args.get_val.buf_size = size; + /* Get the link value */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, - size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value") done: @@ -1104,8 +1184,9 @@ H5L__exists_api_common(hid_t loc_id, const char *name, hbool_t *exists, hid_t la H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1115,12 +1196,15 @@ H5L__exists_api_common(hid_t loc_id, const char *name, hbool_t *exists, hid_t la HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer for link existence") /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, name, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_EXISTS; + vol_cb_args.args.exists.exists = exists; + /* Check for the existence of the link */ - if (H5VL_link_specific(*vol_obj_ptr, &loc_params, H5VL_LINK_EXISTS, H5P_DATASET_XFER_DEFAULT, token_ptr, - exists) < 0) + if (H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1216,9 +1300,10 @@ done: herr_t H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); @@ -1231,18 +1316,22 @@ H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t l if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.obj_type = H5I_get_type(loc_id); loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - /* get the location object */ + /* Get the location object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_INFO; + vol_cb_args.args.get_info.linfo = linfo; + /* Get the link information */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - linfo) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1267,9 +1356,10 @@ herr_t H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id); @@ -1286,6 +1376,7 @@ H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; @@ -1294,13 +1385,16 @@ H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* get the location object */ + /* Get the location object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_INFO; + vol_cb_args.args.get_info.linfo = linfo; + /* Get the link information */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - linfo) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1463,9 +1557,11 @@ ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + size_t link_name_len = 0; /* Length of the link name string */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE8("Zs", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, name, size, lapl_id); @@ -1482,7 +1578,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5 if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, (-1), "can't set access property list info") - /* Fill in location struct fields */ + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; @@ -1491,15 +1587,23 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5 loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* Get the location object */ + /* Get the VOL object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_NAME; + vol_cb_args.args.get_name.name_size = size; + vol_cb_args.args.get_name.name = name; + vol_cb_args.args.get_name.name_len = &link_name_len; + /* Get the link information */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - name, size, &ret_value) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, (-1), "unable to get link name") + /* Set the return value */ + ret_value = (ssize_t)link_name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_name_by_idx() */ @@ -1519,10 +1623,11 @@ H5L__iterate_api_common(hid_t group_id, H5_index_t idx_type, H5_iter_order_t ord { H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = - (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5I_type_t id_type; /* Type of ID */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1541,10 +1646,18 @@ H5L__iterate_api_common(hid_t group_id, H5_index_t idx_type, H5_iter_order_t ord if (H5VL_setup_self_args(group_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = FALSE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = idx_p; + vol_cb_args.args.iterate.op = op; + vol_cb_args.args.iterate.op_data = op_data; + /* Iterate over the links */ - if ((ret_value = H5VL_link_specific(*vol_obj_ptr, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - token_ptr, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, op, - op_data)) < 0) + if ((ret_value = H5VL_link_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + token_ptr)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1663,9 +1776,10 @@ herr_t H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hLI*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); @@ -1696,9 +1810,18 @@ H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H loc_params.loc_data.loc_by_name.name = group_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = FALSE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = idx_p; + vol_cb_args.args.iterate.op = op; + vol_cb_args.args.iterate.op_data = op_data; + /* Iterate over the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1736,10 +1859,11 @@ done: herr_t H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5I_type_t id_type; /* Type of ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIoLI*x", group_id, idx_type, order, op, op_data); @@ -1763,9 +1887,18 @@ H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterat if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = TRUE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = NULL; + vol_cb_args.args.iterate.op = op; + vol_cb_args.args.iterate.op_data = op_data; + /* Iterate over the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -1804,9 +1937,10 @@ herr_t H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIoLI*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); @@ -1837,9 +1971,18 @@ H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ loc_params.loc_data.loc_by_name.name = group_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = TRUE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = NULL; + vol_cb_args.args.iterate.op = op; + vol_cb_args.args.iterate.op_data = op_data; + /* Visit the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: diff --git a/src/H5Ldeprec.c b/src/H5Ldeprec.c index df4c384..01e77f9 100644 --- a/src/H5Ldeprec.c +++ b/src/H5Ldeprec.c @@ -141,12 +141,13 @@ herr_t H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate1_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hLi*x", group_id, idx_type, order, idx_p, op, op_data); @@ -181,10 +182,18 @@ H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t shim_data.real_op = op; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = FALSE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = idx_p; + vol_cb_args.args.iterate.op = H5L__iterate2_shim; + vol_cb_args.args.iterate.op_data = &shim_data; + /* Iterate over the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, - H5L__iterate2_shim, (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -219,11 +228,12 @@ herr_t H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hLi*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); @@ -265,10 +275,18 @@ H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H shim_data.real_op = op; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = FALSE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = idx_p; + vol_cb_args.args.iterate.op = H5L__iterate2_shim; + vol_cb_args.args.iterate.op_data = &shim_data; + /* Iterate over the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, H5L__iterate2_shim, - (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -293,11 +311,12 @@ done: herr_t H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_info2_t linfo2; /* New-style link info */ - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); @@ -310,12 +329,13 @@ H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t l if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.obj_type = H5I_get_type(loc_id); loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - /* get the location object */ + /* Get the location object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") @@ -326,9 +346,12 @@ H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t l HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lget_info1 is only meant to be used with the native VOL connector") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_INFO; + vol_cb_args.args.get_info.linfo = &linfo2; + /* Get the link information */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &linfo2) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") /* Copy the new-style members into the old-style struct */ @@ -376,11 +399,12 @@ herr_t H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info1_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_info2_t linfo2; /* New-style link info */ - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_link_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id); @@ -397,6 +421,7 @@ H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up location struct */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; @@ -405,7 +430,7 @@ H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* get the location object */ + /* Get the location object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") @@ -416,9 +441,12 @@ H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lget_info_by_idx1 is only meant to be used with the native VOL connector") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_GET_INFO; + vol_cb_args.args.get_info.linfo = &linfo2; + /* Get the link information */ - if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &linfo2) < 0) + if (H5VL_link_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") /* Copy the new-style members into the old-style struct */ @@ -479,12 +507,13 @@ done: herr_t H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIoLi*x", group_id, idx_type, order, op, op_data); @@ -519,10 +548,18 @@ H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterat shim_data.real_op = op; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = TRUE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = NULL; + vol_cb_args.args.iterate.op = H5L__iterate2_shim; + vol_cb_args.args.iterate.op_data = &shim_data; + /* Iterate over the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, - (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -563,11 +600,12 @@ herr_t H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_link_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIoLi*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); @@ -609,10 +647,18 @@ H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ shim_data.real_op = op; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_ITER; + vol_cb_args.args.iterate.recursive = TRUE; + vol_cb_args.args.iterate.idx_type = idx_type; + vol_cb_args.args.iterate.order = order; + vol_cb_args.args.iterate.idx_p = NULL; + vol_cb_args.args.iterate.op = H5L__iterate2_shim; + vol_cb_args.args.iterate.op_data = &shim_data; + /* Visit the links */ - if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, - (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: diff --git a/src/H5Ldevelop.h b/src/H5Ldevelop.h new file mode 100644 index 0000000..43ed7de --- /dev/null +++ b/src/H5Ldevelop.h @@ -0,0 +1,314 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5L (link) developer + * support routines. + */ + +#ifndef _H5Ldevelop_H +#define _H5Ldevelop_H + +/* Include package's public header */ +#include "H5Lpublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/** + * \brief Current version of the H5L_class_t struct + */ +#define H5L_LINK_CLASS_T_VERS 1 + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* The H5L_class_t struct can be used to override the behavior of a + * "user-defined" link class. Users should populate the struct with callback + * functions defined below. + */ +/* Callback prototypes for user-defined links */ +/** + * \brief Link creation callback + */ +typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, const void *lnkdata, + size_t lnkdata_size, hid_t lcpl_id); +/** + * \brief Callback for link move + */ +typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, + size_t lnkdata_size); +/** + * \brief Callback for link copy + */ +typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, + size_t lnkdata_size); +/** + * \brief Callback during link traversal + */ +typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, + size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); +/** + * \brief Callback for link deletion + */ +typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, const void *lnkdata, + size_t lnkdata_size); +/** + * \brief Callback for querying the link. + * + * Returns the size of the buffer needed. + */ +typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, size_t lnkdata_size, + void *buf /*out*/, size_t buf_size); + +/** + * \brief Link prototype + * + * The H5L_class_t struct can be used to override the behavior of a + * "user-defined" link class. Users should populate the struct with callback + * functions defined elsewhere. + */ +//! +typedef struct { + int version; /**< Version number of this struct */ + H5L_type_t id; /**< Link type ID */ + const char * comment; /**< Comment for debugging */ + H5L_create_func_t create_func; /**< Callback during link creation */ + H5L_move_func_t move_func; /**< Callback after moving link */ + H5L_copy_func_t copy_func; /**< Callback after copying link */ + H5L_traverse_func_t trav_func; /**< Callback during link traversal */ + H5L_delete_func_t del_func; /**< Callback for link deletion */ + H5L_query_func_t query_func; /**< Callback for queries */ +} H5L_class_t; +//! + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup H5LA + * + * \brief Registers a user-defined link class or changes behavior of an + * existing class + * + * \param[in] cls Pointer to a buffer containing the struct describing the + * user-defined link class + * + * \return \herr_t + * + * \details H5Lregister() registers a class of user-defined links, or changes + * the behavior of an existing class. + * + * \p cls is a pointer to a buffer containing a copy of the + * H5L_class_t struct. This struct is defined in H5Lpublic.h as + * follows: + * \snippet this H5L_class_t_snip + * + * The class definition passed with \p cls must include at least the + * following: + * \li An H5L_class_t version (which should be #H5L_LINK_CLASS_T_VERS) + * \li A link class identifier, \c class_id + * \li A traversal function, \c trav_func + * + * Remaining \c struct members are optional and may be passed as NULL. + * + * The link class passed in \c class_id must be in the user-definable + * range between #H5L_TYPE_UD_MIN and #H5L_TYPE_UD_MAX + * (see the table below) and will override + * any existing link class with that identifier. + * + * As distributed, valid values of \c class_id used in HDF5 include + * the following (defined in H5Lpublic.h): + * \link_types + * + * The hard and soft link class identifiers cannot be modified or + * reassigned, but the external link class is implemented as an + * example in the user-definable link class identifier range. + * H5Lregister() is used to register additional link classes. It could + * also be used to modify the behavior of the external link class, + * though that is not recommended. + * + * The following table summarizes existing link types and values and + * the reserved and user-definable link class identifier value ranges. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Link class identifier or Value rangeDescriptionLink class or label
0 to 63Reserved range
64 to 255User-definable range
64Minimum user-defined value#H5L_TYPE_UD_MIN
64External link#H5L_TYPE_EXTERNAL
255Maximum user-defined value#H5L_TYPE_UD_MAX
255Maximum value#H5L_TYPE_MAX
-1Error#H5L_TYPE_ERROR
+ * + * Note that HDF5 internally registers user-defined link classes only + * by the numeric value of the link class identifier. An application, + * on the other hand, will generally use a name for a user-defined + * class, if for no other purpose than as a variable name. Assume, + * for example, that a complex link type is registered with the link + * class identifier 73 and that the code includes the following + * assignment: + * \code + * H5L_TYPE_COMPLEX_A = 73 + * \endcode + * The application can refer to the link class with a term, + * \c H5L_TYPE_COMPLEX_A, that conveys meaning to a human reviewing + * the code, while HDF5 recognizes it by the more cryptic numeric + * identifier, 73. + * + * \attention Important details and considerations include the following: + * \li If you plan to distribute files or software with a + * user-defined link class, please contact the Help Desk at + * The HDF Group to help prevent collisions between \c class_id + * values. See below. + * \li As distributed with HDF5, the external link class is + * implemented as an example of a user-defined link class with + * #H5L_TYPE_EXTERNAL equal to #H5L_TYPE_UD_MIN. \c class_id in + * the H5L_class_t \c struct must not equal #H5L_TYPE_UD_MIN + * unless you intend to overwrite or modify the behavior of + * external links. + * \li H5Lregister() can be used only with link class identifiers + * in the user-definable range (see table above). + * \li The hard and soft links defined by the HDF5 library, + * #H5L_TYPE_HARD and #H5L_TYPE_SOFT, reside in the reserved + * range below #H5L_TYPE_UD_MIN and cannot be redefined or + * modified. + * \li H5Lis_registered() can be used to determine whether a desired + * link class identifier is available. \Emph{Note that this + * function will tell you only whether the link class identifier + * has been registered with the installed copy of HDF5; it + * cannot tell you whether the link class has been registered + * with The HDF Group.} + * \li #H5L_TYPE_MAX is the maximum allowed value for a link type + * identifier. + * \li #H5L_TYPE_UD_MIN equals #H5L_TYPE_EXTERNAL. + * \li #H5L_TYPE_UD_MAX equals #H5L_TYPE_MAX. + * \li #H5L_TYPE_ERROR indicates that an error has occurred. + * + * \note \Bold{Registration with The HDF Group:}\n + * There are sometimes reasons to take a broader approach to registering + * a user-defined link class than just invoking H5Lregister(). For + * example: + * \li A user-defined link class is intended for use across an + * organization, among collaborators, or across a community of users. + * \li An application or library overlying HDF5 invokes a user-defined + * link class that must be shipped with the software. + * \li Files are distributed that make use of a user-defined link class. + * \li Or simply, a specific user-defined link class is thought to be + * widely useful. + * + * In such cases, you are encouraged to register that link class with + * The HDF Group's Helpdesk. The HDF Group maintains a registry of known + * user-defined link classes and tracks the selected link class + * identifiers. This registry is intended to reduce the risk of + * collisions between \c class_id values and to help coordinate the use + * of specialized link classes. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lregister(const H5L_class_t *cls); +/** + * \ingroup H5LA + * + * \brief Unregisters a class of user-defined links + * + * \param[in] id User-defined link class identifier + * + * \return \herr_t + * + * \details H5Lunregister() unregisters a class of user-defined links, + * preventing them from being traversed, queried, moved, etc. + * + * \note A link class can be re-registered using H5Lregister(). + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lunregister(H5L_type_t id); + +#ifdef __cplusplus +} +#endif + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* Previous versions of the H5L_class_t struct */ +#define H5L_LINK_CLASS_T_VERS_0 0 + +/** Callback during link traversal */ +typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, + size_t lnkdata_size, hid_t lapl_id); + +/** User-defined link types */ +typedef struct { + int version; /**< Version number of this struct */ + H5L_type_t id; /**< Link type ID */ + const char * comment; /**< Comment for debugging */ + H5L_create_func_t create_func; /**< Callback during link creation */ + H5L_move_func_t move_func; /**< Callback after moving link */ + H5L_copy_func_t copy_func; /**< Callback after copying link */ + H5L_traverse_0_func_t trav_func; /**< Callback during link traversal */ + H5L_delete_func_t del_func; /**< Callback for link deletion */ + H5L_query_func_t query_func; /**< Callback for queries */ +} H5L_class_0_t; + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +#endif /* _H5Ldevelop_H */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index eccd2c6..2f7c7eb 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -173,30 +173,30 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, cons /* Make callback if it exists */ if (cb_info.func) { - const char *parent_file_name; /* Parent file name */ - ssize_t group_name_len; /* Length of parent group name */ + const char *parent_file_name; /* Parent file name */ + size_t group_name_len = 0; /* Length of parent group name */ /* Get parent file name */ parent_file_name = H5F_OPEN_NAME(loc.oloc->file); /* Query length of parent group name */ - if ((group_name_len = H5G_get_name(&loc, NULL, (size_t)0, NULL)) < 0) + if (H5G_get_name(&loc, NULL, (size_t)0, &group_name_len, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve length of group name") /* Account for null terminator */ group_name_len++; /* Check if we need to allocate larger buffer */ - if ((size_t)group_name_len > sizeof(local_group_name)) { - if (NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) + if (group_name_len > sizeof(local_group_name)) { + if (NULL == (parent_group_name = (char *)H5MM_malloc(group_name_len))) HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, - "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) + "can't allocate buffer to hold group name, group_name_len = %zu", group_name_len) } /* end if */ else parent_group_name = local_group_name; /* Get parent group name */ - if (H5G_get_name(&loc, parent_group_name, (size_t)group_name_len, NULL) < 0) + if (H5G_get_name(&loc, parent_group_name, group_name_len, NULL, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve group name") /* Make callback */ diff --git a/src/H5Lint.c b/src/H5Lint.c index a8e9ba2..346c37d 100644 --- a/src/H5Lint.c +++ b/src/H5Lint.c @@ -47,6 +47,50 @@ typedef struct { H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gi_t; +/* User data for path traversal routine for getting link value by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of user buffer */ + + /* Out */ + void *buf; /* User buffer */ +} H5L_trav_gvbi_t; + +/* User data for path traversal routine for getting link info by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + + /* Out */ + H5L_info2_t *linfo; /* Buffer to return to user */ +} H5L_trav_gibi_t; + +/* User data for path traversal routine for removing link by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ +} H5L_trav_rmbi_t; + +/* User data for path traversal routine for getting name by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of name buffer */ + + /* Out */ + char * name; /* Buffer to return name to user */ + size_t name_len; /* Length of full name */ +} H5L_trav_gnbi_t; + /* User data for path traversal callback to creating a link */ typedef struct { H5F_t * file; /* Pointer to the file */ @@ -2012,8 +2056,8 @@ H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if ((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, - udata->name, udata->size)) < 0) + if (H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, udata->name, + udata->size, &udata->name_len) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") done: @@ -2034,18 +2078,19 @@ done: * *------------------------------------------------------------------------- */ -ssize_t +herr_t H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, char *name /*out*/, size_t size) + hsize_t n, char *name /*out*/, size_t size, size_t *link_name_len) { - H5L_trav_gnbi_t udata; /* User data for callback */ - ssize_t ret_value = FAIL; /* Return value */ + H5L_trav_gnbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(loc); HDassert(group_name && *group_name); + HDassert(link_name_len); /* Set up user data for callback */ udata.idx_type = idx_type; @@ -2053,7 +2098,7 @@ H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t id udata.n = n; udata.name = name; udata.size = size; - udata.name_len = -1; + udata.name_len = 0; /* Traverse the group hierarchy to locate the link to get name of */ if (H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < @@ -2061,7 +2106,7 @@ H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t id HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get name") /* Set the return value */ - ret_value = udata.name_len; + *link_name_len = udata.name_len; done: FUNC_LEAVE_NOAPI(ret_value) @@ -2104,9 +2149,9 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t /* Expand soft or external link, if requested */ if ((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) || (H5L_TYPE_EXTERNAL == src_lnk->type && cpy_info->expand_ext_link)) { - H5G_loc_t lnk_grp_loc; /* Group location holding link */ - H5G_name_t lnk_grp_path; /* Path for link */ - htri_t tar_exists; /* Whether the target object exists */ + H5G_loc_t lnk_grp_loc; /* Group location holding link */ + H5G_name_t lnk_grp_path; /* Path for link */ + hbool_t tar_exists = FALSE; /* Whether the target object exists */ /* Set up group location for link */ H5G_name_reset(&lnk_grp_path); @@ -2114,7 +2159,7 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ /* Check if the target object exists */ - if ((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) + if (H5G_loc_exists(&lnk_grp_loc, src_lnk->name, &tar_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to check if target object exists") if (tar_exists) { diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index 7057e30..36a4d12 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -53,26 +53,27 @@ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5L__create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, - const char *link_name, hid_t lcpl_id); -H5_DLL herr_t H5L__create_soft(const char *target_path, const H5G_loc_t *cur_loc, const char *cur_name, - hid_t lcpl_id); -H5_DLL herr_t H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, - size_t ud_data_size, H5L_type_t type, hid_t lcpl_id); -H5_DLL herr_t H5L__exists(const H5G_loc_t *loc, const char *name, hbool_t *exists); -H5_DLL herr_t H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/); -H5_DLL ssize_t H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size); -H5_DLL herr_t H5L__get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size); -H5_DLL herr_t H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size); -H5_DLL herr_t H5L__move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, - const char *dst_name, hbool_t copy_flag, hid_t lcpl_id); -H5_DLL herr_t H5L__delete(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, - H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); +H5_DLL herr_t H5L__create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, + const char *link_name, hid_t lcpl_id); +H5_DLL herr_t H5L__create_soft(const char *target_path, const H5G_loc_t *cur_loc, const char *cur_name, + hid_t lcpl_id); +H5_DLL herr_t H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, + size_t ud_data_size, H5L_type_t type, hid_t lcpl_id); +H5_DLL herr_t H5L__exists(const H5G_loc_t *loc, const char *name, hbool_t *exists); +H5_DLL herr_t H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/); +H5_DLL herr_t H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, + size_t *name_len); +H5_DLL herr_t H5L__get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size); +H5_DLL herr_t H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size); +H5_DLL herr_t H5L__move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id); +H5_DLL herr_t H5L__delete(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, + H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); #endif /* H5Lpkg_H */ diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index b114c17..98e3051 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -18,8 +18,9 @@ #ifndef H5Lprivate_H #define H5Lprivate_H -/* Include package's public header */ +/* Include package's public headers */ #include "H5Lpublic.h" +#include "H5Ldevelop.h" /* Private headers needed by this file */ #include "H5Gprivate.h" /* Groups */ @@ -51,50 +52,6 @@ /* Library Private Typedefs */ /****************************/ -/* User data for path traversal routine for getting link value by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of user buffer */ - - /* Out */ - void *buf; /* User buffer */ -} H5L_trav_gvbi_t; - -/* User data for path traversal routine for getting link info by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - - /* Out */ - H5L_info2_t *linfo; /* Buffer to return to user */ -} H5L_trav_gibi_t; - -/* User data for path traversal routine for getting name by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of name buffer */ - - /* Out */ - char * name; /* Buffer to return name to user */ - ssize_t name_len; /* Length of full name */ -} H5L_trav_gnbi_t; - -/* User data for path traversal routine for removing link by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ -} H5L_trav_rmbi_t; - /* Structure for external link traversal callback property */ typedef struct H5L_elink_cb_t { H5L_elink_traverse_t func; diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 5274649..f665526 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -46,11 +46,6 @@ */ #define H5L_SAME_LOC 0 /* (hid_t) */ -/** - * \brief Current version of the H5L_class_t struct - */ -#define H5L_LINK_CLASS_T_VERS 1 - #ifdef __cplusplus extern "C" { #endif @@ -105,65 +100,6 @@ typedef struct { } H5L_info2_t; //! -/* The H5L_class_t struct can be used to override the behavior of a - * "user-defined" link class. Users should populate the struct with callback - * functions defined below. - */ -/* Callback prototypes for user-defined links */ -/** - * \brief Link creation callback - */ -typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, const void *lnkdata, - size_t lnkdata_size, hid_t lcpl_id); -/** - * \brief Callback for link move - */ -typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, - size_t lnkdata_size); -/** - * \brief Callback for link copy - */ -typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, - size_t lnkdata_size); -/** - * \brief Callback during link traversal - */ -typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, - size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); -/** - * \brief Callback for link deletion - */ -typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, const void *lnkdata, - size_t lnkdata_size); -/** - * \brief Callback for querying the link. - * - * Returns the size of the buffer needed. - */ -typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, size_t lnkdata_size, - void *buf /*out*/, size_t buf_size); - -/** - * \brief Link prototype - * - * The H5L_class_t struct can be used to override the behavior of a - * "user-defined" link class. Users should populate the struct with callback - * functions defined elsewhere. - */ -//! -typedef struct { - int version; /**< Version number of this struct */ - H5L_type_t id; /**< Link type ID */ - const char * comment; /**< Comment for debugging */ - H5L_create_func_t create_func; /**< Callback during link creation */ - H5L_move_func_t move_func; /**< Callback after moving link */ - H5L_copy_func_t copy_func; /**< Callback after copying link */ - H5L_traverse_func_t trav_func; /**< Callback during link traversal */ - H5L_delete_func_t del_func; /**< Callback for link deletion */ - H5L_query_func_t query_func; /**< Callback for queries */ -} H5L_class_t; -//! - /** * \brief Prototype for H5Literate2(), H5Literate_by_name2() operator * @@ -1250,179 +1186,6 @@ H5_DLL herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t /** * \ingroup H5LA * - * \brief Registers a user-defined link class or changes behavior of an - * existing class - * - * \param[in] cls Pointer to a buffer containing the struct describing the - * user-defined link class - * - * \return \herr_t - * - * \details H5Lregister() registers a class of user-defined links, or changes - * the behavior of an existing class. - * - * \p cls is a pointer to a buffer containing a copy of the - * H5L_class_t struct. This struct is defined in H5Lpublic.h as - * follows: - * \snippet this H5L_class_t_snip - * - * The class definition passed with \p cls must include at least the - * following: - * \li An H5L_class_t version (which should be #H5L_LINK_CLASS_T_VERS) - * \li A link class identifier, \c class_id - * \li A traversal function, \c trav_func - * - * Remaining \c struct members are optional and may be passed as NULL. - * - * The link class passed in \c class_id must be in the user-definable - * range between #H5L_TYPE_UD_MIN and #H5L_TYPE_UD_MAX - * (see the table below) and will override - * any existing link class with that identifier. - * - * As distributed, valid values of \c class_id used in HDF5 include - * the following (defined in H5Lpublic.h): - * \link_types - * - * The hard and soft link class identifiers cannot be modified or - * reassigned, but the external link class is implemented as an - * example in the user-definable link class identifier range. - * H5Lregister() is used to register additional link classes. It could - * also be used to modify the behavior of the external link class, - * though that is not recommended. - * - * The following table summarizes existing link types and values and - * the reserved and user-definable link class identifier value ranges. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Link class identifier or Value rangeDescriptionLink class or label
0 to 63Reserved range
64 to 255User-definable range
64Minimum user-defined value#H5L_TYPE_UD_MIN
64External link#H5L_TYPE_EXTERNAL
255Maximum user-defined value#H5L_TYPE_UD_MAX
255Maximum value#H5L_TYPE_MAX
-1Error#H5L_TYPE_ERROR
- * - * Note that HDF5 internally registers user-defined link classes only - * by the numeric value of the link class identifier. An application, - * on the other hand, will generally use a name for a user-defined - * class, if for no other purpose than as a variable name. Assume, - * for example, that a complex link type is registered with the link - * class identifier 73 and that the code includes the following - * assignment: - * \code - * H5L_TYPE_COMPLEX_A = 73 - * \endcode - * The application can refer to the link class with a term, - * \c H5L_TYPE_COMPLEX_A, that conveys meaning to a human reviewing - * the code, while HDF5 recognizes it by the more cryptic numeric - * identifier, 73. - * - * \attention Important details and considerations include the following: - * \li If you plan to distribute files or software with a - * user-defined link class, please contact the Help Desk at - * The HDF Group to help prevent collisions between \c class_id - * values. See below. - * \li As distributed with HDF5, the external link class is - * implemented as an example of a user-defined link class with - * #H5L_TYPE_EXTERNAL equal to #H5L_TYPE_UD_MIN. \c class_id in - * the H5L_class_t \c struct must not equal #H5L_TYPE_UD_MIN - * unless you intend to overwrite or modify the behavior of - * external links. - * \li H5Lregister() can be used only with link class identifiers - * in the user-definable range (see table above). - * \li The hard and soft links defined by the HDF5 library, - * #H5L_TYPE_HARD and #H5L_TYPE_SOFT, reside in the reserved - * range below #H5L_TYPE_UD_MIN and cannot be redefined or - * modified. - * \li H5Lis_registered() can be used to determine whether a desired - * link class identifier is available. \Emph{Note that this - * function will tell you only whether the link class identifier - * has been registered with the installed copy of HDF5; it - * cannot tell you whether the link class has been registered - * with The HDF Group.} - * \li #H5L_TYPE_MAX is the maximum allowed value for a link type - * identifier. - * \li #H5L_TYPE_UD_MIN equals #H5L_TYPE_EXTERNAL. - * \li #H5L_TYPE_UD_MAX equals #H5L_TYPE_MAX. - * \li #H5L_TYPE_ERROR indicates that an error has occurred. - * - * \note \Bold{Registration with The HDF Group:}\n - * There are sometimes reasons to take a broader approach to registering - * a user-defined link class than just invoking H5Lregister(). For - * example: - * \li A user-defined link class is intended for use across an - * organization, among collaborators, or across a community of users. - * \li An application or library overlying HDF5 invokes a user-defined - * link class that must be shipped with the software. - * \li Files are distributed that make use of a user-defined link class. - * \li Or simply, a specific user-defined link class is thought to be - * widely useful. - * - * In such cases, you are encouraged to register that link class with - * The HDF Group's Helpdesk. The HDF Group maintains a registry of known - * user-defined link classes and tracks the selected link class - * identifiers. This registry is intended to reduce the risk of - * collisions between \c class_id values and to help coordinate the use - * of specialized link classes. - * - * \since 1.8.0 - * - */ -H5_DLL herr_t H5Lregister(const H5L_class_t *cls); -/** - * \ingroup H5LA - * - * \brief Unregisters a class of user-defined links - * - * \param[in] id User-defined link class identifier - * - * \return \herr_t - * - * \details H5Lunregister() unregisters a class of user-defined links, - * preventing them from being traversed, queried, moved, etc. - * - * \note A link class can be re-registered using H5Lregister(). - * - * \since 1.8.0 - * - */ -H5_DLL herr_t H5Lunregister(H5L_type_t id); -/** - * \ingroup H5LA - * * \brief Determines whether a class of user-defined links is registered * * \param[in] id User-defined link class identifier @@ -1647,9 +1410,6 @@ H5_DLL herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hi /* Macros */ -/* Previous versions of the H5L_class_t struct */ -#define H5L_LINK_CLASS_T_VERS_0 0 - /* Typedefs */ //! @@ -1668,23 +1428,6 @@ typedef struct { } H5L_info1_t; //! -/** Callback during link traversal */ -typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, - size_t lnkdata_size, hid_t lapl_id); - -/** User-defined link types */ -typedef struct { - int version; /**< Version number of this struct */ - H5L_type_t id; /**< Link type ID */ - const char * comment; /**< Comment for debugging */ - H5L_create_func_t create_func; /**< Callback during link creation */ - H5L_move_func_t move_func; /**< Callback after moving link */ - H5L_copy_func_t copy_func; /**< Callback after copying link */ - H5L_traverse_0_func_t trav_func; /**< Callback during link traversal */ - H5L_delete_func_t del_func; /**< Callback for link deletion */ - H5L_query_func_t query_func; /**< Callback for queries */ -} H5L_class_0_t; - /** Prototype for H5Literate1() / H5Literate_by_name1() operator */ //! typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_t *info, void *op_data); diff --git a/src/H5M.c b/src/H5M.c index 552d3fc..c7d1bc9 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -211,15 +211,20 @@ H5M_term_package(void) static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj, void **request) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(map_vol_obj); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_MAP_CLOSE; + vol_cb_args.args = NULL; + /* Close the map */ - if (H5VL_optional(map_vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, request) < 0) + if (H5VL_optional(map_vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, request) < 0) HGOTO_ERROR(H5E_MAP, H5E_CLOSEERROR, FAIL, "unable to close map"); /* Free the VOL object */ @@ -251,8 +256,9 @@ H5M__create_api_common(hid_t loc_id, const char *name, hid_t key_type_id, hid_t H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -274,14 +280,24 @@ H5M__create_api_common(hid_t loc_id, const char *name, hid_t key_type_id, hid_t else if (TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "mcpl_id is not a map create property list ID") - /* Set up object access arguments */ - if (H5VL_setup_acc_args(loc_id, H5P_CLS_MACC, TRUE, &mapl_id, vol_obj_ptr, &loc_params) < 0) + /* Set up VOL callback arguments */ + if (H5VL_setup_acc_args(loc_id, H5P_CLS_MACC, TRUE, &mapl_id, vol_obj_ptr, &map_args.create.loc_params) < + 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") + map_args.create.name = name; + map_args.create.lcpl_id = lcpl_id; + map_args.create.key_type_id = key_type_id; + map_args.create.val_type_id = val_type_id; + map_args.create.mcpl_id = mcpl_id; + map_args.create.mapl_id = mapl_id; + map_args.create.map = NULL; + vol_cb_args.op_type = H5VL_MAP_CREATE; + vol_cb_args.args = &map_args; /* Create the map */ - if (H5VL_optional(*vol_obj_ptr, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, token_ptr, &loc_params, name, - lcpl_id, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) + if (H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") + map = map_args.create.map; /* Get an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, (*vol_obj_ptr)->connector, TRUE)) < 0) @@ -289,9 +305,14 @@ H5M__create_api_common(hid_t loc_id, const char *name, hid_t key_type_id, hid_t done: /* Cleanup on failure */ - if (H5I_INVALID_HID == ret_value) - if (map && H5VL_optional(*vol_obj_ptr, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) { + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_MAP_CLOSE; + vol_cb_args.args = NULL; + + if (map && H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5M__create_api_common() */ @@ -407,10 +428,11 @@ done: hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id, hid_t mapl_id) { - void * map = NULL; /* map object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * map = NULL; /* map object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "iiiii", loc_id, key_type_id, val_type_id, mcpl_id, mapl_id); @@ -430,13 +452,24 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + + /* Set up VOL callback arguments */ + map_args.create.loc_params.type = H5VL_OBJECT_BY_SELF; + map_args.create.loc_params.obj_type = H5I_get_type(loc_id); + map_args.create.name = NULL; + map_args.create.lcpl_id = H5P_LINK_CREATE_DEFAULT; + map_args.create.key_type_id = key_type_id; + map_args.create.val_type_id = val_type_id; + map_args.create.mcpl_id = mcpl_id; + map_args.create.mapl_id = mapl_id; + map_args.create.map = NULL; + vol_cb_args.op_type = H5VL_MAP_CREATE; + vol_cb_args.args = &map_args; /* Create the map */ - if (H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, NULL, - H5P_LINK_CREATE_DEFAULT, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) + if (H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") + map = map_args.create.map; /* Get an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) @@ -444,9 +477,14 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id done: /* Cleanup on failure */ - if (H5I_INVALID_HID == ret_value) - if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) { + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_MAP_CLOSE; + vol_cb_args.args = NULL; + + if (map && H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Mcreate_anon() */ @@ -470,8 +508,9 @@ H5M__open_api_common(hid_t loc_id, const char *name, hid_t mapl_id, void **token H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -481,14 +520,20 @@ H5M__open_api_common(hid_t loc_id, const char *name, hid_t mapl_id, void **token if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - /* Set up object access arguments */ - if (H5VL_setup_acc_args(loc_id, H5P_CLS_MACC, FALSE, &mapl_id, vol_obj_ptr, &loc_params) < 0) + /* Set up VOL callback arguments */ + if (H5VL_setup_acc_args(loc_id, H5P_CLS_MACC, FALSE, &mapl_id, vol_obj_ptr, &map_args.open.loc_params) < + 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") + map_args.open.name = name; + map_args.open.mapl_id = mapl_id; + map_args.open.map = NULL; + vol_cb_args.op_type = H5VL_MAP_OPEN; + vol_cb_args.args = &map_args; /* Open the map */ - if (H5VL_optional(*vol_obj_ptr, H5VL_MAP_OPEN, H5P_DATASET_XFER_DEFAULT, token_ptr, &loc_params, name, - mapl_id, &map) < 0) + if (H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map") + map = map_args.create.map; /* Register an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, (*vol_obj_ptr)->connector, TRUE)) < 0) @@ -496,9 +541,14 @@ H5M__open_api_common(hid_t loc_id, const char *name, hid_t mapl_id, void **token done: /* Cleanup on failure */ - if (H5I_INVALID_HID == ret_value) - if (map && H5VL_optional(*vol_obj_ptr, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) { + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_MAP_CLOSE; + vol_cb_args.args = NULL; + + if (map && H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5M__open_api_common() */ @@ -521,9 +571,7 @@ done: hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) { - void * map = NULL; /* map object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, mapl_id); @@ -533,11 +581,6 @@ H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) HGOTO_ERROR(H5E_MAP, H5E_CANTCREATE, H5I_INVALID_HID, "unable to open map synchronously") done: - /* Cleanup on failure */ - if (H5I_INVALID_HID == ret_value) - if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") - FUNC_LEAVE_API(ret_value) } /* end H5Mopen() */ @@ -697,8 +740,10 @@ done: hid_t H5Mget_key_type(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Map structure */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); @@ -707,10 +752,18 @@ H5Mget_key_type(hid_t map_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") - /* get the datatype */ - if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_KEY_TYPE, - &ret_value) < 0) - HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + /* Set up VOL callback arguments */ + map_args.get.get_type = H5VL_MAP_GET_KEY_TYPE; + map_args.get.args.get_key_type.type_id = H5I_INVALID_HID; + vol_cb_args.op_type = H5VL_MAP_GET; + vol_cb_args.args = &map_args; + + /* Get the key datatype */ + if (H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get key datatype") + + /* Set return value */ + ret_value = map_args.get.args.get_key_type.type_id; done: FUNC_LEAVE_API(ret_value) @@ -732,8 +785,10 @@ done: hid_t H5Mget_val_type(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Map structure */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); @@ -742,10 +797,18 @@ H5Mget_val_type(hid_t map_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") - /* get the datatype */ - if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_VAL_TYPE, - &ret_value) < 0) - HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + /* Set up VOL callback arguments */ + map_args.get.get_type = H5VL_MAP_GET_VAL_TYPE; + map_args.get.args.get_val_type.type_id = H5I_INVALID_HID; + vol_cb_args.op_type = H5VL_MAP_GET; + vol_cb_args.args = &map_args; + + /* Get the value datatype */ + if (H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get value datatype") + + /* Set return value */ + ret_value = map_args.get.args.get_val_type.type_id; done: FUNC_LEAVE_API(ret_value) @@ -767,8 +830,10 @@ done: hid_t H5Mget_create_plist(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Map structure */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); @@ -777,11 +842,19 @@ H5Mget_create_plist(hid_t map_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + /* Set up VOL callback arguments */ + map_args.get.get_type = H5VL_MAP_GET_MCPL; + map_args.get.args.get_mcpl.mcpl_id = H5I_INVALID_HID; + vol_cb_args.op_type = H5VL_MAP_GET; + vol_cb_args.args = &map_args; + /* Get the map creation property list */ - if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MCPL, - &ret_value) < 0) + if (H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map creation properties") + /* Set return value */ + ret_value = map_args.get.args.get_mcpl.mcpl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_create_plist() */ @@ -805,8 +878,10 @@ done: hid_t H5Mget_access_plist(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Map structure */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); @@ -815,11 +890,19 @@ H5Mget_access_plist(hid_t map_id) if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + /* Set up VOL callback arguments */ + map_args.get.get_type = H5VL_MAP_GET_MAPL; + map_args.get.args.get_mapl.mapl_id = H5I_INVALID_HID; + vol_cb_args.op_type = H5VL_MAP_GET; + vol_cb_args.args = &map_args; + /* Get the map access property list */ - if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MAPL, - &ret_value) < 0) + if (H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") + /* Set return value */ + ret_value = map_args.get.args.get_mapl.mapl_id; + done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_access_plist() */ @@ -839,8 +922,10 @@ done: herr_t H5Mget_count(hid_t map_id, hsize_t *count /*out*/, hid_t dxpl_id) { - H5VL_object_t *vol_obj; /* Map structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Map structure */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("e", "ixi", map_id, count, dxpl_id); @@ -858,9 +943,19 @@ H5Mget_count(hid_t map_id, hsize_t *count /*out*/, hid_t dxpl_id) /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); + /* Set up VOL callback arguments */ + map_args.get.get_type = H5VL_MAP_GET_COUNT; + map_args.get.args.get_count.count = 0; + vol_cb_args.op_type = H5VL_MAP_GET; + vol_cb_args.args = &map_args; + /* Get the number of key-value pairs stored in the map */ - if (H5VL_optional(vol_obj, H5VL_MAP_GET, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_GET_COUNT, count) < 0) - HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") + if (H5VL_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get KV pair count for map") + + /* Set value to return */ + if (count) + *count = map_args.get.args.get_count.count; done: FUNC_LEAVE_API(ret_value) @@ -882,7 +977,9 @@ H5M__put_api_common(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -905,9 +1002,16 @@ H5M__put_api_common(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); + /* Set up VOL callback arguments */ + map_args.put.key_mem_type_id = key_mem_type_id; + map_args.put.key = key; + map_args.put.value_mem_type_id = val_mem_type_id; + map_args.put.value = value; + vol_cb_args.op_type = H5VL_MAP_PUT; + vol_cb_args.args = &map_args; + /* Set the key/value pair */ - if (H5VL_optional(*vol_obj_ptr, H5VL_MAP_PUT, dxpl_id, token_ptr, key_mem_type_id, key, val_mem_type_id, - value) < 0) + if (H5VL_optional(*vol_obj_ptr, &vol_cb_args, dxpl_id, token_ptr) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to put key/value pair") done: @@ -1008,7 +1112,9 @@ H5M__get_api_common(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1031,9 +1137,16 @@ H5M__get_api_common(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); + /* Set up VOL callback arguments */ + map_args.get_val.key_mem_type_id = key_mem_type_id; + map_args.get_val.key = key; + map_args.get_val.value_mem_type_id = val_mem_type_id; + map_args.get_val.value = value; + vol_cb_args.op_type = H5VL_MAP_GET_VAL; + vol_cb_args.args = &map_args; + /* Get the value for the key */ - if (H5VL_optional(*vol_obj_ptr, H5VL_MAP_GET_VAL, dxpl_id, token_ptr, key_mem_type_id, key, - val_mem_type_id, value) < 0) + if (H5VL_optional(*vol_obj_ptr, &vol_cb_args, dxpl_id, token_ptr) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, FAIL, "unable to get value from map") done: @@ -1137,8 +1250,10 @@ done: herr_t H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, hid_t dxpl_id) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*x*bi", map_id, key_mem_type_id, key, exists, dxpl_id); @@ -1160,11 +1275,21 @@ H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); + /* Set up VOL callback arguments */ + map_args.exists.key_mem_type_id = key_mem_type_id; + map_args.exists.key = key; + map_args.exists.exists = FALSE; + vol_cb_args.op_type = H5VL_MAP_EXISTS; + vol_cb_args.args = &map_args; + /* Check if key exists */ - if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_EXISTS, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, - exists)) < 0) + if (H5VL_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, ret_value, "unable to check if key exists") + /* Set value to return */ + if (exists) + *exists = map_args.exists.exists; + done: FUNC_LEAVE_API(ret_value) } /* end H5Mexists() */ @@ -1203,9 +1328,10 @@ done: herr_t H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id) { - H5VL_object_t * vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*hiMI*xi", map_id, idx, key_mem_type_id, op, op_data, dxpl_id); @@ -1229,14 +1355,23 @@ H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(map_id); + /* Set up VOL callback arguments */ + map_args.specific.specific_type = H5VL_MAP_ITER; + map_args.specific.args.iterate.loc_params.type = H5VL_OBJECT_BY_SELF; + map_args.specific.args.iterate.loc_params.obj_type = H5I_get_type(map_id); + map_args.specific.args.iterate.idx = (idx ? *idx : 0); + map_args.specific.args.iterate.op = op; + map_args.specific.args.iterate.op_data = op_data; + vol_cb_args.op_type = H5VL_MAP_SPECIFIC; + vol_cb_args.args = &map_args; /* Iterate over keys */ - if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, - H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) - HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to iterate over keys") + if ((ret_value = H5VL_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL)) < 0) + HERROR(H5E_MAP, H5E_BADITER, "unable to iterate over keys"); + + /* Set value to return */ + if (idx) + *idx = map_args.specific.args.iterate.idx; done: FUNC_LEAVE_API(ret_value) @@ -1277,9 +1412,10 @@ herr_t H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*s*hiMI*xii", loc_id, map_name, idx, key_mem_type_id, op, op_data, dxpl_id, lapl_id); @@ -1307,16 +1443,25 @@ H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_m /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = map_name; - loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Set up VOL callback arguments */ + map_args.specific.specific_type = H5VL_MAP_ITER; + map_args.specific.args.iterate.loc_params.type = H5VL_OBJECT_BY_NAME; + map_args.specific.args.iterate.loc_params.obj_type = H5I_get_type(loc_id); + map_args.specific.args.iterate.loc_params.loc_data.loc_by_name.name = map_name; + map_args.specific.args.iterate.loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + map_args.specific.args.iterate.idx = (idx ? *idx : 0); + map_args.specific.args.iterate.op = op; + map_args.specific.args.iterate.op_data = op_data; + vol_cb_args.op_type = H5VL_MAP_SPECIFIC; + vol_cb_args.args = &map_args; /* Iterate over keys */ - if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, - H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) - HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to ierate over keys") + if ((ret_value = H5VL_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL)) < 0) + HERROR(H5E_MAP, H5E_BADITER, "unable to ierate over keys"); + + /* Set value to return */ + if (idx) + *idx = map_args.specific.args.iterate.idx; done: FUNC_LEAVE_API(ret_value) @@ -1340,9 +1485,10 @@ done: herr_t H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id) { - H5VL_object_t * vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_map_args_t map_args; /* Arguments for map operations */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ii*xi", map_id, key_mem_type_id, key, dxpl_id); @@ -1364,13 +1510,17 @@ H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id) /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(map_id); + /* Set up VOL callback arguments */ + map_args.specific.specific_type = H5VL_MAP_DELETE; + map_args.specific.args.del.loc_params.type = H5VL_OBJECT_BY_SELF; + map_args.specific.args.del.loc_params.obj_type = H5I_get_type(map_id); + map_args.specific.args.del.key_mem_type_id = key_mem_type_id; + map_args.specific.args.del.key = key; + vol_cb_args.op_type = H5VL_MAP_SPECIFIC; + vol_cb_args.args = &map_args; /* Delete the key/value pair */ - if (H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, H5VL_MAP_DELETE, - key_mem_type_id, key) < 0) + if (H5VL_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to delete key/value pair") done: diff --git a/src/H5MF.c b/src/H5MF.c index 17301f7..d1809ca 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -2323,15 +2323,15 @@ done: * Purpose: To retrieve free-space section information for * paged or non-paged aggregation * - * Return: Success: Number of free sections - * Failure: -1 + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi; Dec 2012 * *------------------------------------------------------------------------- */ -ssize_t -H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info) +herr_t +H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info, + size_t *sect_count) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ @@ -2340,9 +2340,9 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ H5F_mem_page_t ty; /* Memory type for iteration */ - ssize_t ret_value = -1; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, (-1)) + FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) /* check args */ HDassert(f); @@ -2404,7 +2404,7 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t if (!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { if (H5MF__open_fstype(f, ty) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't open the free space manager") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't open the free space manager") HDassert(f->shared->fs_man[ty]); fs_started = TRUE; } /* end if */ @@ -2412,7 +2412,7 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t /* Check if there's free space sections of this type */ if (f->shared->fs_man[ty]) if (H5MF__get_free_sects(f, f->shared->fs_man[ty], §_udata, &nums) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get section info for the free space manager") /* Increment total # of sections */ @@ -2421,13 +2421,13 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t /* Close the free space manager of this type, if we started it here */ if (fs_started) if (H5MF__close_fstype(f, ty) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, (-1), "can't close file free space") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, FAIL, "can't close file free space") if ((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) ty = (H5F_mem_page_t)(ty + H5FD_MEM_NTYPES - 2); } /* end for */ - /* Set return value */ - ret_value = (ssize_t)total_sects; + /* Set value to return */ + *sect_count = total_sects; done: /* Reset the ring in the API context */ diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h index 292e85c..65e6e94 100644 --- a/src/H5MFprivate.h +++ b/src/H5MFprivate.h @@ -56,7 +56,8 @@ H5_DLL haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size); H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); H5_DLL herr_t H5MF_try_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); H5_DLL htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size); -H5_DLL ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info); +H5_DLL herr_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info, + size_t *sect_count); /* File 'temporary' space allocation routines */ H5_DLL haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size); diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h index 1a2524e..e62434a 100644 --- a/src/H5Mprivate.h +++ b/src/H5Mprivate.h @@ -21,10 +21,9 @@ #include "H5Mpublic.h" /* Private headers needed by this file */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Zprivate.h" /* Data filters */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 3f6bf01..b3a0903 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -25,6 +25,7 @@ /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" +#include "H5VLconnector.h" /*****************/ /* Public Macros */ @@ -68,6 +69,115 @@ typedef enum H5VL_map_specific_t { typedef herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, void *op_data); //! +/* Parameters for map operations */ +typedef union H5VL_map_args_t { + /* H5VL_MAP_CREATE */ + struct { + H5VL_loc_params_t loc_params; /* Location parameters for object */ + const char * name; /* Name of new map object */ + hid_t lcpl_id; /* Link creation property list for map */ + hid_t key_type_id; /* Datatype for map keys */ + hid_t val_type_id; /* Datatype for map values */ + hid_t mcpl_id; /* Map creation property list */ + hid_t mapl_id; /* Map access property list */ + void * map; /* Pointer to newly created map object (OUT) */ + } create; + + /* H5VL_MAP_OPEN */ + struct { + H5VL_loc_params_t loc_params; /* Location parameters for object */ + const char * name; /* Name of new map object */ + hid_t mapl_id; /* Map access property list */ + void * map; /* Pointer to newly created map object (OUT) */ + } open; + + /* H5VL_MAP_GET_VAL */ + struct { + hid_t key_mem_type_id; /* Memory datatype for key */ + const void *key; /* Pointer to key */ + hid_t value_mem_type_id; /* Memory datatype for value */ + void * value; /* Buffer for value (OUT) */ + } get_val; + + /* H5VL_MAP_EXISTS */ + struct { + hid_t key_mem_type_id; /* Memory datatype for key */ + const void *key; /* Pointer to key */ + hbool_t exists; /* Flag indicating whether key exists in map (OUT) */ + } exists; + + /* H5VL_MAP_PUT */ + struct { + hid_t key_mem_type_id; /* Memory datatype for key */ + const void *key; /* Pointer to key */ + hid_t value_mem_type_id; /* Memory datatype for value */ + const void *value; /* Pointer to value */ + } put; + + /* H5VL_MAP_GET */ + struct { + H5VL_map_get_t get_type; /* 'get' operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_MAP_GET_MAPL */ + struct { + hid_t mapl_id; /* Map access property list ID (OUT) */ + } get_mapl; + + /* H5VL_MAP_GET_MCPL */ + struct { + hid_t mcpl_id; /* Map creation property list ID (OUT) */ + } get_mcpl; + + /* H5VL_MAP_GET_KEY_TYPE */ + struct { + hid_t type_id; /* Datatype ID for map's keys (OUT) */ + } get_key_type; + + /* H5VL_MAP_GET_VAL_TYPE */ + struct { + hid_t type_id; /* Datatype ID for map's values (OUT) */ + } get_val_type; + + /* H5VL_MAP_GET_COUNT */ + struct { + hsize_t count; /* # of KV pairs in map (OUT) */ + } get_count; + } args; + } get; + + /* H5VL_MAP_SPECIFIC */ + struct { + H5VL_map_specific_t specific_type; /* 'specific' operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_MAP_ITER */ + struct { + H5VL_loc_params_t loc_params; /* Location parameters for object */ + hsize_t idx; /* Start/end iteration index (IN/OUT) */ + hid_t key_mem_type_id; /* Memory datatype for key */ + H5M_iterate_t op; /* Iteration callback routine */ + void * op_data; /* Pointer to callback context */ + } iterate; + + /* H5VL_MAP_DELETE */ + struct { + H5VL_loc_params_t loc_params; /* Location parameters for object */ + hid_t key_mem_type_id; /* Memory datatype for key */ + const void * key; /* Pointer to key */ + } del; + } args; + } specific; + + /* H5VL_MAP_OPTIONAL */ + /* Unused */ + + /* H5VL_MAP_CLOSE */ + /* No args */ +} H5VL_map_args_t; + /********************/ /* Public Variables */ /********************/ diff --git a/src/H5O.c b/src/H5O.c index 4876bb0..a1c9c2d 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -70,7 +70,7 @@ static herr_t H5O__copy_api_common(hid_t src_loc_id, const char *src_name, hid_t H5VL_object_t **_vol_obj_ptr); static herr_t H5O__flush_api_common(hid_t obj_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); static herr_t H5O__refresh_api_common(hid_t oid, void **token_ptr, H5VL_object_t **_vol_obj_ptr); -static htri_t H5O__close_check_common(hid_t object_id); +static htri_t H5O__close_check_type(hid_t object_id); /*********************/ /* Package Variables */ @@ -112,7 +112,7 @@ H5O__open_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token /* name is checked in this H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, name, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") /* Open the object */ @@ -239,7 +239,7 @@ H5O__open_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx /* Check args */ /* group_name, idx_type, order are checked in H5VL_setup_idx-args() */ /* Set up object access arguments */ - if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, + if (H5VL_setup_idx_args(loc_id, group_name, idx_type, order, n, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, H5I_INVALID_HID, "can't set object access arguments") @@ -448,6 +448,7 @@ H5O__copy_api_common(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, c /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); + /* Setup and check args */ if (H5VL_setup_loc_args(src_loc_id, &vol_obj1, &loc_params1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments") @@ -616,19 +617,23 @@ H5O__flush_api_common(hid_t obj_id, void **token_ptr, H5VL_object_t **_vol_obj_p H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Check args */ - + /* Setup and check args */ if (H5VL_setup_loc_args(obj_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_FLUSH; + vol_cb_args.args.flush.obj_id = obj_id; + /* Flush the object */ - if (H5VL_object_specific(*vol_obj_ptr, &loc_params, H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, - token_ptr, obj_id) < 0) + if (H5VL_object_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") done: @@ -718,19 +723,23 @@ H5O__refresh_api_common(hid_t oid, void **token_ptr, H5VL_object_t **_vol_obj_pt H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Check args */ - + /* Setup and check args */ if (H5VL_setup_loc_args(oid, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_REFRESH; + vol_cb_args.args.refresh.obj_id = oid; + /* Refresh the object */ - if (H5VL_object_specific(*vol_obj_ptr, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, - token_ptr, oid) < 0) + if (H5VL_object_specific(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") done: @@ -829,12 +838,12 @@ done: herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj1 = NULL; /* object of obj_id */ - H5VL_object_t * vol_obj2 = NULL; /* object of new_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object */ - H5VL_loc_params_t loc_params1; - H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj1 = NULL; /* object of obj_id */ + H5VL_object_t * vol_obj2 = NULL; /* object of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t new_loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*sii", obj_id, new_loc_id, new_name, lcpl_id, lapl_id); @@ -864,36 +873,45 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params1.type = H5VL_OBJECT_BY_SELF; - loc_params1.obj_type = H5I_get_type(obj_id); - - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.obj_type = H5I_get_type(new_loc_id); - loc_params2.loc_data.loc_by_name.name = new_name; - loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + /* Set up new location struct */ + new_loc_params.type = H5VL_OBJECT_BY_NAME; + new_loc_params.obj_type = H5I_get_type(new_loc_id); + new_loc_params.loc_data.loc_by_name.name = new_name; + new_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - if (H5L_SAME_LOC != obj_id) - /* get the location object */ - if (NULL == (vol_obj1 = H5VL_vol_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the first location object */ + if (NULL == (vol_obj1 = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") if (H5L_SAME_LOC != new_loc_id) /* get the location object */ if (NULL == (vol_obj2 = H5VL_vol_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if (vol_obj1 && vol_obj2) - if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + if (vol_obj1 && vol_obj2) { + int same_connector = 0; + + /* Check if both objects are associated with the same VOL connector */ + if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + if (same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + } /* end if */ /* Construct a temporary VOL object */ tmp_vol_obj.data = vol_obj2->data; - tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); + tmp_vol_obj.connector = vol_obj1->connector; + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; + vol_cb_args.args.hard.curr_obj = vol_obj1->data; + vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_SELF; + vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(obj_id); /* Create a link to the object */ - if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, &loc_params1) < 0) + if (H5VL_link_create(&vol_cb_args, &tmp_vol_obj, &new_loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link") done: @@ -923,9 +941,10 @@ done: herr_t H5Oincr_refcount(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); @@ -941,9 +960,13 @@ H5Oincr_refcount(hid_t object_id) if (H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_CHANGE_REF_COUNT; + vol_cb_args.args.change_rc.delta = 1; + /* Change the object's reference count */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, 1) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -973,9 +996,10 @@ done: herr_t H5Odecr_refcount(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); @@ -991,9 +1015,13 @@ H5Odecr_refcount(hid_t object_id) if (H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_CHANGE_REF_COUNT; + vol_cb_args.args.change_rc.delta = -1; + /* Change the object's reference count */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, -1) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -1016,9 +1044,11 @@ done: htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - htri_t ret_value = FAIL; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + hbool_t obj_exists = FALSE; /* Whether object exists */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); @@ -1043,11 +1073,18 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.loc_data.loc_by_name.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_EXISTS; + vol_cb_args.args.exists.exists = &obj_exists; + /* Check if the object exists */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_EXISTS, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) + /* Set return value */ + ret_value = (htri_t)obj_exists; + done: FUNC_LEAVE_API(ret_value) } /* end H5Oexists_by_name() */ @@ -1067,9 +1104,10 @@ done: herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo /*out*/, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixIu", loc_id, oinfo, fields); @@ -1088,9 +1126,13 @@ H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo /*out*/, unsigned fields) if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; + vol_cb_args.args.get_info.oinfo = oinfo; + vol_cb_args.args.get_info.fields = fields; + /* Retrieve the object's information */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - oinfo, fields) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: @@ -1114,8 +1156,9 @@ H5O__get_info_by_name_api_common(hid_t loc_id, const char *name, H5O_info2_t *oi H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters for object access */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1127,12 +1170,16 @@ H5O__get_info_by_name_api_common(hid_t loc_id, const char *name, H5O_info2_t *oi /* "name" is checked in H5VL_setup_name_args() */ /* Set up object access arguments */ - if (H5VL_setup_name_args(loc_id, name, H5P_CLS_LACC, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) + if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, vol_obj_ptr, &loc_params) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set object access arguments") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; + vol_cb_args.args.get_info.oinfo = oinfo; + vol_cb_args.args.get_info.fields = fields; + /* Retrieve the object's information */ - if (H5VL_object_get(*vol_obj_ptr, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, token_ptr, - oinfo, fields) < 0) + if (H5VL_object_get(*vol_obj_ptr, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: @@ -1230,9 +1277,10 @@ herr_t H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo /*out*/, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIohxIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); @@ -1253,6 +1301,7 @@ H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location struct fields */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; @@ -1265,9 +1314,13 @@ H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; + vol_cb_args.args.get_info.oinfo = oinfo; + vol_cb_args.args.get_info.fields = fields; + /* Retrieve the object's information */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - oinfo, fields) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: @@ -1289,9 +1342,11 @@ done: herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo /*out*/, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixIu", loc_id, oinfo, fields); @@ -1310,9 +1365,15 @@ H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo /*out*/, unsigned fiel if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.get_native_info.fields = fields; + obj_opt_args.get_native_info.ninfo = oinfo; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; + vol_cb_args.args = &obj_opt_args; + /* Retrieve the object's information */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") done: @@ -1335,9 +1396,11 @@ herr_t H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo /*out*/, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sxIui", loc_id, name, oinfo, fields, lapl_id); @@ -1366,9 +1429,15 @@ H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oi if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.get_native_info.fields = fields; + obj_opt_args.get_native_info.ninfo = oinfo; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; + vol_cb_args.args = &obj_opt_args; + /* Retrieve the object's information */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object: '%s'", name) done: @@ -1393,9 +1462,11 @@ herr_t H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_native_info_t *oinfo /*out*/, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIohxIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); @@ -1416,6 +1487,7 @@ H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_t if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location struct fields */ loc_params.type = H5VL_OBJECT_BY_IDX; loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; @@ -1428,9 +1500,15 @@ H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_t if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.get_native_info.fields = fields; + obj_opt_args.get_native_info.ninfo = oinfo; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; + vol_cb_args.args = &obj_opt_args; + /* Retrieve the object's information */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") done: @@ -1457,9 +1535,11 @@ done: herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", obj_id, comment); @@ -1476,9 +1556,14 @@ H5Oset_comment(hid_t obj_id, const char *comment) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(obj_id); + /* Set up VOL callback arguments */ + obj_opt_args.set_comment.comment = comment; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_SET_COMMENT; + vol_cb_args.args = &obj_opt_args; + /* (Re)set the object's comment */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, comment) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object") done: @@ -1505,9 +1590,11 @@ done: herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, name, comment, lapl_id); @@ -1530,9 +1617,14 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.set_comment.comment = comment; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_SET_COMMENT; + vol_cb_args.args = &obj_opt_args; + /* (Re)set the object's comment */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, comment) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name) done: @@ -1558,9 +1650,12 @@ done: ssize_t H5Oget_comment(hid_t obj_id, char *comment /*out*/, size_t bufsize) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + size_t comment_len = 0; /* Length of comment string */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, comment, bufsize); @@ -1573,11 +1668,21 @@ H5Oget_comment(hid_t obj_id, char *comment /*out*/, size_t bufsize) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(obj_id); + /* Set up VOL callback arguments */ + obj_opt_args.get_comment.buf = comment; + obj_opt_args.get_comment.buf_size = bufsize; + obj_opt_args.get_comment.comment_len = &comment_len; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_COMMENT; + vol_cb_args.args = &obj_opt_args; + /* Retrieve the object's comment */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object") + /* Set return value */ + ret_value = (ssize_t)comment_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment() */ @@ -1601,9 +1706,12 @@ done: ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment /*out*/, size_t bufsize, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; + size_t comment_len = 0; /* Length of comment string */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "i*sxzi", loc_id, name, comment, bufsize, lapl_id); @@ -1626,11 +1734,21 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment /*out*/, si if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Set up VOL callback arguments */ + obj_opt_args.get_comment.buf = comment; + obj_opt_args.get_comment.buf_size = bufsize; + obj_opt_args.get_comment.comment_len = &comment_len; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_COMMENT; + vol_cb_args.args = &obj_opt_args; + /* Retrieve the object's comment */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name) + /* Set return value */ + ret_value = (ssize_t)comment_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment_by_name() */ @@ -1674,9 +1792,10 @@ herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIoOI*xIu", obj_id, idx_type, order, op, op_data, fields); @@ -1699,10 +1818,17 @@ H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2 loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(obj_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_VISIT; + vol_cb_args.args.visit.idx_type = idx_type; + vol_cb_args.args.visit.order = order; + vol_cb_args.args.visit.op = op; + vol_cb_args.args.visit.op_data = op_data; + vol_cb_args.args.visit.fields = fields; + /* Visit the objects */ - if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < - 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1748,9 +1874,10 @@ herr_t H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIoOI*xIui", loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id); @@ -1783,10 +1910,17 @@ H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_it loc_params.loc_data.loc_by_name.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_VISIT; + vol_cb_args.args.visit.idx_type = idx_type; + vol_cb_args.args.visit.order = order; + vol_cb_args.args.visit.op = op; + vol_cb_args.args.visit.op_data = op_data; + vol_cb_args.args.visit.fields = fields; + /* Visit the objects */ - if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < - 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1794,23 +1928,23 @@ done: } /* end H5Ovisit_by_name3() */ /*------------------------------------------------------------------------- - * Function: H5O__close_check_common + * Function: H5O__close_check_type * * Purpose: This is the common function to validate an object - * when closing it. + * before closing it. * * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ static htri_t -H5O__close_check_common(hid_t object_id) +H5O__close_check_type(hid_t object_id) { htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC - /* Get the type of the object and close it in the correct way */ + /* Check for closeable object */ switch (H5I_get_type(object_id)) { case H5I_GROUP: case H5I_DATATYPE: @@ -1836,14 +1970,13 @@ H5O__close_check_common(hid_t object_id) case H5I_EVENTSET: case H5I_NTYPES: default: - HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FALSE, - "not a valid file object ID (dataset, group, or datatype)") + HGOTO_DONE(FALSE); break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__close_check_common() */ +} /* H5O__close_check_type() */ /*------------------------------------------------------------------------- * Function: H5Oclose @@ -1871,7 +2004,7 @@ H5Oclose(hid_t object_id) H5TRACE1("e", "i", object_id); /* Validate the object type before closing */ - if (H5O__close_check_common(object_id) <= 0) + if (H5O__close_check_type(object_id) <= 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "not a valid object") if (H5I_dec_app_ref(object_id) < 0) @@ -1903,7 +2036,7 @@ H5Oclose_async(const char *app_file, const char *app_func, unsigned app_line, hi H5TRACE5("e", "*s*sIuii", app_file, app_func, app_line, object_id, es_id); /* Validate the object type before closing */ - if (H5O__close_check_common(object_id) <= 0) + if (H5O__close_check_type(object_id) <= 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "not a valid object") /* Prepare for possible asynchronous operation */ @@ -1943,7 +2076,7 @@ done: } /* end H5Oclose_async() */ /*------------------------------------------------------------------------- - * Function: H5O_disable_mdc_flushes + * Function: H5O__disable_mdc_flushes * * Purpose: Private version of the metadata cache cork function. * @@ -1952,18 +2085,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_disable_mdc_flushes(H5O_loc_t *oloc) +H5O__disable_mdc_flushes(H5O_loc_t *oloc) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_PACKAGE if (H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: FUNC_LEAVE_NOAPI(ret_value); -} /* H5O_disable_mdc_flushes() */ +} /* H5O__disable_mdc_flushes() */ /*------------------------------------------------------------------------- * Function: H5Odisable_mdc_flushes @@ -1982,9 +2115,10 @@ done: herr_t H5Odisable_mdc_flushes(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); @@ -2001,9 +2135,13 @@ H5Odisable_mdc_flushes(hid_t object_id) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES; + vol_cb_args.args = NULL; + /* Cork the object */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: @@ -2011,7 +2149,7 @@ done: } /* H5Odisable_mdc_flushes() */ /*------------------------------------------------------------------------- - * Function: H5O_enable_mdc_flushes + * Function: H5O__enable_mdc_flushes * * Purpose: Private version of the metadata cache uncork function. * @@ -2020,18 +2158,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_enable_mdc_flushes(H5O_loc_t *oloc) +H5O__enable_mdc_flushes(H5O_loc_t *oloc) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_PACKAGE if (H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: FUNC_LEAVE_NOAPI(ret_value); -} /* H5O_enable_mdc_flushes() */ +} /* H5O__enable_mdc_flushes() */ /*------------------------------------------------------------------------- * Function: H5Oenable_mdc_flushes @@ -2050,9 +2188,10 @@ done: herr_t H5Oenable_mdc_flushes(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); @@ -2069,9 +2208,13 @@ H5Oenable_mdc_flushes(hid_t object_id) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES; + vol_cb_args.args = NULL; + /* Uncork the object */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: @@ -2079,7 +2222,7 @@ done: } /* H5Oenable_mdc_flushes() */ /*------------------------------------------------------------------------- - * Function: H5O_are_mdc_flushes_disabled + * Function: H5O__are_mdc_flushes_disabled * * Purpose: Private version of cork status getter. * @@ -2088,11 +2231,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled) +H5O__are_mdc_flushes_disabled(const H5O_loc_t *oloc, hbool_t *are_disabled) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_PACKAGE HDassert(are_disabled); @@ -2101,7 +2244,7 @@ H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_are_mdc_flushes_disabled() */ +} /* H5O__are_mdc_flushes_disabled() */ /*------------------------------------------------------------------------- * Function: H5Oare_mdc_flushes_disabled @@ -2123,9 +2266,11 @@ done: herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", object_id, are_disabled); @@ -2146,9 +2291,14 @@ H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); + /* Set up VOL callback arguments */ + obj_opt_args.are_mdc_flushes_disabled.flag = are_disabled; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED; + vol_cb_args.args = &obj_opt_args; + /* Get the cork status */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, are_disabled) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); done: diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 5e13f9f..7def20a 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -122,8 +122,6 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, H5O_info1_t oinfo; /* Deprecated object info struct */ unsigned dm_fields; /* Fields for data model query */ unsigned nat_fields; /* Fields for native query */ - H5VL_object_t * vol_obj; /* Object of obj_id */ - H5VL_loc_params_t loc_params; /* Location parameters for VOL callback */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -160,24 +158,34 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, oinfo.num_attrs = oinfo2->num_attrs; } - /* Fill out location struct */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; - loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(obj_id); - - /* Get the location object */ - if (NULL == (vol_obj = H5VL_vol_object(obj_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") - /* Check for retrieving native information */ nat_fields = shim_data->fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); if (nat_fields) { - H5O_native_info_t nat_info; /* Native object info */ + H5VL_object_t * vol_obj; /* Object of obj_id */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5VL_loc_params_t loc_params; /* Location parameters for VOL callback */ + H5O_native_info_t nat_info; /* Native object info */ + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") + + /* Set up VOL callback arguments */ + obj_opt_args.get_native_info.fields = nat_fields; + obj_opt_args.get_native_info.ninfo = &nat_info; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; + vol_cb_args.args = &obj_opt_args; /* Retrieve the object's native information */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &loc_params, &nat_info, nat_fields) < 0) + if (H5VL_object_optional(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") /* Set the native fields */ @@ -228,11 +236,16 @@ H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_inf /* Check for retrieving data model information */ dm_fields = fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); if (dm_fields) { - H5O_info2_t dm_info; /* Data model object info */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5O_info2_t dm_info; /* Data model object info */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_INFO; + vol_cb_args.args.get_info.oinfo = &dm_info; + vol_cb_args.args.get_info.fields = dm_fields; /* Retrieve the object's data model information */ - if (H5VL_object_get(vol_obj, loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &dm_info, dm_fields) < 0) + if (H5VL_object_get(vol_obj, loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") /* Set the data model fields */ @@ -265,11 +278,19 @@ H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_inf /* Check for retrieving native information */ nat_fields = fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); if (nat_fields) { - H5O_native_info_t nat_info; /* Native object info */ + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_object_optional_args_t obj_opt_args; /* Arguments for optional operation */ + H5O_native_info_t nat_info; /* Native object info */ + + /* Set up VOL callback arguments */ + obj_opt_args.get_native_info.fields = nat_fields; + obj_opt_args.get_native_info.ninfo = &nat_info; + vol_cb_args.op_type = H5VL_NATIVE_OBJECT_GET_NATIVE_INFO; + vol_cb_args.args = &obj_opt_args; /* Retrieve the object's native information */ - if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, loc_params, &nat_info, nat_fields) < 0) + if (H5VL_object_optional(vol_obj, loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") /* Set the native fields */ @@ -751,10 +772,11 @@ done: herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIoOi*x", obj_id, idx_type, order, op, op_data); @@ -780,10 +802,17 @@ H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1 shim_data.fields = H5O_INFO_ALL; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_VISIT; + vol_cb_args.args.visit.idx_type = idx_type; + vol_cb_args.args.visit.order = order; + vol_cb_args.args.visit.op = H5O__iterate1_adapter; + vol_cb_args.args.visit.op_data = &shim_data; + vol_cb_args.args.visit.fields = H5O_INFO_ALL; + /* Visit the objects */ - if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, - (void *)&shim_data, H5O_INFO_ALL)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: @@ -826,10 +855,11 @@ herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIoOi*xi", loc_id, obj_name, idx_type, order, op, op_data, lapl_id); @@ -865,10 +895,17 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_it shim_data.fields = H5O_INFO_ALL; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_VISIT; + vol_cb_args.args.visit.idx_type = idx_type; + vol_cb_args.args.visit.order = order; + vol_cb_args.args.visit.op = H5O__iterate1_adapter; + vol_cb_args.args.visit.op_data = &shim_data; + vol_cb_args.args.visit.fields = H5O_INFO_ALL; + /* Visit the objects */ - if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, - (void *)&shim_data, H5O_INFO_ALL)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: @@ -914,11 +951,12 @@ herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIoOi*xIu", obj_id, idx_type, order, op, op_data, fields); @@ -954,10 +992,17 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1 shim_data.fields = fields; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_VISIT; + vol_cb_args.args.visit.idx_type = idx_type; + vol_cb_args.args.visit.order = order; + vol_cb_args.args.visit.op = H5O__iterate1_adapter; + vol_cb_args.args.visit.op_data = &shim_data; + vol_cb_args.args.visit.fields = fields; + /* Visit the objects */ - if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, - (void *)&shim_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1003,11 +1048,12 @@ herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIoOi*xIui", loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id); @@ -1053,10 +1099,17 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_it shim_data.fields = fields; shim_data.real_op_data = op_data; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_VISIT; + vol_cb_args.args.visit.idx_type = idx_type; + vol_cb_args.args.visit.order = order; + vol_cb_args.args.visit.op = H5O__iterate1_adapter; + vol_cb_args.args.visit.op_data = &shim_data; + vol_cb_args.args.visit.fields = fields; + /* Visit the objects */ - if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, - (void *)&shim_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: diff --git a/src/H5Oflush.c b/src/H5Oflush.c index ea25550..801ef01 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -48,7 +48,7 @@ /* Local Prototypes */ /********************/ static herr_t H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag); -static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc); +static herr_t H5O__refresh_metadata_close(H5O_loc_t *oloc, H5G_loc_t *obj_loc, hid_t oid); /*************/ /* Functions */ @@ -193,7 +193,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) +H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) { H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */ hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ @@ -202,7 +202,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) FUNC_ENTER_NOAPI(FAIL) /* If the file is opened with write access, no need to perform refresh actions. */ - if (!(H5F_INTENT(oloc.file) & H5F_ACC_RDWR)) { + if (!(H5F_INTENT(oloc->file) & H5F_ACC_RDWR)) { H5G_loc_t obj_loc; H5O_loc_t obj_oloc; H5G_name_t obj_path; @@ -217,7 +217,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) /* "Fake" another open object in the file, so that it doesn't get closed * if this object is the only thing holding the file open. */ - H5F_incr_nopen_objs(oloc.file); + H5F_incr_nopen_objs(oloc->file); objs_incr = TRUE; /* Save important datatype state */ @@ -239,11 +239,11 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) connector->nrefs++; /* Close object & evict its metadata */ - if ((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) + if (H5O__refresh_metadata_close(oloc, &obj_loc, oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Re-open the object, re-fetching its metadata */ - if ((H5O_refresh_metadata_reopen(oid, &obj_loc, connector, FALSE)) < 0) + if (H5O_refresh_metadata_reopen(oid, &obj_loc, connector, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Restore the number of references on the VOL connector */ @@ -258,7 +258,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) done: if (objs_incr) - H5F_decr_nopen_objs(oloc.file); + H5F_decr_nopen_objs(oloc->file); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_refresh_metadata() */ @@ -283,8 +283,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) +H5O__refresh_metadata_close(H5O_loc_t *oloc, H5G_loc_t *obj_loc, hid_t oid) { + H5F_t * file; /* Local copy of the object's file pointer */ haddr_t tag = 0; /* Tag for object */ hbool_t corked = FALSE; /* Whether object's metadata is corked */ herr_t ret_value = SUCCEED; /* Return value */ @@ -305,28 +306,32 @@ H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to prepare refresh for dataset") /* Retrieve tag for object */ - if (H5O__oh_tag(&oloc, &tag) < 0) + if (H5O__oh_tag(oloc, &tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to get object header address") /* Get cork status of the object with tag */ - if (H5AC_cork(oloc.file, tag, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(oloc->file, tag, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status") + /* Hold a copy of the object's file pointer, since closing the object will + * invalidate the file pointer in the oloc. + */ + file = oloc->file; /* Close the object */ if (H5I_dec_ref(oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to close object") /* Flush metadata based on tag value of the object */ - if (H5F_flush_tagged_metadata(oloc.file, tag) < 0) + if (H5F_flush_tagged_metadata(file, tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Evict the object's tagged metadata */ - if (H5F_evict_tagged_metadata(oloc.file, tag) < 0) + if (H5F_evict_tagged_metadata(file, tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to evict metadata") /* Re-cork object with tag */ if (corked) - if (H5AC_cork(oloc.file, tag, H5AC__SET_CORK, &corked) < 0) + if (H5AC_cork(file, tag, H5AC__SET_CORK, &corked) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to cork the object") done: diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 6e203bb..331fcf6 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -581,6 +581,11 @@ H5_DLL herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_pr H5_DLL herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx); H5_DLL herr_t H5O__chunk_dest(H5O_chunk_proxy_t *chunk_proxy); +/* Cache corking functions */ +H5_DLL herr_t H5O__disable_mdc_flushes(H5O_loc_t *oloc); +H5_DLL herr_t H5O__enable_mdc_flushes(H5O_loc_t *oloc); +H5_DLL herr_t H5O__are_mdc_flushes_disabled(const H5O_loc_t *oloc, hbool_t *are_disabled); + /* Collect storage info for btree and heap */ H5_DLL herr_t H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 65f0308..050bd49 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -981,15 +981,10 @@ H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t /* Object metadata flush/refresh routines */ H5_DLL herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id); -H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc); +H5_DLL herr_t H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid); H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr); -/* Cache corking functions */ -H5_DLL herr_t H5O_disable_mdc_flushes(H5O_loc_t *oloc); -H5_DLL herr_t H5O_enable_mdc_flushes(H5O_loc_t *oloc); -H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled); - /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, H5O_copy_t *cpy_info, hbool_t inc_depth, H5O_type_t *obj_type, diff --git a/src/H5PLextern.h b/src/H5PLextern.h index 7f3df5e..5042069 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -17,8 +17,8 @@ #ifndef H5PLextern_H #define H5PLextern_H -/* Include HDF5 header */ -#include "hdf5.h" +/* Include package's public header */ +#include "H5PLpublic.h" /* plugins always export */ #if defined(_MSC_VER) /* MSVC Compiler Case */ diff --git a/src/H5PLint.c b/src/H5PLint.c index cf6135d..6bb8404 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -236,11 +236,13 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) if ((H5PL_plugin_control_mask_g & H5PL_FILTER_PLUGIN) == 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "filter plugins disabled") break; + case H5PL_TYPE_VOL: if ((H5PL_plugin_control_mask_g & H5PL_VOL_PLUGIN) == 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "Virtual Object Layer (VOL) driver plugins disabled") break; + case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index 2ec0845..4f5c0ce 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -263,33 +263,59 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f /* Loop over all the plugins, looking for one that matches */ for (u = 0; u < H5PL_num_plugins_g; u++) { - - /* If the plugin type (filter, VOL connector, etc.) and ID match, query the plugin for its info */ - if ((search_params->type == (H5PL_cache_g[u]).type) && - (search_params->key->id == (H5PL_cache_g[u]).key.id)) { - - H5PL_get_plugin_info_t get_plugin_info_function; - const void * info; - - /* Get the "get plugin info" function from the plugin. */ - if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( - (H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") - - /* Call the "get plugin info" function */ - if (NULL == (info = (*get_plugin_info_function)())) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") - - /* Set output parameters */ - *found = TRUE; - *plugin_info = info; - - /* No need to continue processing */ - break; - - } /* end if */ - - } /* end for */ + /* If the plugin type (filter, VOL connector, etc.) match, proceed */ + if (search_params->type == H5PL_cache_g[u].type) { + hbool_t matched = FALSE; /* Whether cached plugin info matches */ + + switch (search_params->type) { + case H5PL_TYPE_FILTER: + if (search_params->key->id == H5PL_cache_g[u].key.id) + matched = TRUE; + break; + + case H5PL_TYPE_VOL: + if (search_params->key->vol.kind == H5VL_GET_CONNECTOR_BY_VALUE) { + if (search_params->key->vol.u.value == H5PL_cache_g[u].key.vol.u.value) + matched = TRUE; + } /* end if */ + else if (search_params->key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { + if (0 == HDstrcmp(search_params->key->vol.u.name, H5PL_cache_g[u].key.vol.u.name)) + matched = TRUE; + } /* end else-if */ + else + HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, FAIL, "bad VOL plugin search key type") + break; + + case H5PL_TYPE_ERROR: + case H5PL_TYPE_NONE: + default: + HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, FAIL, "bad plugin type") + } /* end switch */ + + /* If the plugin type (filter, VOL connector, etc.) and key match, query the plugin for its info + */ + if (matched) { + H5PL_get_plugin_info_t get_plugin_info_function; + const void * info; + + /* Get the "get plugin info" function from the plugin. */ + if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( + (H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") + + /* Call the "get plugin info" function */ + if (NULL == (info = (*get_plugin_info_function)())) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + + /* Set output parameters */ + *found = TRUE; + *plugin_info = info; + + /* No need to continue processing */ + break; + } /* end if */ + } /* end if */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index de67dfd..046b046 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -159,6 +159,16 @@ #define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy #define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp #define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close +/* Definitions for dataset I/O selection property */ +#define H5D_XFER_DSET_IO_SEL_SIZE sizeof(H5S_t *) +#define H5D_XFER_DSET_IO_SEL_DEF NULL +#define H5D_XFER_DSET_IO_SEL_COPY H5P__dxfr_dset_io_hyp_sel_copy +#define H5D_XFER_DSET_IO_SEL_CMP H5P__dxfr_dset_io_hyp_sel_cmp +#define H5D_XFER_DSET_IO_SEL_CLOSE H5P__dxfr_dset_io_hyp_sel_close +#ifdef QAK +#define H5D_XFER_DSET_IO_SEL_ENC H5P__dxfr_edc_enc +#define H5D_XFER_DSET_IO_SEL_DEC H5P__dxfr_edc_dec +#endif /* QAK */ /******************/ /* Local Typedefs */ @@ -196,6 +206,9 @@ static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char *name, size_t size, static herr_t H5P__dxfr_xform_copy(const char *name, size_t size, void *value); static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__dxfr_xform_close(const char *name, size_t size, void *value); +static herr_t H5P__dxfr_dset_io_hyp_sel_copy(const char *name, size_t size, void *value); +static int H5P__dxfr_dset_io_hyp_sel_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dxfr_dset_io_hyp_sel_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -262,7 +275,9 @@ static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ static const H5T_conv_cb_t H5D_def_conv_cb_g = H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ -static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ +static const void * H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ +static const H5S_t *H5D_def_dset_io_sel_g = + H5D_XFER_DSET_IO_SEL_DEF; /* Default value for dataset I/O selection */ /*------------------------------------------------------------------------- * Function: H5P__dxfr_reg_prop @@ -420,6 +435,13 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass) H5D_XFER_XFORM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the dataset I/O selection property */ + if (H5P__register_real(pclass, H5D_XFER_DSET_IO_SEL_NAME, H5D_XFER_DSET_IO_SEL_SIZE, + &H5D_def_dset_io_sel_g, NULL, NULL, NULL, NULL, NULL, NULL, + H5D_XFER_DSET_IO_SEL_COPY, H5D_XFER_DSET_IO_SEL_CMP, + H5D_XFER_DSET_IO_SEL_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_reg_prop() */ @@ -894,7 +916,7 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__dxfr_xform_copy() */ +} /* end H5P__dxfr_xform_cmp() */ /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_close @@ -965,7 +987,7 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) /* Create data transform info from expression */ if (NULL == (data_xform_prop = H5Z_xform_create(expression))) - HGOTO_ERROR(H5E_PLINE, H5E_NOSPACE, FAIL, "unable to create data transform info") + HGOTO_ERROR(H5E_PLIST, H5E_NOSPACE, FAIL, "unable to create data transform info") /* Update property list (takes ownership of transform) */ if (H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) @@ -974,7 +996,7 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) done: if (ret_value < 0) if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") FUNC_LEAVE_API(ret_value) } /* end H5Pset_data_transform() */ @@ -2109,3 +2131,251 @@ H5P__dxfr_edc_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_edc_dec() */ + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_dset_io_hyp_sel_copy + * + * Purpose: Creates a copy of the dataset I/O selection. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Sunday, January 31, 2021 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dxfr_dset_io_hyp_sel_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + H5S_t *orig_space = *(H5S_t **)value; /* Original dataspace for property */ + H5S_t *new_space = NULL; /* New dataspace for property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* If there's a dataspace I/O selection set, copy it */ + if (orig_space) { + /* Make copy of dataspace */ + if (NULL == (new_space = H5S_copy(orig_space, FALSE, TRUE))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the dataset I/O selection") + + /* Set new value for property */ + *(void **)value = new_space; + } /* end if */ + +done: + /* Cleanup on error */ + if (ret_value < 0) + if (new_space && H5S_close(new_space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_dset_io_hyp_sel_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_dset_io_hyp_sel_cmp + * + * Purpose: Compare two dataset I/O selections. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is + * greater than VALUE1 and zero if VALUE1 and VALUE2 are equal. + * + * Programmer: Quincey Koziol + * Sunday, January 31, 2021 + * + *------------------------------------------------------------------------- + */ +static int +H5P__dxfr_dset_io_hyp_sel_cmp(const void *_space1, const void *_space2, size_t H5_ATTR_UNUSED size) +{ + const H5S_t *const *space1 = (const H5S_t *const *)_space1; /* Create local aliases for values */ + const H5S_t *const *space2 = (const H5S_t *const *)_space2; /* Create local aliases for values */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(space1); + HDassert(space1); + HDassert(size == sizeof(H5S_t *)); + + /* Check for a property being set */ + if (*space1 == NULL && *space2 != NULL) + HGOTO_DONE(-1); + if (*space1 != NULL && *space2 == NULL) + HGOTO_DONE(1); + + if (*space1) { + HDassert(*space2); + + /* Compare the extents of the dataspaces */ + /* (Error & not-equal count the same) */ + if (TRUE != H5S_extent_equal(*space1, *space2)) + HGOTO_DONE(-1); + + /* Compare the selection "shape" of the dataspaces */ + /* (Error & not-equal count the same) */ + if (TRUE != H5S_select_shape_same(*space1, *space2)) + HGOTO_DONE(-1); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_dset_io_hyp_sel_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_dset_io_hyp_sel_close + * + * Purpose: Frees resources for dataset I/O selection + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Sunday, January 31, 2021 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dxfr_dset_io_hyp_sel_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *_value) +{ + H5S_t *space = *(H5S_t **)_value; /* Dataspace for property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Release any dataspace */ + if (space && H5S_close(space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_dset_io_hyp_sel_close() */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_dataset_io_hyperslab_selection + * + * Purpose: H5Pset_dataset_io_hyperslab_selection() is designed to be used + * in conjunction with using H5S_PLIST for the file dataspace + * ID when making a call to H5Dread() or H5Dwrite(). When used + * with H5S_PLIST, the selection created by one or more calls to + * this routine is used for determining which dataset elements to + * access. + * + * 'rank' is the dimensionality of the selection and determines + * the size of the 'start', 'stride', 'count', and 'block' arrays. + * 'rank' must be between 1 and H5S_MAX_RANK, inclusive. + * + * The 'op', 'start', 'stride', 'count', and 'block' parameters + * behave identically to their behavior for H5Sselect_hyperslab(), + * please see the documentation for that routine for details about + * their use. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, January 30, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, const hsize_t start[], + const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5S_t * space; /* Dataspace to hold selection */ + hbool_t space_created = FALSE; /* Whether a new dataspace has been created */ + hbool_t reset_prop_on_error = FALSE; /* Whether to reset the property on failure */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "iIuSs*h*h*h*h", plist_id, rank, op, start, stride, count, block); + + /* Check arguments */ + if (rank < 1 || rank > H5S_MAX_RANK) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank value: %u", rank) + if (!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID)) + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") + if (start == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'count' pointer is NULL") + if (stride != NULL) { + unsigned u; /* Local index variable */ + + /* Check for 0-sized strides */ + for (u = 0; u < rank; u++) + if (stride[u] == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value - stride[%u]==0", u) + } /* end if */ + if (count == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'start' pointer is NULL") + /* block is allowed to be NULL, and will be assumed to be all '1's when NULL */ + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID") + + /* See if a dataset I/O selection is already set, and free it if it is */ + if (H5P_peek(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting dataset I/O selection") + + /* Check for operation on existing dataspace selection */ + if (NULL != space) { + int sndims; /* Rank of existing dataspace */ + + /* Get dimensions from current dataspace for selection */ + if ((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get selection's dataspace rank") + + /* Check for different # of dimensions */ + if ((unsigned)sndims != rank) { + /* Set up new dataspace for 'set' operation, otherwise fail */ + if (op == H5S_SELECT_SET) { + /* Close previous dataspace */ + if (H5S_close(space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + + /* Reset 'space' pointer, so it's re-created */ + space = NULL; + + /* Set flag to reset property list on error */ + reset_prop_on_error = TRUE; + } /* end if */ + else + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "different rank for previous and new selections") + } /* end if */ + } /* end if */ + + /* Check for first time called */ + if (NULL == space) { + hsize_t dims[H5S_MAX_RANK]; /* Dimensions for new dataspace */ + unsigned u; /* Local index variable */ + + /* Initialize dimensions to largest possible actual size */ + for (u = 0; u < rank; u++) + dims[u] = (H5S_UNLIMITED - 1); + + /* Create dataspace of the correct dimensionality, with maximum dimensions */ + if (NULL == (space = H5S_create_simple(rank, dims, NULL))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create dataspace for selection") + space_created = TRUE; + } /* end if */ + + /* Set selection for dataspace */ + if (H5S_select_hyperslab(space, op, start, stride, count, block) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSELECT, FAIL, "can't create selection") + + /* Update property list (takes ownership of dataspace, if new) */ + if (H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection") + space_created = FALSE; /* Reset now that property owns the dataspace */ + +done: + /* Cleanup on failure */ + if (ret_value < 0) { + if (reset_prop_on_error && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection") + if (space_created && H5S_close(space) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } /* end if */ + + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_dataset_io_hyperslab_selection() */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 49cc27e..a8e0d8e 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -5703,6 +5703,64 @@ done: } /* end H5Pget_vol_info() */ /*------------------------------------------------------------------------- + * Function: H5Pget_vol_cap_flags + * + * Purpose: Queries the current VOL connector information for a FAPL to + * retrieve the capability flags for the VOL connector stack, as will + * be used by a file open or create operation that uses this FAPL. + * + * Current capability flags are: + * H5VL_CAP_FLAG_THREADSAFE - Connector is threadsafe + * H5VL_CAP_FLAG_ASYNC - Connector performs operations asynchronously + * H5VL_CAP_FLAG_NATIVE_FILES - Connector produces native file format + * + * Note: This routine supports the use of the HDF5_VOL_CONNECTOR environment + * environment variable to override the VOL connector set programmatically + * for the FAPL (with H5Pset_vol). + * + * Note: The H5VL_CAP_FLAG_ASYNC flag can be checked to see if asynchronous + * operations are supported by the VOL connector stack. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_vol_cap_flags(hid_t plist_id, unsigned *cap_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*Iu", plist_id, cap_flags); + + /* Get the 'cap_flags' from the connector */ + if (cap_flags) { + if (TRUE == H5P_isa_class(plist_id, H5P_FILE_ACCESS)) { + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + + /* Get property list for ID */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get the connector property */ + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property") + + /* Query the capability flags */ + if (H5VL_get_cap_flags(&connector_prop, cap_flags) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector capability flags") + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_vol_cap_flags() */ + +/*------------------------------------------------------------------------- * Function: H5P__facc_vol_create * connectorose: Create callback for the VOL connector ID & info property. diff --git a/src/H5Pint.c b/src/H5Pint.c index dd1ad9b..9530d87 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -4878,7 +4878,8 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) /* If not, get the information required to do an H5Pinsert2 with the property into the destination list */ else { /* Get the pointer to the source property */ - prop = H5P__find_prop_plist(src_plist, name); + if (NULL == (prop = H5P__find_prop_plist(src_plist, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Create property object from parameters */ if (NULL == diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 3d6968e..10609b2 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -22,16 +22,17 @@ /* Public headers needed by this file */ #include "H5public.h" -#include "H5ACpublic.h" -#include "H5Dpublic.h" -#include "H5Fpublic.h" -#include "H5FDpublic.h" -#include "H5Ipublic.h" -#include "H5Lpublic.h" -#include "H5Opublic.h" -#include "H5MMpublic.h" -#include "H5Tpublic.h" -#include "H5Zpublic.h" +#include "H5ACpublic.h" /* Metadata cache */ +#include "H5Dpublic.h" /* Datasets */ +#include "H5Fpublic.h" /* Files */ +#include "H5FDpublic.h" /* File drivers */ +#include "H5Ipublic.h" /* ID management */ +#include "H5Lpublic.h" /* Links */ +#include "H5MMpublic.h" /* Memory management */ +#include "H5Opublic.h" /* Object headers */ +#include "H5Spublic.h" /* Dataspaces */ +#include "H5Tpublic.h" /* Datatypes */ +#include "H5Zpublic.h" /* Data filters */ /*****************/ /* Public Macros */ @@ -5206,6 +5207,34 @@ H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); */ H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); +/** + * \ingroup FAPL + * + * \brief Query the capability flags for the VOL connector that will be used + * with this file access property list (FAPL). + * + * \fapl_id{plist_id} + * \param[out] cap_flags Flags that indicate the VOL connector capabilities + * + * \return \herr_t + * + * \details H5Pget_vol_cap_flags() queries the current VOL connector information + * for a FAPL to retrieve the capability flags for the VOL + * connector stack, as will be used by a file open or create + * operation that uses this FAPL. + * + * \note This routine supports the use of the HDF5_VOL_CONNECTOR environment + * variable to override the VOL connector set programmatically for the + * FAPL (with H5Pset_vol). + * + * \note The H5VL_CAP_FLAG_ASYNC flag can be checked to see if asynchronous + * operations are supported by the VOL connector stack. + * + * \since 1.13.0 + * + */ +H5_DLL herr_t H5Pget_vol_cap_flags(hid_t plist_id, unsigned *cap_flags); + #ifdef H5_HAVE_PARALLEL /** * \ingroup GACPL @@ -7999,6 +8028,44 @@ H5_DLL herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); #endif /* H5_HAVE_PARALLEL */ +/** + * + * \ingroup DXPL + * + * \brief Sets a hyperslab file selection for a dataset I/O operation + * + * \param[in] plist_id Property list identifier + * \param[in] rank Number of dimensions of selection + * \param[in] op Operation to perform on current selection + * \param[in] start Offset of start of hyperslab + * \param[in] stride Hyperslab stride + * \param[in] count Number of blocks included in hyperslab + * \param[in] block Size of block in hyperslab + * + * \return \herr_t + * + * \details H5Pset_dataset_io_hyperslab_selection() is designed to be used + * in conjunction with using #H5S_PLIST for the file dataspace + * ID when making a call to H5Dread() or H5Dwrite(). When used + * with #H5S_PLIST, the selection created by one or more calls to + * this routine is used for determining which dataset elements to + * access. + * + * \p rank is the dimensionality of the selection and determines + * the size of the \p start, \p stride, \p count, and \p block arrays. + * \p rank must be between 1 and #H5S_MAX_RANK, inclusive. + * + * The \op, \p start, \p stride, \p count, and \p block parameters + * behave identically to their behavior for H5Sselect_hyperslab(), + * please see the documentation for that routine for details about + * their use. + * + * \since 1.13.0 + * + */ +H5_DLL herr_t H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, + const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]); /* Link creation property list (LCPL) routines */ /** diff --git a/src/H5R.c b/src/H5R.c index f23b993..5fa2a8b 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -79,14 +79,16 @@ static hid_t H5R__open_attr_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t obj_type; /* Object type of loc_id */ - hid_t file_id = H5I_INVALID_HID; /* File ID */ - H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t obj_type; /* Object type of loc_id */ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_object_specific_args_t obj_spec_vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5VL_file_get_args_t file_get_vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*si*Rr", loc_id, name, oapl_id, ref_ptr); @@ -121,9 +123,12 @@ H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_p if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + file_get_vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + file_get_vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, &file_get_vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Set location parameters */ @@ -132,15 +137,18 @@ H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_p loc_params.loc_data.loc_by_name.lapl_id = oapl_id; loc_params.obj_type = obj_type; + /* Set up VOL callback arguments */ + obj_spec_vol_cb_args.op_type = H5VL_OBJECT_LOOKUP; + obj_spec_vol_cb_args.args.lookup.token_ptr = &obj_token; + /* Get the object token */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &obj_spec_vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if (H5R__create_object((const H5O_token_t *)&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < - 0) + if (H5R__create_object(&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") /* Attach loc_id to reference and hold reference to it */ @@ -167,15 +175,17 @@ done: herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t obj_type; /* Object type of loc_id */ - hid_t file_id = H5I_INVALID_HID; /* File ID */ - H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - struct H5S_t * space = NULL; /* Pointer to dataspace containing region */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t obj_type; /* Object type of loc_id */ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_object_specific_args_t obj_spec_vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5VL_file_get_args_t file_get_vol_cb_args; /* Arguments to VOL callback */ + struct H5S_t * space = NULL; /* Pointer to dataspace containing region */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sii*Rr", loc_id, name, space_id, oapl_id, ref_ptr); @@ -185,7 +195,7 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if ((space_id == H5I_INVALID_HID) || (space_id == H5S_ALL)) + if ((space_id == H5I_INVALID_HID) || (space_id == H5S_ALL) || (space_id == H5S_BLOCK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") @@ -214,9 +224,12 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + file_get_vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + file_get_vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, &file_get_vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Set location parameters */ @@ -225,9 +238,13 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, loc_params.loc_data.loc_by_name.lapl_id = oapl_id; loc_params.obj_type = obj_type; + /* Set up VOL callback arguments */ + obj_spec_vol_cb_args.op_type = H5VL_OBJECT_LOOKUP; + obj_spec_vol_cb_args.args.lookup.token_ptr = &obj_token; + /* Get the object token */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &obj_spec_vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Create the reference (do not pass filename, since file_id is attached) */ @@ -259,14 +276,16 @@ done: herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t obj_type; /* Object type of loc_id */ - hid_t file_id = H5I_INVALID_HID; /* File ID */ - H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t obj_type; /* Object type of loc_id */ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_object_specific_args_t obj_spec_vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5VL_file_get_args_t file_get_vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*si*Rr", loc_id, name, attr_name, oapl_id, ref_ptr); @@ -303,9 +322,12 @@ H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + file_get_vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + file_get_vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, &file_get_vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Set location parameters */ @@ -314,9 +336,13 @@ H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl loc_params.loc_data.loc_by_name.lapl_id = oapl_id; loc_params.obj_type = obj_type; + /* Set up VOL callback arguments */ + obj_spec_vol_cb_args.op_type = H5VL_OBJECT_LOOKUP; + obj_spec_vol_cb_args.args.lookup.token_ptr = &obj_token; + /* Get the object token */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &obj_spec_vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Create the reference (do not pass filename, since file_id is attached) */ @@ -611,15 +637,16 @@ H5R__open_region_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id, vo hid_t loc_id; /* Reference location ID */ H5VL_object_t * tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = - (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ - hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ - H5S_t * space = NULL; /* Dataspace pointer (copy) */ - hid_t space_id = H5I_INVALID_HID; /* Dataspace ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5O_token_t obj_token = {0}; /* Object token */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ + H5S_t * space = NULL; /* Dataspace pointer (copy) */ + hid_t space_id = H5I_INVALID_HID; /* Dataspace ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -662,10 +689,14 @@ H5R__open_region_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id, vo if (NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_SPACE; + vol_cb_args.args.get_space.space_id = H5I_INVALID_HID; + /* Get dataspace from object */ - if (H5VL_dataset_get(opened_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &space_id) < 0) + if (H5VL_dataset_get(opened_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace from dataset") + space_id = vol_cb_args.args.get_space.space_id; if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") @@ -940,11 +971,12 @@ done: herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type /*out*/) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*Rrix", ref_ptr, rapl_id, obj_type); @@ -959,11 +991,10 @@ H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type /*out*/ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve loc_id from reference */ - if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) /* Attempt to re-open file and pass rapl_id as a fapl_id */ if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, FAIL, "cannot re-open referenced file") - } /* Get object token */ if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) @@ -978,9 +1009,12 @@ H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type /*out*/ loc_params.loc_data.loc_by_token.token = &obj_token; loc_params.obj_type = H5I_get_type(loc_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_TYPE; + vol_cb_args.args.get_type.obj_type = obj_type; + /* Retrieve object's type */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - obj_type) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: @@ -1021,15 +1055,27 @@ H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf /*out*/, size_t size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to retrieve file name") } else { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + size_t file_name_len = 0; /* Length of file name */ /* Retrieve VOL file object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5I_FILE, - size, buf, &ret_value) < 0) + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_NAME; + vol_cb_args.args.get_name.type = H5I_FILE; + vol_cb_args.args.get_name.buf_size = size; + vol_cb_args.args.get_name.buf = buf; + vol_cb_args.args.get_name.file_name_len = &file_name_len; + + /* Get file name */ + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get file name") + + /* Set return value */ + ret_value = (ssize_t)file_name_len; } done: @@ -1049,11 +1095,13 @@ done: ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf /*out*/, size_t size) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - ssize_t ret_value = 0; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + size_t obj_name_len = 0; /* Length of object's name */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "*Rrixz", ref_ptr, rapl_id, buf, size); @@ -1068,11 +1116,10 @@ H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf /*out*/, size_t siz HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a property list") /* Retrieve loc_id from reference */ - if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) /* Attempt to re-open file and pass rapl_id as a fapl_id */ if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, (-1), "cannot re-open referenced file") - } /* Get object token */ if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) @@ -1087,11 +1134,19 @@ H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf /*out*/, size_t siz loc_params.loc_data.loc_by_token.token = &obj_token; loc_params.obj_type = H5I_get_type(loc_id); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_NAME; + vol_cb_args.args.get_name.buf_size = size; + vol_cb_args.args.get_name.buf = buf; + vol_cb_args.args.get_name.name_len = &obj_name_len; + /* Retrieve object's name */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value, buf, size) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") + /* Set return value */ + ret_value = (ssize_t)obj_name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_obj_name() */ diff --git a/src/H5RS.c b/src/H5RS.c index 96d55e7..31fa23a 100644 --- a/src/H5RS.c +++ b/src/H5RS.c @@ -698,7 +698,7 @@ H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2) const H5RS_str_t *rs; IN: Ref-counted string to compute length of RETURNS - Returns non-negative value on success, negative value on failure + Returns non-negative value on success, can't fail DESCRIPTION Compute the length of a ref-counted string. [same as strlen()] GLOBAL VARIABLES @@ -706,7 +706,7 @@ H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -ssize_t +size_t H5RS_len(const H5RS_str_t *rs) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -715,7 +715,7 @@ H5RS_len(const H5RS_str_t *rs) HDassert(rs); HDassert(rs->s); - FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(rs->s)) + FUNC_LEAVE_NOAPI(HDstrlen(rs->s)) } /* end H5RS_len() */ /*-------------------------------------------------------------------------- diff --git a/src/H5RSprivate.h b/src/H5RSprivate.h index 7d2b728..ebca1a3 100644 --- a/src/H5RSprivate.h +++ b/src/H5RSprivate.h @@ -53,7 +53,7 @@ H5_DLL herr_t H5RS_acat(H5RS_str_t *rs, const char *s); H5_DLL herr_t H5RS_ancat(H5RS_str_t *rs, const char *s, size_t len); H5_DLL herr_t H5RS_aputc(H5RS_str_t *rs, int c); H5_DLL int H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2); -H5_DLL ssize_t H5RS_len(const H5RS_str_t *rs); +H5_DLL size_t H5RS_len(const H5RS_str_t *rs); H5_DLL char * H5RS_get_str(const H5RS_str_t *rs); H5_DLL unsigned H5RS_get_count(const H5RS_str_t *rs); diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index d5f5a7d..3f1d70f 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -94,7 +94,8 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ H5VL_object_t * vol_obj_file = NULL; H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - herr_t ret_value = SUCCEED; + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -119,9 +120,12 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") if (ref_type == H5R_OBJECT1) { @@ -240,13 +244,14 @@ done: H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5O_type_t obj_type; /* Object type */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ - H5G_obj_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + const unsigned char * buf = (const unsigned char *)ref; /* Reference buffer */ + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Type of the referenced object */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE3("Go", "iRt*x", id, ref_type, ref); @@ -274,9 +279,12 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) loc_params.loc_data.loc_by_token.token = &obj_token; loc_params.obj_type = vol_obj_type; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_TYPE; + vol_cb_args.args.get_type.obj_type = &obj_type; + /* Retrieve object's type */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &obj_type) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "can't retrieve object type") /* Set return value */ @@ -365,15 +373,17 @@ done: herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - void * vol_obj_file = NULL; - unsigned char * buf = (unsigned char *)ref; /* Return reference pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_object_specific_args_t obj_spec_vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5VL_file_get_args_t file_get_vol_cb_args; /* Arguments to VOL callback */ + hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ + void * vol_obj_file = NULL; + unsigned char * buf = (unsigned char *)ref; /* Return reference pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id); @@ -417,9 +427,13 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; loc_params.obj_type = vol_obj_type; + /* Set up VOL callback arguments */ + obj_spec_vol_cb_args.op_type = H5VL_OBJECT_LOOKUP; + obj_spec_vol_cb_args.args.lookup.token_ptr = &obj_token; + /* Get the object token */ - if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, &obj_spec_vol_cb_args, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Get the file for the object */ @@ -430,9 +444,12 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set up VOL callback arguments */ + file_get_vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + file_get_vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, &file_get_vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Create reference */ @@ -483,12 +500,13 @@ done: herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type /*out*/) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + const unsigned char * buf = (const unsigned char *)ref; /* Reference pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iRt*xx", id, ref_type, ref, obj_type); @@ -516,9 +534,12 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj loc_params.loc_data.loc_by_token.token = &obj_token; loc_params.obj_type = vol_obj_type; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_TYPE; + vol_cb_args.args.get_type.obj_type = obj_type; + /* Retrieve object's type */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - obj_type) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: @@ -612,12 +633,13 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ void * vol_obj_file = NULL; /* VOL file */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - H5F_t * f = NULL; /* Native file */ - size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */ - H5S_t * space = NULL; /* Dataspace object */ - hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - const unsigned char * buf = (const unsigned char *)ref; /* Reference pointer */ - hid_t ret_value; /* Return value */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5F_t * f = NULL; /* Native file */ + size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */ + H5S_t * space = NULL; /* Dataspace object */ + hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ + const unsigned char * buf = (const unsigned char *)ref; /* Reference pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iRt*x", id, ref_type, ref); @@ -658,9 +680,12 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get container info") /* Retrieve file from VOL object */ @@ -695,12 +720,14 @@ done: ssize_t H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name /*out*/, size_t size) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + const unsigned char * buf = (const unsigned char *)ref; /* Reference pointer */ + size_t obj_name_len = 0; /* Length of object's name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "iRt*xxz", id, ref_type, ref, name, size); @@ -728,11 +755,19 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name /*out*/, loc_params.loc_data.loc_by_token.token = &obj_token; loc_params.obj_type = vol_obj_type; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_OBJECT_GET_NAME; + vol_cb_args.args.get_name.buf_size = size; + vol_cb_args.args.get_name.buf = name; + vol_cb_args.args.get_name.name_len = &obj_name_len; + /* Retrieve object's name */ - if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value, name, size) < 0) + if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") + /* Set return value */ + ret_value = (ssize_t)obj_name_len; + done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_name() */ diff --git a/src/H5Rint.c b/src/H5Rint.c index b714f09..e1a5dcd 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -588,11 +588,18 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) supported = 0; if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") - if (supported & H5VL_OPT_QUERY_SUPPORTED) - if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL) < 0) + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = NULL; + + /* Make the 'post open' callback */ + if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") + } /* end if */ /* Attach loc_id to reference */ if (H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE, TRUE) < 0) diff --git a/src/H5S.c b/src/H5S.c index 747d297..13d32cf 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -84,7 +84,7 @@ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ H5I_DATASPACE, /* ID class value */ 0, /* Class flags */ - 2, /* # of reserved IDs for class */ + 3, /* # of reserved IDs for class */ (H5I_free_t)H5S__close_cb /* Callback routine for closing objects of this class */ }}; @@ -277,55 +277,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5S_get_validiated_dataspace - PURPOSE - Get a pointer to a validated H5S_t pointer - USAGE - H5S_t *H5S_get_validated_space(dataspace_id, space) - hid_t space_id; IN: The ID of the dataspace - const H5S_t * space; OUT: A pointer to the dataspace - RETURNS - SUCCEED/FAIL - DESCRIPTION - Gets a pointer to a dataspace struct after validating it. The pointer - can be NULL (if the ID is H5S_ALL, for example). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(space); - - /* Check for invalid ID */ - if (space_id < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid space_id (ID cannot be a negative number)") - - /* No special dataspace struct for H5S_ALL */ - if (H5S_ALL == space_id) - *space = NULL; - else { - /* Get the dataspace pointer */ - if (NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "space_id is not a dataspace ID") - - /* Check for valid selection */ - if (H5S_SELECT_VALID(*space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_get_validated_dataspace() */ - -/*-------------------------------------------------------------------------- - NAME H5S_create PURPOSE Create empty, typed dataspace diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 56c1646..51a98a6 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -217,7 +217,6 @@ H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max); H5_DLL H5S_t *H5S_create(H5S_class_t type); -H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space /*out*/); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); H5_DLL herr_t H5S_set_version(H5F_t *f, H5S_t *ds); H5_DLL herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc); diff --git a/src/H5Spublic.h b/src/H5Spublic.h index c2c0aef..7962035 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -21,8 +21,12 @@ #include "H5public.h" #include "H5Ipublic.h" -/* Define atomic datatypes */ -#define H5S_ALL 0 /* (hid_t) */ +/* Define special dataspaces for dataset I/O operations */ +#define H5S_ALL 0 /* (hid_t) */ +#define H5S_BLOCK 1 /* (hid_t) */ +#define H5S_PLIST 2 /* (hid_t) */ + +/* Define value for 'unlimited' dimensions */ #define H5S_UNLIMITED HSIZE_UNDEF /* Define user-level maximum number of dimensions */ diff --git a/src/H5T.c b/src/H5T.c index 532feac..74b7655 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1892,19 +1892,24 @@ H5Tcopy(hid_t obj_id) break; case H5I_DATASET: { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + H5VL_object_t * vol_obj; /* Object for obj_id */ + H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */ /* 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") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATASET_GET_TYPE; + vol_cb_args.args.get_type.type_id = H5I_INVALID_HID; + /* 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) + if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype from the dataset") + dset_tid = vol_cb_args.args.get_type.type_id; /* Unwrap the type ID */ if (NULL == (dt = (H5T_t *)H5I_object(dset_tid))) diff --git a/src/H5TSdevelop.h b/src/H5TSdevelop.h new file mode 100644 index 0000000..9e8f718 --- /dev/null +++ b/src/H5TSdevelop.h @@ -0,0 +1,50 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5TS (threadsafety) developer + * support routines. + */ + +#ifndef H5TSdevelop_H +#define H5TSdevelop_H + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* HDF5 global library lock routines */ +H5_DLL herr_t H5TSmutex_acquire(unsigned int lock_count, hbool_t *acquired); +H5_DLL herr_t H5TSmutex_release(unsigned int *lock_count); +H5_DLL herr_t H5TSmutex_get_attempt_count(unsigned int *count); + +#ifdef __cplusplus +} +#endif + +#endif /* H5TSdevelop_H */ diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index 6f9f1c0..3150f59 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -25,8 +25,8 @@ #define H5TSprivate_H_ #ifdef H5_HAVE_THREADSAFE -/* Public headers needed by this file */ -#include "H5TSpublic.h" /* Public API prototypes */ +/* Include package's public headers */ +#include "H5TSdevelop.h" #ifdef H5_HAVE_WIN_THREADS diff --git a/src/H5TSpublic.h b/src/H5TSpublic.h deleted file mode 100644 index 41213f9..0000000 --- a/src/H5TSpublic.h +++ /dev/null @@ -1,52 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * This file contains public declarations for the H5TS (threadsafety) module. - */ - -#ifndef H5TSpublic_H -#define H5TSpublic_H - -/* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ - -/*****************/ -/* Public Macros */ -/*****************/ - -/*******************/ -/* Public Typedefs */ -/*******************/ - -/********************/ -/* Public Variables */ -/********************/ - -/*********************/ -/* Public Prototypes */ -/*********************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* HDF5 global library lock routines */ -H5_DLL herr_t H5TSmutex_acquire(unsigned int lock_count, hbool_t *acquired); -H5_DLL herr_t H5TSmutex_release(unsigned int *lock_count); -H5_DLL herr_t H5TSmutex_get_attempt_count(unsigned int *count); - -#ifdef __cplusplus -} -#endif - -#endif /* H5TSpublic_H */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index d214ca1..451a1a8 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -790,12 +790,19 @@ H5Tget_create_plist(hid_t dtype_id) } /* end if */ /* If the datatype is committed, retrieve further information */ else { - H5VL_object_t *vol_obj = type->vol_obj; + H5VL_object_t * vol_obj = type->vol_obj; + H5VL_datatype_get_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATATYPE_GET_TCPL; + vol_cb_args.args.get_tcpl.tcpl_id = H5I_INVALID_HID; /* Get the property list through the VOL */ - if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value) < 0) + if (H5VL_datatype_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") + + /* Set return value */ + ret_value = vol_cb_args.args.get_tcpl.tcpl_id; } /* end else */ done: @@ -829,15 +836,21 @@ H5Tflush(hid_t type_id) if (!H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") - /* Set up collective metadata if appropriate */ - if (H5CX_set_loc(type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") - /* Flush metadata for named datatype */ - if (dt->vol_obj) - if (H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, type_id) < 0) + if (dt->vol_obj) { + H5VL_datatype_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATATYPE_FLUSH; + vol_cb_args.args.flush.type_id = type_id; + + if (H5VL_datatype_specific(dt->vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + } done: FUNC_LEAVE_API(ret_value) @@ -870,15 +883,21 @@ H5Trefresh(hid_t type_id) if (!H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") - /* Set up collective metadata if appropriate */ - if (H5CX_set_loc(type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") - /* Refresh the datatype's metadata */ - if (dt->vol_obj) - if (H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, type_id) < 0) + if (dt->vol_obj) { + H5VL_datatype_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATATYPE_REFRESH; + vol_cb_args.args.refresh.type_id = type_id; + + if (H5VL_datatype_specific(dt->vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + } done: FUNC_LEAVE_API(ret_value) @@ -1222,32 +1241,41 @@ H5T_update_shared(H5T_t *dt) H5T_t * H5T_construct_datatype(H5VL_object_t *vol_obj) { - ssize_t nalloc; - void * buf = NULL; - H5T_t * dt = NULL; /* datatype object from VOL connector */ - H5T_t * ret_value = NULL; + H5T_t * dt = NULL; /* Datatype object from VOL connector */ + H5VL_datatype_get_args_t vol_cb_args; /* Arguments to VOL callback */ + size_t nalloc = 0; /* Size required to store serialized form of datatype */ + void * buf = NULL; /* Buffer to store serialized datatype */ + H5T_t * ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - /* get required buf size for encoding the datatype */ - if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &nalloc, NULL, 0) < 0) + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATATYPE_GET_BINARY_SIZE; + vol_cb_args.args.get_binary_size.size = &nalloc; + + /* Get required buf size for encoding the datatype */ + if (H5VL_datatype_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size") - /* allocate buffer to store binary description of the datatype */ - if (NULL == (buf = (void *)H5MM_calloc((size_t)nalloc))) + /* Allocate buffer to store binary description of the datatype */ + if (NULL == (buf = (void *)H5MM_calloc(nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_DATATYPE_GET_BINARY; + vol_cb_args.args.get_binary.buf = buf; + vol_cb_args.args.get_binary.buf_size = nalloc; + /* get binary description of the datatype */ - if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &nalloc, buf, (size_t)nalloc) < 0) + if (H5VL_datatype_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype") - if (NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) + /* Construct datatype, from serialized form in buffer */ + if (NULL == (dt = H5T_decode(nalloc, buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't decode datatype") - dt->vol_obj = vol_obj; + /* Set return value */ ret_value = dt; done: @@ -1407,3 +1435,34 @@ H5T_already_vol_managed(const H5T_t *dt) FUNC_LEAVE_NOAPI(dt->vol_obj != NULL) } /* end H5T_already_vol_managed() */ + +/*------------------------------------------------------------------------- + * Function: H5T_invoke_vol_optional + * + * Purpose: Invokes an optional VOL connector-specific operation on a named datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_invoke_vol_optional(H5T_t *dt, H5VL_optional_args_t *args, hid_t dxpl_id, void **req, + H5VL_object_t **vol_obj_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check that datatype is committed */ + if (!H5T_is_named(dt)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a committed datatype") + + /* Only invoke callback if VOL object is set for the datatype */ + if (dt->vol_obj) + if (H5VL_datatype_optional_op(dt->vol_obj, args, dxpl_id, req, vol_obj_ptr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_invoke_vol_optional() */ diff --git a/src/H5Tdevelop.h b/src/H5Tdevelop.h new file mode 100644 index 0000000..e642d7c --- /dev/null +++ b/src/H5Tdevelop.h @@ -0,0 +1,227 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5T (datatype) developer + * support routines. + */ + +#ifndef _H5Tdevelop_H +#define _H5Tdevelop_H + +/* Include package's public header */ +#include "H5Tpublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/** + * Commands sent to conversion functions + */ +typedef enum H5T_cmd_t { + H5T_CONV_INIT = 0, /**< query and/or initialize private data */ + H5T_CONV_CONV = 1, /**< convert data from source to dest datatype */ + H5T_CONV_FREE = 2 /**< function is being removed from path */ +} H5T_cmd_t; + +/** + * How is the `bkg' buffer used by the conversion function? + */ +typedef enum H5T_bkg_t { + H5T_BKG_NO = 0, /**< background buffer is not needed, send NULL */ + H5T_BKG_TEMP = 1, /**< bkg buffer used as temp storage only */ + H5T_BKG_YES = 2 /**< init bkg buf with data before conversion */ +} H5T_bkg_t; + +/** + * Type conversion client data + */ +//! +typedef struct H5T_cdata_t { + H5T_cmd_t command; /**< what should the conversion function do? */ + H5T_bkg_t need_bkg; /**< is the background buffer needed? */ + hbool_t recalc; /**< recalculate private data */ + void * priv; /**< private data */ +} H5T_cdata_t; +//! + +/** + * Conversion function persistence + */ +typedef enum H5T_pers_t { + H5T_PERS_DONTCARE = -1, /**< wild card */ + H5T_PERS_HARD = 0, /**< hard conversion function */ + H5T_PERS_SOFT = 1 /**< soft conversion function */ +} H5T_pers_t; + +/** + * All datatype conversion functions are... + */ +//! +typedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); +//! + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup CONV + * + * \brief Registers a datatype conversion function + * + * \param[in] pers Conversion function type + * \param[in] name Name displayed in diagnostic output + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[in] func Function to convert between source and destination datatypes + * + * \return \herr_t + * + * \details H5Tregister() registers a hard or soft conversion function for a + * datatype conversion path. The parameter \p pers indicates whether a + * conversion function is hard (#H5T_PERS_HARD) or soft + * (#H5T_PERS_SOFT). User-defined functions employing compiler casting + * are designated as \Emph{hard}; other user-defined conversion + * functions registered with the HDF5 library (with H5Tregister() ) + * are designated as \Emph{soft}. The HDF5 library also has its own + * hard and soft conversion functions. + * + * A conversion path can have only one hard function. When type is + * #H5T_PERS_HARD, \p func replaces any previous hard function. + * + * When type is #H5T_PERS_SOFT, H5Tregister() adds the function to the + * end of the master soft list and replaces the soft function in all + * applicable existing conversion paths. Soft functions are used when + * determining which conversion function is appropriate for this path. + * + * The \p name is used only for debugging and should be a short + * identifier for the function. + * + * The path is specified by the source and destination datatypes \p + * src_id and \p dst_id. For soft conversion functions, only the class + * of these types is important. + * + * The type of the conversion function pointer is declared as: + * \snippet this H5T_conv_t_snip + * + * The \ref H5T_cdata_t \c struct is declared as: + * \snippet this H5T_cdata_t_snip + * + * \since 1.6.3 The following change occurred in the \ref H5T_conv_t function: + * the \c nelmts parameter type changed to size_t. + * + */ +H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); +/** + * \ingroup CONV + * + * \brief Removes a conversion function + * + * \param[in] pers Conversion function type + * \param[in] name Name displayed in diagnostic output + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[in] func Function to convert between source and destination datatypes + * + * \return \herr_t + * + * \details H5Tunregister() removes a conversion function matching criteria + * such as soft or hard conversion, source and destination types, and + * the conversion function. + * + * If a user is trying to remove a conversion function he registered, + * all parameters can be used. If he is trying to remove a library’s + * default conversion function, there is no guarantee the \p name and + * \p func parameters will match the user’s chosen values. Passing in + * some values may cause this function to fail. A good practice is to + * pass in NULL as their values. + * + * All parameters are optional. The missing parameters will be used to + * generalize the search criteria. + * + * The conversion function pointer type declaration is described in + * H5Tregister(). + * + * \version 1.6.3 The following change occurred in the \ref H5T_conv_t function: + * the \c nelmts parameter type changed to size_t. + * + */ +H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); +/** + * \ingroup CONV + * + * \brief Finds a conversion function + * + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[out] pcdata Pointer to type conversion data + * + * \return Returns a pointer to a suitable conversion function if successful. + * Otherwise returns NULL. + * + * \details H5Tfind() finds a conversion function that can handle a conversion + * from type \p src_id to type \p dst_id. The \p pcdata argument is a + * pointer to a pointer to type conversion data which was created and + * initialized by the soft type conversion function of this path when + * the conversion function was installed on the path. + * + */ +H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); +/** + * \ingroup CONV + * + * \brief Check whether the library’s default conversion is hard conversion + * + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * + * \return \htri_t + * + * \details H5Tcompiler_conv() determines whether the library’s conversion + * function from type \p src_id to type \p dst_id is a compiler (hard) + * conversion or not. A compiler conversion uses compiler’s casting; a + * library (soft) conversion uses the library’s own conversion + * function. + * + * \since 1.8.0 + * + */ +H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); + +#ifdef __cplusplus +} +#endif + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +#endif /* _H5Tdevelop_H */ diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 9ee0d04..6624096 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -20,8 +20,9 @@ /* Early typedefs to avoid circular dependencies */ typedef struct H5T_t H5T_t; -/* Get package's public header */ +/* Include package's public headers */ #include "H5Tpublic.h" +#include "H5Tdevelop.h" /* Other public headers needed by this file */ #include "H5MMpublic.h" /* Memory management */ @@ -151,6 +152,8 @@ H5_DLL herr_t H5T_save_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O H5_DLL herr_t H5T_restore_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); H5_DLL hbool_t H5T_already_vol_managed(const H5T_t *dt); H5_DLL htri_t H5T_is_vl_storage(const H5T_t *dt); +H5_DLL herr_t H5T_invoke_vol_optional(H5T_t *dt, H5VL_optional_args_t *args, hid_t dxpl_id, void **req, + H5VL_object_t **vol_obj_ptr); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 70a119d..bb5b0ef 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -153,52 +153,13 @@ typedef enum H5T_pad_t { //! /** - * Commands sent to conversion functions - */ -typedef enum H5T_cmd_t { - H5T_CONV_INIT = 0, /**< query and/or initialize private data */ - H5T_CONV_CONV = 1, /**< convert data from source to dest datatype */ - H5T_CONV_FREE = 2 /**< function is being removed from path */ -} H5T_cmd_t; - -/** - * How is the `bkg' buffer used by the conversion function? - */ -typedef enum H5T_bkg_t { - H5T_BKG_NO = 0, /**< background buffer is not needed, send NULL */ - H5T_BKG_TEMP = 1, /**< bkg buffer used as temp storage only */ - H5T_BKG_YES = 2 /**< init bkg buf with data before conversion */ -} H5T_bkg_t; - -/** - * Type conversion client data - */ -//! -typedef struct H5T_cdata_t { - H5T_cmd_t command; /**< what should the conversion function do? */ - H5T_bkg_t need_bkg; /**< is the background buffer needed? */ - hbool_t recalc; /**< recalculate private data */ - void * priv; /**< private data */ -} H5T_cdata_t; -//! - -/** - * Conversion function persistence - */ -typedef enum H5T_pers_t { - H5T_PERS_DONTCARE = -1, /**< wild card */ - H5T_PERS_HARD = 0, /**< hard conversion function */ - H5T_PERS_SOFT = 1 /**< soft conversion function */ -} H5T_pers_t; - -/** * The order to retrieve atomic native datatype */ //! typedef enum H5T_direction_t { - H5T_DIR_DEFAULT = 0, /**< default direction is inscendent */ - H5T_DIR_ASCEND = 1, /**< in inscendent order */ - H5T_DIR_DESCEND = 2 /**< in descendent order */ + H5T_DIR_DEFAULT = 0, /**< default direction is ascending */ + H5T_DIR_ASCEND = 1, /**< in ascending order */ + H5T_DIR_DESCEND = 2 /**< in descending order */ } H5T_direction_t; //! @@ -258,14 +219,6 @@ typedef struct { extern "C" { #endif -/** - * All datatype conversion functions are... - */ -//! -typedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -//! - //! /** * \brief Exception handler. @@ -279,7 +232,7 @@ typedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, siz * \returns Valid callback function return values are #H5T_CONV_ABORT, * #H5T_CONV_UNHANDLED and #H5T_CONV_HANDLED. * - * \details If an exception like overflow happenes during conversion, this + * \details If an exception like overflow happens during conversion, this * function is called if it's registered through H5Pset_type_conv_cb(). * */ @@ -2710,130 +2663,6 @@ H5_DLL herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset); */ H5_DLL herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad); -/* Type conversion database */ -/** - * \ingroup CONV - * - * \brief Registers a datatype conversion function - * - * \param[in] pers Conversion function type - * \param[in] name Name displayed in diagnostic output - * \type_id{src_id} of source datatype - * \type_id{dst_id} of destination datatype - * \param[in] func Function to convert between source and destination datatypes - * - * \return \herr_t - * - * \details H5Tregister() registers a hard or soft conversion function for a - * datatype conversion path. The parameter \p pers indicates whether a - * conversion function is hard (#H5T_PERS_HARD) or soft - * (#H5T_PERS_SOFT). User-defined functions employing compiler casting - * are designated as \Emph{hard}; other user-defined conversion - * functions registered with the HDF5 library (with H5Tregister() ) - * are designated as \Emph{soft}. The HDF5 library also has its own - * hard and soft conversion functions. - * - * A conversion path can have only one hard function. When type is - * #H5T_PERS_HARD, \p func replaces any previous hard function. - * - * When type is #H5T_PERS_SOFT, H5Tregister() adds the function to the - * end of the master soft list and replaces the soft function in all - * applicable existing conversion paths. Soft functions are used when - * determining which conversion function is appropriate for this path. - * - * The \p name is used only for debugging and should be a short - * identifier for the function. - * - * The path is specified by the source and destination datatypes \p - * src_id and \p dst_id. For soft conversion functions, only the class - * of these types is important. - * - * The type of the conversion function pointer is declared as: - * \snippet this H5T_conv_t_snip - * - * The \ref H5T_cdata_t \c struct is declared as: - * \snippet this H5T_cdata_t_snip - * - * \since 1.6.3 The following change occurred in the \ref H5T_conv_t function: - * the \c nelmts parameter type changed to size_t. - * - */ -H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); -/** - * \ingroup CONV - * - * \brief Removes a conversion function - * - * \param[in] pers Conversion function type - * \param[in] name Name displayed in diagnostic output - * \type_id{src_id} of source datatype - * \type_id{dst_id} of destination datatype - * \param[in] func Function to convert between source and destination datatypes - * - * \return \herr_t - * - * \details H5Tunregister() removes a conversion function matching criteria - * such as soft or hard conversion, source and destination types, and - * the conversion function. - * - * If a user is trying to remove a conversion function he registered, - * all parameters can be used. If he is trying to remove a library’s - * default conversion function, there is no guarantee the \p name and - * \p func parameters will match the user’s chosen values. Passing in - * some values may cause this function to fail. A good practice is to - * pass in NULL as their values. - * - * All parameters are optional. The missing parameters will be used to - * generalize the search criteria. - * - * The conversion function pointer type declaration is described in - * H5Tregister(). - * - * \version 1.6.3 The following change occurred in the \ref H5T_conv_t function: - * the \c nelmts parameter type changed to size_t. - * - */ -H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); -/** - * \ingroup CONV - * - * \brief Finds a conversion function - * - * \type_id{src_id} of source datatype - * \type_id{dst_id} of destination datatype - * \param[out] pcdata Pointer to type conversion data - * - * \return Returns a pointer to a suitable conversion function if successful. - * Otherwise returns NULL. - * - * \details H5Tfind() finds a conversion function that can handle a conversion - * from type \p src_id to type \p dst_id. The \p pcdata argument is a - * pointer to a pointer to type conversion data which was created and - * initialized by the soft type conversion function of this path when - * the conversion function was installed on the path. - * - */ -H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); -/** - * \ingroup CONV - * - * \brief Check whether the library’s default conversion is hard conversion - * - * \type_id{src_id} of source datatype - * \type_id{dst_id} of destination datatype - * - * \return \htri_t - * - * \details H5Tcompiler_conv() determines whether the library’s conversion - * function from type \p src_id to type \p dst_id is a compiler (hard) - * conversion or not. A compiler conversion uses compiler’s casting; a - * library (soft) conversion uses the library’s own conversion - * function. - * - * \since 1.8.0 - * - */ -H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); /** * -------------------------------------------------------------------------- * \ingroup CONV diff --git a/src/H5Tref.c b/src/H5Tref.c index 1114c25..cac8cf6 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -289,12 +289,16 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) } /* end else-if */ else { H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ size_t ref_encode_size; H5R_ref_priv_t fixed_ref; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &cont_info) < 0) + if (H5VL_file_get(file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") /* Retrieve min encode size (when references have no vlen part) */ @@ -434,8 +438,10 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf /* Force re-calculating encoding size if any flags are set */ if (flags || !src_ref->encode_size) { - char file_name_buf_static[256]; /* File name */ - ssize_t file_name_len; /* Size of file name buffer */ + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + char * file_name = NULL; /* Actual file name */ + char file_name_buf_static[256]; /* File name */ + size_t file_name_len = 0; /* Length of file name */ /* Pass the correct encoding version for the selection depending on the * file libver bounds, this is later retrieved in H5S hyper encode */ @@ -458,21 +464,38 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf H5CX_set_libver_bounds(NULL); } /* end if */ + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_NAME; + vol_cb_args.args.get_name.type = H5I_FILE; + vol_cb_args.args.get_name.buf_size = sizeof(file_name_buf_static); + vol_cb_args.args.get_name.buf = file_name_buf_static; + vol_cb_args.args.get_name.file_name_len = &file_name_len; + /* Get file name */ - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, - sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") - if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { - if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, - (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + + /* Check if we need to allocate a buffer for the file name */ + if (file_name_len >= sizeof(file_name_buf_static)) { + /* Allocate file name buffer */ + if (NULL == (file_name_buf_dyn = H5MM_malloc(file_name_len + 1))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, 0, "can't allocate space for file name") + + /* Update VOL callback arguments */ + vol_cb_args.args.get_name.buf_size = file_name_len + 1; + vol_cb_args.args.get_name.buf = file_name_buf_dyn; + + /* Get file name again */ + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + + file_name = file_name_buf_dyn; } /* end if */ + else + file_name = file_name_buf_static; /* Determine encoding size */ - if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, NULL, - &ret_value, flags) < 0) + if (H5R__encode(file_name, src_ref, NULL, &ret_value, flags) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, 0, "unable to determine encoding size") } /* end if */ else { @@ -506,10 +529,10 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s H5VL_object_t * vol_obj; /* VOL object for src ref's location */ const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ + char * file_name = NULL; /* Actual file name */ char file_name_buf_static[256] = {'\0'}; /* File name */ char * file_name_buf_dyn = NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ - ssize_t file_name_len; /* Size of file name buffer */ unsigned flags = 0; /* References flags */ herr_t ret_value = SUCCEED; /* Return value */ @@ -560,21 +583,42 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s /* Get file name (if external reference) */ if (flags) { - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, - sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + size_t file_name_len = 0; /* Length of file name */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_NAME; + vol_cb_args.args.get_name.type = H5I_FILE; + vol_cb_args.args.get_name.buf_size = sizeof(file_name_buf_static); + vol_cb_args.args.get_name.buf = file_name_buf_static; + vol_cb_args.args.get_name.file_name_len = &file_name_len; + + /* Get file name */ + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") - if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { - if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") - if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, - (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + + /* Check if we need to allocate a buffer for the file name */ + if (file_name_len >= sizeof(file_name_buf_static)) { + /* Allocate file name buffer */ + if (NULL == (file_name_buf_dyn = H5MM_malloc(file_name_len + 1))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, 0, "can't allocate space for file name") + + /* Update VOL callback arguments */ + vol_cb_args.args.get_name.buf_size = file_name_len + 1; + vol_cb_args.args.get_name.buf = file_name_buf_dyn; + + /* Get file name again */ + if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + + file_name = file_name_buf_dyn; } /* end if */ - } /* end if */ + else + file_name = file_name_buf_static; + } /* end if */ /* Encode reference */ - if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, - (unsigned char *)dst_buf, &dst_size, flags) < 0) + if (H5R__encode(file_name, src_ref, (unsigned char *)dst_buf, &dst_size, flags) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Cannot encode reference") done: @@ -731,11 +775,17 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull = FALSE; } else { + H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + /* Skip the size / header */ p = (const uint8_t *)src_buf + H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_ISNULL; + vol_cb_args.args.is_null.isnull = isnull; + /* Check if blob ID is "nil" */ - if (H5VL_blob_specific(src_file, (void *)p, H5VL_BLOB_ISNULL, isnull) < 0) + if (H5VL_blob_specific(src_file, (void *)p, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") } @@ -755,9 +805,10 @@ done: static herr_t H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) { - uint8_t *q = (uint8_t *)dst_buf; - uint8_t *p_bg = (uint8_t *)bg_buf; - herr_t ret_value = SUCCEED; + H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + uint8_t * q = (uint8_t *)dst_buf; + uint8_t * p_bg = (uint8_t *)bg_buf; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC H5T_REF_LOG_DEBUG(""); @@ -770,8 +821,11 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) /* Skip the size / header */ p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_DELETE; + /* Remove blob for old data */ - if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) + if (H5VL_blob_specific(dst_file, (void *)p_bg, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ @@ -782,8 +836,11 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) /* Set the size */ UINT32ENCODE(q, 0); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_SETNULL; + /* Set blob ID to "nil" */ - if (H5VL_blob_specific(dst_file, q, H5VL_BLOB_SETNULL) < 0) + if (H5VL_blob_specific(dst_file, q, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") done: @@ -913,15 +970,19 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, /* TODO Should get rid of bg stuff */ if (p_bg) { - size_t p_buf_size_left = dst_size; + H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + size_t p_buf_size_left = dst_size; /* Skip the size / header */ p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); HDassert(p_buf_size_left > (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE)); p_buf_size_left -= (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_DELETE; + /* Remove blob for old data */ - if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) + if (H5VL_blob_specific(dst_file, (void *)p_bg, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 39d14f3..080d725 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -247,8 +247,7 @@ done: htri_t H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) { - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - htri_t ret_value = FALSE; /* Indicate success, but no location change */ + htri_t ret_value = FALSE; /* Indicate success, but no location change */ FUNC_ENTER_PACKAGE @@ -293,15 +292,22 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) dt->shared->u.vlen.file = NULL; break; - case H5T_LOC_DISK: /* Disk based VL datatype */ + /* Disk based VL datatype */ + case H5T_LOC_DISK: { + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ + HDassert(file); /* Mark this type as being stored on disk */ dt->shared->u.vlen.loc = H5T_LOC_DISK; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO; + vol_cb_args.args.get_cont_info.info = &cont_info; + /* Get container info */ - if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &cont_info) < 0) + if (H5VL_file_get(file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") /* The datatype size is equal to 4 bytes for the sequence length @@ -319,6 +325,7 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) if (H5T_own_vol_obj(dt, file) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't give ownership of VOL object") break; + } case H5T_LOC_BADLOC: /* Allow undefined location. In H5Odtype.c, H5O_dtype_decode sets undefined @@ -841,8 +848,9 @@ H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_ static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) { - uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -854,8 +862,12 @@ H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) /* Skip the sequence's length */ vl += 4; + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_ISNULL; + vol_cb_args.args.is_null.isnull = isnull; + /* Check if blob ID is "nil" */ - if (H5VL_blob_specific(file, vl, H5VL_BLOB_ISNULL, isnull) < 0) + if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") done: @@ -877,8 +889,9 @@ done: static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) { - uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -895,8 +908,11 @@ H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) /* Set the length of the sequence */ UINT32ENCODE(vl, 0); + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_SETNULL; + /* Set blob ID to "nil" */ - if (H5VL_blob_specific(file, vl, H5VL_BLOB_SETNULL) < 0) + if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") done: @@ -1013,10 +1029,16 @@ H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) UINT32DECODE(vl, seq_len); /* Delete object, if length > 0 */ - if (seq_len > 0) - if (H5VL_blob_specific(file, (void *)vl, H5VL_BLOB_DELETE) < 0) /* Casting away 'const' OK -QAK */ + if (seq_len > 0) { + H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_BLOB_DELETE; + + if (H5VL_blob_specific(file, (void *)vl, &vol_cb_args) < 0) /* Casting away 'const' OK -QAK */ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5VL.c b/src/H5VL.c index a77a6f3..2cece6d 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -764,6 +764,39 @@ done: } /* H5VLretrieve_lib_state() */ /*--------------------------------------------------------------------------- + * Function: H5VLstart_lib_state + * + * Purpose: Opens a new internal state for the HDF5 library. + * + * Note: This routine is _only_ for HDF5 VOL connector authors! It is + * _not_ part of the public API for HDF5 application developers. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, February 5, 2021 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLstart_lib_state(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */ + FUNC_ENTER_API_NOINIT + H5TRACE0("e", ""); + + /* Start a new library state */ + if (H5VL_start_lib_state() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't start new library state") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLstart_lib_state() */ + +/*--------------------------------------------------------------------------- * Function: H5VLrestore_lib_state * * Purpose: Restores the internal state of the HDF5 library. @@ -801,16 +834,16 @@ done: } /* H5VLrestore_lib_state() */ /*--------------------------------------------------------------------------- - * Function: H5VLreset_lib_state + * Function: H5VLfinish_lib_state * - * Purpose: Resets the internal state of the HDF5 library, undoing the - * affects of H5VLrestore_lib_state. + * Purpose: Closes the internal state of the HDF5 library, undoing the + * affects of H5VLstart_lib_state. * * Note: This routine is _only_ for HDF5 VOL connector authors! It is * _not_ part of the public API for HDF5 application developers. * * Note: This routine must be called as a "pair" with - * H5VLrestore_lib_state. It can be called before / after / + * H5VLstart_lib_state. It can be called before / after / * independently of H5VLfree_lib_state. * * Return: Success: Non-negative @@ -822,7 +855,7 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5VLreset_lib_state(void) +H5VLfinish_lib_state(void) { herr_t ret_value = SUCCEED; /* Return value */ @@ -831,12 +864,12 @@ H5VLreset_lib_state(void) H5TRACE0("e", ""); /* Reset the library state */ - if (H5VL_reset_lib_state() < 0) + if (H5VL_finish_lib_state() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset library state") done: FUNC_LEAVE_API_NOINIT(ret_value) -} /* H5VLreset_lib_state() */ +} /* H5VLfinish_lib_state() */ /*--------------------------------------------------------------------------- * Function: H5VLfree_lib_state @@ -911,3 +944,136 @@ H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, uint64_t done: FUNC_LEAVE_API(ret_value) } /* H5VLquery_optional() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLregister_opt_operation + * + * Purpose: Allow a VOL connector to register a new optional operation + * for a VOL object subclass. The operation name must be runtime + * unique for each operation, preferably avoiding naming clashes + * by using a Uniform Type Identifier (UTI, + *https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html) + * for each operation name. The value returned in the 'op_val' + * pointer will be unique for that VOL connector to use for its + * operation on that subclass. + * + * For example, registering a 'prefetch' operation for the + * caching VOL connector written at the ALCF at Argonne National + * Laboratory could have a UTI of: "gov.anl.alcf.cache.prefetch", + * and the "evict" operation for the same connector could have a + * UTI of: "gov.anl.alcf.cache.evict". Registering a "suspend + * background threads" operation for the asynchronous VOL connector + * written at NERSC at Lawrence Berkeley National Laboratory could + * have a UTI of: "gov.lbnl.nersc.async.suspend_bkg_threads". + * + * Note: The first 1024 values of each subclass's optional operations + * are reserved for the native VOL connector's use. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLregister_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val /*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "VS*sx", subcls, op_name, op_val); + + /* Check args */ + if (NULL == op_val) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_val pointer") + if (NULL == op_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_name pointer") + if ('\0' == *op_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_name string") + if (!((H5VL_SUBCLS_ATTR == subcls) || (H5VL_SUBCLS_DATASET == subcls) || + (H5VL_SUBCLS_DATATYPE == subcls) || (H5VL_SUBCLS_FILE == subcls) || (H5VL_SUBCLS_GROUP == subcls) || + (H5VL_SUBCLS_OBJECT == subcls) || (H5VL_SUBCLS_LINK == subcls) || (H5VL_SUBCLS_REQUEST == subcls))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid VOL subclass type") + + /* Register the operation */ + if (H5VL__register_opt_operation(subcls, op_name, op_val) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register dynamic optional operation: '%s'", + op_name) + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLregister_opt_operation() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLfind_opt_operation + * + * Purpose: Look up a optional operation for a VOL object subclass, by name. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLfind_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val /*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "VS*sx", subcls, op_name, op_val); + + /* Check args */ + if (NULL == op_val) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_val pointer") + if (NULL == op_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_name pointer") + if ('\0' == *op_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_name string") + if (!((H5VL_SUBCLS_ATTR == subcls) || (H5VL_SUBCLS_DATASET == subcls) || + (H5VL_SUBCLS_DATATYPE == subcls) || (H5VL_SUBCLS_FILE == subcls) || (H5VL_SUBCLS_GROUP == subcls) || + (H5VL_SUBCLS_OBJECT == subcls) || (H5VL_SUBCLS_LINK == subcls) || (H5VL_SUBCLS_REQUEST == subcls))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid VOL subclass type") + + /* Find the operation */ + if (H5VL__find_opt_operation(subcls, op_name, op_val) < 0) + HGOTO_ERROR(H5E_VOL, H5E_NOTFOUND, FAIL, "can't find dynamic optional operation: '%s'", op_name) + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLfind_opt_operation() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLunregister_opt_operation + * + * Purpose: Unregister a optional operation for a VOL object subclass, by name. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLunregister_opt_operation(H5VL_subclass_t subcls, const char *op_name) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "VS*s", subcls, op_name); + + /* Check args */ + if (NULL == op_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_name pointer") + if ('\0' == *op_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid op_name string") + if (!((H5VL_SUBCLS_ATTR == subcls) || (H5VL_SUBCLS_DATASET == subcls) || + (H5VL_SUBCLS_DATATYPE == subcls) || (H5VL_SUBCLS_FILE == subcls) || (H5VL_SUBCLS_GROUP == subcls) || + (H5VL_SUBCLS_OBJECT == subcls) || (H5VL_SUBCLS_LINK == subcls) || (H5VL_SUBCLS_REQUEST == subcls))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid VOL subclass type") + + /* Unregister the operation */ + if (H5VL__unregister_opt_operation(subcls, op_name) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "can't unregister dynamic optional operation: '%s'", + op_name) + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLunregister_opt_operation() */ diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 02e0ee0..baedbf1 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -29,11 +29,13 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ +#include "H5ESprivate.h" /* Event Sets */ +#include "H5Fprivate.h" /* File access */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5PLprivate.h" /* Plugins */ +#include "H5Tprivate.h" /* Datatypes */ #include "H5VLpkg.h" /* Virtual Object Layer */ /****************/ @@ -54,6 +56,10 @@ typedef struct H5VL_file_open_find_connector_t { hid_t fapl_id; } H5VL_file_open_find_connector_t; +/* Typedef for common callback form of registered optional operations */ +typedef herr_t (*H5VL_reg_opt_oper_t)(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); + /********************/ /* Package Typedefs */ /********************/ @@ -70,13 +76,12 @@ static herr_t H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type void **req); static herr_t H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); +static herr_t H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_args_t *args, hid_t dxpl_id, + void **req); static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); static void * H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, @@ -87,26 +92,24 @@ static herr_t H5VL__dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_ hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); static herr_t H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); -static herr_t H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, - H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); static void * H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); static void * H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, - H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); static herr_t H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); static void * H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); @@ -114,28 +117,28 @@ static void * H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigne hid_t dxpl_id, void **req); static herr_t H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_info, void *op_data); -static herr_t H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); static void * H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); static void * H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); -static herr_t H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req); static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); @@ -143,12 +146,11 @@ static herr_t H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + H5VL_link_get_args_t *args, hid_t dxpl_id, void **req); static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL__link_optional(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); static void * H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, H5I_type_t *opened_type, hid_t dxpl_id, void **req); static herr_t H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, @@ -156,12 +158,11 @@ static herr_t H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_ const H5VL_class_t *cls, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req); static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL__object_optional(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); static herr_t H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); static herr_t H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, H5VL_subclass_t subcls, @@ -170,27 +171,25 @@ static herr_t H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t ti H5VL_request_status_t *status); static herr_t H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, void *ctx); static herr_t H5VL__request_cancel(void *req, const H5VL_class_t *cls, H5VL_request_status_t *status); -static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls, - H5VL_request_specific_t specific_type, va_list arguments); -static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional_t opt_type, - va_list arguments); +static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls, H5VL_request_specific_args_t *args); +static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_optional_args_t *args); static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls); static herr_t H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, void *blob_id, void *ctx); static herr_t H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, void *buf, size_t size, void *ctx); static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, - H5VL_blob_specific_t specific_type, va_list arguments); + H5VL_blob_specific_args_t *args); static herr_t H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, - H5VL_blob_optional_t opt_type, va_list arguments); + H5VL_optional_args_t *args); static herr_t H5VL__token_cmp(void *obj, const H5VL_class_t *cls, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); static herr_t H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, const H5O_token_t *token, char **token_str); static herr_t H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, const char *token_str, H5O_token_t *token); -static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, - va_list arguments); +static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); /*********************/ /* Package Variables */ @@ -329,6 +328,50 @@ done: } /* H5VLget_value */ /*------------------------------------------------------------------------- + * Function: H5VL__common_optional_op + * + * Purpose: Performs an optional connector-specific operation on an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__common_optional_op(hid_t id, H5I_type_t id_type, H5VL_reg_opt_oper_t reg_opt_op, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req, H5VL_object_t **_vol_obj_ptr) +{ + H5VL_object_t * tmp_vol_obj = NULL; /* Object for id */ + H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for id */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check ID type & get VOL object */ + if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(id, id_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid identifier") + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(*vol_obj_ptr) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + /* (Must return value from callback, for iterators) */ + if ((ret_value = + (*reg_opt_op)((*vol_obj_ptr)->data, (*vol_obj_ptr)->connector->cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute optional callback"); + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__common_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL_copy_connector_info * * Purpose: Copy the VOL info for a connector @@ -1341,8 +1384,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1353,7 +1395,7 @@ H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr get' method") /* Call the corresponding VOL callback */ - if ((cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->attr_cls.get)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") done: @@ -1371,10 +1413,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1386,16 +1426,10 @@ H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -1414,23 +1448,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req /*out*/, - va_list arguments) +H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVaixx", obj, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if (NULL == args) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument struct") /* Call the corresponding internal VOL routine */ - if (H5VL__attr_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__attr_get(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get attribute information") done: @@ -1449,7 +1484,7 @@ done: */ static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1460,8 +1495,9 @@ H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_c HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr specific' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = (cls->attr_cls.specific)(obj, loc_params, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute 'specific' callback"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1479,10 +1515,8 @@ done: */ herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1494,17 +1528,12 @@ H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if ((ret_value = H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, - dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = + H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute 'specific' callback"); done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -1524,13 +1553,13 @@ done: */ herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req /*out*/, va_list arguments) + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE7("e", "*x*#iVbixx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -1539,8 +1568,9 @@ H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__attr_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__attr_specific(obj, loc_params, cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute 'specific' callback"); done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -1557,8 +1587,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1569,8 +1598,9 @@ H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr optional' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->attr_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = (cls->attr_cls.optional)(obj, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute optional callback"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1587,11 +1617,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, - ...) +H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1603,17 +1630,11 @@ H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if ((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, - arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute optional callback"); done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -1632,14 +1653,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLattr_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVsixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -1648,14 +1669,58 @@ H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__attr_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__attr_optional(obj, cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute optional callback"); done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLattr_optional_op + * + * Purpose: Performs an optional connector-specific operation on an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t attr_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id) +{ + H5VL_object_t *vol_obj = NULL; /* Attribute VOL object */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*s*sIui*!ii", app_file, app_func, app_line, attr_id, args, dxpl_id, es_id); + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Call the common VOL connector optional routine */ + if ((ret_value = H5VL__common_optional_op(attr_id, H5I_ATTR, H5VL__attr_optional, args, dxpl_id, + token_ptr, &vol_obj)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, + H5ARG_TRACE7(FUNC, "*s*sIui*!ii", app_file, app_func, app_line, attr_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__attr_close * * Purpose: Closes an attribute through the VOL @@ -2169,8 +2234,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2181,7 +2246,7 @@ H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_typ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset get' method") /* Call the corresponding VOL callback */ - if ((cls->dataset_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->dataset_cls.get)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") done: @@ -2199,10 +2264,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2214,16 +2277,10 @@ H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_ vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -2242,14 +2299,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req /*out*/, - va_list arguments) +H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVcixx", obj, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -2258,7 +2315,7 @@ H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_t get_type, hid_ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_get(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute dataset get callback") done: @@ -2276,8 +2333,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2288,7 +2345,7 @@ H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset specific' method") /* Call the corresponding VOL callback */ - if ((cls->dataset_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->dataset_cls.specific)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: @@ -2306,11 +2363,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, - void **req, ...) +H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, + void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2322,17 +2377,10 @@ H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t spec vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, - arguments) < 0) + if (H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -2351,14 +2399,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVdixx", obj, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -2367,7 +2415,7 @@ H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t spec HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_specific(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: @@ -2385,8 +2433,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2397,7 +2445,7 @@ H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset optional' method") /* Call the corresponding VOL callback */ - if ((cls->dataset_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->dataset_cls.optional)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: @@ -2415,11 +2463,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, - void **req, ...) +H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2431,16 +2476,10 @@ H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_ vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -2459,14 +2498,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVtixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -2475,7 +2514,7 @@ H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_optional(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: @@ -2483,6 +2522,49 @@ done: } /* end H5VLdataset_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLdataset_optional_op + * + * Purpose: Performs an optional connector-specific operation on a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t dset_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id) +{ + H5VL_object_t *vol_obj = NULL; /* Dataset VOL object */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*s*sIui*!ii", app_file, app_func, app_line, dset_id, args, dxpl_id, es_id); + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Call the corresponding internal VOL routine */ + if (H5VL__common_optional_op(dset_id, H5I_DATASET, H5VL__dataset_optional, args, dxpl_id, token_ptr, + &vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, + H5ARG_TRACE7(FUNC, "*s*sIui*!ii", app_file, app_func, app_line, dset_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__dataset_close * * Purpose: Closes a dataset through the VOL @@ -2807,8 +2889,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2819,8 +2901,8 @@ H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_t HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype get' method") /* Call the corresponding VOL callback */ - if ((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") + if ((cls->datatype_cls.get)(obj, args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype 'get' failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2837,10 +2919,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2852,16 +2932,10 @@ H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hi vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -2880,14 +2954,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVeixx", obj, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -2895,12 +2969,8 @@ H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_t get_type, hi if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->datatype_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `datatype get' method") - /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_get(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback") done: @@ -2918,8 +2988,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_args_t *args, + hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2930,7 +3000,7 @@ H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specif HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype specific' method") /* Call the corresponding VOL callback */ - if ((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->datatype_cls.specific)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: @@ -2948,11 +3018,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, - void **req, ...) +H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_args_t *args, hid_t dxpl_id, + void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2964,17 +3032,10 @@ H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t sp vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, - arguments) < 0) + if (H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -2993,14 +3054,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVfixx", obj, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -3009,7 +3070,7 @@ H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t sp HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_specific(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: @@ -3027,8 +3088,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -3039,7 +3100,7 @@ H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_option HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype optional' method") /* Call the corresponding VOL callback */ - if ((cls->datatype_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->datatype_cls.optional)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: @@ -3057,11 +3118,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, - void **req, ...) +H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3073,17 +3131,10 @@ H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t op vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < - 0) + if (H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -3092,6 +3143,50 @@ done: } /* end H5VL_datatype_optional() */ /*------------------------------------------------------------------------- + * Function: H5VL_datatype_optional_op + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_optional_op(H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req, + H5VL_object_t **_vol_obj_ptr) +{ + H5VL_object_t * tmp_vol_obj = NULL; /* Object for id */ + H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for id */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set up vol_obj_ptr */ + *vol_obj_ptr = vol_obj; + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(*vol_obj_ptr) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__datatype_optional((*vol_obj_ptr)->data, (*vol_obj_ptr)->connector->cls, args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VLdatatype_optional * * Purpose: Performs an optional connector-specific operation on a datatype @@ -3102,14 +3197,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVuixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -3118,7 +3213,7 @@ H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t op HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_optional(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: @@ -3126,6 +3221,53 @@ done: } /* end H5VLdatatype_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLdatatype_optional_op + * + * Purpose: Performs an optional connector-specific operation on a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t type_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id) +{ + H5T_t * dt; /* Datatype for this operation */ + H5VL_object_t *vol_obj = NULL; /* Datatype VOL object */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*s*sIui*!ii", app_file, app_func, app_line, type_id, args, dxpl_id, es_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") + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Only invoke callback if VOL object is set for the datatype */ + if (H5T_invoke_vol_optional(dt, args, dxpl_id, token_ptr, &vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to invoke datatype optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, + H5ARG_TRACE7(FUNC, "*s*sIui*!ii", app_file, app_func, app_line, type_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__datatype_close * * Purpose: Closes a datatype through the VOL @@ -3380,14 +3522,15 @@ static herr_t H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_info, void *op_data) { H5VL_file_open_find_connector_t *udata = (H5VL_file_open_find_connector_t *)op_data; - const H5VL_class_t * cls = (const H5VL_class_t *)plugin_info; + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ + const H5VL_class_t * cls = (const H5VL_class_t *)plugin_info; H5P_genplist_t * fapl_plist; H5P_genplist_t * fapl_plist_copy; + hbool_t is_accessible = FALSE; /* Whether file is accessible */ herr_t status; - htri_t is_accessible = FALSE; - hid_t connector_id = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - herr_t ret_value = H5_ITER_CONT; + hid_t connector_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + herr_t ret_value = H5_ITER_CONT; FUNC_ENTER_STATIC @@ -3416,11 +3559,16 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in if (H5P_set_vol(fapl_plist_copy, connector_id, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5_ITER_ERROR, "can't set VOL connector on fapl") + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_IS_ACCESSIBLE; + vol_cb_args.args.is_accessible.filename = udata->filename; + vol_cb_args.args.is_accessible.fapl_id = fapl_id; + vol_cb_args.args.is_accessible.accessible = &is_accessible; + /* Check if file is accessible with given VOL connector */ H5E_BEGIN_TRY { - status = H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - fapl_id, udata->filename, &is_accessible); + status = H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL); } H5E_END_TRY; @@ -3428,7 +3576,7 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in * the FAPL with that VOL connector set on it. Errors are ignored here * as some VOL connectors may not support H5Fis_accessible. */ - if (status == SUCCEED && is_accessible > 0) { + if (status == SUCCEED && is_accessible) { /* Modify 'connector_prop' to point to the VOL connector that * was actually used to open the file, rather than the original * VOL connector that was requested. @@ -3479,21 +3627,18 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned /* Call the corresponding internal VOL routine */ if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) { - H5VL_file_open_find_connector_t find_connector_ud; - hbool_t find_connector; - hbool_t connector_available = FALSE; + hbool_t is_default_conn = TRUE; /* Opening the file failed - Determine whether we should search * the plugin path to see if any other VOL connectors are available - * to attempt to open the file with. This only occurs if no particular - * VOL connector was specified (either via a FAPL or the - * HDF5_VOL_CONNECTOR environment variable). + * to attempt to open the file with. This only occurs if the default + * VOL connector was used for the initial file open attempt. */ - find_connector = !getenv("HDF5_VOL_CONNECTOR") && ((H5P_FILE_ACCESS_DEFAULT == fapl_id) || - connector_prop->connector_id == H5_DEFAULT_VOL); + H5VL__is_default_conn(fapl_id, connector_prop->connector_id, &is_default_conn); - if (find_connector) { - herr_t iter_ret; + if (is_default_conn) { + H5VL_file_open_find_connector_t find_connector_ud; + herr_t iter_ret; find_connector_ud.connector_prop = connector_prop; find_connector_ud.filename = name; @@ -3505,24 +3650,24 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned if (iter_ret < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, NULL, "failed to iterate over available VOL connector plugins") - else if (iter_ret) - connector_available = TRUE; + else if (iter_ret) { + /* If one of the available VOL connector plugins is + * able to open the file, clear the error stack from any + * previous file open failures and then open the file. + * Otherwise, if no VOL connectors are available, throw + * error from original file open failure. + */ + H5E_clear_stack(NULL); + + if (NULL == (ret_value = H5VL__file_open(find_connector_ud.cls, name, flags, + find_connector_ud.fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, + "can't open file '%s' with VOL connector '%s'", name, + find_connector_ud.cls->name) + } + else + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") } /* end if */ - - /* If one of the available VOL connector plugins is - * able to open the file, clear the error stack from any - * previous file open failures and then open the file. - * Otherwise, if no VOL connectors are available, throw - * error from original file open failure. - */ - if (connector_available) { - H5E_clear_stack(NULL); - - if (NULL == (ret_value = H5VL__file_open(find_connector_ud.cls, name, flags, - find_connector_ud.fapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "can't open file '%s' with VOL connector '%s'", - name, find_connector_ud.cls->name) - } else HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") } /* end if */ @@ -3581,8 +3726,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -3593,7 +3737,7 @@ H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file get' method") /* Call the corresponding VOL callback */ - if ((cls->file_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->file_cls.get)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") done: @@ -3611,10 +3755,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3626,16 +3768,10 @@ H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__file_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_get(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -3654,14 +3790,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req /*out*/, - va_list arguments) +H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVgixx", obj, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -3670,7 +3805,7 @@ H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__file_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_get(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute file get callback") done: @@ -3688,8 +3823,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -3700,7 +3835,7 @@ H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t spe HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file specific' method") /* Call the corresponding VOL callback */ - if ((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->file_cls.specific)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") done: @@ -3718,33 +3853,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, - void **req, ...) +H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, void **req) { const H5VL_class_t *cls; /* VOL connector's class struct */ - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Start access to the varargs, so they are available in all situations below */ - HDva_start(arguments, req); - arg_started = TRUE; - /* Special treatment of file access check & delete operations */ /* (Retrieve the VOL connector from the FAPL, since the file isn't open) */ - if (specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { + if (args->op_type == H5VL_FILE_IS_ACCESSIBLE || args->op_type == H5VL_FILE_DELETE) { H5P_genplist_t * plist; /* Property list pointer */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - va_list tmp_args; /* argument list passed from the API call */ hid_t fapl_id; /* File access property list for accessing the file */ /* Get the file access property list to access the file */ - HDva_copy(tmp_args, arguments); - fapl_id = HDva_arg(tmp_args, hid_t); - HDva_end(tmp_args); + if (args->op_type == H5VL_FILE_IS_ACCESSIBLE) + fapl_id = args->args.is_accessible.fapl_id; + else { + HDassert(args->op_type == H5VL_FILE_DELETE); + fapl_id = args->args.del.fapl_id; + } /* Get the VOL info from the FAPL */ if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) @@ -3770,14 +3900,10 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t } /* end else */ /* Call the corresponding internal VOL routine */ - if (H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -3798,21 +3924,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVhixx", obj, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__file_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_specific(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file specific callback") done: @@ -3830,8 +3956,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -3842,7 +3967,7 @@ H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file optional' method") /* Call the corresponding VOL callback */ - if ((cls->file_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->file_cls.optional)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") done: @@ -3860,11 +3985,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, - ...) +H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3876,16 +3998,10 @@ H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -3904,14 +4020,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLfile_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVvixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -3920,7 +4036,7 @@ H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__file_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_optional(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback") done: @@ -3928,6 +4044,49 @@ done: } /* end H5VLfile_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLfile_optional_op + * + * Purpose: Performs an optional connector-specific operation on a file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t file_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id) +{ + H5VL_object_t *vol_obj = NULL; /* File VOL object */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*s*sIui*!ii", app_file, app_func, app_line, file_id, args, dxpl_id, es_id); + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Call the corresponding internal VOL routine */ + if (H5VL__common_optional_op(file_id, H5I_FILE, H5VL__file_optional, args, dxpl_id, token_ptr, &vol_obj) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, + H5ARG_TRACE7(FUNC, "*s*sIui*!ii", app_file, app_func, app_line, file_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__file_close * * Purpose: Closes a file through the VOL @@ -4244,8 +4403,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -4256,7 +4414,7 @@ H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, h HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group get' method") /* Call the corresponding VOL callback */ - if ((cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->group_cls.get)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") done: @@ -4274,10 +4432,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4289,16 +4445,10 @@ H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dx vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__group_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_get(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -4317,14 +4467,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req /*out*/, - va_list arguments) +H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiViixx", obj, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -4333,7 +4482,7 @@ H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dx HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__group_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_get(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute group get callback") done: @@ -4351,8 +4500,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -4363,7 +4512,7 @@ H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t s HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group specific' method") /* Call the corresponding VOL callback */ - if ((cls->group_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->group_cls.specific)(obj, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: @@ -4381,11 +4530,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, - void **req, ...) +H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4397,17 +4543,10 @@ H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < - 0) + if (H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -4426,14 +4565,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVjixx", obj, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -4442,7 +4581,7 @@ H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__group_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_specific(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: @@ -4460,8 +4599,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -4472,8 +4611,9 @@ H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t o HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group optional' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->group_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = (cls->group_cls.optional)(obj, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute group optional callback"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -4490,11 +4630,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, - ...) +H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4506,17 +4643,11 @@ H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if ((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, - arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute group optional callback"); done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -4535,14 +4666,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVwixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -4551,14 +4682,58 @@ H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__group_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__group_optional(obj, cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute group optional callback"); done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLgroup_optional_op + * + * Purpose: Performs an optional connector-specific operation on a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t group_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id) +{ + H5VL_object_t *vol_obj = NULL; /* Group VOL object */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*s*sIui*!ii", app_file, app_func, app_line, group_id, args, dxpl_id, es_id); + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__common_optional_op(group_id, H5I_GROUP, H5VL__group_optional, args, dxpl_id, + token_ptr, &vol_obj)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, + H5ARG_TRACE7(FUNC, "*s*sIui*!ii", app_file, app_func, app_line, group_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__group_close * * Purpose: Closes a group through the VOL @@ -4672,9 +4847,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, - va_list arguments) +H5VL__link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -4685,7 +4859,7 @@ H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link create' method") /* Call the corresponding VOL callback */ - if ((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + if ((cls->link_cls.create)(args, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") done: @@ -4703,31 +4877,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, - ...) +H5VL_link_create(H5VL_link_create_args_t *args, const H5VL_object_t *vol_obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) { - H5VL_object_t tmp_vol_obj; /* Temporary object */ - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + H5VL_object_t tmp_vol_obj; /* Temporary VOL object */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Start the varargs, so they can be copied */ - HDva_start(arguments, req); - arg_started = TRUE; - /* Special case for hard links */ - if (H5VL_LINK_CREATE_HARD == create_type && NULL == vol_obj->data) { - va_list tmp_arguments; /* Copy of argument list passed in */ - - /* Get the VOL data pointer from the varargs */ - HDva_copy(tmp_arguments, arguments); - tmp_vol_obj.data = HDva_arg(tmp_arguments, void *); - HDva_end(tmp_arguments); - } /* end if */ + if (H5VL_LINK_CREATE_HARD == args->op_type && NULL == vol_obj->data) + /* Get the VOL data pointer from the arguments */ + tmp_vol_obj.data = args->args.hard.curr_obj; else /* Use the VOL object passed in */ tmp_vol_obj.data = vol_obj->data; @@ -4739,15 +4901,11 @@ H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_o vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if (H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, - dxpl_id, req, arguments) < 0) + if (H5VL__link_create(args, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, + req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -4768,23 +4926,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req /*out*/, - va_list arguments) +H5VLlink_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, + hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE9("e", "Vk*x*#iiiixx", create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, - arguments); + H5TRACE8("e", "*!*x*#iiiix", args, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req); /* Get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + if (H5VL__link_create(args, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link") done: @@ -5017,7 +5173,7 @@ done: */ static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_link_get_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5028,7 +5184,7 @@ H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link get' method") /* Call the corresponding VOL callback */ - if ((cls->link_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + if ((cls->link_cls.get)(obj, loc_params, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") done: @@ -5046,11 +5202,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t *args, + hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5062,17 +5216,10 @@ H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, - arguments) < 0) + if (H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -5091,14 +5238,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req /*out*/, va_list arguments) +H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_args_t *args, + hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE7("e", "*x*#iVlixx", obj, loc_params, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -5107,7 +5254,7 @@ H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__link_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_get(obj, loc_params, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute link get callback") done: @@ -5126,7 +5273,7 @@ done: */ static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5137,8 +5284,9 @@ H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_c HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link specific' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->link_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = (cls->link_cls.specific)(obj, loc_params, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute link specific callback"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -5156,10 +5304,8 @@ done: */ herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5171,17 +5317,12 @@ H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if ((ret_value = H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, - dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = + H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute link specific callback"); done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -5201,13 +5342,13 @@ done: */ herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req /*out*/, va_list arguments) + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE7("e", "*x*#iVmixx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -5216,8 +5357,9 @@ H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__link_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__link_specific(obj, loc_params, cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute link specific callback"); done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -5234,8 +5376,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__link_optional(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5246,7 +5388,7 @@ H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link optional' method") /* Call the corresponding VOL callback */ - if ((cls->link_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->link_cls.optional)(obj, loc_params, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: @@ -5264,11 +5406,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, - ...) +H5VL_link_optional(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5280,16 +5420,10 @@ H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__link_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_optional(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -5308,14 +5442,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLlink_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVxixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -5324,7 +5458,7 @@ H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__link_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_optional(obj, loc_params, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: @@ -5332,6 +5466,67 @@ done: } /* end H5VLlink_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLlink_optional_op + * + * Purpose: Performs an optional connector-specific operation on a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, + const char *name, hid_t lapl_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id) +{ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE9("e", "*s*sIui*si*!ii", app_file, app_func, app_line, loc_id, name, lapl_id, args, dxpl_id, + es_id); + + /* Check arguments */ + /* name is verified in H5VL_setup_name_args() */ + + /* Set up object access arguments */ + if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, &vol_obj, &loc_params) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set link access arguments") + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_optional(vol_obj->data, &loc_params, vol_obj->connector->cls, args, dxpl_id, token_ptr) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, H5ARG_TRACE9(FUNC, "*s*sIui*si*!ii", app_file, app_func, app_line, loc_id, name, lapl_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__object_open * * Purpose: Opens a object through the VOL @@ -5556,7 +5751,7 @@ done: */ static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5567,7 +5762,7 @@ H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_clas HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object get' method") /* Call the corresponding VOL callback */ - if ((cls->object_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + if ((cls->object_cls.get)(obj, loc_params, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") done: @@ -5585,11 +5780,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5601,17 +5794,10 @@ H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_param vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, - arguments) < 0) + if (H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -5630,14 +5816,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req /*out*/, va_list arguments) +H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE7("e", "*x*#iVnixx", obj, loc_params, connector_id, get_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -5646,7 +5832,7 @@ H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_i HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__object_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_get(obj, loc_params, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute object get callback") done: @@ -5665,7 +5851,7 @@ done: */ static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5676,8 +5862,9 @@ H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object specific' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") + /* (Must return value from callback, for iterators) */ + if ((ret_value = (cls->object_cls.specific)(obj, loc_params, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "object specific failed"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -5695,10 +5882,8 @@ done: */ herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5710,17 +5895,12 @@ H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_ vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if ((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, - dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") + /* (Must return value from callback, for iterators) */ + if ((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, + req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "object specific failed"); done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -5740,14 +5920,13 @@ done: */ herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req /*out*/, - va_list arguments) + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE7("e", "*x*#iVoixx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -5755,13 +5934,10 @@ H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->object_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `object specific' method") - /* Bypass the H5VLint layer, calling the VOL callback directly */ - if ((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object specific callback") + /* (Must return value from callback, for iterators) */ + if ((ret_value = (cls->object_cls.specific)(obj, loc_params, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute object specific callback"); done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -5778,8 +5954,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__object_optional(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -5790,7 +5966,7 @@ H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object optional' method") /* Call the corresponding VOL callback */ - if ((cls->object_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->object_cls.optional)(obj, loc_params, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: @@ -5808,11 +5984,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, - ...) +H5VL_object_optional(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5824,16 +5998,10 @@ H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_ty vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if (H5VL__object_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_optional(vol_obj->data, loc_params, vol_obj->connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") @@ -5852,14 +6020,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, hid_t dxpl_id, - void **req /*out*/, va_list arguments) +H5VLobject_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiVyixx", obj, connector_id, opt_type, dxpl_id, req, arguments); + H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -5868,7 +6036,7 @@ H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_ty HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (H5VL__object_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_optional(obj, loc_params, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: @@ -5876,6 +6044,68 @@ done: } /* end H5VLobject_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLobject_optional_op + * + * Purpose: Performs an optional connector-specific operation on an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_optional_op(const char *app_file, const char *app_func, unsigned app_line, hid_t loc_id, + const char *name, hid_t lapl_id, H5VL_optional_args_t *args, hid_t dxpl_id, + hid_t es_id) +{ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE9("e", "*s*sIui*si*!ii", app_file, app_func, app_line, loc_id, name, lapl_id, args, dxpl_id, + es_id); + + /* Check arguments */ + /* name is verified in H5VL_setup_name_args() */ + + /* Set up object access arguments */ + if (H5VL_setup_name_args(loc_id, name, FALSE, lapl_id, &vol_obj, &loc_params) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set link access arguments") + + /* Set up request token pointer for asynchronous operation */ + if (H5ES_NONE != es_id) + token_ptr = &token; /* Point at token for VOL connector to set up */ + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__object_optional(vol_obj->data, &loc_params, vol_obj->connector->cls, args, dxpl_id, token_ptr) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + + /* If a token was created, add the token to the event set */ + if (NULL != token) + /* clang-format off */ + if (H5ES_insert(es_id, vol_obj->connector, token, H5ARG_TRACE9(FUNC, "*s*sIui*si*!ii", app_file, app_func, app_line, loc_id, name, lapl_id, args, dxpl_id, es_id)) < 0) + /* clang-format on */ + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert token into event set") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__introspect_get_conn_cls * * Purpose: Calls the connector-specific callback to query the connector @@ -5989,6 +6219,76 @@ done: } /* end H5VLintrospect_get_conn_cls() */ /*------------------------------------------------------------------------- + * Function: H5VL_introspect_get_cap_flags + * + * Purpose: Calls the connector-specific callback to query the connector's + * capability flags. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_introspect_get_cap_flags(const void *info, const H5VL_class_t *cls, unsigned *cap_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(cls); + HDassert(cap_flags); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->introspect_cls.get_cap_flags) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'get_cap_flags' method") + + /* Call the corresponding VOL callback */ + if ((cls->introspect_cls.get_cap_flags)(info, cap_flags) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector capability flags") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_introspect_get_cap_flags() */ + +/*------------------------------------------------------------------------- + * Function: H5VLintrospect_get_cap_flags + * + * Purpose: Calls the connector-specific callback to query the connector's + * capability flags. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLintrospect_get_cap_flags(const void *info, hid_t connector_id, unsigned *cap_flags /*out*/) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*xix", info, connector_id, cap_flags); + + /* Check args */ + if (NULL == cap_flags) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL conn_cls pointer") + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL_introspect_get_cap_flags(info, cls, cap_flags) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector's capability flags") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLintrospect_get_cap_flags() */ + +/*------------------------------------------------------------------------- * Function: H5VL__introspect_opt_query * * Purpose: Calls the connector-specific callback to query if an optional @@ -6135,28 +6435,18 @@ done: herr_t H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5VL_request_status_t *status) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(vol_obj); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ if (H5VL__request_wait(vol_obj->data, vol_obj->connector->cls, timeout, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_wait() */ @@ -6239,28 +6529,18 @@ done: herr_t H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void *ctx) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_obj); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ if (H5VL__request_notify(vol_obj->data, vol_obj->connector->cls, cb, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "request notify failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_notify() */ @@ -6342,28 +6622,18 @@ done: herr_t H5VL_request_cancel(const H5VL_object_t *vol_obj, H5VL_request_status_t *status) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_obj); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ if (H5VL__request_cancel(vol_obj->data, vol_obj->connector->cls, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_cancel() */ @@ -6378,13 +6648,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_cancel(void *req, hid_t connector_id, H5VL_request_status_t *status) +H5VLrequest_cancel(void *req, hid_t connector_id, H5VL_request_status_t *status /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE3("e", "*xi*#", req, connector_id, status); + H5TRACE3("e", "*xix", req, connector_id, status); /* Get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) @@ -6409,8 +6679,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__request_specific(void *req, const H5VL_class_t *cls, H5VL_request_specific_t specific_type, - va_list arguments) +H5VL__request_specific(void *req, const H5VL_class_t *cls, H5VL_request_specific_args_t *args) { herr_t ret_value = SUCCEED; /* Return value */ @@ -6425,7 +6694,7 @@ H5VL__request_specific(void *req, const H5VL_class_t *cls, H5VL_request_specific HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async specific' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->request_cls.specific)(req, specific_type, arguments)) < 0) + if ((cls->request_cls.specific)(req, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") @@ -6444,40 +6713,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_t specific_type, ...) +H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_args_t *args) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_obj); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - HDva_start(arguments, specific_type); - arg_started = TRUE; - if ((ret_value = - H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, specific_type, arguments)) < 0) + if (H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_specific() */ @@ -6492,20 +6742,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments) +H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_args_t *args) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE4("e", "*xiVrx", req, connector_id, specific_type, arguments); + H5TRACE3("e", "*xi*!", req, connector_id, args); /* Get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__request_specific(req, cls, specific_type, arguments)) < 0) + if (H5VL__request_specific(req, cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") @@ -6524,8 +6774,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional_t opt_type, - va_list arguments) +H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_optional_args_t *args) { herr_t ret_value = SUCCEED; /* Return value */ @@ -6540,7 +6789,7 @@ H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async optional' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->request_cls.optional)(req, opt_type, arguments)) < 0) + if ((cls->request_cls.optional)(req, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") @@ -6559,39 +6808,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_type, ...) +H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_obj); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - HDva_start(arguments, opt_type); - arg_started = TRUE; - if ((ret_value = H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, opt_type, arguments)) < 0) + if (H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_optional() */ @@ -6606,20 +6837,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, va_list arguments) +H5VLrequest_optional(void *req, hid_t connector_id, H5VL_optional_args_t *args) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE4("e", "*xiVzx", req, connector_id, opt_type, arguments); + H5TRACE3("e", "*xi*!", req, connector_id, args); /* Get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__request_optional(req, cls, opt_type, arguments)) < 0) + if (H5VL__request_optional(req, cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") @@ -6628,6 +6859,43 @@ done: } /* end H5VLrequest_optional() */ /*------------------------------------------------------------------------- + * Function: H5VLrequest_optional_op + * + * Purpose: Performs an optional connector-specific operation on a request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_optional_op(void *req, hid_t connector_id, H5VL_optional_args_t *args) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "*xi*!", req, connector_id, args); + + /* Check arguments */ + if (NULL == req) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request") + if (NULL == args) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid arguments") + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_optional(req, cls, args) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute request optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_optional_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL__request_free * * Purpose: Frees an asynchronous request through the VOL @@ -6673,28 +6941,18 @@ done: herr_t H5VL_request_free(const H5VL_object_t *vol_obj) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_obj); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding VOL callback */ if (H5VL__request_free(vol_obj->data, vol_obj->connector->cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_free() */ @@ -6778,8 +7036,7 @@ done: herr_t H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, void *ctx) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6788,19 +7045,11 @@ H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void * HDassert(size == 0 || buf); HDassert(blob_id); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding VOL callback */ if (H5VL__blob_put(vol_obj->data, vol_obj->connector->cls, buf, size, blob_id, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_put() */ @@ -6882,8 +7131,7 @@ done: herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, void *ctx) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6892,19 +7140,11 @@ H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size HDassert(blob_id); HDassert(buf); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding VOL callback */ if (H5VL__blob_get(vol_obj->data, vol_obj->connector->cls, blob_id, buf, size, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_get() */ @@ -6953,8 +7193,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_specific_t specific_type, - va_list arguments) +H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_specific_args_t *args) { herr_t ret_value = SUCCEED; /* Return value */ @@ -6970,7 +7209,7 @@ H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob specific' method") /* Call the corresponding VOL callback */ - if ((cls->blob_cls.specific)(obj, blob_id, specific_type, arguments) < 0) + if ((cls->blob_cls.specific)(obj, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") done: @@ -6988,12 +7227,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_t specific_type, ...) +H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_args_t *args) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7001,27 +7237,11 @@ H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specif HDassert(vol_obj); HDassert(blob_id); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - HDva_start(arguments, specific_type); - arg_started = TRUE; - if ((ret_value = H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, specific_type, - arguments)) < 0) + if (H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_specific() */ @@ -7035,14 +7255,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_t specific_type, - va_list arguments) +H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_args_t *args) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE5("e", "*xi*xVBx", obj, connector_id, blob_id, specific_type, arguments); + H5TRACE4("e", "*xi*x*!", obj, connector_id, blob_id, args); /* Get class pointer */ if (NULL == obj) @@ -7051,7 +7270,7 @@ H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specif HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding VOL callback */ - if (H5VL__blob_specific(obj, cls, blob_id, specific_type, arguments) < 0) + if (H5VL__blob_specific(obj, cls, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed") done: @@ -7071,8 +7290,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_optional_t opt_type, - va_list arguments) +H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_optional_args_t *args) { herr_t ret_value = SUCCEED; /* Return value */ @@ -7088,7 +7306,7 @@ H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob optional' method") /* Call the corresponding VOL callback */ - if ((cls->blob_cls.optional)(obj, blob_id, opt_type, arguments) < 0) + if ((cls->blob_cls.optional)(obj, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob optional callback") done: @@ -7106,12 +7324,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, ...) +H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_optional_args_t *args) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7119,27 +7334,11 @@ H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_option HDassert(vol_obj); HDassert(blob_id); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - HDva_start(arguments, opt_type); - arg_started = TRUE; - if ((ret_value = - H5VL__blob_optional(vol_obj->data, vol_obj->connector->cls, blob_id, opt_type, arguments)) < 0) + if (H5VL__blob_optional(vol_obj->data, vol_obj->connector->cls, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob optional callback") done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_optional() */ @@ -7153,14 +7352,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, - va_list arguments) +H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_optional_args_t *args) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE5("e", "*xi*xVAx", obj, connector_id, blob_id, opt_type, arguments); + H5TRACE4("e", "*xi*x*!", obj, connector_id, blob_id, args); /* Get class pointer */ if (NULL == obj) @@ -7169,7 +7367,7 @@ H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_option HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding VOL callback */ - if (H5VL__blob_optional(obj, cls, blob_id, opt_type, arguments) < 0) + if (H5VL__blob_optional(obj, cls, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob optional operation failed") done: @@ -7243,8 +7441,7 @@ herr_t H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7252,20 +7449,11 @@ H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, const H5 HDassert(vol_obj); HDassert(cmp_value); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value)) < 0) + if (H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "token compare failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_token_cmp() */ @@ -7362,8 +7550,7 @@ herr_t H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7372,21 +7559,11 @@ H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_t HDassert(token); HDassert(token_str); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str)) < - 0) + if (H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "token serialization failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_token_to_str() */ @@ -7480,8 +7657,7 @@ herr_t H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7490,21 +7666,11 @@ H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const cha HDassert(token); HDassert(token_str); - /* Set wrapper info in API context */ - if (H5VL_set_vol_wrapper(vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Call the corresponding internal VOL routine */ - if ((ret_value = - H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token)) < 0) + if (H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "token deserialization failed") done: - /* Reset object wrapping info in API context */ - if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_token_from_str() */ @@ -7557,7 +7723,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, va_list arguments) +H5VL__optional(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { herr_t ret_value = SUCCEED; /* Return value */ @@ -7568,8 +7734,8 @@ H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, v HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'optional' method") /* Call the corresponding VOL callback */ - if ((ret_value = (cls->optional)(obj, op_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") + if ((ret_value = (cls->optional)(obj, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute optional callback"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -7586,10 +7752,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...) +H5VL_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -7601,20 +7765,13 @@ H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **r vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - HDva_start(arguments, req); - arg_started = TRUE; - if ((ret_value = - H5VL__optional(vol_obj->data, vol_obj->connector->cls, op_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute optional callback") + if ((ret_value = H5VL__optional(vol_obj->data, vol_obj->connector->cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute optional callback"); done: - /* End access to the va_list, if we started it */ - if (arg_started) - HDva_end(arguments); - /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, ret_value, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_optional() */ @@ -7630,13 +7787,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req /*out*/, va_list arguments) +H5VLoptional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE6("e", "*xiIsixx", obj, connector_id, op_type, dxpl_id, req, arguments); + H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ if (NULL == obj) @@ -7645,8 +7802,8 @@ H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **r HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__optional(obj, cls, op_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") + if ((ret_value = H5VL__optional(obj, cls, args, dxpl_id, req)) < 0) + HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute optional callback"); done: FUNC_LEAVE_API_NOINIT(ret_value) diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 63613bc..af3530c 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -20,6 +20,7 @@ /* Public headers needed by this file */ #include "H5public.h" /* Generic Functions */ #include "H5Apublic.h" /* Attributes */ +#include "H5Dpublic.h" /* Datasets */ #include "H5ESpublic.h" /* Event Stack */ #include "H5Fpublic.h" /* Files */ #include "H5Ipublic.h" /* IDs */ @@ -33,8 +34,10 @@ /*****************/ /* Capability flags for connector */ -#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */ -#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */ +#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */ +#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */ +#define H5VL_CAP_FLAG_ASYNC 0x02 /* Connector performs operations asynchronously*/ +#define H5VL_CAP_FLAG_NATIVE_FILES 0x04 /* Connector produces native file format */ /* Container info version */ #define H5VL_CONTAINER_INFO_VERSION 0x01 /* Container info struct version */ @@ -42,11 +45,64 @@ /* The maximum size allowed for blobs */ #define H5VL_MAX_BLOB_ID_SIZE (16) /* Allow for 128-bits blob IDs */ +/* # of optional operations reserved for the native VOL connector */ +#define H5VL_RESERVED_NATIVE_OPTIONAL 1024 + /*******************/ /* Public Typedefs */ /*******************/ -/* types for attribute GET callback */ +/* Types for different ways that objects are located in an HDF5 container */ +typedef enum H5VL_loc_type_t { + H5VL_OBJECT_BY_SELF, + H5VL_OBJECT_BY_NAME, + H5VL_OBJECT_BY_IDX, + H5VL_OBJECT_BY_TOKEN +} H5VL_loc_type_t; + +typedef struct H5VL_loc_by_name { + const char *name; + hid_t lapl_id; +} H5VL_loc_by_name_t; + +typedef struct H5VL_loc_by_idx { + const char * name; + H5_index_t idx_type; + H5_iter_order_t order; + hsize_t n; + hid_t lapl_id; +} H5VL_loc_by_idx_t; + +typedef struct H5VL_loc_by_token { + H5O_token_t *token; +} H5VL_loc_by_token_t; + +/* Structure to hold parameters for object locations. + * Either: BY_SELF, BY_NAME, BY_IDX, BY_TOKEN + * + * Note: Leave loc_by_token as the first union member so we + * can perform the simplest initialization of the struct + * without raising warnings. + * + * Note: BY_SELF requires no union members. + */ +typedef struct H5VL_loc_params_t { + H5I_type_t obj_type; + H5VL_loc_type_t type; + union { + H5VL_loc_by_token_t loc_by_token; + H5VL_loc_by_name_t loc_by_name; + H5VL_loc_by_idx_t loc_by_idx; + } loc_data; +} H5VL_loc_params_t; + +/* Struct for all 'optional' callbacks */ +typedef struct H5VL_optional_args_t { + int op_type; /* Operation to perform */ + void *args; /* Pointer to operation's argument struct */ +} H5VL_optional_args_t; + +/* Values for attribute 'get' operations */ typedef enum H5VL_attr_get_t { H5VL_ATTR_GET_ACPL, /* creation property list */ H5VL_ATTR_GET_INFO, /* info */ @@ -56,18 +112,115 @@ typedef enum H5VL_attr_get_t { H5VL_ATTR_GET_TYPE /* datatype */ } H5VL_attr_get_t; -/* types for attribute SPECFIC callback */ +/* Parameters for attribute 'get_name' operation */ +typedef struct H5VL_attr_get_name_args_t { + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + size_t buf_size; /* Size of attribute name buffer */ + char * buf; /* Buffer for attribute name (OUT) */ + size_t * attr_name_len; /* Actual length of attribute name (OUT) */ +} H5VL_attr_get_name_args_t; + +/* Parameters for attribute 'get_info' operation */ +typedef struct H5VL_attr_get_info_args_t { + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + const char * attr_name; /* Attribute name (for get_info_by_name) */ + H5A_info_t * ainfo; /* Attribute info (OUT) */ +} H5VL_attr_get_info_args_t; + +/* Parameters for attribute 'get' operations */ +typedef struct H5VL_attr_get_args_t { + H5VL_attr_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_ATTR_GET_ACPL */ + struct { + hid_t acpl_id; /* Attribute creation property list ID (OUT) */ + } get_acpl; + + /* H5VL_ATTR_GET_INFO */ + H5VL_attr_get_info_args_t get_info; /* Attribute info */ + + /* H5VL_ATTR_GET_NAME */ + H5VL_attr_get_name_args_t get_name; /* Attribute name */ + + /* H5VL_ATTR_GET_SPACE */ + struct { + hid_t space_id; /* Dataspace ID (OUT) */ + } get_space; + + /* H5VL_ATTR_GET_STORAGE_SIZE */ + struct { + hsize_t *data_size; /* Size of attribute in file (OUT) */ + } get_storage_size; + + /* H5VL_ATTR_GET_TYPE */ + struct { + hid_t type_id; /* Datatype ID (OUT) */ + } get_type; + } args; +} H5VL_attr_get_args_t; + +/* Values for attribute 'specific' operation */ typedef enum H5VL_attr_specific_t { - H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */ - H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ - H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ - H5VL_ATTR_RENAME /* H5Arename(_by_name) */ + H5VL_ATTR_DELETE, /* H5Adelete(_by_name) */ + H5VL_ATTR_DELETE_BY_IDX, /* H5Adelete_by_idx */ + H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ + H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ + H5VL_ATTR_RENAME /* H5Arename(_by_name) */ } H5VL_attr_specific_t; +/* Parameters for attribute 'iterate' operation */ +typedef struct H5VL_attr_iterate_args_t { + H5_index_t idx_type; /* Type of index to iterate over */ + H5_iter_order_t order; /* Order of index iteration */ + hsize_t * idx; /* Start/stop iteration index (IN/OUT) */ + H5A_operator2_t op; /* Iteration callback function */ + void * op_data; /* Iteration callback context */ +} H5VL_attr_iterate_args_t; + +/* Parameters for attribute 'delete_by_idx' operation */ +typedef struct H5VL_attr_delete_by_idx_args_t { + H5_index_t idx_type; /* Type of index to iterate over */ + H5_iter_order_t order; /* Order of index iteration */ + hsize_t n; /* Iteration index */ +} H5VL_attr_delete_by_idx_args_t; + +/* Parameters for attribute 'specific' operations */ +typedef struct H5VL_attr_specific_args_t { + H5VL_attr_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_ATTR_DELETE */ + struct { + const char *name; /* Name of attribute to delete */ + } del; + + /* H5VL_ATTR_DELETE_BY_IDX */ + H5VL_attr_delete_by_idx_args_t delete_by_idx; + + /* H5VL_ATTR_EXISTS */ + struct { + const char *name; /* Name of attribute to check */ + hbool_t * exists; /* Whether attribute exists (OUT) */ + } exists; + + /* H5VL_ATTR_ITER */ + H5VL_attr_iterate_args_t iterate; + + /* H5VL_ATTR_RENAME */ + struct { + const char *old_name; /* Name of attribute to rename */ + const char *new_name; /* New attribute name */ + } rename; + } args; +} H5VL_attr_specific_args_t; + /* Typedef for VOL connector attribute optional VOL operations */ typedef int H5VL_attr_optional_t; -/* types for dataset GET callback */ +/* Values for dataset 'get' operation */ typedef enum H5VL_dataset_get_t { H5VL_DATASET_GET_DAPL, /* access property list */ H5VL_DATASET_GET_DCPL, /* creation property list */ @@ -77,32 +230,146 @@ typedef enum H5VL_dataset_get_t { H5VL_DATASET_GET_TYPE /* datatype */ } H5VL_dataset_get_t; -/* types for dataset SPECFIC callback */ +/* Parameters for dataset 'get' operations */ +typedef struct H5VL_dataset_get_args_t { + H5VL_dataset_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_DATASET_GET_DAPL */ + struct { + hid_t dapl_id; /* Dataset access property list ID (OUT) */ + } get_dapl; + + /* H5VL_DATASET_GET_DCPL */ + struct { + hid_t dcpl_id; /* Dataset creation property list ID (OUT) */ + } get_dcpl; + + /* H5VL_DATASET_GET_SPACE */ + struct { + hid_t space_id; /* Dataspace ID (OUT) */ + } get_space; + + /* H5VL_DATASET_GET_SPACE_STATUS */ + struct { + H5D_space_status_t *status; /* Storage space allocation status (OUT) */ + } get_space_status; + + /* H5VL_DATASET_GET_STORAGE_SIZE */ + struct { + hsize_t *storage_size; /* Size of dataset's storage (OUT) */ + } get_storage_size; + + /* H5VL_DATASET_GET_TYPE */ + struct { + hid_t type_id; /* Datatype ID (OUT) */ + } get_type; + } args; +} H5VL_dataset_get_args_t; + +/* Values for dataset 'specific' operation */ typedef enum H5VL_dataset_specific_t { H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */ H5VL_DATASET_FLUSH, /* H5Dflush */ - H5VL_DATASET_REFRESH, /* H5Drefresh */ - H5VL_DATASET_WAIT, /* H5Dwait */ - H5VL_DATASET_CHUNK_ITER /* H5Dchunk_iter */ + H5VL_DATASET_REFRESH /* H5Drefresh */ } H5VL_dataset_specific_t; +/* Parameters for dataset 'specific' operations */ +typedef struct H5VL_dataset_specific_args_t { + H5VL_dataset_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_DATASET_SET_EXTENT */ + struct { + const hsize_t *size; /* New dataspace extent */ + } set_extent; + + /* H5VL_DATASET_FLUSH */ + struct { + hid_t dset_id; /* Dataset ID (IN) */ + } flush; + + /* H5VL_DATASET_REFRESH */ + struct { + hid_t dset_id; /* Dataset ID (IN) */ + } refresh; + } args; +} H5VL_dataset_specific_args_t; + /* Typedef for VOL connector dataset optional VOL operations */ typedef int H5VL_dataset_optional_t; -/* types for datatype GET callback */ +/* Values for datatype 'get' operation */ typedef enum H5VL_datatype_get_t { - H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */ - H5VL_DATATYPE_GET_TCPL /* datatype creation property list */ + H5VL_DATATYPE_GET_BINARY_SIZE, /* Get size of serialized form of transient type */ + H5VL_DATATYPE_GET_BINARY, /* Get serialized form of transient type */ + H5VL_DATATYPE_GET_TCPL /* Datatype creation property list */ } H5VL_datatype_get_t; -/* types for datatype SPECFIC callback */ -typedef enum H5VL_datatype_specific_t { H5VL_DATATYPE_FLUSH, H5VL_DATATYPE_REFRESH } H5VL_datatype_specific_t; +/* Parameters for datatype 'get' operations */ +typedef struct H5VL_datatype_get_args_t { + H5VL_datatype_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_DATATYPE_GET_BINARY_SIZE */ + struct { + size_t *size; /* Size of serialized form of datatype (OUT) */ + } get_binary_size; + + /* H5VL_DATATYPE_GET_BINARY */ + struct { + void * buf; /* Buffer to store serialized form of datatype (OUT) */ + size_t buf_size; /* Size of serialized datatype buffer */ + } get_binary; + + /* H5VL_DATATYPE_GET_TCPL */ + struct { + hid_t tcpl_id; /* Named datatype creation property list ID (OUT) */ + } get_tcpl; + } args; +} H5VL_datatype_get_args_t; + +/* Values for datatype 'specific' operation */ +typedef enum H5VL_datatype_specific_t { + H5VL_DATATYPE_FLUSH, /* H5Tflush */ + H5VL_DATATYPE_REFRESH /* H5Trefresh */ +} H5VL_datatype_specific_t; + +/* Parameters for datatype 'specific' operations */ +typedef struct H5VL_datatype_specific_args_t { + H5VL_datatype_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_DATATYPE_FLUSH */ + struct { + hid_t type_id; /* Named datatype ID (IN) */ + } flush; + + /* H5VL_DATATYPE_REFRESH */ + struct { + hid_t type_id; /* Named datatype ID (IN) */ + } refresh; + } args; +} H5VL_datatype_specific_args_t; /* Typedef and values for native VOL connector named datatype optional VOL operations */ typedef int H5VL_datatype_optional_t; /* (No optional named datatype VOL operations currently) */ -/* types for file GET callback */ +/* Info for H5VL_FILE_GET_CONT_INFO */ +typedef struct H5VL_file_cont_info_t { + unsigned version; /* version information (keep first) */ + uint64_t feature_flags; /* Container feature flags */ + /* (none currently defined) */ + size_t token_size; /* Size of tokens */ + size_t blob_id_size; /* Size of blob IDs */ +} H5VL_file_cont_info_t; + +/* Values for file 'get' operation */ typedef enum H5VL_file_get_t { H5VL_FILE_GET_CONT_INFO, /* file get container info */ H5VL_FILE_GET_FAPL, /* file access property list */ @@ -114,59 +381,296 @@ typedef enum H5VL_file_get_t { H5VL_FILE_GET_OBJ_IDS /* object ids in file */ } H5VL_file_get_t; -/* types for file SPECIFIC callback */ +/* Parameters for file 'get_name' operation */ +typedef struct H5VL_file_get_name_args_t { + H5I_type_t type; /* ID type of object pointer */ + size_t buf_size; /* Size of file name buffer (IN) */ + char * buf; /* Buffer for file name (OUT) */ + size_t * file_name_len; /* Actual length of file name (OUT) */ +} H5VL_file_get_name_args_t; + +/* Parameters for file 'get_obj_ids' operation */ +typedef struct H5VL_file_get_obj_ids_args_t { + unsigned types; /* Type of objects to count */ + size_t max_objs; /* Size of array of object IDs */ + hid_t * oid_list; /* Array of object IDs (OUT) */ + size_t * count; /* # of objects (OUT) */ +} H5VL_file_get_obj_ids_args_t; + +/* Parameters for file 'get' operations */ +typedef struct H5VL_file_get_args_t { + H5VL_file_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_FILE_GET_CONT_INFO */ + struct { + H5VL_file_cont_info_t *info; /* Container info (OUT) */ + } get_cont_info; + + /* H5VL_FILE_GET_FAPL */ + struct { + hid_t fapl_id; /* File access property list (OUT) */ + } get_fapl; + + /* H5VL_FILE_GET_FCPL */ + struct { + hid_t fcpl_id; /* File creation property list (OUT) */ + } get_fcpl; + + /* H5VL_FILE_GET_FILENO */ + struct { + unsigned long *fileno; /* File "number" (OUT) */ + } get_fileno; + + /* H5VL_FILE_GET_INTENT */ + struct { + unsigned *flags; /* File open/create intent flags (OUT) */ + } get_intent; + + /* H5VL_FILE_GET_NAME */ + H5VL_file_get_name_args_t get_name; + + /* H5VL_FILE_GET_OBJ_COUNT */ + struct { + unsigned types; /* Type of objects to count */ + size_t * count; /* # of objects (OUT) */ + } get_obj_count; + + /* H5VL_FILE_GET_OBJ_IDS */ + H5VL_file_get_obj_ids_args_t get_obj_ids; + } args; +} H5VL_file_get_args_t; + +/* Values for file 'specific' operation */ typedef enum H5VL_file_specific_t { H5VL_FILE_FLUSH, /* Flush file */ H5VL_FILE_REOPEN, /* Reopen the file */ - H5VL_FILE_MOUNT, /* Mount a file */ - H5VL_FILE_UNMOUNT, /* Unmount a file */ H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ H5VL_FILE_DELETE, /* Delete a file */ - H5VL_FILE_IS_EQUAL, /* Check if two files are the same */ - H5VL_FILE_WAIT /* Wait for async operations to complete */ + H5VL_FILE_IS_EQUAL /* Check if two files are the same */ } H5VL_file_specific_t; +/* Parameters for file 'specific' operations */ +typedef struct H5VL_file_specific_args_t { + H5VL_file_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_FILE_FLUSH */ + struct { + H5I_type_t obj_type; /* Type of object to use */ + H5F_scope_t scope; /* Scope of flush operation */ + } flush; + + /* H5VL_FILE_REOPEN */ + struct { + void **file; /* File object for new file (OUT) */ + } reopen; + + /* H5VL_FILE_IS_ACCESSIBLE */ + struct { + const char *filename; /* Name of file to check */ + hid_t fapl_id; /* File access property list to use */ + hbool_t * accessible; /* Whether file is accessible with FAPL settings (OUT) */ + } is_accessible; + + /* H5VL_FILE_DELETE */ + struct { + const char *filename; /* Name of file to delete */ + hid_t fapl_id; /* File access property list to use */ + } del; + + /* H5VL_FILE_IS_EQUAL */ + struct { + void * obj2; /* Second file object to compare against */ + hbool_t *same_file; /* Whether files are the same (OUT) */ + } is_equal; + } args; +} H5VL_file_specific_args_t; + /* Typedef for VOL connector file optional VOL operations */ typedef int H5VL_file_optional_t; -/* types for group GET callback */ +/* Values for group 'get' operation */ typedef enum H5VL_group_get_t { H5VL_GROUP_GET_GCPL, /* group creation property list */ H5VL_GROUP_GET_INFO /* group info */ } H5VL_group_get_t; -/* types for group SPECFIC callback */ -typedef enum H5VL_group_specific_t { H5VL_GROUP_FLUSH, H5VL_GROUP_REFRESH } H5VL_group_specific_t; +/* Parameters for group 'get_info' operation */ +typedef struct H5VL_group_get_info_args_t { + H5VL_loc_params_t loc_params; /* Location parameters for object access */ + H5G_info_t * ginfo; /* Group info (OUT) */ +} H5VL_group_get_info_args_t; + +/* Parameters for group 'get' operations */ +typedef struct H5VL_group_get_args_t { + H5VL_group_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_GROUP_GET_GCPL */ + struct { + hid_t gcpl_id; /* Group creation property list (OUT) */ + } get_gcpl; + + /* H5VL_GROUP_GET_INFO */ + H5VL_group_get_info_args_t get_info; /* Group info */ + } args; +} H5VL_group_get_args_t; + +/* Values for group 'specific' operation */ +typedef enum H5VL_group_specific_t { + H5VL_GROUP_MOUNT, /* Mount a file on a group */ + H5VL_GROUP_UNMOUNT, /* Unmount a file on a group */ + H5VL_GROUP_FLUSH, /* H5Gflush */ + H5VL_GROUP_REFRESH /* H5Grefresh */ +} H5VL_group_specific_t; + +/* Parameters for group 'mount' operation */ +typedef struct H5VL_group_spec_mount_args_t { + const char *name; /* Name of location to mount child file */ + void * child_file; /* Pointer to child file object */ + hid_t fmpl_id; /* File mount property list to use */ +} H5VL_group_spec_mount_args_t; + +/* Parameters for group 'specific' operations */ +typedef struct H5VL_group_specific_args_t { + H5VL_group_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_GROUP_MOUNT */ + H5VL_group_spec_mount_args_t mount; + + /* H5VL_GROUP_UNMOUNT */ + struct { + const char *name; /* Name of location to unmount child file */ + } unmount; + + /* H5VL_GROUP_FLUSH */ + struct { + hid_t grp_id; /* Group ID (IN) */ + } flush; + + /* H5VL_GROUP_REFRESH */ + struct { + hid_t grp_id; /* Group ID (IN) */ + } refresh; + } args; +} H5VL_group_specific_args_t; /* Typedef for VOL connector group optional VOL operations */ typedef int H5VL_group_optional_t; -/* link create types for VOL */ -typedef enum H5VL_link_create_type_t { +/* Link create types for VOL */ +typedef enum H5VL_link_create_t { H5VL_LINK_CREATE_HARD, H5VL_LINK_CREATE_SOFT, H5VL_LINK_CREATE_UD -} H5VL_link_create_type_t; +} H5VL_link_create_t; -/* types for link GET callback */ +/* Parameters for link 'create' operations */ +typedef struct H5VL_link_create_args_t { + H5VL_link_create_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_LINK_CREATE_HARD */ + struct { + void * curr_obj; /* Current object */ + H5VL_loc_params_t curr_loc_params; /* Location parameters for current object */ + } hard; + + /* H5VL_LINK_CREATE_SOFT */ + struct { + const char *target; /* Target of soft link */ + } soft; + + /* H5VL_LINK_CREATE_UD */ + struct { + H5L_type_t type; /* Type of link to create */ + const void *buf; /* Buffer that contains link info */ + size_t buf_size; /* Size of link info buffer */ + } ud; + } args; +} H5VL_link_create_args_t; + +/* Values for link 'get' operation */ typedef enum H5VL_link_get_t { H5VL_LINK_GET_INFO, /* link info */ H5VL_LINK_GET_NAME, /* link name */ H5VL_LINK_GET_VAL /* link value */ } H5VL_link_get_t; -/* types for link SPECIFIC callback */ +/* Parameters for link 'get' operations */ +typedef struct H5VL_link_get_args_t { + H5VL_link_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_LINK_GET_INFO */ + struct { + H5L_info2_t *linfo; /* Pointer to link's info (OUT) */ + } get_info; + + /* H5VL_LINK_GET_NAME */ + struct { + size_t name_size; /* Size of link name buffer (IN) */ + char * name; /* Buffer for link name (OUT) */ + size_t *name_len; /* Actual length of link name (OUT) */ + } get_name; + + /* H5VL_LINK_GET_VAL */ + struct { + size_t buf_size; /* Size of link value buffer (IN) */ + void * buf; /* Buffer for link value (OUT) */ + } get_val; + } args; +} H5VL_link_get_args_t; + +/* Values for link 'specific' operation */ typedef enum H5VL_link_specific_t { H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */ H5VL_LINK_EXISTS, /* link existence */ H5VL_LINK_ITER /* H5Literate/visit(_by_name) */ } H5VL_link_specific_t; +/* Parameters for link 'iterate' operation */ +typedef struct H5VL_link_iterate_args_t { + hbool_t recursive; /* Whether iteration is recursive */ + H5_index_t idx_type; /* Type of index to iterate over */ + H5_iter_order_t order; /* Order of index iteration */ + hsize_t * idx_p; /* Start/stop iteration index (OUT) */ + H5L_iterate2_t op; /* Iteration callback function */ + void * op_data; /* Iteration callback context */ +} H5VL_link_iterate_args_t; + +/* Parameters for link 'specific' operations */ +typedef struct H5VL_link_specific_args_t { + H5VL_link_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_LINK_DELETE */ + /* No args */ + + /* H5VL_LINK_EXISTS */ + struct { + hbool_t *exists; /* Whether link exists (OUT) */ + } exists; + + /* H5VL_LINK_ITER */ + H5VL_link_iterate_args_t iterate; + } args; +} H5VL_link_specific_args_t; + /* Typedef and values for native VOL connector link optional VOL operations */ typedef int H5VL_link_optional_t; /* (No optional link VOL operations currently) */ -/* types for object GET callback */ +/* Values for object 'get' operation */ typedef enum H5VL_object_get_t { H5VL_OBJECT_GET_FILE, /* object file */ H5VL_OBJECT_GET_NAME, /* object name */ @@ -174,7 +678,38 @@ typedef enum H5VL_object_get_t { H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name) */ } H5VL_object_get_t; -/* types for object SPECIFIC callback */ +/* Parameters for object 'get' operations */ +typedef struct H5VL_object_get_args_t { + H5VL_object_get_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_OBJECT_GET_FILE */ + struct { + void **file; /* File object (OUT) */ + } get_file; + + /* H5VL_OBJECT_GET_NAME */ + struct { + size_t buf_size; /* Size of name buffer (IN) */ + char * buf; /* Buffer for name (OUT) */ + size_t *name_len; /* Actual length of name (OUT) */ + } get_name; + + /* H5VL_OBJECT_GET_TYPE */ + struct { + H5O_type_t *obj_type; /* Type of object (OUT) */ + } get_type; + + /* H5VL_OBJECT_GET_INFO */ + struct { + unsigned fields; /* Flags for fields to retrieve */ + H5O_info2_t *oinfo; /* Pointer to object info (OUT) */ + } get_info; + } args; +} H5VL_object_get_args_t; + +/* Values for object 'specific' operation */ typedef enum H5VL_object_specific_t { H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ @@ -184,6 +719,51 @@ typedef enum H5VL_object_specific_t { H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */ } H5VL_object_specific_t; +/* Parameters for object 'visit' operation */ +typedef struct H5VL_object_visit_args_t { + H5_index_t idx_type; /* Type of index to iterate over */ + H5_iter_order_t order; /* Order of index iteration */ + unsigned fields; /* Flags for fields to provide in 'info' object for 'op' callback */ + H5O_iterate2_t op; /* Iteration callback function */ + void * op_data; /* Iteration callback context */ +} H5VL_object_visit_args_t; + +/* Parameters for object 'specific' operations */ +typedef struct H5VL_object_specific_args_t { + H5VL_object_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_OBJECT_CHANGE_REF_COUNT */ + struct { + int delta; /* Amount to modify object's refcount */ + } change_rc; + + /* H5VL_OBJECT_EXISTS */ + struct { + hbool_t *exists; /* Whether object exists (OUT) */ + } exists; + + /* H5VL_OBJECT_LOOKUP */ + struct { + H5O_token_t *token_ptr; /* Pointer to token for lookup (OUT) */ + } lookup; + + /* H5VL_OBJECT_VISIT */ + H5VL_object_visit_args_t visit; + + /* H5VL_OBJECT_FLUSH */ + struct { + hid_t obj_id; /* Object ID (IN) */ + } flush; + + /* H5VL_OBJECT_REFRESH */ + struct { + hid_t obj_id; /* Object ID (IN) */ + } refresh; + } args; +} H5VL_object_specific_args_t; + /* Typedef for VOL connector object optional VOL operations */ typedef int H5VL_object_optional_t; @@ -200,82 +780,64 @@ typedef enum H5VL_request_status_t { H5VL_REQUEST_STATUS_CANCELED /* Operation has not completed and was canceled */ } H5VL_request_status_t; -/* types for async request SPECIFIC callback */ +/* Values for async request 'specific' operation */ typedef enum H5VL_request_specific_t { - H5VL_REQUEST_WAITANY, /* Wait until any request completes */ - H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */ - H5VL_REQUEST_WAITALL, /* Wait until all requests complete */ - H5VL_REQUEST_GET_ERR_STACK /* Retrieve error stack for failed operation */ + H5VL_REQUEST_GET_ERR_STACK, /* Retrieve error stack for failed operation */ + H5VL_REQUEST_GET_EXEC_TIME /* Retrieve execution time for operation */ } H5VL_request_specific_t; +/* Parameters for request 'specific' operations */ +typedef struct H5VL_request_specific_args_t { + H5VL_request_specific_t op_type; /* Operation to perform */ + + /* Parameters for each operation */ + union { + /* H5VL_REQUEST_GET_ERR_STACK */ + struct { + hid_t err_stack_id; /* Error stack ID for operation (OUT) */ + } get_err_stack; + + /* H5VL_REQUEST_GET_EXEC_TIME */ + struct { + uint64_t *exec_ts; /* Timestamp for start of task execution (OUT) */ + uint64_t *exec_time; /* Duration of task execution (in ns) (OUT) */ + } get_exec_time; + } args; +} H5VL_request_specific_args_t; + /* Typedef and values for native VOL connector request optional VOL operations */ typedef int H5VL_request_optional_t; /* (No optional request VOL operations currently) */ -/* types for 'blob' SPECIFIC callback */ +/* Values for 'blob' 'specific' operation */ typedef enum H5VL_blob_specific_t { - H5VL_BLOB_DELETE, /* Delete a blob (by ID) */ - H5VL_BLOB_GETSIZE, /* Get size of blob */ - H5VL_BLOB_ISNULL, /* Check if a blob ID is "null" */ - H5VL_BLOB_SETNULL /* Set a blob ID to the connector's "null" blob ID value */ + H5VL_BLOB_DELETE, /* Delete a blob (by ID) */ + H5VL_BLOB_ISNULL, /* Check if a blob ID is "null" */ + H5VL_BLOB_SETNULL /* Set a blob ID to the connector's "null" blob ID value */ } H5VL_blob_specific_t; -/* Typedef and values for native VOL connector blob optional VOL operations */ -typedef int H5VL_blob_optional_t; -/* (No optional blob VOL operations currently) */ - -/* Types for different ways that objects are located in an HDF5 container */ -typedef enum H5VL_loc_type_t { - H5VL_OBJECT_BY_SELF, - H5VL_OBJECT_BY_NAME, - H5VL_OBJECT_BY_IDX, - H5VL_OBJECT_BY_TOKEN -} H5VL_loc_type_t; +/* Parameters for blob 'specific' operations */ +typedef struct H5VL_blob_specific_args_t { + H5VL_blob_specific_t op_type; /* Operation to perform */ -typedef struct H5VL_loc_by_name { - const char *name; - hid_t lapl_id; -} H5VL_loc_by_name_t; - -typedef struct H5VL_loc_by_idx { - const char * name; - H5_index_t idx_type; - H5_iter_order_t order; - hsize_t n; - hid_t lapl_id; -} H5VL_loc_by_idx_t; + /* Parameters for each operation */ + union { + /* H5VL_BLOB_DELETE */ + /* No args */ -typedef struct H5VL_loc_by_token { - H5O_token_t *token; -} H5VL_loc_by_token_t; + /* H5VL_BLOB_ISNULL */ + struct { + hbool_t *isnull; /* Whether blob ID is "null" (OUT) */ + } is_null; -/* Structure to hold parameters for object locations. - * Either: BY_SELF, BY_NAME, BY_IDX, BY_TOKEN - * - * Note: Leave loc_by_token as the first union member so we - * can perform the simplest initialization of the struct - * without raising warnings. - * - * Note: BY_SELF requires no union members. - */ -typedef struct H5VL_loc_params_t { - H5I_type_t obj_type; - H5VL_loc_type_t type; - union { - H5VL_loc_by_token_t loc_by_token; - H5VL_loc_by_name_t loc_by_name; - H5VL_loc_by_idx_t loc_by_idx; - } loc_data; -} H5VL_loc_params_t; + /* H5VL_BLOB_SETNULL */ + /* No args */ + } args; +} H5VL_blob_specific_args_t; -/* Info for H5VL_FILE_GET_CONT_INFO */ -typedef struct H5VL_file_cont_info_t { - unsigned version; /* version information (keep first) */ - uint64_t feature_flags; /* Container feature flags */ - /* (none currently defined) */ - size_t token_size; /* Size of tokens */ - size_t blob_id_size; /* Size of blob IDs */ -} H5VL_file_cont_info_t; +/* Typedef and values for native VOL connector blob optional VOL operations */ +typedef int H5VL_blob_optional_t; +/* (No optional blob VOL operations currently) */ /* VOL connector info fields & callbacks */ typedef struct H5VL_info_class_t { @@ -310,11 +872,10 @@ typedef struct H5VL_attr_class_t { hid_t dxpl_id, void **req); herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_args_t *args, + hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); herr_t (*close)(void *attr, hid_t dxpl_id, void **req); } H5VL_attr_class_t; @@ -328,11 +889,9 @@ typedef struct H5VL_dataset_class_t { void *buf, void **req); herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); - herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); - herr_t (*optional)(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); herr_t (*close)(void *dset, hid_t dxpl_id, void **req); } H5VL_dataset_class_t; @@ -342,11 +901,9 @@ typedef struct H5VL_datatype_class_t { hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); - herr_t (*optional)(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, H5VL_datatype_get_args_t *args, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_datatype_specific_args_t *args, hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); herr_t (*close)(void *dt, hid_t dxpl_id, void **req); } H5VL_datatype_class_t; @@ -355,11 +912,9 @@ typedef struct H5VL_file_class_t { void *(*create)(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); - herr_t (*optional)(void *obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); herr_t (*close)(void *file, hid_t dxpl_id, void **req); } H5VL_file_class_t; @@ -369,30 +924,28 @@ typedef struct H5VL_group_class_t { hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); - herr_t (*optional)(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_group_specific_args_t *args, hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); herr_t (*close)(void *grp, hid_t dxpl_id, void **req); } H5VL_group_class_t; /* H5L routines */ typedef struct H5VL_link_class_t { - herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*create)(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); - herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t *args, hid_t dxpl_id, + void **req); + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_args_t *args, + hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); } H5VL_link_class_t; /* H5O routines */ @@ -402,12 +955,12 @@ typedef struct H5VL_object_class_t { herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); - herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_args_t *args, hid_t dxpl_id, + void **req); + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_args_t *args, + hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req); } H5VL_object_class_t; /* Asynchronous request 'notify' callback */ @@ -427,6 +980,7 @@ struct H5VL_class_t; /* Container/connector introspection routines */ typedef struct H5VL_introspect_class_t { herr_t (*get_conn_cls)(void *obj, H5VL_get_conn_lvl_t lvl, const struct H5VL_class_t **conn_cls); + herr_t (*get_cap_flags)(const void *info, unsigned *cap_flags); herr_t (*opt_query)(void *obj, H5VL_subclass_t cls, int opt_type, uint64_t *flags); } H5VL_introspect_class_t; @@ -435,8 +989,8 @@ typedef struct H5VL_request_class_t { herr_t (*wait)(void *req, uint64_t timeout, H5VL_request_status_t *status); herr_t (*notify)(void *req, H5VL_request_notify_t cb, void *ctx); herr_t (*cancel)(void *req, H5VL_request_status_t *status); - herr_t (*specific)(void *req, H5VL_request_specific_t specific_type, va_list arguments); - herr_t (*optional)(void *req, H5VL_request_optional_t opt_type, va_list arguments); + herr_t (*specific)(void *req, H5VL_request_specific_args_t *args); + herr_t (*optional)(void *req, H5VL_optional_args_t *args); herr_t (*free)(void *req); } H5VL_request_class_t; @@ -444,8 +998,8 @@ typedef struct H5VL_request_class_t { typedef struct H5VL_blob_class_t { herr_t (*put)(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); herr_t (*get)(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); - herr_t (*specific)(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); - herr_t (*optional)(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); + herr_t (*specific)(void *obj, void *blob_id, H5VL_blob_specific_args_t *args); + herr_t (*optional)(void *obj, void *blob_id, H5VL_optional_args_t *args); } H5VL_blob_class_t; /* Object token routines */ @@ -490,8 +1044,8 @@ typedef struct H5VL_class_t { H5VL_token_class_t token_cls; /**< VOL connector object token class callbacks */ /* Catch-all */ - herr_t (*optional)(void *obj, int op_type, hid_t dxpl_id, void **req, - va_list arguments); /**< Optional callback */ + herr_t (*optional)(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); /**< Optional callback */ } H5VL_class_t; //! @@ -557,6 +1111,53 @@ H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name); */ H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); +/* User-defined optional operations */ +H5_DLL herr_t H5VLregister_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); +H5_DLL herr_t H5VLfind_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); +H5_DLL herr_t H5VLunregister_opt_operation(H5VL_subclass_t subcls, const char *op_name); +H5_DLL herr_t H5VLattr_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t attr_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLdataset_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t dset_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLdatatype_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t type_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLfile_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t file_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLgroup_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t group_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLlink_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t loc_id, const char *name, hid_t lapl_id, H5VL_optional_args_t *args, + hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLobject_optional_op(const char *app_file, const char *app_func, unsigned app_line, + hid_t loc_id, const char *name, hid_t lapl_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +H5_DLL herr_t H5VLrequest_optional_op(void *req, hid_t connector_id, H5VL_optional_args_t *args); + +/* API Wrappers for "optional_op" routines */ +/* (Must be defined _after_ the function prototype) */ +/* (And must only defined when included in application code, not the library) */ +#ifndef H5VL_MODULE +/* Inject application compile-time macros into function calls */ +#define H5VLattr_optional_op(...) H5VLattr_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define H5VLdataset_optional_op(...) H5VLdataset_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define H5VLdatatype_optional_op(...) H5VLdatatype_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define H5VLfile_optional_op(...) H5VLfile_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define H5VLgroup_optional_op(...) H5VLgroup_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define H5VLlink_optional_op(...) H5VLlink_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define H5VLobject_optional_op(...) H5VLobject_optional_op(__FILE__, __func__, __LINE__, __VA_ARGS__) + +/* Define "wrapper" versions of function calls, to allow compile-time values to + * be passed in by language wrapper or library layer on top of HDF5. + */ +#define H5VLattr_optional_op_wrap H5_NO_EXPAND(H5VLattr_optional_op) +#define H5VLdataset_optional_op_wrap H5_NO_EXPAND(H5VLdataset_optional_op) +#define H5VLdatatype_optional_op_wrap H5_NO_EXPAND(H5VLdatatype_optional_op) +#define H5VLfile_optional_op_wrap H5_NO_EXPAND(H5VLfile_optional_op) +#define H5VLgroup_optional_op_wrap H5_NO_EXPAND(H5VLgroup_optional_op) +#define H5VLlink_optional_op_wrap H5_NO_EXPAND(H5VLlink_optional_op) +#define H5VLobject_optional_op_wrap H5_NO_EXPAND(H5VLobject_optional_op) +#endif /* H5VL_MODULE */ + #ifdef __cplusplus } #endif diff --git a/src/H5VLconnector_passthru.h b/src/H5VLconnector_passthru.h index 720740f..17029f0 100644 --- a/src/H5VLconnector_passthru.h +++ b/src/H5VLconnector_passthru.h @@ -58,8 +58,9 @@ extern "C" { H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2); H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type); H5_DLL herr_t H5VLretrieve_lib_state(void **state); +H5_DLL herr_t H5VLstart_lib_state(void); H5_DLL herr_t H5VLrestore_lib_state(const void *state); -H5_DLL herr_t H5VLreset_lib_state(void); +H5_DLL herr_t H5VLfinish_lib_state(void); H5_DLL herr_t H5VLfree_lib_state(void *state); /* Pass-through callbacks */ @@ -92,13 +93,12 @@ H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void void **req); H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); +H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VLattr_close(void *attr, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for dataset callbacks */ @@ -111,12 +111,12 @@ H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id hid_t file_space_id, hid_t plist_id, void *buf, void **req); H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_args_t *args, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VLdataset_close(void *dset, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for named datatype callbacks */ @@ -125,24 +125,24 @@ H5_DLL void * H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params hid_t dxpl_id, void **req); H5_DLL void * H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_args_t *args, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for file callbacks */ H5_DLL void * H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); H5_DLL void * H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VLfile_close(void *file, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for group callbacks */ @@ -151,18 +151,17 @@ H5_DLL void * H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, h void **req); H5_DLL void * H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_args_t *args, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VLgroup_close(void *grp, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for link callbacks */ -H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, + hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); @@ -170,12 +169,11 @@ H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + H5VL_link_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Public wrappers for object callbacks */ H5_DLL void * H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, @@ -184,16 +182,16 @@ H5_DLL herr_t H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *loc_params void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Public wrappers for connector/container introspection callbacks */ H5_DLL herr_t H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VLintrospect_get_cap_flags(const void *info, hid_t connector_id, unsigned *cap_flags); H5_DLL herr_t H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, int opt_type, uint64_t *flags); @@ -202,10 +200,8 @@ H5_DLL herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5VL_request_status_t *status); H5_DLL herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx); H5_DLL herr_t H5VLrequest_cancel(void *req, hid_t connector_id, H5VL_request_status_t *status); -H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, - va_list arguments); -H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, - va_list arguments); +H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_args_t *args); +H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, H5VL_optional_args_t *args); H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id); /* Public wrappers for blob callbacks */ @@ -214,9 +210,8 @@ H5_DLL herr_t H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_ H5_DLL herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t size, void *ctx); H5_DLL herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, - H5VL_blob_specific_t specific_type, va_list arguments); -H5_DLL herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, - va_list arguments); + H5VL_blob_specific_args_t *args); +H5_DLL herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_optional_args_t *args); /* Public wrappers for token callbacks */ H5_DLL herr_t H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, @@ -227,8 +222,8 @@ H5_DLL herr_t H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector H5O_token_t *token); /* Public wrappers for generic 'optional' callback */ -H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req, - va_list arguments); +H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); #ifdef __cplusplus } diff --git a/src/H5VLdyn_ops.c b/src/H5VLdyn_ops.c new file mode 100644 index 0000000..0992452 --- /dev/null +++ b/src/H5VLdyn_ops.c @@ -0,0 +1,334 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Dynamic operation info */ +typedef struct H5VL_dyn_op_t { + char *op_name; /* Name of operation */ + int op_val; /* Value of operation */ +} H5VL_dyn_op_t; + +/********************/ +/* Local Prototypes */ +/********************/ +static void H5VL__release_dyn_op(H5VL_dyn_op_t *dyn_op); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* The current optional operation values */ +static int H5VL_opt_vals_g[H5VL_SUBCLS_TOKEN + 1] = { + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_NONE */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_INFO */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_WRAP */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_ATTR */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_DATASET */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_DATATYPE */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_FILE */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_GROUP */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_LINK */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_OBJECT */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_REQUEST */ + H5VL_RESERVED_NATIVE_OPTIONAL, /* H5VL_SUBCLS_BLOB */ + H5VL_RESERVED_NATIVE_OPTIONAL /* H5VL_SUBCLS_TOKEN */ +}; + +/* The current optional operations' info */ +static H5SL_t *H5VL_opt_ops_g[H5VL_SUBCLS_TOKEN + 1] = { + NULL, /* H5VL_SUBCLS_NONE */ + NULL, /* H5VL_SUBCLS_INFO */ + NULL, /* H5VL_SUBCLS_WRAP */ + NULL, /* H5VL_SUBCLS_ATTR */ + NULL, /* H5VL_SUBCLS_DATASET */ + NULL, /* H5VL_SUBCLS_DATATYPE */ + NULL, /* H5VL_SUBCLS_FILE */ + NULL, /* H5VL_SUBCLS_GROUP */ + NULL, /* H5VL_SUBCLS_LINK */ + NULL, /* H5VL_SUBCLS_OBJECT */ + NULL, /* H5VL_SUBCLS_REQUEST */ + NULL, /* H5VL_SUBCLS_BLOB */ + NULL /* H5VL_SUBCLS_TOKEN */ +}; + +/* Declare a free list to manage the H5VL_class_t struct */ +H5FL_DEFINE_STATIC(H5VL_dyn_op_t); + +/*--------------------------------------------------------------------------- + * Function: H5VL__release_dyn_op + * + * Purpose: Release a dynamic operation info node + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +static void +H5VL__release_dyn_op(H5VL_dyn_op_t *dyn_op) +{ + FUNC_ENTER_STATIC_NOERR + + H5MM_xfree(dyn_op->op_name); + H5FL_FREE(H5VL_dyn_op_t, dyn_op); + + FUNC_LEAVE_NOAPI_VOID +} /* H5VL__release_dyn_op() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__term_opt_operation_cb + * + * Purpose: Callback for releasing a dynamically registered operation info + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL__term_opt_operation_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data) +{ + H5VL_dyn_op_t *item = (H5VL_dyn_op_t *)_item; /* Item to release */ + + FUNC_ENTER_STATIC_NOERR + + /* Release the dynamically registered operation info */ + H5VL__release_dyn_op(item); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5VL__term_opt_operation_cb() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__term_opt_operation + * + * Purpose: Terminate the dynamically registered optional operations, + * releasing all operations. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__term_opt_operation(void) +{ + size_t subcls; /* Index over the elements of operation array */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Iterate over the VOL subclasses */ + for (subcls = 0; subcls < NELMTS(H5VL_opt_vals_g); subcls++) + if (H5VL_opt_ops_g[subcls]) + H5SL_destroy(H5VL_opt_ops_g[subcls], H5VL__term_opt_operation_cb, NULL); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5VL__term_opt_operation() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__register_opt_operation + * + * Purpose: Register a new optional operation for a VOL object subclass. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__register_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val) +{ + H5VL_dyn_op_t *new_op; /* Info about new operation */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + HDassert(op_val); + HDassert(op_name && *op_name); + + /* Check for duplicate operation */ + if (H5VL_opt_ops_g[subcls]) { + if (NULL != H5SL_search(H5VL_opt_ops_g[subcls], op_name)) + HGOTO_ERROR(H5E_VOL, H5E_EXISTS, FAIL, "operation name already exists") + } /* end if */ + else { + /* Create skip list for operation of this subclass */ + if (NULL == (H5VL_opt_ops_g[subcls] = H5SL_create(H5SL_TYPE_STR, NULL))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create skip list for operations") + } /* end else */ + + /* Register new operation */ + if (NULL == (new_op = H5FL_CALLOC(H5VL_dyn_op_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate memory for dynamic operation info") + if (NULL == (new_op->op_name = H5MM_strdup(op_name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate name for dynamic operation info") + new_op->op_val = H5VL_opt_vals_g[subcls]++; + + /* Insert into subclass's skip list */ + if (H5SL_insert(H5VL_opt_ops_g[subcls], new_op, new_op->op_name) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, FAIL, "can't insert operation info into skip list") + + /* Return the next operation value to the caller */ + *op_val = new_op->op_val; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL__register_opt_operation() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__num_opt_operation + * + * Purpose: Returns the # of currently registered optional operations + * + * Return: # of registered optional operations / + * + *--------------------------------------------------------------------------- + */ +size_t +H5VL__num_opt_operation(void) +{ + size_t subcls; /* Index over the elements of operation array */ + size_t ret_value = 0; /* Return value */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Iterate over the VOL subclasses */ + for (subcls = 0; subcls < NELMTS(H5VL_opt_vals_g); subcls++) + if (H5VL_opt_ops_g[subcls]) + ret_value += H5SL_count(H5VL_opt_ops_g[subcls]); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL__num_opt_operation() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__find_opt_operation + * + * Purpose: Look up a optional operation for a VOL object subclass, by name. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__find_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + HDassert(op_val); + HDassert(op_name && *op_name); + + /* Check for dynamic operations in the VOL subclass */ + if (H5VL_opt_ops_g[subcls]) { + H5VL_dyn_op_t *dyn_op; /* Info about operation */ + + /* Search for dynamic operation with correct name */ + if (NULL == (dyn_op = H5SL_search(H5VL_opt_ops_g[subcls], op_name))) + HGOTO_ERROR(H5E_VOL, H5E_NOTFOUND, FAIL, "operation name isn't registered") + + /* Set operation value for user */ + *op_val = dyn_op->op_val; + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_NOTFOUND, FAIL, "operation name isn't registered") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL__find_opt_operation() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__unregister_opt_operation + * + * Purpose: Unregister a optional operation for a VOL object subclass, by name. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__unregister_opt_operation(H5VL_subclass_t subcls, const char *op_name) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + HDassert(op_name && *op_name); + + /* Check for dynamic operations in the VOL subclass */ + if (H5VL_opt_ops_g[subcls]) { + H5VL_dyn_op_t *dyn_op; /* Info about operation */ + + /* Search for dynamic operation with correct name */ + if (NULL == (dyn_op = H5SL_remove(H5VL_opt_ops_g[subcls], op_name))) + HGOTO_ERROR(H5E_VOL, H5E_NOTFOUND, FAIL, "operation name isn't registered") + + /* Release the info for the operation */ + H5VL__release_dyn_op(dyn_op); + + /* Close the skip list, if no more operations in it */ + if (0 == H5SL_count(H5VL_opt_ops_g[subcls])) { + if (H5SL_close(H5VL_opt_ops_g[subcls]) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "can't close dyn op skip list") + H5VL_opt_ops_g[subcls] = NULL; + } /* end if */ + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_NOTFOUND, FAIL, "operation name isn't registered") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL__unregister_opt_operation() */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 500e075..70c8112 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -88,7 +88,6 @@ typedef struct { /********************/ static herr_t H5VL__free_cls(H5VL_class_t *cls, void **request); static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data); -static herr_t H5VL__set_def_conn(void); static void * H5VL__wrap_obj(void *obj, H5I_type_t obj_type); static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t wrap_obj); @@ -194,6 +193,10 @@ H5VL_init_phase2(void) if (H5M_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize map interface") + /* Sanity check default VOL connector */ + HDassert(H5VL_def_conn_s.connector_id == (-1)); + HDassert(H5VL_def_conn_s.connector_info == NULL); + /* Set up the default VOL connector in the default FAPL */ if (H5VL__set_def_conn() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set default VOL connector") @@ -261,15 +264,22 @@ H5VL_term_package(void) n++; } /* end if */ else { - /* Destroy the VOL connector ID group */ - n += (H5I_dec_type_ref(H5I_VOL) > 0); - - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end else */ - } /* end if */ + if (H5VL__num_opt_operation() > 0) { + /* Unregister all dynamically registered optional operations */ + (void)H5VL__term_opt_operation(); + n++; + } /* end if */ + else { + /* Destroy the VOL connector ID group */ + n += (H5I_dec_type_ref(H5I_VOL) > 0); + + /* Mark interface as closed */ + if (0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end else */ + } /* end else */ + } /* end else */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5VL_term_package() */ @@ -365,7 +375,7 @@ H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5VL__set_def_conn(void) { H5P_genplist_t *def_fapl; /* Default file access property list */ @@ -376,11 +386,16 @@ H5VL__set_def_conn(void) void * vol_info = NULL; /* VOL connector info */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - /* Sanity check */ - HDassert(H5VL_def_conn_s.connector_id == (-1)); - HDassert(H5VL_def_conn_s.connector_info == NULL); + /* Reset default VOL connector, if it's set already */ + /* (Can happen during testing -QAK) */ + if (H5VL_def_conn_s.connector_id > 0) { + /* Release the default VOL connector */ + (void)H5VL_conn_free(&H5VL_def_conn_s); + H5VL_def_conn_s.connector_id = -1; + H5VL_def_conn_s.connector_info = NULL; + } /* end if */ /* Check for environment variable set */ env_var = HDgetenv("HDF5_VOL_CONNECTOR"); @@ -760,51 +775,47 @@ done: } /* end H5VL_register_using_existing_id() */ /*------------------------------------------------------------------------- - * Function: H5VL_register_using_vol_id + * Function: H5VL_new_connector * - * Purpose: Utility function to create a user ID for an object created - * or opened through the VOL. Uses the VOL connector's ID to - * get the connector information instead of it being passed in. + * Purpose: Utility function to create a connector for a connector ID. * - * Return: Success: A valid HDF5 ID - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to a new connector object + * Failure: NULL * *------------------------------------------------------------------------- */ -hid_t -H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref) +H5VL_t * +H5VL_new_connector(hid_t connector_id) { - H5VL_class_t *cls = NULL; /* VOL connector class */ - H5VL_t * connector = NULL; /* VOL connector struct */ - hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_class_t *cls = NULL; /* VOL connector class */ + H5VL_t * connector = NULL; /* New VOL connector struct */ + hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ + H5VL_t * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(NULL) /* Get the VOL class object from the connector's ID */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL connector ID") + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Setup VOL info struct */ if (NULL == (connector = H5FL_CALLOC(H5VL_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate VOL info struct") + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate VOL connector struct") connector->cls = cls; connector->id = connector_id; if (H5I_inc_ref(connector->id, FALSE) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL connector") conn_id_incr = TRUE; - /* Get an ID for the VOL object */ - if ((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + /* Set return value */ + ret_value = connector; done: /* Clean up on error */ - if (ret_value < 0) { + if (NULL == ret_value) { /* Decrement VOL connector ID ref count on error */ if (conn_id_incr && H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, - "unable to decrement ref count on VOL connector") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") /* Free VOL connector struct */ if (NULL != connector) @@ -812,6 +823,45 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_new_connector() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_register_using_vol_id + * + * Purpose: Utility function to create a user ID for an object created + * or opened through the VOL. Uses the VOL connector's ID to + * get the connector information instead of it being passed in. + * + * Return: Success: A valid HDF5 ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref) +{ + H5VL_t *connector = NULL; /* VOL connector struct */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Create new VOL connector object, using the connector ID */ + if (NULL == (connector = H5VL_new_connector(connector_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't create VOL connector object") + + /* Get an ID for the VOL object */ + if ((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + +done: + /* Clean up on error */ + if (H5I_INVALID_HID == ret_value) + /* Release newly created connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector") + + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_register_using_vol_id() */ /*------------------------------------------------------------------------- @@ -1125,15 +1175,20 @@ H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, if (cmp_value) *same_file = FALSE; else { - void *obj2; /* Terminal object for second file */ + void * obj2; /* Terminal object for second file */ + H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ /* Get unwrapped (terminal) object for vol_obj2 */ if (NULL == (obj2 = H5VL_object_data(vol_obj2))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get unwrapped object") - /* Make callback */ - if (H5VL_file_specific(vol_obj1, H5VL_FILE_IS_EQUAL, H5P_DATASET_XFER_DEFAULT, NULL, obj2, - same_file) < 0) + /* Set up VOL callback arguments */ + vol_cb_args.op_type = H5VL_FILE_IS_EQUAL; + vol_cb_args.args.is_equal.obj2 = obj2; + vol_cb_args.args.is_equal.same_file = same_file; + + /* Make 'are files equal' callback */ + if (H5VL_file_specific(vol_obj1, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") } /* end else */ @@ -2047,6 +2102,36 @@ done: } /* end H5VL_retrieve_lib_state() */ /*------------------------------------------------------------------------- + * Function: H5VL_start_lib_state + * + * Purpose: Opens a new internal state for the HDF5 library. + * + * Note: Currently just pushes a new API context state, but could be + * expanded in the future. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, February 5, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_start_lib_state(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Push a new API context on the stack */ + if (H5CX_push() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't push API context") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_start_lib_state() */ + +/*------------------------------------------------------------------------- * Function: H5VL_restore_lib_state * * Purpose: Restore the state of the library. @@ -2071,10 +2156,6 @@ H5VL_restore_lib_state(const void *state) /* Sanity checks */ HDassert(state); - /* Push a new API context on the stack */ - if (H5CX_push() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't push API context") - /* Restore the API context state */ if (H5CX_restore_state((const H5CX_state_t *)state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context state") @@ -2084,16 +2165,16 @@ done: } /* end H5VL_restore_lib_state() */ /*------------------------------------------------------------------------- - * Function: H5VL_reset_lib_state + * Function: H5VL_finish_lib_state * - * Purpose: Reset the state of the library, undoing affects of - * H5VL_restore_lib_state. + * Purpose: Closes the state of the library, undoing affects of + * H5VL_start_lib_state. * * Note: Currently just resets the API context state, but could be * expanded in the future. * * Note: This routine must be called as a "pair" with - * H5VL_restore_lib_state. It can be called before / after / + * H5VL_start_lib_state. It can be called before / after / * independently of H5VL_free_lib_state. * * Return: SUCCEED / FAIL @@ -2104,7 +2185,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_reset_lib_state(void) +H5VL_finish_lib_state(void) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2116,7 +2197,7 @@ H5VL_reset_lib_state(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_reset_lib_state() */ +} /* end H5VL_finish_lib_state() */ /*------------------------------------------------------------------------- * Function: H5VL_free_lib_state @@ -2484,6 +2565,33 @@ done: } /* end H5VL_check_plugin_load() */ /*------------------------------------------------------------------------- + * Function: H5VL__is_default_conn + * + * Purpose: Check if the default connector will be used for a container. + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +void +H5VL__is_default_conn(hid_t fapl_id, hid_t connector_id, hbool_t *is_default) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity checks */ + HDassert(is_default); + + /* Determine if the default VOL connector will be used, based on non-default + * values in the FAPL, connector ID, or the HDF5_VOL_CONNECTOR environment + * variable being set. + */ + *is_default = (H5VL_def_conn_s.connector_id == H5_DEFAULT_VOL) && + ((H5P_FILE_ACCESS_DEFAULT == fapl_id) || connector_id == H5_DEFAULT_VOL); + + FUNC_LEAVE_NOAPI_VOID +} /* end H5VL__is_default_conn() */ + +/*------------------------------------------------------------------------- * Function: H5VL_setup_args * * Purpose: Set up arguments to access an object @@ -2506,7 +2614,7 @@ H5VL_setup_args(hid_t loc_id, H5I_type_t id_type, H5VL_object_t **vol_obj) if (NULL == (*vol_obj = (H5VL_object_t *)H5I_object_verify(loc_id, id_type))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not the correct type of ID") - /* Set up collective metadata (if appropriate */ + /* Set up collective metadata (if appropriate) */ if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set collective metadata read") @@ -2631,8 +2739,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_setup_name_args(hid_t loc_id, const char *name, const H5P_libclass_t *libclass, hbool_t is_collective, - hid_t acspl_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) +H5VL_setup_name_args(hid_t loc_id, const char *name, hbool_t is_collective, hid_t lapl_id, + H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2649,7 +2757,7 @@ H5VL_setup_name_args(hid_t loc_id, const char *name, const H5P_libclass_t *libcl HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if (H5CX_set_apl(&acspl_id, libclass, loc_id, is_collective) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, is_collective) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ @@ -2659,7 +2767,7 @@ H5VL_setup_name_args(hid_t loc_id, const char *name, const H5P_libclass_t *libcl /* Set up location parameters */ loc_params->type = H5VL_OBJECT_BY_NAME; loc_params->loc_data.loc_by_name.name = name; - loc_params->loc_data.loc_by_name.lapl_id = acspl_id; + loc_params->loc_data.loc_by_name.lapl_id = lapl_id; loc_params->obj_type = H5I_get_type(loc_id); done: @@ -2677,8 +2785,8 @@ done: */ herr_t H5VL_setup_idx_args(hid_t loc_id, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - const H5P_libclass_t *libclass, hbool_t is_collective, hid_t acspl_id, - H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) + hbool_t is_collective, hid_t lapl_id, H5VL_object_t **vol_obj, + H5VL_loc_params_t *loc_params) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2699,7 +2807,7 @@ H5VL_setup_idx_args(hid_t loc_id, const char *name, H5_index_t idx_type, H5_iter HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if (H5CX_set_apl(&acspl_id, libclass, loc_id, is_collective) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, is_collective) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ @@ -2712,7 +2820,7 @@ H5VL_setup_idx_args(hid_t loc_id, const char *name, H5_index_t idx_type, H5_iter loc_params->loc_data.loc_by_idx.idx_type = idx_type; loc_params->loc_data.loc_by_idx.order = order; loc_params->loc_data.loc_by_idx.n = n; - loc_params->loc_data.loc_by_idx.lapl_id = acspl_id; + loc_params->loc_data.loc_by_idx.lapl_id = lapl_id; loc_params->obj_type = H5I_get_type(loc_id); done: @@ -2752,3 +2860,45 @@ H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_object_t **vol_ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_setup_token_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_get_cap_flags + * + * Purpose: Query capability flags for connector property. + * + * Note: VOL connector set with HDF5_VOL_CONNECTOR overrides the + * property passed in. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_get_cap_flags(const H5VL_connector_prop_t *connector_prop, unsigned *cap_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(connector_prop); + + /* Copy the connector ID & info, if there is one */ + if (connector_prop->connector_id > 0) { + H5VL_class_t *connector; /* Pointer to connector */ + + /* Retrieve the connector for the ID */ + if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Query the connector's capability flags */ + if (H5VL_introspect_get_cap_flags(connector_prop->connector_info, connector, cap_flags) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector's capability flags") + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector ID not set?") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_cap_flags() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index b70d489..18b5b9c 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -47,13 +47,13 @@ static herr_t H5VL__native_term(void); /* Native VOL connector class struct */ static const H5VL_class_t H5VL_native_cls_g = { - H5VL_VERSION, /* VOL class struct version */ - H5VL_NATIVE_VALUE, /* value */ - H5VL_NATIVE_NAME, /* name */ - H5VL_NATIVE_VERSION, /* connector version */ - 0, /* capability flags */ - NULL, /* initialize */ - H5VL__native_term, /* terminate */ + H5VL_VERSION, /* VOL class struct version */ + H5VL_NATIVE_VALUE, /* value */ + H5VL_NATIVE_NAME, /* name */ + H5VL_NATIVE_VERSION, /* connector version */ + H5VL_CAP_FLAG_NATIVE_FILES, /* capability flags */ + NULL, /* initialize */ + H5VL__native_term, /* terminate */ { /* info_cls */ (size_t)0, /* info size */ @@ -139,8 +139,9 @@ static const H5VL_class_t H5VL_native_cls_g = { }, { /* introspect_cls */ - H5VL__native_introspect_get_conn_cls, /* get_conn_cls */ - H5VL__native_introspect_opt_query, /* opt_query */ + H5VL__native_introspect_get_conn_cls, /* get_conn_cls */ + H5VL__native_introspect_get_cap_flags, /* get_cap_flags */ + H5VL__native_introspect_opt_query, /* opt_query */ }, { /* request_cls */ @@ -244,6 +245,32 @@ H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, H5VL_get_conn_lvl FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_introspect_get_conn_cls() */ +/*--------------------------------------------------------------------------- + * Function: H5VL__native_introspect_get_cap_flags + * + * Purpose: Query the capability flags for this connector. + * + * Note: This routine is in this file so that it can return the field + * from the staticly declared class struct. + * + * Returns: SUCCEED (Can't fail) + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_introspect_get_cap_flags(const void H5_ATTR_UNUSED *info, unsigned *cap_flags) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(cap_flags); + + /* Set the flags from the connector's field */ + *cap_flags = H5VL_native_cls_g.cap_flags; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__native_introspect_get_cap_flags() */ + /*------------------------------------------------------------------------- * Function: H5VL_native_get_file_addr_len * diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 4a46e9e..fe8ede2 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -18,6 +18,7 @@ #define H5VLnative_H /* Public headers needed by this file */ +#include "H5Apublic.h" /* Attributes */ #include "H5VLpublic.h" /* Virtual Object Layer */ /*****************/ @@ -39,21 +40,140 @@ #ifndef H5_NO_DEPRECATED_SYMBOLS #define H5VL_NATIVE_ATTR_ITERATE_OLD 0 /* H5Aiterate (deprecated routine) */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ +/* NOTE: If values over 1023 are added, the H5VL_RESERVED_NATIVE_OPTIONAL macro + * must be updated. + */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS +/* Parameters for attribute 'iterate old' operation */ +typedef struct H5VL_native_attr_iterate_old_t { + hid_t loc_id; + unsigned * attr_num; + H5A_operator1_t op; + void * op_data; +} H5VL_native_attr_iterate_old_t; + +/* Parameters for native connector's attribute 'optional' operations */ +typedef union H5VL_native_attr_optional_args_t { + /* H5VL_NATIVE_ATTR_ITERATE_OLD */ + H5VL_native_attr_iterate_old_t iterate_old; +} H5VL_native_attr_optional_args_t; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Values for native VOL connector dataset optional VOL operations */ /* NOTE: If new values are added here, the H5VL__native_introspect_opt_query * routine must be updated. */ -#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ -#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */ -#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */ -#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */ -#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */ -#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */ +#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ +#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */ +#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */ +#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */ +#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */ +#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */ +#define H5VL_NATIVE_DATASET_CHUNK_ITER 10 /* H5Dget_offset */ +/* NOTE: If values over 1023 are added, the H5VL_RESERVED_NATIVE_OPTIONAL macro + * must be updated. + */ + +/* Parameters for native connector's dataset 'chunk read' operation */ +typedef struct H5VL_native_dataset_chunk_read_t { + const hsize_t *offset; + uint32_t filters; + void * buf; +} H5VL_native_dataset_chunk_read_t; + +/* Parameters for native connector's dataset 'chunk write' operation */ +typedef struct H5VL_native_dataset_chunk_write_t { + const hsize_t *offset; + uint32_t filters; + uint32_t size; + const void * buf; +} H5VL_native_dataset_chunk_write_t; + +/* Parameters for native connector's dataset 'get vlen buf size' operation */ +typedef struct H5VL_native_dataset_get_vlen_buf_size_t { + hid_t type_id; + hid_t space_id; + hsize_t *size; /* Size of variable-length data buffer (OUT) */ +} H5VL_native_dataset_get_vlen_buf_size_t; + +/* Parameters for native connector's dataset 'get chunk storage size' operation */ +typedef struct H5VL_native_dataset_get_chunk_storage_size_t { + const hsize_t *offset; /* Offset of chunk */ + hsize_t * size; /* Size of chunk (OUT) */ +} H5VL_native_dataset_get_chunk_storage_size_t; + +/* Parameters for native connector's dataset 'get num chunks' operation */ +typedef struct H5VL_native_dataset_get_num_chunks_t { + hid_t space_id; /* Space selection */ + hsize_t *nchunks; /* # of chunk for space selection (OUT) */ +} H5VL_native_dataset_get_num_chunks_t; + +/* Parameters for native connector's dataset 'get chunk info by idx' operation */ +typedef struct H5VL_native_dataset_get_chunk_info_by_idx_t { + hid_t space_id; /* Space selection */ + hsize_t chk_index; /* Chunk index within space */ + hsize_t * offset; /* Chunk coordinates (OUT) */ + unsigned *filter_mask; /* Filter mask for chunk (OUT) */ + haddr_t * addr; /* Address of chunk in file (OUT) */ + hsize_t * size; /* Size of chunk in file (OUT) */ +} H5VL_native_dataset_get_chunk_info_by_idx_t; + +/* Parameters for native connector's dataset 'get chunk info by coord' operation */ +typedef struct H5VL_native_dataset_get_chunk_info_by_coord_t { + const hsize_t *offset; /* Chunk coordinates */ + unsigned * filter_mask; /* Filter mask for chunk (OUT) */ + haddr_t * addr; /* Address of chunk in file (OUT) */ + hsize_t * size; /* Size of chunk in file (OUT) */ +} H5VL_native_dataset_get_chunk_info_by_coord_t; + +/* Parameters for native connector's dataset 'optional' operations */ +typedef union H5VL_native_dataset_optional_args_t { + /* H5VL_NATIVE_DATASET_FORMAT_CONVERT */ + /* No args */ + + /* H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE */ + struct { + H5D_chunk_index_t *idx_type; /* Type of chunk index (OUT) */ + } get_chunk_idx_type; + + /* H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE */ + H5VL_native_dataset_get_chunk_storage_size_t get_chunk_storage_size; + + /* H5VL_NATIVE_DATASET_GET_NUM_CHUNKS */ + H5VL_native_dataset_get_num_chunks_t get_num_chunks; + + /* H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX */ + H5VL_native_dataset_get_chunk_info_by_idx_t get_chunk_info_by_idx; + + /* H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD */ + H5VL_native_dataset_get_chunk_info_by_coord_t get_chunk_info_by_coord; + + /* H5VL_NATIVE_DATASET_CHUNK_READ */ + H5VL_native_dataset_chunk_read_t chunk_read; + + /* H5VL_NATIVE_DATASET_CHUNK_WRITE */ + H5VL_native_dataset_chunk_write_t chunk_write; + + /* H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE */ + H5VL_native_dataset_get_vlen_buf_size_t get_vlen_buf_size; + + /* H5VL_NATIVE_DATASET_GET_OFFSET */ + struct { + haddr_t *offset; /* Contiguous dataset's offset in the file (OUT) */ + } get_offset; + + /* H5VL_NATIVE_DATASET_CHUNK_ITER */ + struct { + H5D_chunk_iter_op_t op; /* Chunk iteration callback */ + void * op_data; /* Context to pass to iteration callback */ + } chunk_iter; + +} H5VL_native_dataset_optional_args_t; /* Values for native VOL connector file optional VOL operations */ /* NOTE: If new values are added here, the H5VL__native_introspect_opt_query @@ -85,9 +205,195 @@ #define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 23 /* H5Fset_latest_format/libver_bounds */ #define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 24 /* H5Fget_dset_no_attrs_hint */ #define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 25 /* H5Fset_dset_no_attrs_hint */ -#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 26 /* H5Fget_mpi_atomicity */ -#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 27 /* H5Fset_mpi_atomicity */ -#define H5VL_NATIVE_FILE_POST_OPEN 28 /* Adjust file after open, with wrapping context */ +#ifdef H5_HAVE_PARALLEL +#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 26 /* H5Fget_mpi_atomicity */ +#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 27 /* H5Fset_mpi_atomicity */ +#endif /* H5_HAVE_PARALLEL */ +#define H5VL_NATIVE_FILE_POST_OPEN 28 /* Adjust file after open, with wrapping context */ +/* NOTE: If values over 1023 are added, the H5VL_RESERVED_NATIVE_OPTIONAL macro + * must be updated. + */ + +/* Parameters for native connector's file 'get file image' operation */ +typedef struct H5VL_native_file_get_file_image_t { + size_t buf_size; /* Size of file image buffer */ + void * buf; /* Buffer for file image (OUT) */ + size_t *image_len; /* Size of file image (OUT) */ +} H5VL_native_file_get_file_image_t; + +/* Parameters for native connector's file 'get free sections' operation */ +typedef struct H5VL_native_file_get_free_sections_t { + H5F_mem_t type; /* Type of file memory to query */ + H5F_sect_info_t *sect_info; /* Array of sections (OUT) */ + size_t nsects; /* Size of section array */ + size_t * sect_count; /* Actual # of sections of type (OUT) */ +} H5VL_native_file_get_free_sections_t; + +/* Parameters for native connector's file 'get freespace' operation */ +typedef struct H5VL_native_file_get_freespace_t { + hsize_t *size; /* Size of free space (OUT) */ +} H5VL_native_file_get_freespace_t; + +/* Parameters for native connector's file 'get info' operation */ +typedef struct H5VL_native_file_get_info_t { + H5I_type_t type; /* Type of object */ + H5F_info2_t *finfo; /* Pointer to file info (OUT) */ +} H5VL_native_file_get_info_t; + +/* Parameters for native connector's file 'get metadata cache size' operation */ +typedef struct H5VL_native_file_get_mdc_size_t { + size_t * max_size; /* Maximum amount of cached data (OUT) */ + size_t * min_clean_size; /* Minimum amount of cached data to keep clean (OUT) */ + size_t * cur_size; /* Current amount of cached data (OUT) */ + uint32_t *cur_num_entries; /* Current # of cached entries (OUT) */ +} H5VL_native_file_get_mdc_size_t; + +/* Parameters for native connector's file 'get VFD handle' operation */ +typedef struct H5VL_native_file_get_vfd_handle_t { + hid_t fapl_id; + void **file_handle; /* File handle from VFD (OUT) */ +} H5VL_native_file_get_vfd_handle_t; + +/* Parameters for native connector's file 'get MDC logging status' operation */ +typedef struct H5VL_native_file_get_mdc_logging_status_t { + hbool_t *is_enabled; /* Whether logging is enabled (OUT) */ + hbool_t *is_currently_logging; /* Whether currently logging (OUT) */ +} H5VL_native_file_get_mdc_logging_status_t; + +/* Parameters for native connector's file 'get page buffering stats' operation */ +typedef struct H5VL_native_file_get_page_buffering_stats_t { + unsigned *accesses; /* Metadata/raw data page access counts (OUT) */ + unsigned *hits; /* Metadata/raw data page hit counts (OUT) */ + unsigned *misses; /* Metadata/raw data page miss counts (OUT) */ + unsigned *evictions; /* Metadata/raw data page eviction counts (OUT) */ + unsigned *bypasses; /* Metadata/raw data page bypass counts (OUT) */ +} H5VL_native_file_get_page_buffering_stats_t; + +/* Parameters for native connector's file 'get MDC image info' operation */ +typedef struct H5VL_native_file_get_mdc_image_info_t { + haddr_t *addr; /* Address of image (OUT) */ + hsize_t *len; /* Length of image (OUT) */ +} H5VL_native_file_get_mdc_image_info_t; + +/* Parameters for native connector's file 'set libver bounds' operation */ +typedef struct H5VL_native_file_set_libver_bounds_t { + H5F_libver_t low; /* Lowest version possible */ + H5F_libver_t high; /* Highest version possible */ +} H5VL_native_file_set_libver_bounds_t; + +/* Parameters for native connector's file 'optional' operations */ +typedef union H5VL_native_file_optional_args_t { + /* H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE */ + /* No args */ + + /* H5VL_NATIVE_FILE_GET_FILE_IMAGE */ + H5VL_native_file_get_file_image_t get_file_image; + + /* H5VL_NATIVE_FILE_GET_FREE_SECTIONS */ + H5VL_native_file_get_free_sections_t get_free_sections; + + /* H5VL_NATIVE_FILE_GET_FREE_SPACE */ + H5VL_native_file_get_freespace_t get_freespace; + + /* H5VL_NATIVE_FILE_GET_INFO */ + H5VL_native_file_get_info_t get_info; + + /* H5VL_NATIVE_FILE_GET_MDC_CONF */ + struct { + H5AC_cache_config_t *config; /* Pointer to MDC config (OUT) */ + } get_mdc_config; + + /* H5VL_NATIVE_FILE_GET_MDC_HR */ + struct { + double *hit_rate; /* Metadata cache hit rate (OUT) */ + } get_mdc_hit_rate; + + /* H5VL_NATIVE_FILE_GET_MDC_SIZE */ + H5VL_native_file_get_mdc_size_t get_mdc_size; + + /* H5VL_NATIVE_FILE_GET_SIZE */ + struct { + hsize_t *size; /* Size of file (OUT) */ + } get_size; + + /* H5VL_NATIVE_FILE_GET_VFD_HANDLE */ + H5VL_native_file_get_vfd_handle_t get_vfd_handle; + + /* H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE */ + /* No args */ + + /* H5VL_NATIVE_FILE_SET_MDC_CONFIG */ + struct { + const H5AC_cache_config_t *config; /* Pointer to new MDC config */ + } set_mdc_config; + + /* H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO */ + struct { + H5F_retry_info_t *info; /* Pointer to metadata read retry info (OUT) */ + } get_metadata_read_retry_info; + + /* H5VL_NATIVE_FILE_START_SWMR_WRITE */ + /* No args */ + + /* H5VL_NATIVE_FILE_START_MDC_LOGGING */ + /* No args */ + + /* H5VL_NATIVE_FILE_STOP_MDC_LOGGING */ + /* No args */ + + /* H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS */ + H5VL_native_file_get_mdc_logging_status_t get_mdc_logging_status; + + /* H5VL_NATIVE_FILE_FORMAT_CONVERT */ + /* No args */ + + /* H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS */ + /* No args */ + + /* H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS */ + H5VL_native_file_get_page_buffering_stats_t get_page_buffering_stats; + + /* H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO */ + H5VL_native_file_get_mdc_image_info_t get_mdc_image_info; + + /* H5VL_NATIVE_FILE_GET_EOA */ + struct { + haddr_t *eoa; /* End of allocated file address space (OUT) */ + } get_eoa; + + /* H5VL_NATIVE_FILE_INCR_FILESIZE */ + struct { + hsize_t increment; /* Amount to increment file size */ + } increment_filesize; + + /* H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS */ + H5VL_native_file_set_libver_bounds_t set_libver_bounds; + + /* H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG */ + struct { + hbool_t *minimize; /* Flag whether dataset object headers are minimal (OUT) */ + } get_min_dset_ohdr_flag; + + /* H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG */ + struct { + hbool_t minimize; /* Flag whether dataset object headers should be minimal */ + } set_min_dset_ohdr_flag; + +#ifdef H5_HAVE_PARALLEL + /* H5VL_NATIVE_FILE_GET_MPI_ATOMICITY */ + struct { + hbool_t *flag; /* Flag whether MPI atomicity is set for files (OUT) */ + } get_mpi_atomicity; + + /* H5VL_NATIVE_FILE_SET_MPI_ATOMICITY */ + struct { + hbool_t flag; /* Flag whether to set MPI atomicity for files */ + } set_mpi_atomicity; +#endif /* H5_HAVE_PARALLEL */ + + /* H5VL_NATIVE_FILE_POST_OPEN */ + /* No args */ +} H5VL_native_file_optional_args_t; /* Values for native VOL connector group optional VOL operations */ /* NOTE: If new values are added here, the H5VL__native_introspect_opt_query @@ -97,6 +403,36 @@ #define H5VL_NATIVE_GROUP_ITERATE_OLD 0 /* HG5Giterate (deprecated routine) */ #define H5VL_NATIVE_GROUP_GET_OBJINFO 1 /* HG5Gget_objinfo (deprecated routine) */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ +/* NOTE: If values over 1023 are added, the H5VL_RESERVED_NATIVE_OPTIONAL macro + * must be updated. + */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS +/* Parameters for group 'iterate old' operation */ +typedef struct H5VL_native_group_iterate_old_t { + H5VL_loc_params_t loc_params; /* Location parameters for iteration */ + hsize_t idx; /* Index of link to begin iteration at */ + hsize_t * last_obj; /* Index of last link looked at (OUT) */ + H5G_iterate_t op; /* Group (link) operator callback */ + void * op_data; /* Context to pass to iterator callback */ +} H5VL_native_group_iterate_old_t; + +/* Parameters for group 'get objinfo' operation */ +typedef struct H5VL_native_group_get_objinfo_t { + H5VL_loc_params_t loc_params; /* Location parameters for iteration */ + hbool_t follow_link; /* Whether to follow links for query */ + H5G_stat_t * statbuf; /* Pointer to object info struct (OUT) */ +} H5VL_native_group_get_objinfo_t; + +/* Parameters for native connector's group 'optional' operations */ +typedef union H5VL_native_group_optional_args_t { + /* H5VL_NATIVE_GROUP_ITERATE_OLD */ + H5VL_native_group_iterate_old_t iterate_old; + + /* H5VL_NATIVE_GROUP_GET_OBJINFO */ + H5VL_native_group_get_objinfo_t get_objinfo; +} H5VL_native_group_optional_args_t; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Values for native VOL connector object optional VOL operations */ /* NOTE: If new values are added here, the H5VL__native_introspect_opt_query @@ -108,6 +444,47 @@ #define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 3 /* H5Oenable_mdc_flushes */ #define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 4 /* H5Oare_mdc_flushes_disabled */ #define H5VL_NATIVE_OBJECT_GET_NATIVE_INFO 5 /* H5Oget_native_info(_by_idx, _by_name) */ +/* NOTE: If values over 1023 are added, the H5VL_RESERVED_NATIVE_OPTIONAL macro + * must be updated. + */ + +/* Parameters for native connector's object 'get comment' operation */ +typedef struct H5VL_native_object_get_comment_t { + size_t buf_size; /* Size of comment buffer */ + void * buf; /* Buffer for comment (OUT) */ + size_t *comment_len; /* Actual size of comment (OUT) */ +} H5VL_native_object_get_comment_t; + +/* Parameters for object 'get native info' operation */ +typedef struct H5VL_native_object_get_native_info_t { + unsigned fields; /* Fields to retrieve */ + H5O_native_info_t *ninfo; /* Native info (OUT) */ +} H5VL_native_object_get_native_info_t; + +/* Parameters for native connector's object 'optional' operations */ +typedef union H5VL_native_object_optional_args_t { + /* H5VL_NATIVE_OBJECT_GET_COMMENT */ + H5VL_native_object_get_comment_t get_comment; + + /* H5VL_NATIVE_OBJECT_SET_COMMENT */ + struct { + const char *comment; /* Comment string to set for the object (IN) */ + } set_comment; + + /* H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES */ + /* No args */ + + /* H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES */ + /* No args */ + + /* H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED */ + struct { + hbool_t *flag; /* Flag whether metadata cache flushes are disabled for this object (OUT) */ + } are_mdc_flushes_disabled; + + /* H5VL_NATIVE_OBJECT_GET_NATIVE_INFO */ + H5VL_native_object_get_native_info_t get_native_info; +} H5VL_native_object_optional_args_t; /*******************/ /* Public Typedefs */ diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 7beb98f..834ae40 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -15,8 +15,15 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5A_FRIEND /* Suppress error about including H5Apkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ @@ -30,6 +37,30 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- * Function: H5VL__native_attr_create * @@ -214,40 +245,37 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (get_type) { + switch (args->op_type) { /* H5Aget_space */ case H5VL_ATTR_GET_SPACE: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; + H5A_t *attr = (H5A_t *)obj; - if ((*ret_id = H5A_get_space(attr)) < 0) + if ((args->args.get_space.space_id = H5A_get_space(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") break; } /* H5Aget_type */ case H5VL_ATTR_GET_TYPE: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; + H5A_t *attr = (H5A_t *)obj; - if ((*ret_id = H5A__get_type(attr)) < 0) + if ((args->args.get_type.type_id = H5A__get_type(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") break; } /* H5Aget_create_plist */ case H5VL_ATTR_GET_ACPL: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; + H5A_t *attr = (H5A_t *)obj; - if ((*ret_id = H5A__get_create_plist(attr)) < 0) + if ((args->args.get_acpl.acpl_id = H5A__get_create_plist(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") break; @@ -255,40 +283,37 @@ H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED /* H5Aget_name */ case H5VL_ATTR_GET_NAME: { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - size_t buf_size = HDva_arg(arguments, size_t); - char * buf = HDva_arg(arguments, char *); - ssize_t * ret_val = HDva_arg(arguments, ssize_t *); - H5A_t * attr = NULL; + H5VL_attr_get_name_args_t *get_name_args = &args->args.get_name; - if (H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - /* Call private function in turn */ - if (0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + if (H5VL_OBJECT_BY_SELF == get_name_args->loc_params.type) { + if (H5A__get_name((H5A_t *)obj, get_name_args->buf_size, get_name_args->buf, + get_name_args->attr_name_len) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") } - else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + else if (H5VL_OBJECT_BY_IDX == get_name_args->loc_params.type) { H5G_loc_t loc; + H5A_t * attr; /* check arguments */ - if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, get_name_args->loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the attribute on the object header */ - if (NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) + if (NULL == (attr = H5A__open_by_idx(&loc, get_name_args->loc_params.loc_data.loc_by_idx.name, + get_name_args->loc_params.loc_data.loc_by_idx.idx_type, + get_name_args->loc_params.loc_data.loc_by_idx.order, + get_name_args->loc_params.loc_data.loc_by_idx.n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the length of the name */ - *ret_val = (ssize_t)HDstrlen(attr->shared->name); + *get_name_args->attr_name_len = HDstrlen(attr->shared->name); /* Copy the name into the user's buffer, if given */ - if (buf) { - HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); - if ((size_t)(*ret_val) >= buf_size) - buf[buf_size - 1] = '\0'; + if (get_name_args->buf) { + HDstrncpy(get_name_args->buf, attr->shared->name, + MIN((*get_name_args->attr_name_len + 1), get_name_args->buf_size)); + if (*get_name_args->attr_name_len >= get_name_args->buf_size) + get_name_args->buf[get_name_args->buf_size - 1] = '\0'; } /* end if */ /* Release resources */ @@ -303,52 +328,51 @@ H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED /* H5Aget_info */ case H5VL_ATTR_GET_INFO: { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - H5A_info_t * ainfo = HDva_arg(arguments, H5A_info_t *); - H5A_t * attr = NULL; + H5VL_attr_get_info_args_t *get_info_args = &args->args.get_info; + H5A_t * attr = NULL; - if (H5VL_OBJECT_BY_SELF == loc_params->type) { + if (H5VL_OBJECT_BY_SELF == get_info_args->loc_params.type) { attr = (H5A_t *)obj; - if (H5A__get_info(attr, ainfo) < 0) + if (H5A__get_info(attr, get_info_args->ainfo) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") } - else if (H5VL_OBJECT_BY_NAME == loc_params->type) { - char * attr_name = HDva_arg(arguments, char *); + else if (H5VL_OBJECT_BY_NAME == get_info_args->loc_params.type) { H5G_loc_t loc; /* check arguments */ - if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, get_info_args->loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the attribute on the object header */ if (NULL == - (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + (attr = H5A__open_by_name(&loc, get_info_args->loc_params.loc_data.loc_by_name.name, + get_info_args->attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the attribute information */ - if (H5A__get_info(attr, ainfo) < 0) + if (H5A__get_info(attr, get_info_args->ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") /* Release resources */ if (attr && H5A__close(attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") } - else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + else if (H5VL_OBJECT_BY_IDX == get_info_args->loc_params.type) { H5G_loc_t loc; /* check arguments */ - if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, get_info_args->loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the attribute on the object header */ - if (NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) + if (NULL == (attr = H5A__open_by_idx(&loc, get_info_args->loc_params.loc_data.loc_by_idx.name, + get_info_args->loc_params.loc_data.loc_by_idx.idx_type, + get_info_args->loc_params.loc_data.loc_by_idx.order, + get_info_args->loc_params.loc_data.loc_by_idx.n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the attribute information */ - if (H5A__get_info(attr, ainfo) < 0) + if (H5A__get_info(attr, get_info_args->ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") /* Release resources */ @@ -362,11 +386,10 @@ H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED } case H5VL_ATTR_GET_STORAGE_SIZE: { - hsize_t *ret = HDva_arg(arguments, hsize_t *); - H5A_t * attr = (H5A_t *)obj; + H5A_t *attr = (H5A_t *)obj; - /* Set return value */ - *ret = attr->shared->data_size; + /* Set storage size */ + *args->args.get_storage_size.data_size = attr->shared->data_size; break; } @@ -388,8 +411,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { H5G_loc_t loc; herr_t ret_value = SUCCEED; /* Return value */ @@ -400,48 +423,51 @@ H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch (specific_type) { + switch (args->op_type) { + /* H5Adelete/delete_by_name */ case H5VL_ATTR_DELETE: { - char *attr_name = HDva_arg(arguments, char *); - if (H5VL_OBJECT_BY_SELF == loc_params->type) { - /* H5Adelete */ /* Delete the attribute from the location */ - if (H5O__attr_remove(loc.oloc, attr_name) < 0) + if (H5O__attr_remove(loc.oloc, args->args.del.name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end if */ else if (H5VL_OBJECT_BY_NAME == loc_params->type) { - /* H5Adelete_by_name */ /* Delete the attribute */ - if (H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) + if (H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, args->args.del.name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end else-if */ - else if (H5VL_OBJECT_BY_IDX == loc_params->type) { - /* H5Adelete_by_idx */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute delete location") + break; + } + + /* H5Adelete_by_idx */ + case H5VL_ATTR_DELETE_BY_IDX: { + H5VL_attr_delete_by_idx_args_t *del_by_idx_args = + &args->args.delete_by_idx; /* Arguments to delete_by_idx operation */ + + if (H5VL_OBJECT_BY_NAME == loc_params->type) { /* Delete the attribute from the location */ - if (H5A__delete_by_idx( - &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + if (H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_name.name, del_by_idx_args->idx_type, + del_by_idx_args->order, del_by_idx_args->n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ + } /* end if */ else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute delete_by_idx location") break; } + /* H5Aexists/exists_by_name */ case H5VL_ATTR_EXISTS: { - const char *attr_name = HDva_arg(arguments, const char *); - hbool_t * attr_exists = HDva_arg(arguments, hbool_t *); - - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* Check if the attribute exists */ - if (H5O__attr_exists(loc.oloc, attr_name, attr_exists) < 0) + if (H5O__attr_exists(loc.oloc, args->args.exists.name, args->args.exists.exists) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end if */ - else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* Check if the attribute exists */ - if (H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name, attr_exists) < - 0) + if (H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, args->args.exists.name, + args->args.exists.exists) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") } /* end else-if */ else @@ -449,42 +475,38 @@ H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ break; } + /* H5Aiterate/iterate_by_name */ case H5VL_ATTR_ITER: { - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t * idx = HDva_arg(arguments, hsize_t *); - H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); - void * op_data = HDva_arg(arguments, void *); - - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ - /* Iterate over attributes */ - if ((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - } /* end if */ - else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ - /* Iterate over attributes by name */ - if ((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, - idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); - } /* end else-if */ + H5VL_attr_iterate_args_t *iter_args = &args->args.iterate; /* Arguments to iterate operation */ + static const char * self_name = "."; /* Name for 'self' location */ + const char * loc_name; /* Location name */ + + /* Set correct name, for type of location */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) /* H5Aiterate2 */ + loc_name = self_name; + else if (loc_params->type == H5VL_OBJECT_BY_NAME) /* H5Aiterate_by_name */ + loc_name = loc_params->loc_data.loc_by_name.name; else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unsupported location type") + + /* Iterate over attributes */ + if ((ret_value = H5A__iterate(&loc, loc_name, iter_args->idx_type, iter_args->order, + iter_args->idx, iter_args->op, iter_args->op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); break; } /* H5Arename/rename_by_name */ case H5VL_ATTR_RENAME: { - const char *old_name = HDva_arg(arguments, const char *); - const char *new_name = HDva_arg(arguments, const char *); - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ /* Call attribute rename routine */ - if (H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + if (H5O__attr_rename(loc.oloc, args->args.rename.old_name, args->args.rename.new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ /* Call attribute rename routine */ - if (H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) + if (H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, + args->args.rename.old_name, args->args.rename.new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end else-if */ else @@ -510,24 +532,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, H5VL_attr_optional_t opt_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, - va_list H5_ATTR_DEPRECATED_USED arguments) +H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, H5VL_optional_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - herr_t ret_value = SUCCEED; /* Return value */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + H5VL_native_attr_optional_args_t *opt_args = args->args; /* Pointer to native operation's arguments */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (opt_type) { + switch (args->op_type) { #ifndef H5_NO_DEPRECATED_SYMBOLS case H5VL_NATIVE_ATTR_ITERATE_OLD: { - hid_t loc_id = HDva_arg(arguments, hid_t); - unsigned * attr_num = HDva_arg(arguments, unsigned *); - H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); - void * op_data = HDva_arg(arguments, void *); + H5VL_native_attr_iterate_old_t *iter_args = &opt_args->iterate_old; /* Call the actual iteration routine */ - if ((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) + if ((ret_value = H5A__iterate_old(iter_args->loc_id, iter_args->attr_num, iter_args->op, + iter_args->op_data)) < 0) HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); break; diff --git a/src/H5VLnative_blob.c b/src/H5VLnative_blob.c index 170a5bc..1107227 100644 --- a/src/H5VLnative_blob.c +++ b/src/H5VLnative_blob.c @@ -145,7 +145,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments) +H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t *args) { H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */ herr_t ret_value = SUCCEED; /* Return value */ @@ -156,44 +156,24 @@ H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specif HDassert(f); HDassert(blob_id); - switch (specific_type) { - case H5VL_BLOB_GETSIZE: { - const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ - size_t * size = HDva_arg(arguments, size_t *); - H5HG_t hobjid; /* blob's heap ID */ - - /* Get heap information */ - H5F_addr_decode(f, &id, &(hobjid.addr)); - UINT32DECODE(id, hobjid.idx); - - /* Get heap object's size */ - if (hobjid.addr > 0) { - if (H5HG_get_obj_size(f, &hobjid, size) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") - } /* end if */ - else - *size = 0; /* Return '0' size for 'nil' blob ID */ - - break; - } - + switch (args->op_type) { case H5VL_BLOB_ISNULL: { - const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ - hbool_t * isnull = HDva_arg(arguments, hbool_t *); - haddr_t addr; /* Sequence's heap address */ + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + haddr_t addr; /* Sequence's heap address */ /* Get the heap address */ H5F_addr_decode(f, &id, &addr); /* Check if heap address is 'nil' */ - *isnull = (addr == 0 ? TRUE : FALSE); + *args->args.is_null.isnull = (addr == 0 ? TRUE : FALSE); break; } case H5VL_BLOB_SETNULL: { uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */ - /* Encode the "nil" heap pointer information */ + + /* Encode the 'nil' heap pointer information */ H5F_addr_encode(f, &id, (haddr_t)0); UINT32ENCODE(id, 0); diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 21491e7..1375344 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -15,8 +15,15 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5D_FRIEND /* Suppress error about including H5Dpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ @@ -30,6 +37,128 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Helper routines for read/write API calls */ +static herr_t H5VL__native_dataset_io_setup(H5D_t *dset, hid_t dxpl_id, hid_t file_space_id, + hid_t mem_space_id, H5S_t **file_space, H5S_t **mem_space); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_io_setup + * + * Purpose: Set up file and memory dataspaces for dataset I/O operation + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__native_dataset_io_setup(H5D_t *dset, hid_t dxpl_id, hid_t file_space_id, hid_t mem_space_id, + H5S_t **file_space, H5S_t **mem_space) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(dset); + HDassert(file_space && NULL == *file_space); + HDassert(mem_space && NULL == *mem_space); + + /* Set up file dataspace */ + if (H5S_ALL == file_space_id) + /* Use dataspace for dataset */ + *file_space = dset->shared->space; + else if (H5S_BLOCK == file_space_id) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "H5S_BLOCK is not allowed for file dataspace") + else if (H5S_PLIST == file_space_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5S_t * space; /* Dataspace to hold selection */ + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_DATASET, H5E_BADID, FAIL, "bad dataset transfer property list") + + /* See if a dataset I/O selection is already set, and free it if it is */ + if (H5P_peek(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting dataset I/O selection") + + /* Use dataspace for dataset */ + *file_space = dset->shared->space; + + /* Copy, but share, selection from property list to dataset's dataspace */ + if (H5S_SELECT_COPY(*file_space, space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataset I/O selection") + } /* end else-if */ + else { + /* Get the dataspace pointer */ + if (NULL == (*file_space = (H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "file_space_id is not a dataspace ID") + } /* end else */ + + /* Get dataspace for memory buffer */ + if (H5S_ALL == mem_space_id) + *mem_space = *file_space; + else if (H5S_BLOCK == mem_space_id) { + hsize_t nelmts; /* # of selected elements in file */ + + /* Get the # of elements selected */ + nelmts = H5S_GET_SELECT_NPOINTS(*file_space); + + /* Check for any elements */ + if (nelmts > 0) { + /* Create a 1-D dataspace of the same # of elements */ + if (NULL == (*mem_space = H5S_create_simple(1, &nelmts, NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create simple memory dataspace") + } /* end if */ + else { + /* Create a NULL dataspace of the same # of elements */ + if (NULL == (*mem_space = H5S_create(H5S_NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create NULL memory dataspace") + } /* end else */ + } /* end if */ + else if (H5S_PLIST == mem_space_id) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "H5S_PLIST is not allowed for memory dataspace") + else { + /* Get the dataspace pointer */ + if (NULL == (*mem_space = (H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "mem_space_id is not a dataspace ID") + } /* end else */ + + /* Check for valid selections */ + if (H5S_SELECT_VALID(*file_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "selection + offset not within extent for file dataspace") + if (H5S_SELECT_VALID(*mem_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "selection + offset not within extent for memory dataspace") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_io_setup() */ + /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_create * @@ -141,10 +270,10 @@ herr_t H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf, void H5_ATTR_UNUSED **req) { - H5D_t * dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; + H5S_t *mem_space = NULL; + H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -152,11 +281,10 @@ H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_ if (NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + /* Get file & memory dataspaces */ + if (H5VL__native_dataset_io_setup(dset, dxpl_id, file_space_id, mem_space_id, &file_space, &mem_space) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up file and memory dataspaces") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -166,6 +294,17 @@ H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: + /* Clean up */ + if (H5S_BLOCK == mem_space_id && mem_space) { + if (H5S_close(mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release temporary memory dataspace for H5S_BLOCK") + } /* end if */ + else if (H5S_PLIST == file_space_id && file_space) + if (H5S_select_all(file_space, TRUE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release file dataspace selection for H5S_PLIST") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_read() */ @@ -182,10 +321,10 @@ herr_t H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, void H5_ATTR_UNUSED **req) { - H5D_t * dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; + H5S_t *mem_space = NULL; + H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -193,11 +332,10 @@ H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid if (NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + /* Get file & memory dataspaces */ + if (H5VL__native_dataset_io_setup(dset, dxpl_id, file_space_id, mem_space_id, &file_space, &mem_space) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up file and memory dataspaces") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -207,6 +345,17 @@ H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: + /* Clean up */ + if (H5S_BLOCK == mem_space_id && mem_space) { + if (H5S_close(mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release temporary memory dataspace for H5S_BLOCK") + } /* end if */ + else if (H5S_PLIST == file_space_id && file_space) + if (H5S_select_all(file_space, TRUE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release file dataspace selection for H5S_PLIST") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_write() */ @@ -220,31 +369,26 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_dataset_get(void *obj, H5VL_dataset_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5D_t *dset = (H5D_t *)obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (get_type) { + switch (args->op_type) { /* H5Dget_space */ case H5VL_DATASET_GET_SPACE: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if ((*ret_id = H5D__get_space(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + if ((args->args.get_space.space_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get space ID of dataset") break; } /* H5Dget_space_status */ case H5VL_DATASET_GET_SPACE_STATUS: { - H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); - - /* Read data space address and return */ - if (H5D__get_space_status(dset, allocation) < 0) + if (H5D__get_space_status(dset, args->args.get_space_status.status) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") break; @@ -252,40 +396,31 @@ H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_U /* H5Dget_type */ case H5VL_DATASET_GET_TYPE: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if ((*ret_id = H5D__get_type(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + if ((args->args.get_type.type_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") break; } /* H5Dget_create_plist */ case H5VL_DATASET_GET_DCPL: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if ((*ret_id = H5D_get_create_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + if ((args->args.get_dcpl.dcpl_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get creation property list for dataset") break; } /* H5Dget_access_plist */ case H5VL_DATASET_GET_DAPL: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if ((*ret_id = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + if ((args->args.get_dapl.dapl_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get access property list for dataset") break; } /* H5Dget_storage_size */ case H5VL_DATASET_GET_STORAGE_SIZE: { - hsize_t *ret = HDva_arg(arguments, hsize_t *); - - /* Set return value */ - if (H5D__get_storage_size(dset, ret) < 0) + if (H5D__get_storage_size(dset, args->args.get_storage_size.storage_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") break; } @@ -308,69 +443,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5D_t *dset = (H5D_t *)obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (specific_type) { - /* H5Dspecific_space */ - case H5VL_DATASET_SET_EXTENT: { /* H5Dset_extent (H5Dextend - deprecated) */ - const hsize_t *size = HDva_arg(arguments, const hsize_t *); - - if (H5D__set_extent(dset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + switch (args->op_type) { + /* H5Dset_extent (H5Dextend - deprecated) */ + case H5VL_DATASET_SET_EXTENT: { + if (H5D__set_extent(dset, args->args.set_extent.size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set extent of dataset") break; } - case H5VL_DATASET_FLUSH: { /* H5Dflush */ - hid_t dset_id = HDva_arg(arguments, hid_t); - - /* Flush the dataset */ - if (H5D__flush(dset, dset_id) < 0) + /* H5Dflush */ + case H5VL_DATASET_FLUSH: { + if (H5D__flush(dset, args->args.flush.dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") break; } - case H5VL_DATASET_REFRESH: { /* H5Drefresh */ - hid_t dset_id = HDva_arg(arguments, hid_t); - - /* Refresh the dataset */ - if ((H5D__refresh(dset_id, dset)) < 0) + /* H5Drefresh */ + case H5VL_DATASET_REFRESH: { + if (H5D__refresh(dset, args->args.refresh.dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") break; } - case H5VL_DATASET_WAIT: { /* H5Dwait */ - /* The native VOL connector doesn't support asynchronous - * operations, so this is a no-op. - */ - break; - } - - case H5VL_DATASET_CHUNK_ITER: { /* H5Dchunk_iter */ - H5D_chunk_iter_op_t cb = HDva_arg(arguments, H5D_chunk_iter_op_t); - void * op_data = HDva_arg(arguments, void *); - - HDassert(dset->shared); - - /* Make sure the dataset is chunked */ - if (H5D_CHUNKED != dset->shared->layout.type) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - } - - /* Call private function */ - if (H5D__chunk_iter(dset, cb, op_data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't iterate over chunks") - - break; - } - default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") } /* end switch */ @@ -389,11 +493,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hid_t dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_dataset_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void H5_ATTR_UNUSED **req) { - H5D_t *dset = (H5D_t *)obj; /* Dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t * dset = (H5D_t *)obj; /* Dataset */ + H5VL_native_dataset_optional_args_t *opt_args = args->args; /* Pointer to native operation's arguments */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -403,13 +507,14 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - switch (optional_type) { - case H5VL_NATIVE_DATASET_FORMAT_CONVERT: { /* H5Dformat_convert */ + switch (args->op_type) { + /* H5Dformat_convert */ + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: { switch (dset->shared->layout.type) { case H5D_CHUNKED: /* Convert the chunk indexing type to version 1 B-tree if not */ if (dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if ((H5D__format_convert(dset)) < 0) + if (H5D__format_convert(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") break; @@ -418,7 +523,7 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, case H5D_COMPACT: /* Downgrade the layout version to 3 if greater than 3 */ if (dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if ((H5D__format_convert(dset)) < 0) + if (H5D__format_convert(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") break; @@ -438,47 +543,46 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, break; } - case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: { /* H5Dget_chunk_index_type */ - H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); - + /* H5Dget_chunk_index_type */ + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: { /* Make sure the dataset is chunked */ if (H5D_CHUNKED != dset->shared->layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") /* Get the chunk indexing type */ - *idx_type = dset->shared->layout.u.chunk.idx_type; + *opt_args->get_chunk_idx_type.idx_type = dset->shared->layout.u.chunk.idx_type; break; } - case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: { /* H5Dget_chunk_storage_size */ - hsize_t *offset = HDva_arg(arguments, hsize_t *); - hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); + /* H5Dget_chunk_storage_size */ + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: { + H5VL_native_dataset_get_chunk_storage_size_t *gcss_args = &opt_args->get_chunk_storage_size; /* Make sure the dataset is chunked */ if (H5D_CHUNKED != dset->shared->layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") /* Call private function */ - if (H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + if (H5D__get_chunk_storage_size(dset, gcss_args->offset, gcss_args->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") break; } - case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: { /* H5Dget_num_chunks */ - const H5S_t *space = NULL; - hid_t space_id = HDva_arg(arguments, hid_t); - hsize_t * nchunks = HDva_arg(arguments, hsize_t *); + /* H5Dget_num_chunks */ + case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: { + H5VL_native_dataset_get_num_chunks_t *gnc_args = &opt_args->get_num_chunks; + const H5S_t * space = NULL; HDassert(dset->shared); HDassert(dset->shared->space); /* When default dataspace is given, use the dataset's dataspace */ - if (space_id == H5S_ALL) + if (gnc_args->space_id == H5S_ALL) space = dset->shared->space; else /* otherwise, use the given space ID */ - if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (const H5S_t *)H5I_object_verify(gnc_args->space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") /* Make sure the dataset is chunked */ @@ -486,29 +590,25 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") /* Call private function */ - if (H5D__get_num_chunks(dset, space, nchunks) < 0) + if (H5D__get_num_chunks(dset, space, gnc_args->nchunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") break; } - case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: { /* H5Dget_chunk_info */ - const H5S_t *space = NULL; - hid_t space_id = HDva_arg(arguments, hid_t); - hsize_t chk_index = HDva_arg(arguments, hsize_t); - hsize_t * offset = HDva_arg(arguments, hsize_t *); - unsigned * filter_mask = HDva_arg(arguments, unsigned *); - haddr_t * addr = HDva_arg(arguments, haddr_t *); - hsize_t * size = HDva_arg(arguments, hsize_t *); + /* H5Dget_chunk_info */ + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: { + H5VL_native_dataset_get_chunk_info_by_idx_t *gcibi_args = &opt_args->get_chunk_info_by_idx; + const H5S_t * space; HDassert(dset->shared); HDassert(dset->shared->space); /* When default dataspace is given, use the dataset's dataspace */ - if (space_id == H5S_ALL) + if (gcibi_args->space_id == H5S_ALL) space = dset->shared->space; else /* otherwise, use the given space ID */ - if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (const H5S_t *)H5I_object_verify(gcibi_args->space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") /* Make sure the dataset is chunked */ @@ -516,16 +616,16 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") /* Call private function */ - if (H5D__get_chunk_info(dset, space, chk_index, offset, filter_mask, addr, size) < 0) + if (H5D__get_chunk_info(dset, space, gcibi_args->chk_index, gcibi_args->offset, + gcibi_args->filter_mask, gcibi_args->addr, gcibi_args->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index") + break; } - case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: { /* H5Dget_chunk_info_by_coord */ - hsize_t * offset = HDva_arg(arguments, hsize_t *); - unsigned *filter_mask = HDva_arg(arguments, unsigned *); - haddr_t * addr = HDva_arg(arguments, haddr_t *); - hsize_t * size = HDva_arg(arguments, hsize_t *); + /* H5Dget_chunk_info_by_coord */ + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: { + H5VL_native_dataset_get_chunk_info_by_coord_t *gcibc_args = &opt_args->get_chunk_info_by_coord; HDassert(dset->shared); @@ -534,17 +634,17 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") /* Call private function */ - if (H5D__get_chunk_info_by_coord(dset, offset, filter_mask, addr, size) < 0) + if (H5D__get_chunk_info_by_coord(dset, gcibc_args->offset, gcibc_args->filter_mask, + gcibc_args->addr, gcibc_args->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by its logical coordinates") break; } - case H5VL_NATIVE_DATASET_CHUNK_READ: { /* H5Dread_chunk */ - const hsize_t *offset = HDva_arg(arguments, hsize_t *); - uint32_t * filters = HDva_arg(arguments, uint32_t *); - void * buf = HDva_arg(arguments, void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + /* H5Dread_chunk */ + case H5VL_NATIVE_DATASET_CHUNK_READ: { + H5VL_native_dataset_chunk_read_t *chunk_read_args = &opt_args->chunk_read; + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ /* Check arguments */ if (NULL == dset->oloc.file) @@ -555,22 +655,21 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, /* Copy the user's offset array so we can be sure it's terminated properly. * (we don't want to mess with the user's buffer). */ - if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + if (H5D__chunk_get_offset_copy(dset, chunk_read_args->offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "failure to copy offset array") /* Read the raw chunk */ - if (H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + if (H5D__chunk_direct_read(dset, offset_copy, &chunk_read_args->filters, chunk_read_args->buf) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") break; } - case H5VL_NATIVE_DATASET_CHUNK_WRITE: { /* H5Dwrite_chunk */ - uint32_t filters = HDva_arg(arguments, uint32_t); - const hsize_t *offset = HDva_arg(arguments, const hsize_t *); - uint32_t data_size_32 = HDva_arg(arguments, uint32_t); - const void * buf = HDva_arg(arguments, const void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + /* H5Dwrite_chunk */ + case H5VL_NATIVE_DATASET_CHUNK_WRITE: { + H5VL_native_dataset_chunk_write_t *chunk_write_args = &opt_args->chunk_write; + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ /* Check arguments */ if (NULL == dset->oloc.file) @@ -581,34 +680,48 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, /* Copy the user's offset array so we can be sure it's terminated properly. * (we don't want to mess with the user's buffer). */ - if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + if (H5D__chunk_get_offset_copy(dset, chunk_write_args->offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "failure to copy offset array") /* Write chunk */ - if (H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + if (H5D__chunk_direct_write(dset, chunk_write_args->filters, offset_copy, chunk_write_args->size, + chunk_write_args->buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") break; } - case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: { /* H5Dvlen_get_buf_size */ - hid_t type_id = HDva_arg(arguments, hid_t); - hid_t space_id = HDva_arg(arguments, hid_t); - hsize_t *size = HDva_arg(arguments, hsize_t *); + /* H5Dvlen_get_buf_size */ + case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: { + H5VL_native_dataset_get_vlen_buf_size_t *gvbs_args = &opt_args->get_vlen_buf_size; - if (H5D__vlen_get_buf_size(dset, type_id, space_id, size) < 0) + if (H5D__vlen_get_buf_size(dset, gvbs_args->type_id, gvbs_args->space_id, gvbs_args->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of vlen buf needed") break; } /* H5Dget_offset */ case H5VL_NATIVE_DATASET_GET_OFFSET: { - haddr_t *ret = HDva_arg(arguments, haddr_t *); + /* Get offset */ + *opt_args->get_offset.offset = H5D__get_offset(dset); + + break; + } + + /* H5Dchunk_iter */ + case H5VL_NATIVE_DATASET_CHUNK_ITER: { + /* Sanity check */ + HDassert(dset->shared); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if ((ret_value = H5D__chunk_iter(dset, opt_args->chunk_iter.op, opt_args->chunk_iter.op_data)) < + 0) + HERROR(H5E_DATASET, H5E_BADITER, "chunk iteration failed"); - /* Set return value */ - *ret = H5D__get_offset(dset); - if (!H5F_addr_defined(*ret)) - *ret = HADDR_UNDEF; break; } diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c index 9551f50..bf6f37c 100644 --- a/src/H5VLnative_datatype.c +++ b/src/H5VLnative_datatype.c @@ -15,8 +15,15 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5T_FRIEND /* Suppress error about including H5Tpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ @@ -28,6 +35,30 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- * Function: H5VL__native_datatype_commit * @@ -144,32 +175,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_datatype_get(void *obj, H5VL_datatype_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5T_t *dt = (H5T_t *)obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (get_type) { - case H5VL_DATATYPE_GET_BINARY: { - ssize_t *nalloc = HDva_arg(arguments, ssize_t *); - void * buf = HDva_arg(arguments, void *); - size_t size = HDva_arg(arguments, size_t); + switch (args->op_type) { + /* H5T_construct_datatype (library private routine) */ + case H5VL_DATATYPE_GET_BINARY_SIZE: { + if (H5T_encode(dt, NULL, args->args.get_binary_size.size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't determine serialized length of datatype") - if (H5T_encode(dt, (unsigned char *)buf, &size) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + break; + } + + /* H5T_construct_datatype (library private routine) */ + case H5VL_DATATYPE_GET_BINARY: { + if (H5T_encode(dt, args->args.get_binary.buf, &args->args.get_binary.buf_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSERIALIZE, FAIL, "can't serialize datatype") - *nalloc = (ssize_t)size; break; } /* H5Tget_create_plist */ case H5VL_DATATYPE_GET_TCPL: { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if (H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + if (H5I_INVALID_HID == (args->args.get_tcpl.tcpl_id = H5T__get_create_plist(dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); break; @@ -193,30 +226,26 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5T_t *dt = (H5T_t *)obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (specific_type) { + switch (args->op_type) { + /* H5VL_DATATYPE_FLUSH */ case H5VL_DATATYPE_FLUSH: { - hid_t type_id = HDva_arg(arguments, hid_t); - - /* To flush metadata and invoke flush callback if there is */ - if (H5O_flush_common(&dt->oloc, type_id) < 0) + if (H5O_flush_common(&dt->oloc, args->args.flush.type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") break; } + /* H5VL_DATATYPE_REFRESH */ case H5VL_DATATYPE_REFRESH: { - hid_t type_id = HDva_arg(arguments, hid_t); - - /* Call private function to refresh datatype object */ - if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + if ((H5O_refresh_metadata(&dt->oloc, args->args.refresh.type_id)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") break; diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index fd86414..1e674dc 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -15,8 +15,15 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5F_FRIEND /* Suppress error about including H5Fpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Cprivate.h" /* Cache */ @@ -31,6 +38,30 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- * Function: H5VL__native_file_create * @@ -116,21 +147,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_file_get(void *obj, H5VL_file_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5F_t *f = NULL; /* File struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (get_type) { + switch (args->op_type) { /* "get container info" */ case H5VL_FILE_GET_CONT_INFO: { - H5VL_file_cont_info_t *info = HDva_arg(arguments, H5VL_file_cont_info_t *); - - /* Retrieve the file's container info */ - if (H5F__get_cont_info((H5F_t *)obj, info) < 0) + if (H5F__get_cont_info((H5F_t *)obj, args->args.get_cont_info.info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file container info") break; @@ -138,31 +166,22 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED /* H5Fget_access_plist */ case H5VL_FILE_GET_FAPL: { - H5P_genplist_t *new_plist; /* New property list */ - hid_t * plist_id = HDva_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - - /* Retrieve the file's access property list */ - if ((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + if ((args->args.get_fapl.fapl_id = H5F_get_access_plist((H5F_t *)obj, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file access property list") - if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") break; } /* H5Fget_create_plist */ case H5VL_FILE_GET_FCPL: { H5P_genplist_t *plist; /* Property list */ - hid_t * plist_id = HDva_arg(arguments, hid_t *); f = (H5F_t *)obj; if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Create the property list object to return */ - if ((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + if ((args->args.get_fcpl.fcpl_id = H5P_copy_plist(plist, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") break; @@ -170,8 +189,6 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED /* H5Fget_intent */ case H5VL_FILE_GET_INTENT: { - unsigned *intent_flags = HDva_arg(arguments, unsigned *); - f = (H5F_t *)obj; /* HDF5 uses some flags internally that users don't know about. @@ -179,18 +196,18 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED * or H5F_ACC_RDONLY and any SWMR flags. */ if (H5F_INTENT(f) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; + *args->args.get_intent.flags = H5F_ACC_RDWR; /* Check for SWMR write access on the file */ if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; + *args->args.get_intent.flags |= H5F_ACC_SWMR_WRITE; } /* end if */ else { - *intent_flags = H5F_ACC_RDONLY; + *args->args.get_intent.flags = H5F_ACC_RDONLY; /* Check for SWMR read access on the file */ if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; + *args->args.get_intent.flags |= H5F_ACC_SWMR_READ; } /* end else */ break; @@ -198,71 +215,52 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED /* H5Fget_fileno */ case H5VL_FILE_GET_FILENO: { - unsigned long *fno = HDva_arg(arguments, unsigned long *); - unsigned long my_fileno = 0; + unsigned long fileno = 0; - f = (H5F_t *)obj; - H5F_GET_FILENO(f, my_fileno); - *fno = my_fileno; /* sigh */ + H5F_GET_FILENO((H5F_t *)obj, fileno); + *args->args.get_fileno.fileno = fileno; break; } /* H5Fget_name */ case H5VL_FILE_GET_NAME: { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - size_t size = HDva_arg(arguments, size_t); - char * name = HDva_arg(arguments, char *); - ssize_t * ret = HDva_arg(arguments, ssize_t *); - size_t len; + H5VL_file_get_name_args_t *file_args = &args->args.get_name; - if (H5VL_native_get_file_struct(obj, type, &f) < 0) + if (H5VL_native_get_file_struct(obj, file_args->type, &f) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - len = HDstrlen(H5F_OPEN_NAME(f)); + /* Get length of file name */ + *file_args->file_name_len = HDstrlen(H5F_OPEN_NAME(f)); - if (name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1, size)); - if (len >= size) - name[size - 1] = '\0'; + /* Populate buffer with name, if given */ + if (file_args->buf) { + HDstrncpy(file_args->buf, H5F_OPEN_NAME(f), + MIN(*file_args->file_name_len + 1, file_args->buf_size)); + if (*file_args->file_name_len >= file_args->buf_size) + file_args->buf[file_args->buf_size - 1] = '\0'; } /* end if */ - /* Set the return value for the API call */ - *ret = (ssize_t)len; break; } /* H5Fget_obj_count */ case H5VL_FILE_GET_OBJ_COUNT: { - unsigned types = HDva_arg(arguments, unsigned); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if (H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + if (H5F_get_obj_count((H5F_t *)obj, args->args.get_obj_count.types, TRUE, + args->args.get_obj_count.count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve object count") - /* Set the return value */ - *ret = (ssize_t)obj_count; break; } /* H5Fget_obj_ids */ case H5VL_FILE_GET_OBJ_IDS: { - unsigned types = HDva_arg(arguments, unsigned); - size_t max_objs = HDva_arg(arguments, size_t); - hid_t * oid_list = HDva_arg(arguments, hid_t *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ + H5VL_file_get_obj_ids_args_t *file_args = &args->args.get_obj_ids; - f = (H5F_t *)obj; - /* Perform the query */ - if (H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + if (H5F_get_obj_ids((H5F_t *)obj, file_args->types, file_args->max_objs, file_args->oid_list, + TRUE, file_args->count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve object IDs") - /* Set the return value */ - *ret = (ssize_t)obj_count; break; } @@ -284,22 +282,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_file_specific(void *obj, H5VL_file_specific_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (specific_type) { + switch (args->op_type) { /* H5Fflush */ case H5VL_FILE_FLUSH: { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_t * f = NULL; /* File to flush */ + H5F_t *f = NULL; /* File to flush */ /* Get the file for the object */ - if (H5VL_native_get_file_struct(obj, type, &f) < 0) + if (H5VL_native_get_file_struct(obj, args->args.flush.obj_type, &f) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Nothing to do if the file is read only. This determination is @@ -310,7 +306,7 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t */ if (H5F_ACC_RDWR & H5F_INTENT(f)) { /* Flush other files, depending on scope */ - if (H5F_SCOPE_GLOBAL == scope) { + if (H5F_SCOPE_GLOBAL == args->args.flush.scope) { /* Call the flush routine for mounted file hierarchies */ if (H5F_flush_mounts(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") @@ -322,98 +318,55 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t "unable to flush file's cached information") } /* end else */ } /* end if */ + break; } /* H5Freopen */ case H5VL_FILE_REOPEN: { - void **ret = HDva_arg(arguments, void **); - H5F_t *new_file = NULL; + H5F_t *new_file; /* Reopen the file through the VOL connector */ if (NULL == (new_file = H5F__reopen((H5F_t *)obj))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") new_file->id_exists = TRUE; - *ret = (void *)new_file; - break; - } - - /* H5Fmount */ - case H5VL_FILE_MOUNT: { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - const char *name = HDva_arg(arguments, const char *); - H5F_t * child = HDva_arg(arguments, H5F_t *); - hid_t fmpl_id = HDva_arg(arguments, hid_t); - H5G_loc_t loc; - - if (H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Do the mount */ - if (H5F__mount(&loc, name, child, fmpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") - - break; - } - - /* H5Funmount */ - case H5VL_FILE_UNMOUNT: { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - const char *name = HDva_arg(arguments, const char *); - H5G_loc_t loc; - - if (H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unmount */ - if (H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + /* Set 'out' value */ + *args->args.reopen.file = new_file; break; } /* H5Fis_accessible */ case H5VL_FILE_IS_ACCESSIBLE: { - hid_t fapl_id = HDva_arg(arguments, hid_t); - const char *name = HDva_arg(arguments, const char *); - htri_t * result = HDva_arg(arguments, htri_t *); + htri_t result; + + if ((result = H5F__is_hdf5(args->args.is_accessible.filename, args->args.is_accessible.fapl_id)) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "error in HDF5 file check") + + /* Set 'out' value */ + *args->args.is_accessible.accessible = (hbool_t)result; - /* Call private routine */ - if ((*result = H5F__is_hdf5(name, fapl_id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "error in HDF5 file check") break; } /* H5Fdelete */ case H5VL_FILE_DELETE: { - hid_t fapl_id = HDva_arg(arguments, hid_t); - const char *name = HDva_arg(arguments, const char *); - herr_t * ret = HDva_arg(arguments, herr_t *); + if (H5F__delete(args->args.del.filename, args->args.del.fapl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "error in HDF5 file deletion") - /* Call private routine */ - if ((*ret = H5F_delete(name, fapl_id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "error in HDF5 file check") break; } /* Check if two files are the same */ case H5VL_FILE_IS_EQUAL: { - H5F_t * file2 = (H5F_t *)HDva_arg(arguments, void *); - hbool_t *is_equal = HDva_arg(arguments, hbool_t *); - - if (!obj || !file2) - *is_equal = FALSE; + if (!obj || !args->args.is_equal.obj2) + *args->args.is_equal.same_file = FALSE; else - *is_equal = (((H5F_t *)obj)->shared == file2->shared); - break; - } + *args->args.is_equal.same_file = + (((H5F_t *)obj)->shared == ((H5F_t *)args->args.is_equal.obj2)->shared); - /* H5Fwait */ - case H5VL_FILE_WAIT: { - /* The native VOL connector doesn't support asynchronous - * operations, so this is a no-op. - */ break; } @@ -435,85 +388,78 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_file_optional(void *obj, H5VL_optional_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5F_t *f = NULL; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f = (H5F_t *)obj; /* File */ + H5VL_native_file_optional_args_t *opt_args = args->args; /* Pointer to native operation's arguments */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - f = (H5F_t *)obj; - switch (optional_type) { + switch (args->op_type) { /* H5Fget_filesize */ case H5VL_NATIVE_FILE_GET_SIZE: { - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ - hsize_t *size = HDva_arg(arguments, hsize_t *); + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ - /* Go get the actual file size */ + /* Get the actual file size & base address */ if (H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - base_addr = H5FD_get_base_addr(f->shared->lf); - if (size) - *size = (hsize_t)(max_eof_eoa + - base_addr); /* Convert relative base address for file to absolute address */ + /* Convert relative base address for file to absolute address */ + *opt_args->get_size.size = (hsize_t)(max_eof_eoa + base_addr); break; } /* H5Fget_file_image */ case H5VL_NATIVE_FILE_GET_FILE_IMAGE: { - void * buf_ptr = HDva_arg(arguments, void *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t buf_len = HDva_arg(arguments, size_t); + H5VL_native_file_get_file_image_t *gfi_args = &opt_args->get_file_image; - /* Do the actual work */ - if ((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + /* Get file image */ + if (H5F__get_file_image(f, gfi_args->buf, gfi_args->buf_size, gfi_args->image_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; } /* H5Fget_freespace */ case H5VL_NATIVE_FILE_GET_FREE_SPACE: { - hsize_t tot_space; /* Amount of free space in the file */ - hssize_t *ret = HDva_arg(arguments, hssize_t *); + H5VL_native_file_get_freespace_t *gfs_args = &opt_args->get_freespace; - /* Go get the actual amount of free space in the file */ - if (H5MF_get_freespace(f, &tot_space, NULL) < 0) + /* Get the actual amount of free space in the file */ + if (H5MF_get_freespace(f, gfs_args->size, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - *ret = (hssize_t)tot_space; + break; } /* H5Fget_free_sections */ case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: { - H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); - ssize_t * ret = HDva_arg(arguments, ssize_t *); - H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ - size_t nsects = HDva_arg(arguments, size_t); + H5VL_native_file_get_free_sections_t *gfs_args = &opt_args->get_free_sections; /* Go get the free-space section information in the file */ - if ((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + if (H5MF_get_free_sections(f, gfs_args->type, gfs_args->nsects, gfs_args->sect_info, + gfs_args->sect_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; } /* H5Fget_info1/2 */ case H5VL_NATIVE_FILE_GET_INFO: { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); + H5VL_native_file_get_info_t *gfi_args = &opt_args->get_info; /* Get the file struct. This call is careful to not return the file pointer * for the top file in a mount hierarchy. */ - if (H5VL_native_get_file_struct(obj, type, &f) < 0) + if (H5VL_native_get_file_struct(obj, gfi_args->type, &f) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") /* Get the file info */ - if (H5F__get_info(f, finfo) < 0) + if (H5F__get_info(f, gfi_args->finfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") break; @@ -521,50 +467,42 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fget_mdc_config */ case H5VL_NATIVE_FILE_GET_MDC_CONF: { - H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + /* Get the metadata cache configuration */ + if (H5AC_get_cache_auto_resize_config(f->shared->cache, opt_args->get_mdc_config.config) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get metadata cache configuration") - /* Go get the resize configuration */ - if (H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") break; } /* H5Fget_mdc_hit_rate */ case H5VL_NATIVE_FILE_GET_MDC_HR: { - double *hit_rate_ptr = HDva_arg(arguments, double *); + /* Get the current hit rate */ + if (H5AC_get_cache_hit_rate(f->shared->cache, opt_args->get_mdc_hit_rate.hit_rate) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get metadata cache hit rate") - /* Go get the current hit rate */ - if (H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") break; } /* H5Fget_mdc_size */ case H5VL_NATIVE_FILE_GET_MDC_SIZE: { - size_t * max_size_ptr = HDva_arg(arguments, size_t *); - size_t * min_clean_size_ptr = HDva_arg(arguments, size_t *); - size_t * cur_size_ptr = HDva_arg(arguments, size_t *); - int * cur_num_entries_ptr = HDva_arg(arguments, int *); - uint32_t cur_num_entries; + H5VL_native_file_get_mdc_size_t *gms_args = &opt_args->get_mdc_size; - /* Go get the size data */ - if (H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, cur_size_ptr, - &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + /* Get the size data */ + if (H5AC_get_cache_size(f->shared->cache, gms_args->max_size, gms_args->min_clean_size, + gms_args->cur_size, gms_args->cur_num_entries) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get metadata cache size") - if (cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; break; } /* H5Fget_vfd_handle */ case H5VL_NATIVE_FILE_GET_VFD_HANDLE: { - void **file_handle = HDva_arg(arguments, void **); - hid_t fapl_id = HDva_arg(arguments, hid_t); + H5VL_native_file_get_vfd_handle_t *gvh_args = &opt_args->get_vfd_handle; /* Retrieve the VFD handle for the file */ - if (H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + if (H5F_get_vfd_handle(f, gvh_args->fapl_id, gvh_args->file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; } @@ -574,6 +512,7 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t if (f->shared->efc) if (H5F__efc_release(f->shared->efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; } @@ -581,26 +520,24 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: { /* Reset the hit rate statistic */ if (H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") + break; } /* H5Fset_mdc_config */ case H5VL_NATIVE_FILE_SET_MDC_CONFIG: { - H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + /* Set the metadata cache configuration */ + if (H5AC_set_cache_auto_resize_config(f->shared->cache, opt_args->set_mdc_config.config) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set metadata cache configuration") - /* set the resize configuration */ - if (H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") break; } /* H5Fget_metadata_read_retry_info */ case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: { - H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); - - if (H5F_get_metadata_read_retry_info(f, info) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + if (H5F_get_metadata_read_retry_info(f, opt_args->get_metadata_read_retry_info.info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get metadata read retry info") break; } @@ -608,7 +545,7 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fstart_swmr_write */ case H5VL_NATIVE_FILE_START_SWMR_WRITE: { if (H5F__start_swmr_write(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't start SWMR write") break; } @@ -633,11 +570,11 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fget_mdc_logging_status */ case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: { - hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); - hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); + H5VL_native_file_get_mdc_logging_status_t *gmls_args = &opt_args->get_mdc_logging_status; /* Call mdc logging function */ - if (H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + if (H5C_get_logging_status(f->shared->cache, gmls_args->is_enabled, + gmls_args->is_currently_logging) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") break; @@ -667,18 +604,15 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fget_page_buffering_stats */ case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: { - unsigned *accesses = HDva_arg(arguments, unsigned *); - unsigned *hits = HDva_arg(arguments, unsigned *); - unsigned *misses = HDva_arg(arguments, unsigned *); - unsigned *evictions = HDva_arg(arguments, unsigned *); - unsigned *bypasses = HDva_arg(arguments, unsigned *); + H5VL_native_file_get_page_buffering_stats_t *gpbs_args = &opt_args->get_page_buffering_stats; /* Sanity check */ if (NULL == f->shared->page_buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") /* Get the statistics */ - if (H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + if (H5PB_get_stats(f->shared->page_buf, gpbs_args->accesses, gpbs_args->hits, gpbs_args->misses, + gpbs_args->evictions, gpbs_args->bypasses) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") break; @@ -686,11 +620,10 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fget_mdc_image_info */ case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: { - haddr_t *image_addr = HDva_arg(arguments, haddr_t *); - hsize_t *image_len = HDva_arg(arguments, hsize_t *); + H5VL_native_file_get_mdc_image_info_t *gmii_args = &opt_args->get_mdc_image_info; /* Go get the address and size of the cache image */ - if (H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) + if (H5AC_get_mdc_image_info(f->shared->cache, gmii_args->addr, gmii_args->len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") break; @@ -698,11 +631,7 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fget_eoa */ case H5VL_NATIVE_FILE_GET_EOA: { - haddr_t *eoa = HDva_arg(arguments, haddr_t *); - haddr_t rel_eoa; /* Relative address of EOA */ - - /* Sanity check */ - HDassert(eoa); + haddr_t rel_eoa; /* Relative address of EOA */ /* This routine will work only for drivers with this feature enabled.*/ /* We might introduce a new feature flag in the future */ @@ -716,14 +645,13 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* Set return value */ /* (Note compensating for base address subtraction in internal routine) */ - *eoa = rel_eoa + H5F_get_base_addr(f); + *opt_args->get_eoa.eoa = rel_eoa + H5F_get_base_addr(f); break; } /* H5Fincrement_filesize */ case H5VL_NATIVE_FILE_INCR_FILESIZE: { - hsize_t increment = HDva_arg(arguments, hsize_t); haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ /* This public routine will work only for drivers with this feature enabled.*/ @@ -737,7 +665,7 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") /* Set EOA to the maximum value + increment */ - if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) + if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + opt_args->increment_filesize.increment) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") break; @@ -745,11 +673,10 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fset_latest_format, H5Fset_libver_bounds */ case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: { - H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + H5VL_native_file_set_libver_bounds_t *slb_args = &opt_args->set_libver_bounds; /* Call internal set_libver_bounds function */ - if (H5F__set_libver_bounds(f, low, high) < 0) + if (H5F__set_libver_bounds(f, slb_args->low, slb_args->high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") break; @@ -757,34 +684,34 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* H5Fget_dset_no_attrs_hint */ case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: { - hbool_t *minimize = HDva_arg(arguments, hbool_t *); - *minimize = H5F_GET_MIN_DSET_OHDR(f); + *opt_args->get_min_dset_ohdr_flag.minimize = H5F_GET_MIN_DSET_OHDR(f); + break; } /* H5Fset_dset_no_attrs_hint */ case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: { - int minimize = HDva_arg(arguments, int); - if (H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0) + if (H5F_set_min_dset_ohdr(f, opt_args->set_min_dset_ohdr_flag.minimize) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set file's dataset object header minimization flag") + break; } #ifdef H5_HAVE_PARALLEL /* H5Fget_mpi_atomicity */ case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: { - hbool_t *flag = (hbool_t *)HDva_arg(arguments, hbool_t *); - if (H5F_get_mpi_atomicity(f, flag) < 0) + if (H5F__get_mpi_atomicity(f, opt_args->get_mpi_atomicity.flag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "cannot get MPI atomicity"); + break; } /* H5Fset_mpi_atomicity */ case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: { - hbool_t flag = (hbool_t)HDva_arg(arguments, int); - if (H5F_set_mpi_atomicity(f, flag) < 0) + if (H5F__set_mpi_atomicity(f, opt_args->set_mpi_atomicity.flag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); + break; } #endif /* H5_HAVE_PARALLEL */ @@ -792,7 +719,7 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t /* Finalize H5Fopen */ case H5VL_NATIVE_FILE_POST_OPEN: { /* Call package routine */ - if (H5F__post_open((H5F_t *)obj) < 0) + if (H5F__post_open(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't finish opening file") break; } @@ -843,7 +770,7 @@ H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_U HGOTO_ERROR(H5E_ID, H5E_CANTGET, FAIL, "can't get ID ref count") if (nref == 1) if (H5F__flush(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ /* Close the file */ diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c index e3fa702..54f8337 100644 --- a/src/H5VLnative_group.c +++ b/src/H5VLnative_group.c @@ -15,8 +15,15 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5G_FRIEND /* Suppress error about including H5Gpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gpkg.h" /* Groups */ @@ -27,6 +34,30 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- * Function: H5VL__native_group_create * @@ -138,55 +169,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_group_get(void *obj, H5VL_group_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (get_type) { + switch (args->op_type) { /* H5Gget_create_plist */ case H5VL_GROUP_GET_GCPL: { - hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); - H5G_t *grp = (H5G_t *)obj; + if ((args->args.get_gcpl.gcpl_id = H5G_get_create_plist((H5G_t *)obj)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get creation property list for group") - if ((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") break; } /* H5Gget_info */ case H5VL_GROUP_GET_INFO: { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - H5G_info_t * group_info = HDva_arg(arguments, H5G_info_t *); - H5G_loc_t loc; + H5VL_group_get_info_args_t *get_info_args = &args->args.get_info; + H5G_loc_t loc; - if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, get_info_args->loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if (loc_params->type == H5VL_OBJECT_BY_SELF) { + if (get_info_args->loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Gget_info */ /* Retrieve the group's information */ - if (H5G__obj_info(loc.oloc, group_info) < 0) + if (H5G__obj_info(loc.oloc, get_info_args->ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") } /* end if */ - else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + else if (get_info_args->loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Gget_info_by_name */ /* Retrieve the group's information */ - if (H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) + if (H5G__get_info_by_name(&loc, get_info_args->loc_params.loc_data.loc_by_name.name, + get_info_args->ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") } /* end else-if */ - else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + else if (get_info_args->loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Gget_info_by_idx */ /* Retrieve the group's information */ - if (H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, group_info) < 0) + if (H5G__get_info_by_idx(&loc, get_info_args->loc_params.loc_data.loc_by_idx.name, + get_info_args->loc_params.loc_data.loc_by_idx.idx_type, + get_info_args->loc_params.loc_data.loc_by_idx.order, + get_info_args->loc_params.loc_data.loc_by_idx.n, + get_info_args->ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") } /* end else-if */ else @@ -212,30 +242,53 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_group_specific(void *obj, H5VL_group_specific_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5G_t *grp = (H5G_t *)obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (specific_type) { - case H5VL_GROUP_FLUSH: { - hid_t group_id = HDva_arg(arguments, hid_t); + switch (args->op_type) { + /* H5Fmount */ + case H5VL_GROUP_MOUNT: { + H5G_loc_t loc; + + if (H5G_loc_real(grp, H5I_GROUP, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group object") + + if (H5F_mount(&loc, args->args.mount.name, args->args.mount.child_file, + args->args.mount.fmpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + + /* H5Funmount */ + case H5VL_GROUP_UNMOUNT: { + H5G_loc_t loc; + + if (H5G_loc_real(grp, H5I_GROUP, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group object") + + if (H5F_unmount(&loc, args->args.unmount.name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_UNMOUNT, FAIL, "unable to unmount file") + + break; + } - /* Flush object's metadata to file */ - if (H5O_flush_common(&grp->oloc, group_id) < 0) + /* H5Gflush */ + case H5VL_GROUP_FLUSH: { + if (H5O_flush_common(&grp->oloc, args->args.flush.grp_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") break; } + /* H5Grefresh */ case H5VL_GROUP_REFRESH: { - hid_t group_id = HDva_arg(arguments, hid_t); - - /* Call private function to refresh group object */ - if ((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + if ((H5O_refresh_metadata(&grp->oloc, args->args.refresh.grp_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") break; @@ -259,50 +312,53 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_optional(void H5_ATTR_UNUSED *obj, H5VL_group_optional_t optional_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, - va_list H5_ATTR_DEPRECATED_USED arguments) +H5VL__native_group_optional(void H5_ATTR_UNUSED *obj, H5VL_optional_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - herr_t ret_value = SUCCEED; /* Return value */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + H5VL_native_group_optional_args_t *opt_args = args->args; /* Pointer to native operation's arguments */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (optional_type) { + switch (args->op_type) { #ifndef H5_NO_DEPRECATED_SYMBOLS /* H5Giterate (deprecated) */ case H5VL_NATIVE_GROUP_ITERATE_OLD: { - const H5VL_loc_params_t * loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - hsize_t idx = HDva_arg(arguments, hsize_t); - hsize_t * last_obj = HDva_arg(arguments, hsize_t *); - const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); - void * op_data = HDva_arg(arguments, void *); - H5G_loc_t grp_loc; + H5VL_native_group_iterate_old_t *iter_args = &opt_args->iterate_old; + H5G_link_iterate_t lnk_op; /* Link operator */ + H5G_loc_t grp_loc; /* Get the location struct for the object */ - if (H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + if (H5G_loc_real(obj, iter_args->loc_params.obj_type, &grp_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + /* Set up link iteration callback struct */ + lnk_op.op_type = H5G_LINK_OP_OLD; + lnk_op.op_func.op_old = iter_args->op; + /* Call the actual iteration routine */ - if ((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, - H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); + if ((ret_value = H5G_iterate(&grp_loc, iter_args->loc_params.loc_data.loc_by_name.name, + H5_INDEX_NAME, H5_ITER_INC, iter_args->idx, iter_args->last_obj, + &lnk_op, iter_args->op_data)) < 0) + HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links"); break; } /* H5Gget_objinfo (deprecated) */ case H5VL_NATIVE_GROUP_GET_OBJINFO: { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); - H5G_stat_t * statbuf = HDva_arg(arguments, H5G_stat_t *); - H5G_loc_t grp_loc; + H5VL_native_group_get_objinfo_t *goi_args = &opt_args->get_objinfo; + H5G_loc_t grp_loc; /* Get the location struct for the object */ - if (H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + if (H5G_loc_real(obj, goi_args->loc_params.obj_type, &grp_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Call the actual group objinfo routine */ - if (H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) + if (H5G__get_objinfo(&grp_loc, goi_args->loc_params.loc_data.loc_by_name.name, + goi_args->follow_link, goi_args->statbuf) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") break; diff --git a/src/H5VLnative_introspect.c b/src/H5VLnative_introspect.c index 6af33ba..fa11bea 100644 --- a/src/H5VLnative_introspect.c +++ b/src/H5VLnative_introspect.c @@ -15,14 +15,46 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ -/* Note: H5VL__native_introspect_get_conn_cls is in src/H5VLnative.c so that - * it can return the address of the staticly declared class struct. +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Note: H5VL__native_introspect_get_conn_cls and H5VL__native_introspect_get_cap_flags + * are in src/H5VLnative.c so that they can work with the staticly declared + * class struct. */ /*--------------------------------------------------------------------------- @@ -150,8 +182,10 @@ H5VL__native_introspect_opt_query(void H5_ATTR_UNUSED *obj, H5VL_subclass_t subc case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: +#ifdef H5_HAVE_PARALLEL case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: +#endif /* H5_HAVE_PARALLEL */ case H5VL_NATIVE_FILE_POST_OPEN: break; diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c index 72f6cde..042c778 100644 --- a/src/H5VLnative_link.c +++ b/src/H5VLnative_link.c @@ -15,8 +15,15 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5L_FRIEND /* Suppress error about including H5Lpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ @@ -27,6 +34,30 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- * Function: H5VL__native_link_create * @@ -37,20 +68,20 @@ *------------------------------------------------------------------------- */ herr_t -H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, +H5VL__native_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) + void H5_ATTR_UNUSED **req) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (create_type) { + switch (args->op_type) { case H5VL_LINK_CREATE_HARD: { H5G_loc_t cur_loc; H5G_loc_t link_loc; - void * cur_obj = HDva_arg(arguments, void *); - H5VL_loc_params_t *cur_params = HDva_arg(arguments, H5VL_loc_params_t *); + void * cur_obj = args->args.hard.curr_obj; + H5VL_loc_params_t *cur_params = &args->args.hard.curr_loc_params; if (NULL != cur_obj && H5G_loc_real(cur_obj, cur_params->obj_type, &cur_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") @@ -73,46 +104,40 @@ H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H "source and destination should be in the same file.") /* Create the link */ - if ((ret_value = - H5L__create_hard(cur_loc_p, cur_params->loc_data.loc_by_name.name, link_loc_p, - loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + if (H5L__create_hard(cur_loc_p, cur_params->loc_data.loc_by_name.name, link_loc_p, + loc_params->loc_data.loc_by_name.name, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else { /* H5Olink */ /* Link to the object */ if (H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") } /* end else */ + break; } case H5VL_LINK_CREATE_SOFT: { - char * target_name = HDva_arg(arguments, char *); H5G_loc_t link_loc; /* Group location for new link */ if (H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (H5L__create_soft(args->args.soft.target, &link_loc, loc_params->loc_data.loc_by_name.name, + lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create link") - /* Create the link */ - if ((ret_value = H5L__create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, - lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") break; } case H5VL_LINK_CREATE_UD: { - H5G_loc_t link_loc; /* Group location for new link */ - H5L_type_t link_type = (H5L_type_t)HDva_arg(arguments, int); - void * udata = HDva_arg(arguments, void *); - size_t udata_size = HDva_arg(arguments, size_t); + H5G_loc_t link_loc; /* Group location for new link */ if (H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Create link */ - if (H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, link_type, - lcpl_id) < 0) + if (H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, args->args.ud.buf, + args->args.ud.buf_size, args->args.ud.type, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; } @@ -218,8 +243,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { H5G_loc_t loc; herr_t ret_value = SUCCEED; /* Return value */ @@ -229,20 +254,19 @@ H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_ if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch (get_type) { + switch (args->op_type) { /* H5Lget_info/H5Lget_info_by_idx */ case H5VL_LINK_GET_INFO: { - H5L_info2_t *linfo2 = HDva_arg(arguments, H5L_info2_t *); - /* Get the link information */ - if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ - if (H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo2) < 0) + if (loc_params->type == H5VL_OBJECT_BY_NAME) { + if (H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, args->args.get_info.linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end if */ - else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ - if (H5L__get_info_by_idx( - &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo2) < 0) + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + if (H5L__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, args->args.get_info.linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") } /* end else-if */ else @@ -253,15 +277,11 @@ H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_ /* H5Lget_name_by_idx */ case H5VL_LINK_GET_NAME: { - char * name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - - /* Get the link name */ - if ((*ret = H5L__get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, name, size)) < 0) + if (H5L__get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, + args->args.get_name.name, args->args.get_name.name_size, + args->args.get_name.name_len) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") break; @@ -269,20 +289,17 @@ H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_ /* H5Lget_val/H5Lget_val_by_idx */ case H5VL_LINK_GET_VAL: { - void * buf = HDva_arg(arguments, void *); - size_t size = HDva_arg(arguments, size_t); - /* Get the link information */ - if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ - if (H5L__get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) + if (loc_params->type == H5VL_OBJECT_BY_NAME) { + if (H5L__get_val(&loc, loc_params->loc_data.loc_by_name.name, args->args.get_val.buf, + args->args.get_val.buf_size) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") } - else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ - - if (H5L__get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, buf, size) < 0) + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + if (H5L__get_val_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, + args->args.get_val.buf, args->args.get_val.buf_size) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") } else @@ -309,35 +326,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch (specific_type) { + switch (args->op_type) { case H5VL_LINK_EXISTS: { - hbool_t * exists = HDva_arg(arguments, hbool_t *); H5G_loc_t loc; if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Check for the existence of the link */ - if (H5L__exists(&loc, loc_params->loc_data.loc_by_name.name, exists) < 0) + if (H5L__exists(&loc, loc_params->loc_data.loc_by_name.name, args->args.exists.exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; } case H5VL_LINK_ITER: { - H5G_loc_t loc; - hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t * idx_p = HDva_arg(arguments, hsize_t *); - H5L_iterate2_t op = HDva_arg(arguments, H5L_iterate2_t); - void * op_data = HDva_arg(arguments, void *); + H5VL_link_iterate_args_t *iter_args = &args->args.iterate; + H5G_loc_t loc; /* Get the location */ if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) @@ -345,28 +355,32 @@ H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ /* Visit or iterate over the links */ if (loc_params->type == H5VL_OBJECT_BY_SELF) { - if (recursive) { + if (iter_args->recursive) { /* H5Lvisit */ - if ((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + if ((ret_value = H5G_visit(&loc, ".", iter_args->idx_type, iter_args->order, + iter_args->op, iter_args->op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") } /* end if */ else { /* H5Literate */ - if ((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + if ((ret_value = H5L_iterate(&loc, ".", iter_args->idx_type, iter_args->order, + iter_args->idx_p, iter_args->op, iter_args->op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") } /* end else */ } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_NAME) { - if (recursive) { + if (iter_args->recursive) { /* H5Lvisit_by_name */ - if ((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, - op, op_data)) < 0) + if ((ret_value = + H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, iter_args->idx_type, + iter_args->order, iter_args->op, iter_args->op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") } /* end if */ else { /* H5Literate_by_name */ - if ((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, - idx_p, op, op_data)) < 0) + if ((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, + iter_args->idx_type, iter_args->order, iter_args->idx_p, + iter_args->op, iter_args->op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") } /* end else */ } /* end else-if */ diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index 449f389..d237617 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -15,9 +15,16 @@ * */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ +/****************/ +/* Module Setup */ +/****************/ + #define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files (pkg needed for id_exists) */ @@ -29,6 +36,30 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- * Function: H5VL__native_object_open * @@ -138,8 +169,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { herr_t ret_value = SUCCEED; /* Return value */ H5G_loc_t loc; /* Location of group */ @@ -149,14 +180,12 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch (get_type) { + switch (args->op_type) { /* Object file */ case H5VL_OBJECT_GET_FILE: { - void **ret = HDva_arg(arguments, void **); - if (loc_params->type == H5VL_OBJECT_BY_SELF) { - *ret = (void *)loc.oloc->file; + *args->args.get_file.file = (void *)loc.oloc->file; /* TODO we currently need to set id_exists to TRUE because * the upper layer will create an ID from the returned @@ -166,18 +195,16 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj } else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_file parameters") + break; } /* Object name */ case H5VL_OBJECT_GET_NAME: { - ssize_t *ret = HDva_arg(arguments, ssize_t *); - char * name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* Retrieve object's name */ - if ((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) + if (H5G_get_name(&loc, args->args.get_name.buf, args->args.get_name.buf_size, + args->args.get_name.name_len, NULL) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve object name") } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_TOKEN) { @@ -194,18 +221,18 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj "can't deserialize object token into address") /* Retrieve object's name */ - if ((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0) + if (H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, args->args.get_name.buf, + args->args.get_name.buf_size, args->args.get_name.name_len) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine object name") } /* end else-if */ else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_name parameters") + break; } /* Object type */ case H5VL_OBJECT_GET_TYPE: { - H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); - if (loc_params->type == H5VL_OBJECT_BY_TOKEN) { H5O_loc_t obj_oloc; /* Object location */ unsigned rc; /* Reference count of object */ @@ -222,35 +249,30 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj /* Get the # of links for object, and its type */ /* (To check to make certain that this object hasn't been deleted) */ - if (H5O_get_rc_and_type(&obj_oloc, &rc, obj_type) < 0 || 0 == rc) + if (H5O_get_rc_and_type(&obj_oloc, &rc, args->args.get_type.obj_type) < 0 || 0 == rc) HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") } else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_type parameters") + break; } /* H5Oget_info(_name|_by_idx)3 */ case H5VL_OBJECT_GET_INFO: { - H5O_info2_t *oinfo = HDva_arg(arguments, H5O_info2_t *); - unsigned fields = HDva_arg(arguments, unsigned); - - /* Use the original H5Oget_info code to get the data */ - - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if (H5G_loc_info(&loc, ".", oinfo, fields) < 0) + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + if (H5G_loc_info(&loc, ".", args->args.get_info.oinfo, args->args.get_info.fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if (H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, oinfo, fields) < 0) + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + if (H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, args->args.get_info.oinfo, + args->args.get_info.fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -265,7 +287,7 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") /* Retrieve the object's information */ - if (H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) { + if (H5O_get_info(obj_loc.oloc, args->args.get_info.oinfo, args->args.get_info.fields) < 0) { H5G_loc_free(&obj_loc); HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") } /* end if */ @@ -276,6 +298,7 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj } /* end else-if */ else HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; } @@ -298,8 +321,8 @@ done: */ herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) + H5VL_object_specific_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { H5G_loc_t loc; herr_t ret_value = SUCCEED; /* Return value */ @@ -309,13 +332,10 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch (specific_type) { + switch (args->op_type) { /* H5Oincr_refcount / H5Odecr_refcount */ case H5VL_OBJECT_CHANGE_REF_COUNT: { - int update_ref = HDva_arg(arguments, int); - H5O_loc_t *oloc = loc.oloc; - - if (H5O_link(oloc, update_ref) < 0) + if (H5O_link(loc.oloc, args->args.change_rc.delta) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") break; @@ -323,25 +343,20 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, /* H5Oexists_by_name */ case H5VL_OBJECT_EXISTS: { - htri_t *ret = HDva_arg(arguments, htri_t *); - if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* Check if the object exists */ - if ((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + if (H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name, args->args.exists.exists) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) } /* end if */ else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; } /* Lookup object */ case H5VL_OBJECT_LOOKUP: { - H5O_token_t *token = HDva_arg(arguments, H5O_token_t *); - - HDassert(token); - if (loc_params->type == H5VL_OBJECT_BY_NAME) { H5G_loc_t obj_loc; /* Group hier. location of object */ H5G_name_t obj_path; /* Object group hier. path */ @@ -357,7 +372,8 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") /* Encode token */ - if (H5VL_native_addr_to_token(loc.oloc->file, H5I_FILE, obj_loc.oloc->addr, token) < 0) + if (H5VL_native_addr_to_token(loc.oloc->file, H5I_FILE, obj_loc.oloc->addr, + args->args.lookup.token_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") @@ -370,46 +386,39 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, break; } + /* H5Ovisit/H5Ovisit_by_name */ case H5VL_OBJECT_VISIT: { - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - H5O_iterate2_t op = HDva_arg(arguments, H5O_iterate2_t); - void * op_data = HDva_arg(arguments, void *); - unsigned fields = HDva_arg(arguments, unsigned); + H5VL_object_visit_args_t *visit_args = &args->args.visit; /* Call internal object visitation routine */ if (loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Ovisit */ - if ((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + if ((ret_value = H5O__visit(&loc, ".", visit_args->idx_type, visit_args->order, + visit_args->op, visit_args->op_data, visit_args->fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Ovisit_by_name */ - if ((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, - op_data, fields)) < 0) + if ((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, visit_args->idx_type, + visit_args->order, visit_args->op, visit_args->op_data, + visit_args->fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end else-if */ else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; } case H5VL_OBJECT_FLUSH: { - hid_t oid = HDva_arg(arguments, hid_t); - /* Flush the object's metadata */ - if (H5O_flush(loc.oloc, oid) < 0) + if (H5O_flush(loc.oloc, args->args.flush.obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") break; } case H5VL_OBJECT_REFRESH: { - hid_t oid = HDva_arg(arguments, hid_t); - H5O_loc_t *oloc = loc.oloc; - /* Refresh the metadata */ - if (H5O_refresh_metadata(oid, *oloc) < 0) + if (H5O_refresh_metadata(loc.oloc, args->args.refresh.obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") break; @@ -433,64 +442,59 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_object_optional(void *obj, const H5VL_loc_params_t *loc_params, H5VL_optional_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + H5VL_native_object_optional_args_t *opt_args = args->args; /* Pointer to native operation's arguments */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch (optional_type) { + switch (args->op_type) { /* H5Oget_comment / H5Oget_comment_by_name */ case H5VL_NATIVE_OBJECT_GET_COMMENT: { - char * comment = HDva_arg(arguments, char *); - size_t bufsize = HDva_arg(arguments, size_t); - ssize_t *ret = HDva_arg(arguments, ssize_t *); + H5VL_native_object_get_comment_t *gc_args = &opt_args->get_comment; /* Retrieve the object's comment */ if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ - if ((*ret = H5G_loc_get_comment(&loc, ".", comment /*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + if (H5G_loc_get_comment(&loc, ".", gc_args->buf, gc_args->buf_size, gc_args->comment_len) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get comment for object") } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ - if ((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment /*out*/, - bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + if (H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, gc_args->buf, + gc_args->buf_size, gc_args->comment_len) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get comment for object") } /* end else-if */ else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; } /* H5Oset_comment */ case H5VL_NATIVE_OBJECT_SET_COMMENT: { - const char *comment = HDva_arg(arguments, char *); - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ - /* (Re)set the object's comment */ - if (H5G_loc_set_comment(&loc, ".", comment) < 0) + if (H5G_loc_set_comment(&loc, ".", opt_args->set_comment.comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ - /* (Re)set the object's comment */ - if (H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) + if (H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, + opt_args->set_comment.comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") } /* end else-if */ else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; } /* H5Odisable_mdc_flushes */ case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES: { - H5O_loc_t *oloc = loc.oloc; - - if (H5O_disable_mdc_flushes(oloc) < 0) + if (H5O__disable_mdc_flushes(loc.oloc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork the metadata cache"); break; @@ -498,9 +502,7 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hi /* H5Oenable_mdc_flushes */ case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES: { - H5O_loc_t *oloc = loc.oloc; - - if (H5O_enable_mdc_flushes(oloc) < 0) + if (H5O__enable_mdc_flushes(loc.oloc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork the metadata cache"); break; @@ -508,10 +510,7 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hi /* H5Oare_mdc_flushes_disabled */ case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: { - H5O_loc_t *oloc = loc.oloc; - hbool_t * are_disabled = (hbool_t *)HDva_arg(arguments, hbool_t *); - - if (H5O_are_mdc_flushes_disabled(oloc, are_disabled) < 0) + if (H5O__are_mdc_flushes_disabled(loc.oloc, opt_args->are_mdc_flushes_disabled.flag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine metadata cache cork status"); break; @@ -519,19 +518,16 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hi /* H5Oget_native_info(_name|_by_idx) */ case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: { - H5O_native_info_t *native_info = HDva_arg(arguments, H5O_native_info_t *); - unsigned fields = HDva_arg(arguments, unsigned); + H5VL_native_object_get_native_info_t *gni_args = &opt_args->get_native_info; /* Use the original H5Oget_info code to get the data */ - - if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if (H5G_loc_native_info(&loc, ".", native_info, fields) < 0) + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + if (H5G_loc_native_info(&loc, ".", gni_args->ninfo, gni_args->fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") } /* end if */ else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if (H5G_loc_native_info(&loc, loc_params->loc_data.loc_by_name.name, native_info, fields) < 0) + if (H5G_loc_native_info(&loc, loc_params->loc_data.loc_by_name.name, gni_args->ninfo, + gni_args->fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") } /* end else-if */ else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ @@ -551,8 +547,7 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hi loc_params->loc_data.loc_by_idx.n, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - /* Retrieve the object's information */ - if (H5O_get_native_info(obj_loc.oloc, native_info, fields) < 0) { + if (H5O_get_native_info(obj_loc.oloc, gni_args->ninfo, gni_args->fields) < 0) { H5G_loc_free(&obj_loc); HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") } /* end if */ diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h index 687221a..1fd90c8 100644 --- a/src/H5VLnative_private.h +++ b/src/H5VLnative_private.h @@ -49,13 +49,10 @@ void * H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_par hid_t aapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VL__native_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); /* Dataset callbacks */ @@ -68,12 +65,11 @@ H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem hid_t file_space_id, hid_t plist_id, void *buf, void **req); H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VL__native_dataset_optional(void *dset, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); /* Datatype callbacks */ @@ -82,10 +78,9 @@ H5_DLL void * H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *l hid_t dxpl_id, void **req); H5_DLL void * H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); /* File callbacks */ @@ -93,12 +88,10 @@ H5_DLL void * H5VL__native_file_create(const char *name, unsigned flags, hid_t f hid_t dxpl_id, void **req); H5_DLL void * H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VL__native_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL__native_file_optional(void *file, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); /* Group callbacks */ @@ -107,29 +100,26 @@ H5_DLL void * H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_ void **req); H5_DLL void * H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -H5_DLL herr_t H5VL__native_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL__native_group_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); /* Link callbacks */ -H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, - hid_t dxpl_id, void **req, va_list arguments); + hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req); /* Object callbacks */ H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, @@ -139,25 +129,23 @@ H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *l const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -H5_DLL herr_t H5VL__native_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_optional(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Connector/container introspection functions */ H5_DLL herr_t H5VL__native_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VL__native_introspect_get_cap_flags(const void *info, unsigned *cap_flags); H5_DLL herr_t H5VL__native_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, uint64_t *flags); /* Blob callbacks */ H5_DLL herr_t H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); H5_DLL herr_t H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); -H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, - va_list arguments); +H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t *args); /* Token callbacks */ H5_DLL herr_t H5VL__native_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, diff --git a/src/H5VLnative_token.c b/src/H5VLnative_token.c index 65591c7..bed0164 100644 --- a/src/H5VLnative_token.c +++ b/src/H5VLnative_token.c @@ -14,6 +14,10 @@ * Purpose: Object token callbacks for the native VOL connector */ +/****************/ +/* Module Setup */ +/****************/ + /***********/ /* Headers */ /***********/ diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 5ccc082..ede2f5f 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -36,7 +36,7 @@ #include /* Public HDF5 file */ -#include "hdf5.h" +#include "hdf5dev.h" /* This connector's header */ #include "H5VLpassthru.h" @@ -77,15 +77,6 @@ typedef struct H5VL_pass_through_wrap_ctx_t { /********************* */ /* Helper routines */ -static herr_t H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, - H5VL_file_specific_t specific_type, hid_t dxpl_id, - void **req, ...); -static herr_t H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, - H5VL_request_specific_t specific_type, ...); -static herr_t H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t connector_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, - ...); static H5VL_pass_through_t *H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id); static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj); @@ -117,13 +108,11 @@ static herr_t H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *b void **req); static herr_t H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); +static herr_t H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_attr_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); static herr_t H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req); /* Dataset callbacks */ @@ -137,12 +126,12 @@ static herr_t H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_ static herr_t H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -static herr_t H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_dataset_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); static herr_t H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req); /* Datatype callbacks */ @@ -151,12 +140,12 @@ static void *H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_ hid_t tapl_id, hid_t dxpl_id, void **req); static void *H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_args_t *args, + hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_datatype_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); static herr_t H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req); /* File callbacks */ @@ -164,12 +153,11 @@ static void * H5VL_pass_through_file_create(const char *name, unsigned flags, hi hid_t dxpl_id, void **req); static void * H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +static herr_t H5VL_pass_through_file_get(void *file, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_file_specific(void *file, H5VL_file_specific_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_file_optional(void *file, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); static herr_t H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req); /* Group callbacks */ @@ -178,18 +166,17 @@ static void * H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t void **req); static void * H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); +static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_args_t *args, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_group_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); static herr_t H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req); /* Link callbacks */ -static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, +static herr_t H5VL_pass_through_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, - hid_t dxpl_id, void **req, va_list arguments); + hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); @@ -197,13 +184,11 @@ static herr_t H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); + H5VL_link_get_args_t *args, hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_optional(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Object callbacks */ static void * H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, @@ -213,17 +198,16 @@ static herr_t H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments); + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_optional(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Container/connector introspection callbacks */ static herr_t H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); +static herr_t H5VL_pass_through_introspect_get_cap_flags(const void *info, unsigned *cap_flags); static herr_t H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, uint64_t *flags); @@ -231,19 +215,15 @@ static herr_t H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t static herr_t H5VL_pass_through_request_wait(void *req, uint64_t timeout, H5VL_request_status_t *status); static herr_t H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx); static herr_t H5VL_pass_through_request_cancel(void *req, H5VL_request_status_t *status); -static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specific_t specific_type, - va_list arguments); -static herr_t H5VL_pass_through_request_optional(void *req, H5VL_request_optional_t opt_type, - va_list arguments); +static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specific_args_t *args); +static herr_t H5VL_pass_through_request_optional(void *req, H5VL_optional_args_t *args); static herr_t H5VL_pass_through_request_free(void *req); /* Blob callbacks */ static herr_t H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); static herr_t H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); -static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, - va_list arguments); -static herr_t H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, - va_list arguments); +static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t *args); +static herr_t H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_optional_args_t *args); /* Token callbacks */ static herr_t H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, @@ -254,8 +234,7 @@ static herr_t H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, c H5O_token_t *token); /* Generic optional callback */ -static herr_t H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, - va_list arguments); +static herr_t H5VL_pass_through_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /*******************/ /* Local variables */ @@ -355,8 +334,9 @@ static const H5VL_class_t H5VL_pass_through_g = { }, { /* introspect_cls */ - H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */ - H5VL_pass_through_introspect_opt_query, /* opt_query */ + H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */ + H5VL_pass_through_introspect_get_cap_flags, /* get_cap_flags */ + H5VL_pass_through_introspect_opt_query, /* opt_query */ }, { /* request_cls */ @@ -1025,7 +1005,7 @@ H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -1034,7 +1014,7 @@ H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, v printf("------- PASS THROUGH VOL ATTRIBUTE Get\n"); #endif - ret_value = H5VLattr_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLattr_get(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1055,8 +1035,7 @@ H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, v */ static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -1065,8 +1044,7 @@ H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, printf("------- PASS THROUGH VOL ATTRIBUTE Specific\n"); #endif - ret_value = H5VLattr_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, - arguments); + ret_value = H5VLattr_specific(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1086,8 +1064,7 @@ H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_attr_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -1096,7 +1073,7 @@ H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t printf("------- PASS THROUGH VOL ATTRIBUTE Optional\n"); #endif - ret_value = H5VLattr_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLattr_optional(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1285,8 +1262,7 @@ H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_i *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; herr_t ret_value; @@ -1295,7 +1271,7 @@ H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxp printf("------- PASS THROUGH VOL DATASET Get\n"); #endif - ret_value = H5VLdataset_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLdataset_get(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1315,8 +1291,7 @@ H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxp *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; hid_t under_vol_id; @@ -1326,12 +1301,12 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t printf("------- PASS THROUGH VOL H5Dspecific\n"); #endif - // Save copy of underlying VOL connector ID and prov helper, in case of - // refresh destroying the current object + /* Save copy of underlying VOL connector ID, in case of + * 'refresh' operation destroying the current object + */ under_vol_id = o->under_vol_id; - ret_value = - H5VLdataset_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = H5VLdataset_specific(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1351,8 +1326,7 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_dataset_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -1361,7 +1335,7 @@ H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, printf("------- PASS THROUGH VOL DATASET Optional\n"); #endif - ret_value = H5VLdataset_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLdataset_optional(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1488,8 +1462,7 @@ H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; herr_t ret_value; @@ -1498,7 +1471,7 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxp printf("------- PASS THROUGH VOL DATATYPE Get\n"); #endif - ret_value = H5VLdatatype_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLdatatype_get(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1518,8 +1491,7 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxp *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; hid_t under_vol_id; @@ -1529,12 +1501,12 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific printf("------- PASS THROUGH VOL DATATYPE Specific\n"); #endif - // Save copy of underlying VOL connector ID and prov helper, in case of - // refresh destroying the current object + /* Save copy of underlying VOL connector ID, in case of + * 'refresh' operation destroying the current object + */ under_vol_id = o->under_vol_id; - ret_value = - H5VLdatatype_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = H5VLdatatype_specific(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1554,8 +1526,7 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_datatype_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -1564,7 +1535,7 @@ H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type printf("------- PASS THROUGH VOL DATATYPE Optional\n"); #endif - ret_value = H5VLdatatype_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLdatatype_optional(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1732,7 +1703,7 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_file_get(void *file, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; herr_t ret_value; @@ -1741,7 +1712,7 @@ H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, printf("------- PASS THROUGH VOL FILE Get\n"); #endif - ret_value = H5VLfile_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLfile_get(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -1751,31 +1722,6 @@ H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, } /* end H5VL_pass_through_file_get() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_file_specific_reissue - * - * Purpose: Re-wrap vararg arguments into a va_list and reissue the - * file specific callback to the underlying VOL connector. - * - * Return: Success: 0 - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; - herr_t ret_value; - - va_start(arguments, req); - ret_value = H5VLfile_specific(obj, connector_id, specific_type, dxpl_id, req, arguments); - va_end(arguments); - - return ret_value; -} /* end H5VL_pass_through_file_specific_reissue() */ - -/*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_specific * * Purpose: Specific operation on file @@ -1786,106 +1732,109 @@ H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, H5VL_file *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_file_specific(void *file, H5VL_file_specific_args_t *args, hid_t dxpl_id, void **req) { - H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; - hid_t under_vol_id = -1; - herr_t ret_value; + H5VL_pass_through_t * o = (H5VL_pass_through_t *)file; + H5VL_pass_through_t * new_o; + H5VL_file_specific_args_t my_args; + H5VL_file_specific_args_t *new_args; + H5VL_pass_through_info_t * info; + hid_t under_vol_id = -1; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Specific\n"); #endif - /* Unpack arguments to get at the child file pointer when mounting a file */ - if (specific_type == H5VL_FILE_MOUNT) { - H5I_type_t loc_type; - const char * name; - H5VL_pass_through_t *child_file; - hid_t plist_id; - - /* Retrieve parameters for 'mount' operation, so we can unwrap the child file */ - loc_type = (H5I_type_t)va_arg(arguments, int); /* enum work-around */ - name = va_arg(arguments, const char *); - child_file = (H5VL_pass_through_t *)va_arg(arguments, void *); - plist_id = va_arg(arguments, hid_t); - - /* Keep the correct underlying VOL ID for possible async request token */ - under_vol_id = o->under_vol_id; - - /* Re-issue 'file specific' call, using the unwrapped pieces */ - ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, - dxpl_id, req, (int)loc_type, name, - child_file->under_object, plist_id); - } /* end if */ - else if (specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { - H5VL_pass_through_info_t *info; - hid_t fapl_id, under_fapl_id; - const char * name; - htri_t * ret; - - /* Get the arguments for the 'is accessible' check */ - fapl_id = va_arg(arguments, hid_t); - name = va_arg(arguments, const char *); - ret = va_arg(arguments, htri_t *); + if (args->op_type == H5VL_FILE_IS_ACCESSIBLE) { + /* Shallow copy the args */ + memcpy(&my_args, args, sizeof(my_args)); /* Get copy of our VOL info from FAPL */ - H5Pget_vol_info(fapl_id, (void **)&info); + H5Pget_vol_info(args->args.is_accessible.fapl_id, (void **)&info); /* Make sure we have info about the underlying VOL to be used */ if (!info) return (-1); + /* Keep the correct underlying VOL ID for later */ + under_vol_id = info->under_vol_id; + /* Copy the FAPL */ - under_fapl_id = H5Pcopy(fapl_id); + my_args.args.is_accessible.fapl_id = H5Pcopy(args->args.is_accessible.fapl_id); /* Set the VOL ID and info for the underlying FAPL */ - H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + H5Pset_vol(my_args.args.is_accessible.fapl_id, info->under_vol_id, info->under_vol_info); - /* Keep the correct underlying VOL ID for possible async request token */ + /* Set argument pointer to new arguments */ + new_args = &my_args; + + /* Set object pointer for operation */ + new_o = NULL; + } /* end else-if */ + else if (args->op_type == H5VL_FILE_DELETE) { + /* Shallow copy the args */ + memcpy(&my_args, args, sizeof(my_args)); + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(args->args.del.fapl_id, (void **)&info); + + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return (-1); + + /* Keep the correct underlying VOL ID for later */ under_vol_id = info->under_vol_id; - /* Re-issue 'file specific' call */ - ret_value = H5VL_pass_through_file_specific_reissue(NULL, info->under_vol_id, specific_type, dxpl_id, - req, under_fapl_id, name, ret); + /* Copy the FAPL */ + my_args.args.del.fapl_id = H5Pcopy(args->args.del.fapl_id); - /* Close underlying FAPL */ - H5Pclose(under_fapl_id); + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(my_args.args.del.fapl_id, info->under_vol_id, info->under_vol_info); - /* Release copy of our VOL info */ - H5VL_pass_through_info_free(info); + /* Set argument pointer to new arguments */ + new_args = &my_args; + + /* Set object pointer for operation */ + new_o = NULL; } /* end else-if */ else { - va_list my_arguments; - - /* Make a copy of the argument list for later, if reopening */ - if (specific_type == H5VL_FILE_REOPEN) - va_copy(my_arguments, arguments); - - /* Keep the correct underlying VOL ID for possible async request token */ + /* Keep the correct underlying VOL ID for later */ under_vol_id = o->under_vol_id; - ret_value = - H5VLfile_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); - - /* Wrap file struct pointer, if we reopened one */ - if (specific_type == H5VL_FILE_REOPEN) { - if (ret_value >= 0) { - void **ret = va_arg(my_arguments, void **); + /* Set argument pointer to current arguments */ + new_args = args; - if (ret && *ret) - *ret = H5VL_pass_through_new_obj(*ret, o->under_vol_id); - } /* end if */ + /* Set object pointer for operation */ + new_o = o->under_object; + } /* end else */ - /* Finish use of copied vararg list */ - va_end(my_arguments); - } /* end if */ - } /* end else */ + ret_value = H5VLfile_specific(new_o, under_vol_id, new_args, dxpl_id, req); /* Check for async request */ if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); + if (args->op_type == H5VL_FILE_IS_ACCESSIBLE) { + /* Close underlying FAPL */ + H5Pclose(my_args.args.is_accessible.fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + } /* end else-if */ + else if (args->op_type == H5VL_FILE_DELETE) { + /* Close underlying FAPL */ + H5Pclose(my_args.args.del.fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + } /* end else-if */ + else if (args->op_type == H5VL_FILE_REOPEN) { + /* Wrap file struct pointer for 'reopen' operation, if we reopened one */ + if (ret_value >= 0 && *args->args.reopen.file) + *args->args.reopen.file = H5VL_pass_through_new_obj(*args->args.reopen.file, under_vol_id); + } /* end else */ + return ret_value; } /* end H5VL_pass_through_file_specific() */ @@ -1900,8 +1849,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_file_optional(void *file, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; herr_t ret_value; @@ -1910,7 +1858,7 @@ H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t printf("------- PASS THROUGH VOL File Optional\n"); #endif - ret_value = H5VLfile_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLfile_optional(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2036,8 +1984,7 @@ H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, con *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_group_get(void *obj, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2046,7 +1993,7 @@ H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, printf("------- PASS THROUGH VOL GROUP Get\n"); #endif - ret_value = H5VLgroup_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLgroup_get(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2066,8 +2013,7 @@ H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; hid_t under_vol_id; @@ -2077,11 +2023,27 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, printf("------- PASS THROUGH VOL GROUP Specific\n"); #endif - // Save copy of underlying VOL connector ID and prov helper, in case of - // refresh destroying the current object + /* Save copy of underlying VOL connector ID, in case of + * 'refresh' operation destroying the current object + */ under_vol_id = o->under_vol_id; - ret_value = H5VLgroup_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + /* Unpack arguments to get at the child file pointer when mounting a file */ + if (args->op_type == H5VL_GROUP_MOUNT) { + H5VL_group_specific_args_t vol_cb_args; /* New group specific arg struct */ + + /* Set up new VOL callback arguments */ + vol_cb_args.op_type = H5VL_GROUP_MOUNT; + vol_cb_args.args.mount.name = args->args.mount.name; + vol_cb_args.args.mount.child_file = + ((H5VL_pass_through_t *)args->args.mount.child_file)->under_object; + vol_cb_args.args.mount.fmpl_id = args->args.mount.fmpl_id; + + /* Re-issue 'group specific' call, using the unwrapped pieces */ + ret_value = H5VLgroup_specific(o->under_object, under_vol_id, &vol_cb_args, dxpl_id, req); + } /* end if */ + else + ret_value = H5VLgroup_specific(o->under_object, under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2101,8 +2063,7 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_group_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2111,7 +2072,7 @@ H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_ printf("------- PASS THROUGH VOL GROUP Optional\n"); #endif - ret_value = H5VLgroup_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLgroup_optional(o->under_object, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2154,33 +2115,6 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) } /* end H5VL_pass_through_group_close() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_link_create_reissue - * - * Purpose: Re-wrap vararg arguments into a va_list and reissue the - * link create callback to the underlying VOL connector. - * - * Return: Success: 0 - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; - herr_t ret_value; - - va_start(arguments, req); - ret_value = H5VLlink_create(create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, - arguments); - va_end(arguments); - - return ret_value; -} /* end H5VL_pass_through_link_create_reissue() */ - -/*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_create * * Purpose: Creates a hard / soft / UD / external link. @@ -2191,9 +2125,8 @@ H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_link_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; hid_t under_vol_id = -1; @@ -2208,32 +2141,22 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, under_vol_id = o->under_vol_id; /* Fix up the link target object for hard link creation */ - if (H5VL_LINK_CREATE_HARD == create_type) { - void * cur_obj; - H5VL_loc_params_t *cur_params; + if (H5VL_LINK_CREATE_HARD == args->op_type) { + void *cur_obj = args->args.hard.curr_obj; - /* Retrieve the object & loc params for the link target */ - cur_obj = va_arg(arguments, void *); - cur_params = va_arg(arguments, H5VL_loc_params_t *); - - /* If it's a non-NULL pointer, find the 'under object' and re-set the property */ + /* If cur_obj is a non-NULL pointer, find its 'under object' and update the pointer */ if (cur_obj) { - /* Check if we still need the "under" VOL ID */ + /* Check if we still haven't set the "under" VOL ID */ if (under_vol_id < 0) under_vol_id = ((H5VL_pass_through_t *)cur_obj)->under_vol_id; - /* Set the object for the link target */ - cur_obj = ((H5VL_pass_through_t *)cur_obj)->under_object; + /* Update the object for the link target */ + args->args.hard.curr_obj = ((H5VL_pass_through_t *)cur_obj)->under_object; } /* end if */ + } /* end if */ - /* Re-issue 'link create' call, using the unwrapped pieces */ - ret_value = H5VL_pass_through_link_create_reissue(create_type, (o ? o->under_object : NULL), - loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, - req, cur_obj, cur_params); - } /* end if */ - else - ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, - lcpl_id, lapl_id, dxpl_id, req, arguments); + ret_value = H5VLlink_create(args, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, + lapl_id, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2347,8 +2270,8 @@ H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t *args, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2357,7 +2280,7 @@ H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ printf("------- PASS THROUGH VOL LINK Get\n"); #endif - ret_value = H5VLlink_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLlink_get(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2378,8 +2301,7 @@ H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ */ static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2388,8 +2310,7 @@ H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, printf("------- PASS THROUGH VOL LINK Specific\n"); #endif - ret_value = H5VLlink_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, - arguments); + ret_value = H5VLlink_specific(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2409,8 +2330,8 @@ H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_link_optional(void *obj, const H5VL_loc_params_t *loc_params, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2419,7 +2340,7 @@ H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t printf("------- PASS THROUGH VOL LINK Optional\n"); #endif - ret_value = H5VLlink_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLlink_optional(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2509,8 +2430,8 @@ H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_pa *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_args_t *args, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2519,8 +2440,7 @@ H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5V printf("------- PASS THROUGH VOL OBJECT Get\n"); #endif - ret_value = - H5VLobject_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = H5VLobject_get(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2541,8 +2461,7 @@ H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5V */ static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; hid_t under_vol_id; @@ -2552,12 +2471,12 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params printf("------- PASS THROUGH VOL OBJECT Specific\n"); #endif - // Save copy of underlying VOL connector ID and prov helper, in case of - // refresh destroying the current object + /* Save copy of underlying VOL connector ID, in case of + * 'refresh' operation destroying the current object + */ under_vol_id = o->under_vol_id; - ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, - arguments); + ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2577,8 +2496,8 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_object_optional(void *obj, const H5VL_loc_params_t *loc_params, H5VL_optional_args_t *args, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2587,7 +2506,7 @@ H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hi printf("------- PASS THROUGH VOL OBJECT Optional\n"); #endif - ret_value = H5VLobject_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + ret_value = H5VLobject_optional(o->under_object, loc_params, o->under_vol_id, args, dxpl_id, req); /* Check for async request */ if (req && *req) @@ -2597,7 +2516,7 @@ H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hi } /* end H5VL_pass_through_object_optional() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_introspect_get_conn_clss + * Function: H5VL_pass_through_introspect_get_conn_cls * * Purpose: Query the connector class. * @@ -2627,6 +2546,36 @@ H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, co } /* end H5VL_pass_through_introspect_get_conn_cls() */ /*------------------------------------------------------------------------- + * Function: H5VL_pass_through_introspect_get_cap_flags + * + * Purpose: Query the capability flags for this connector and any + * underlying connector(s). + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_introspect_get_cap_flags(const void *_info, unsigned *cap_flags) +{ + const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INTROSPECT GetCapFlags\n"); +#endif + + /* Invoke the query on the underlying VOL connector */ + ret_value = H5VLintrospect_get_cap_flags(info->under_vol_info, info->under_vol_id, cap_flags); + + /* Bitwise OR our capability flags in */ + if (ret_value >= 0) + *cap_flags |= H5VL_pass_through_g.cap_flags; + + return ret_value; +} /* end H5VL_pass_through_introspect_get_cap_flags() */ + +/*------------------------------------------------------------------------- * Function: H5VL_pass_through_introspect_opt_query * * Purpose: Query if an optional operation is supported by this connector @@ -2743,31 +2692,6 @@ H5VL_pass_through_request_cancel(void *obj, H5VL_request_status_t *status) } /* end H5VL_pass_through_request_cancel() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_request_specific_reissue - * - * Purpose: Re-wrap vararg arguments into a va_list and reissue the - * request specific callback to the underlying VOL connector. - * - * Return: Success: 0 - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, - H5VL_request_specific_t specific_type, ...) -{ - va_list arguments; - herr_t ret_value; - - va_start(arguments, specific_type); - ret_value = H5VLrequest_specific(obj, connector_id, specific_type, arguments); - va_end(arguments); - - return ret_value; -} /* end H5VL_pass_through_request_specific_reissue() */ - -/*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_specific * * Purpose: Specific operation on a request @@ -2778,139 +2702,16 @@ H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_type, va_list arguments) +H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_args_t *args) { - herr_t ret_value = -1; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value = -1; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Specific\n"); #endif - if (H5VL_REQUEST_WAITANY == specific_type || H5VL_REQUEST_WAITSOME == specific_type || - H5VL_REQUEST_WAITALL == specific_type) { - va_list tmp_arguments; - size_t req_count; - - /* Sanity check */ - assert(obj == NULL); - - /* Get enough info to call the underlying connector */ - va_copy(tmp_arguments, arguments); - req_count = va_arg(tmp_arguments, size_t); - - /* Can only use a request to invoke the underlying VOL connector when there's >0 requests */ - if (req_count > 0) { - void ** req_array; - void ** under_req_array; - uint64_t timeout; - H5VL_pass_through_t *o; - size_t u; /* Local index variable */ - - /* Get the request array */ - req_array = va_arg(tmp_arguments, void **); - - /* Get a request to use for determining the underlying VOL connector */ - o = (H5VL_pass_through_t *)req_array[0]; - - /* Create array of underlying VOL requests */ - under_req_array = (void **)malloc(req_count * sizeof(void **)); - for (u = 0; u < req_count; u++) - under_req_array[u] = ((H5VL_pass_through_t *)req_array[u])->under_object; - - /* Remove the timeout value from the vararg list (it's used in all the calls below) */ - timeout = va_arg(tmp_arguments, uint64_t); - - /* Release requests that have completed */ - if (H5VL_REQUEST_WAITANY == specific_type) { - size_t * idx; /* Pointer to the index of completed request */ - H5VL_request_status_t *status; /* Pointer to the request's status */ - - /* Retrieve the remaining arguments */ - idx = va_arg(tmp_arguments, size_t *); - assert(*idx <= req_count); - status = va_arg(tmp_arguments, H5VL_request_status_t *); - - /* Reissue the WAITANY 'request specific' call */ - ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, - specific_type, req_count, - under_req_array, timeout, idx, status); - - /* Release the completed request, if it completed */ - if (ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) { - H5VL_pass_through_t *tmp_o; - - tmp_o = (H5VL_pass_through_t *)req_array[*idx]; - H5VL_pass_through_free_obj(tmp_o); - } /* end if */ - } /* end if */ - else if (H5VL_REQUEST_WAITSOME == specific_type) { - size_t * outcount; /* # of completed requests */ - unsigned * array_of_indices; /* Array of indices for completed requests */ - H5VL_request_status_t *array_of_statuses; /* Array of statuses for completed requests */ - - /* Retrieve the remaining arguments */ - outcount = va_arg(tmp_arguments, size_t *); - assert(*outcount <= req_count); - array_of_indices = va_arg(tmp_arguments, unsigned *); - array_of_statuses = va_arg(tmp_arguments, H5VL_request_status_t *); - - /* Reissue the WAITSOME 'request specific' call */ - ret_value = H5VL_pass_through_request_specific_reissue( - o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, - outcount, array_of_indices, array_of_statuses); - - /* If any requests completed, release them */ - if (ret_value >= 0 && *outcount > 0) { - unsigned *idx_array; /* Array of indices of completed requests */ - - /* Retrieve the array of completed request indices */ - idx_array = va_arg(tmp_arguments, unsigned *); - - /* Release the completed requests */ - for (u = 0; u < *outcount; u++) { - H5VL_pass_through_t *tmp_o; - - tmp_o = (H5VL_pass_through_t *)req_array[idx_array[u]]; - H5VL_pass_through_free_obj(tmp_o); - } /* end for */ - } /* end if */ - } /* end else-if */ - else { /* H5VL_REQUEST_WAITALL == specific_type */ - H5VL_request_status_t *array_of_statuses; /* Array of statuses for completed requests */ - - /* Retrieve the remaining arguments */ - array_of_statuses = va_arg(tmp_arguments, H5VL_request_status_t *); - - /* Reissue the WAITALL 'request specific' call */ - ret_value = H5VL_pass_through_request_specific_reissue( - o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, - array_of_statuses); - - /* Release the completed requests */ - if (ret_value >= 0) { - for (u = 0; u < req_count; u++) { - if (array_of_statuses[u] != H5ES_STATUS_IN_PROGRESS) { - H5VL_pass_through_t *tmp_o; - - tmp_o = (H5VL_pass_through_t *)req_array[u]; - H5VL_pass_through_free_obj(tmp_o); - } /* end if */ - } /* end for */ - } /* end if */ - } /* end else */ - - /* Release array of requests for underlying connector */ - free(under_req_array); - } /* end if */ - - /* Finish use of copied vararg list */ - va_end(tmp_arguments); - } /* end if */ - else { - H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - - ret_value = H5VLrequest_specific(o->under_object, o->under_vol_id, specific_type, arguments); - } /* end else */ + ret_value = H5VLrequest_specific(o->under_object, o->under_vol_id, args); return ret_value; } /* end H5VL_pass_through_request_specific() */ @@ -2926,7 +2727,7 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_request_optional(void *obj, H5VL_request_optional_t opt_type, va_list arguments) +H5VL_pass_through_request_optional(void *obj, H5VL_optional_args_t *args) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -2935,7 +2736,7 @@ H5VL_pass_through_request_optional(void *obj, H5VL_request_optional_t opt_type, printf("------- PASS THROUGH VOL REQUEST Optional\n"); #endif - ret_value = H5VLrequest_optional(o->under_object, o->under_vol_id, opt_type, arguments); + ret_value = H5VLrequest_optional(o->under_object, o->under_vol_id, args); return ret_value; } /* end H5VL_pass_through_request_optional() */ @@ -3027,8 +2828,7 @@ H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t siz *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, - va_list arguments) +H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t *args) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -3037,7 +2837,7 @@ H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t s printf("------- PASS THROUGH VOL BLOB Specific\n"); #endif - ret_value = H5VLblob_specific(o->under_object, o->under_vol_id, blob_id, specific_type, arguments); + ret_value = H5VLblob_specific(o->under_object, o->under_vol_id, blob_id, args); return ret_value; } /* end H5VL_pass_through_blob_specific() */ @@ -3052,7 +2852,7 @@ H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t s *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments) +H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_optional_args_t *args) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -3061,7 +2861,7 @@ H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t o printf("------- PASS THROUGH VOL BLOB Optional\n"); #endif - ret_value = H5VLblob_optional(o->under_object, o->under_vol_id, blob_id, opt_type, arguments); + ret_value = H5VLblob_optional(o->under_object, o->under_vol_id, blob_id, args); return ret_value; } /* end H5VL_pass_through_blob_optional() */ @@ -3168,7 +2968,7 @@ H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *tok *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; @@ -3177,7 +2977,7 @@ H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va printf("------- PASS THROUGH VOL generic Optional\n"); #endif - ret_value = H5VLoptional(o->under_object, o->under_vol_id, op_type, dxpl_id, req, arguments); + ret_value = H5VLoptional(o->under_object, o->under_vol_id, args, dxpl_id, req); return ret_value; } /* end H5VL_pass_through_optional() */ diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h index 7b8a877..5a4ccc1 100644 --- a/src/H5VLpkg.h +++ b/src/H5VLpkg.h @@ -43,6 +43,7 @@ /******************************/ /* Package Private Prototypes */ /******************************/ +H5_DLL herr_t H5VL__set_def_conn(void); H5_DLL hid_t H5VL__register_connector(const void *cls, hbool_t app_ref, hid_t vipl_id); H5_DLL hid_t H5VL__register_connector_by_class(const H5VL_class_t *cls, hbool_t app_ref, hid_t vipl_id); H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id); @@ -56,5 +57,16 @@ H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size); +H5_DLL void H5VL__is_default_conn(hid_t fapl_id, hid_t connector_id, hbool_t *is_default); +H5_DLL herr_t H5VL__register_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); +H5_DLL size_t H5VL__num_opt_operation(void); +H5_DLL herr_t H5VL__find_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); +H5_DLL herr_t H5VL__unregister_opt_operation(H5VL_subclass_t subcls, const char *op_name); +H5_DLL herr_t H5VL__term_opt_operation(void); + +/* Testing functions */ +#ifdef H5VL_TESTING +H5_DLL herr_t H5VL__reparse_def_vol_conn_variable_test(void); +#endif /* H5VL_TESTING */ #endif /* H5VLpkg_H */ diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 34fb13d..f929d03 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -16,6 +16,11 @@ /* Include package's public header */ #include "H5VLpublic.h" /* Generic Functions */ +/* Include connector author public header(s) */ +#include "H5VLconnector.h" /* VOL connector author routines */ +#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ +#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ + /* Private headers needed by this file */ /**************************/ @@ -61,13 +66,15 @@ typedef enum H5VL_get_connector_kind_t { /******************************/ /* Utility functions */ -H5_DLL herr_t H5VL_init_phase1(void); -H5_DLL herr_t H5VL_init_phase2(void); +H5_DLL herr_t H5VL_init_phase1(void); +H5_DLL herr_t H5VL_init_phase2(void); +H5_DLL H5VL_t *H5VL_new_connector(hid_t connector_id); H5_DLL herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2); H5_DLL herr_t H5VL_conn_copy(H5VL_connector_prop_t *value); H5_DLL int64_t H5VL_conn_inc_rc(H5VL_t *connector); H5_DLL int64_t H5VL_conn_dec_rc(H5VL_t *connector); H5_DLL herr_t H5VL_conn_free(const H5VL_connector_prop_t *info); +H5_DLL herr_t H5VL_get_cap_flags(const H5VL_connector_prop_t *prop, unsigned *cap_flags); /* Functions that deal with VOL connectors */ union H5PL_key_t; @@ -109,8 +116,9 @@ H5_DLL herr_t H5VL_reset_vol_wrapper(void); /* Library state functions */ H5_DLL herr_t H5VL_retrieve_lib_state(void **state); +H5_DLL herr_t H5VL_start_lib_state(void); H5_DLL herr_t H5VL_restore_lib_state(const void *state); -H5_DLL herr_t H5VL_reset_lib_state(void); +H5_DLL herr_t H5VL_finish_lib_state(void); H5_DLL herr_t H5VL_free_lib_state(void *state); /* ID registration functions */ @@ -127,12 +135,11 @@ H5_DLL herr_t H5VL_setup_loc_args(hid_t loc_id, H5VL_object_t **vol_obj, H5VL_lo H5_DLL herr_t H5VL_setup_acc_args(hid_t loc_id, const struct H5P_libclass_t *libclass, hbool_t is_collective, hid_t *acspl_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params); H5_DLL herr_t H5VL_setup_self_args(hid_t loc_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params); -H5_DLL herr_t H5VL_setup_name_args(hid_t loc_id, const char *name, const struct H5P_libclass_t *libclass, - hbool_t is_collective, hid_t acspl_id, H5VL_object_t **vol_obj, - H5VL_loc_params_t *loc_params); +H5_DLL herr_t H5VL_setup_name_args(hid_t loc_id, const char *name, hbool_t is_collective, hid_t lapl_id, + H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params); H5_DLL herr_t H5VL_setup_idx_args(hid_t loc_id, const char *name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, const struct H5P_libclass_t *libclass, hbool_t is_collective, - hid_t acspl_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params); + hsize_t n, hbool_t is_collective, hid_t lapl_id, H5VL_object_t **vol_obj, + H5VL_loc_params_t *loc_params); H5_DLL herr_t H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params); @@ -156,12 +163,12 @@ H5_DLL herr_t H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t dtype_id, void void **req); H5_DLL herr_t H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, - ...); +H5_DLL herr_t H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, - void **req, ...); + H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Dataset functions */ @@ -174,12 +181,12 @@ H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); -H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, - void **req, ...); -H5_DLL herr_t H5VL_dataset_specific(const H5VL_object_t *cls, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_dataset_specific(const H5VL_object_t *cls, H5VL_dataset_specific_args_t *args, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Datatype functions */ @@ -188,12 +195,14 @@ H5_DLL void * H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_ hid_t tapl_id, hid_t dxpl_id, void **req); H5_DLL void * H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, - void **req, ...); -H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_args_t *args, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_datatype_optional_op(H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req, H5VL_object_t **vol_obj_ptr); H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* File functions */ @@ -201,12 +210,12 @@ H5_DLL void * H5VL_file_create(const H5VL_connector_prop_t *connector_prop, cons hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); H5_DLL void * H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, - ...); -H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, - void **req, ...); +H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Group functions */ @@ -215,18 +224,18 @@ H5_DLL void * H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_par void **req); H5_DLL void * H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, - void **req, ...); -H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, - void **req, ...); +H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_args_t *args, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_args_t *args, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); H5_DLL herr_t H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Link functions */ -H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, +H5_DLL herr_t H5VL_link_create(H5VL_link_create_args_t *args, const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, - hid_t dxpl_id, void **req, ...); + hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); @@ -234,11 +243,11 @@ H5_DLL herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_pa const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); + H5VL_link_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, - void **req, ...); + H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Object functions */ H5_DLL void * H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, @@ -248,15 +257,16 @@ H5_DLL herr_t H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_para const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); + H5VL_object_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, ...); + H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); /* Connector/container introspection functions */ H5_DLL herr_t H5VL_introspect_get_conn_cls(const H5VL_object_t *vol_obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VL_introspect_get_cap_flags(const void *info, const H5VL_class_t *cls, unsigned *cap_flags); H5_DLL herr_t H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, int opt_type, uint64_t *flags); @@ -265,8 +275,8 @@ H5_DLL herr_t H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5VL_request_status_t *status); H5_DLL herr_t H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void *ctx); H5_DLL herr_t H5VL_request_cancel(const H5VL_object_t *vol_obj, H5VL_request_status_t *status); -H5_DLL herr_t H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_t specific_type, ...); -H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_type, ...); +H5_DLL herr_t H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_args_t *args); +H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args); H5_DLL herr_t H5VL_request_free(const H5VL_object_t *vol_obj); /* Blob functions */ @@ -275,9 +285,8 @@ H5_DLL herr_t H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_ H5_DLL herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, void *ctx); H5_DLL herr_t H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, - H5VL_blob_specific_t specific_type, ...); -H5_DLL herr_t H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, - ...); + H5VL_blob_specific_args_t *args); +H5_DLL herr_t H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_optional_args_t *args); /* Token functions */ H5_DLL herr_t H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, @@ -288,6 +297,7 @@ H5_DLL herr_t H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_t H5O_token_t *token); /* Generic functions */ -H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dxpl_id, + void **req); #endif /* H5VLprivate_H */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index c5f85dc..78e39e3 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -116,6 +116,9 @@ typedef enum H5VL_subclass_t { H5VL_SUBCLS_REQUEST, /**< 'Request' subclass */ H5VL_SUBCLS_BLOB, /**< 'Blob' subclass */ H5VL_SUBCLS_TOKEN /**< 'Token' subclass */ + /* NOTE: if more operations are added, the + * H5VL_opt_vals_g[] array size should be updated. + */ } H5VL_subclass_t; /********************/ @@ -358,9 +361,4 @@ H5_DLL herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_t } #endif -/* Semi-public headers mainly for VOL connector authors */ -#include "H5VLconnector.h" /* VOL connector author routines */ -#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ -#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ - #endif /* H5VLpublic_H */ diff --git a/src/H5VLtest.c b/src/H5VLtest.c new file mode 100644 index 0000000..1f99ce5 --- /dev/null +++ b/src/H5VLtest.c @@ -0,0 +1,96 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5VLtest.c + * Jan 3 2021 + * Quincey Koziol + * + * Purpose: Virtual Object Layer (VOL) testing routines. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ +#define H5VL_TESTING /* Suppress warning about H5VL testing funcs */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5VL__reparse_def_vol_conn_variable_test + * + * Purpose: Re-parse the default VOL connector environment variable. + * + * Since getenv(3) is fairly expensive, we only parse it once, + * when the library opens. This test function is used to + * re-parse the environment variable after we've changed it + * with setenv(3). + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Feb 3, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__reparse_def_vol_conn_variable_test(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Re-check for the HDF5_VOL_CONNECTOR environment variable */ + if (H5VL__set_def_conn() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize default VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__reparse_def_vol_conn_variable_test() */ diff --git a/src/H5Zdevelop.h b/src/H5Zdevelop.h new file mode 100644 index 0000000..328e221 --- /dev/null +++ b/src/H5Zdevelop.h @@ -0,0 +1,421 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5Z (data filter) developer + * support routines. + */ + +#ifndef _H5Zdevelop_H +#define _H5Zdevelop_H + +/* Include package's public header */ +#include "H5Zpublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/** + * Current version of the H5Z_class_t struct + */ +#define H5Z_CLASS_T_VERS (1) + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/** + * Structure for filter callback property + */ +typedef struct H5Z_cb_t { + H5Z_filter_func_t func; + void * op_data; +} H5Z_cb_t; + +/** + * \brief This callback determines if a filter can be applied to the dataset + * with the characteristics provided + * + * \dcpl_id + * \type_id + * \space_id + * + * \return \htri_t + * + * \details Before a dataset gets created, the \ref H5Z_can_apply_func_t + * callbacks for any filters used in the dataset creation property list + * are called with the dataset's dataset creation property list, the + * dataset's datatype and a dataspace describing a chunk (for chunked + * dataset storage). + * + * The \ref H5Z_can_apply_func_t callback must determine if the + * combination of the dataset creation property list setting, the + * datatype and the dataspace represent a valid combination to apply + * this filter to. For example, some cases of invalid combinations may + * involve the filter not operating correctly on certain datatypes (or + * certain datatype sizes), or certain sizes of the chunk dataspace. + * + * The \ref H5Z_can_apply_func_t callback can be the NULL pointer, in + * which case, the library will assume that it can apply to any + * combination of dataset creation property list values, datatypes and + * dataspaces. + * + * The \ref H5Z_can_apply_func_t callback returns positive a valid + * combination, zero for an invalid combination and negative for an + * error. + */ +//! +typedef htri_t (*H5Z_can_apply_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); +//! + +/** + * \brief The filter operation callback function, defining a filter's operation + * on data + * + * \dcpl_id + * \type_id + * \space_id + * + * \return \herr_t + * + * \details After the \ref H5Z_can_apply_func_t callbacks are checked for new + * datasets, the \ref H5Z_set_local_func_t callbacks for any filters + * used in the dataset creation property list are called. These + * callbacks receive the dataset's private copy of the dataset creation + * property list passed in to H5Dcreate() (i.e. not the actual property + * list passed in to H5Dcreate()) and the datatype ID passed in to + * H5Dcreate() (which is not copied and should not be modified) and a + * dataspace describing the chunk (for chunked dataset storage) (which + * should also not be modified). + * + * The \ref H5Z_set_local_func_t callback must set any parameters that + * are specific to this dataset, based on the combination of the + * dataset creation property list values, the datatype and the + * dataspace. For example, some filters perform different actions based + * on different datatypes (or datatype sizes) or different number of + * dimensions or dataspace sizes. + * + * The \ref H5Z_set_local_func_t callback can be the NULL pointer, in + * which case, the library will assume that there are no + * dataset-specific settings for this filter. + * + * The \ref H5Z_set_local_func_t callback must return non-negative on + * success and negative for an error. + */ +//! +typedef herr_t (*H5Z_set_local_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); +//! + +/** + * \brief The filter operation callback function, defining a filter's operation + * on data + * + * \param[in] flags Bit vector specifying certain general properties of the filter + * \param[in] cd_nelmts Number of elements in \p cd_values + * \param[in] cd_values Auxiliary data for the filter + * \param[in] nbytes The number of valid bytes in \p buf to be filtered + * \param[in,out] buf_size The size of \p buf + * \param[in,out] buf The filter buffer + * + * \return Returns the number of valid bytes of data contained in \p buf. In the + * case of failure, the return value is 0 (zero) and all pointer + * arguments are left unchanged. + * + * \details A filter gets definition flags and invocation flags (defined + * above), the client data array and size defined when the filter was + * added to the pipeline, the size in bytes of the data on which to + * operate, and pointers to a buffer and its allocated size. + * + * The filter should store the result in the supplied buffer if + * possible, otherwise it can allocate a new buffer, freeing the + * original. The allocated size of the new buffer should be returned + * through the \p buf_size pointer and the new buffer through the \p + * buf pointer. + * + * The return value from the filter is the number of bytes in the + * output buffer. If an error occurs then the function should return + * zero and leave all pointer arguments unchanged. + */ +//! +typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], + size_t nbytes, size_t *buf_size, void **buf); +//! + +/** + * The filter table maps filter identification numbers to structs that + * contain a pointers to the filter function and timing statistics. + */ +//! +typedef struct H5Z_class2_t { + int version; /**< Version number of the H5Z_class_t struct */ + H5Z_filter_t id; /**< Filter ID number */ + unsigned encoder_present; /**< Does this filter have an encoder? */ + unsigned decoder_present; /**< Does this filter have a decoder? */ + const char * name; /**< Comment for debugging */ + H5Z_can_apply_func_t can_apply; /**< The "can apply" callback for a filter */ + H5Z_set_local_func_t set_local; /**< The "set local" callback for a filter */ + H5Z_func_t filter; /**< The actual filter function */ +} H5Z_class2_t; +//! + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup H5Z + * + * \brief Registers a new filter with the HDF5 library + * + * \param[in] cls A pointer to a buffer for the struct containing the + * filter-definition + * + * \return \herr_t + * + * \details H5Zregister() registers a new filter with the HDF5 library. + * + * \details Making a new filter available to an application is a two-step + * process. The first step is to write the three filter callback + * functions described below: \c can_apply, \c set_local, and \c + * filter. This call to H5Zregister(), registering the filter with the + * library, is the second step. The can_apply and set_local fields can + * be set to NULL if they are not required for the filter being + * registered. + * + * H5Zregister() accepts a single parameter, a pointer to a buffer for + * the \p cls data structure. That data structure must conform to one + * of the following definitions: + * \snippet this H5Z_class1_t_snip + * or + * \snippet this H5Z_class2_t_snip + * + * \c version is a library-defined value reporting the version number + * of the #H5Z_class_t struct. This currently must be set to + * #H5Z_CLASS_T_VERS. + * + * \c id is the identifier for the new filter. This is a user-defined + * value between #H5Z_FILTER_RESERVED and #H5Z_FILTER_MAX. These + * values are defined in the HDF5 source file H5Zpublic.h, but the + * symbols #H5Z_FILTER_RESERVED and #H5Z_FILTER_MAX should always be + * used instead of the literal values. + * + * \c encoder_present is a library-defined value indicating whether + * the filter’s encoding capability is available to the application. + * + * \c decoder_present is a library-defined value indicating whether + * the filter’s encoding capability is available to the application. + * + * \c name is a descriptive comment used for debugging, may contain a + * descriptive name for the filter, and may be the null pointer. + * + * \c can_apply, described in detail below, is a user-defined callback + * function which determines whether the combination of the dataset + * creation property list values, the datatype, and the dataspace + * represent a valid combination to apply this filter to. + * + * \c set_local, described in detail below, is a user-defined callback + * function which sets any parameters that are specific to this + * dataset, based on the combination of the dataset creation property + * list values, the datatype, and the dataspace. + * + * \c filter, described in detail below, is a user-defined callback + * function which performs the action of the filter. + * + * The statistics associated with a filter are not reset by this + * function; they accumulate over the life of the library. + * + * #H5Z_class_t is a macro which maps to either H5Z_class1_t or + * H5Z_class2_t, depending on the needs of the application. To affect + * only this macro, H5Z_class_t_vers may be defined to either 1 or 2. + * Otherwise, it will behave in the same manner as other API + * compatibility macros. See API Compatibility Macros in HDF5 for more + * information. H5Z_class1_t matches the #H5Z_class_t structure that is + * used in the 1.6.x versions of the HDF5 library. + * + * H5Zregister() will automatically detect which structure type has + * been passed in, regardless of the mapping of the #H5Z_class_t macro. + * However, the application must make sure that the fields are filled + * in according to the correct structure definition if the macro is + * used to declare the structure. + * + * \Bold{The callback functions:}\n Before H5Zregister() can link a + * filter into an application, three callback functions must be + * defined as described in the HDF5 library header file H5Zpublic.h. + * + * When a filter is applied to the fractal heap for a group (e.g., + * when compressing group metadata) and if the can apply and set local + * callback functions have been defined for that filter, HDF5 passes + * the value -1 for all parameters for those callback functions. This + * is done to ensure that the filter will not be applied to groups if + * it relies on these parameters, as they are not applicable to group + * fractal heaps; to operate on group fractal heaps, a filter must be + * capable of operating on an opaque block of binary data. + * + * The \Emph{can apply} callback function must return a positive value + * for a valid combination, zero for an invalid combination, and a + * negative value for an error. + * \snippet this H5Z_can_apply_func_t_snip + * + * Before a dataset is created, the \Emph{can apply} callbacks for any + * filters used in the dataset creation property list are called with + * the dataset's dataset creation property list, \c dcpl_id, the + * dataset's datatype, \p type_id, and a dataspace describing a chunk, + * \p space_id, (for chunked dataset storage). + * + * This callback must determine whether the combination of the dataset + * creation property list settings, the datatype, and the dataspace + * represent a valid combination to which to apply this filter. For + * example, an invalid combination may involve the filter not + * operating correctly on certain datatypes, on certain datatype + * sizes, or on certain sizes of the chunk dataspace. If this filter + * is enabled through H5Pset_filter() as optional and the can apply + * function returns 0, the library will skip the filter in the filter + * pipeline. + * + * This callback can be the NULL pointer, in which case the library + * will assume that the filter can be applied to a dataset with any + * combination of dataset creation property list values, datatypes, + * and dataspaces. + * + * The \Emph{set local} callback function is defined as follows: + * \snippet this H5Z_set_local_func_t_snip + * + * After the can apply callbacks are checked for a new dataset, the + * \Emph{set local} callback functions for any filters used in the + * dataset creation property list are called. These callbacks receive + * \c dcpl_id, the dataset's private copy of the dataset creation + * property list passed in to H5Dcreate() (i.e. not the actual + * property list passed in to H5Dcreate()); \c type_id, the datatype + * identifier passed in to H5Dcreate(), which is not copied and should + * not be modified; and \c space_id, a dataspace describing the chunk + * (for chunked dataset storage), which should also not be modified. + * + * The set local callback must set any filter parameters that are + * specific to this dataset, based on the combination of the dataset + * creation property list values, the datatype, and the dataspace. For + * example, some filters perform different actions based on different + * datatypes, datatype sizes, numbers of dimensions, or dataspace + * sizes. + * + * The \Emph{set local} callback may be the NULL pointer, in which + * case, the library will assume that there are no dataset-specific + * settings for this filter. + * + * The \Emph{set local} callback function must return a non-negative + * value on success and a negative value for an error. + * + * The \Emph{filter operation} callback function, defining the + * filter's operation on the data, is defined as follows: + * \snippet this H5Z_func_t_snip + * + * The parameters \c flags, \c cd_nelmts, and \c cd_values are the + * same as for the function H5Pset_filter(). The one exception is that + * an additional flag, #H5Z_FLAG_REVERSE, is set when the filter is + * called as part of the input pipeline. + * + * The parameter \c buf points to the input buffer which has a size of + * \c buf_size bytes, \c nbytes of which are valid data. + * + * The filter should perform the transformation in place if possible. + * If the transformation cannot be done in place, then the filter + * should allocate a new buffer with malloc() and assign it to \c buf, + * assigning the allocated size of that buffer to \c buf_size. The old + * buffer should be freed by calling free(). + * + * If successful, the \Emph{filter operation} callback function + * returns the number of valid bytes of data contained in \c buf. In + * the case of failure, the return value is 0 (zero) and all pointer + * arguments are left unchanged. + * + * \version 1.8.6 Return type for the \Emph{can apply} callback function, + * \ref H5Z_can_apply_func_t, changed to \ref htri_t. + * \version 1.8.5 Semantics of the \Emph{can apply} and \Emph{set local} + * callback functions changed to accommodate the use of filters + * with group fractal heaps. + * \version 1.8.3 #H5Z_class_t renamed to H5Z_class2_t, H5Z_class1_t structure + * introduced for backwards compatibility with release 1.6.x, + * and #H5Z_class_t macro introduced in this release. Function + * modified to accept either structure type. + * \version 1.8.0 The fields \c version, \c encoder_present, and + * \c decoder_present were added to the #H5Z_class_t \c struct + * in this release. + * \version 1.6.0 This function was substantially revised in Release 1.6.0 with + * a new #H5Z_class_t struct and new set local and can apply + * callback functions. + * + */ +H5_DLL herr_t H5Zregister(const void *cls); +/** + * \ingroup H5Z + * + * \brief Unregisters a filter. + * + * \param[in] id Identifier of the filter to be unregistered. + * \return \herr_t + * + * \details H5Zunregister() unregisters the filter specified in \p id. + * + * \details This function first iterates through all opened datasets and + * groups. If an open object that uses this filter is found, the + * function will fail with a message indicating that an object using + * the filter is still open. All open files are then flushed to make + * sure that all cached data that may use this filter are written out. + * + * If the application is a parallel program, all processes that + * participate in collective data write should call this function to + * ensure that all data is flushed. + * + * After a call to H5Zunregister(), the filter specified in filter + * will no longer be available to the application. + * + * \version 1.8.12 Function modified to check for open objects using the + * filter. + * \since 1.6.0 + */ +H5_DLL herr_t H5Zunregister(H5Z_filter_t id); + +#ifdef __cplusplus +} +#endif + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/** + * The filter table maps filter identification numbers to structs that + * contain a pointers to the filter function and timing statistics. + */ +//! +typedef struct H5Z_class1_t { + H5Z_filter_t id; /**< Filter ID number */ + const char * name; /**< Comment for debugging */ + H5Z_can_apply_func_t can_apply; /**< The "can apply" callback for a filter */ + H5Z_set_local_func_t set_local; /**< The "set local" callback for a filter */ + H5Z_func_t filter; /**< The actual filter function */ +} H5Z_class1_t; +//! + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +#endif /* _H5Zdevelop_H */ diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 51690b4..13eb26f 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -21,8 +21,9 @@ /* Early typedefs to avoid circular dependencies */ typedef struct H5Z_filter_info_t H5Z_filter_info_t; -/* Include package's public header */ +/* Include package's public headers */ #include "H5Zpublic.h" +#include "H5Zdevelop.h" /* Private headers needed by this file */ #include "H5Tprivate.h" /* Datatypes */ diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index 90277cf..5d04c9a 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -207,11 +207,6 @@ typedef enum H5Z_SO_scale_type_t { } H5Z_SO_scale_type_t; /** - * Current version of the H5Z_class_t struct - */ -#define H5Z_CLASS_T_VERS (1) - -/** * \ingroup FLETCHER32 * Values to decide if EDC is enabled for reading data */ @@ -243,354 +238,11 @@ typedef enum H5Z_cb_return_t { typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void *buf, size_t buf_size, void *op_data); //! -/** - * Structure for filter callback property - */ -typedef struct H5Z_cb_t { - H5Z_filter_func_t func; - void * op_data; -} H5Z_cb_t; - #ifdef __cplusplus extern "C" { #endif /** - * \brief This callback determines if a filter can be applied to the dataset - * with the characteristics provided - * - * \dcpl_id - * \type_id - * \space_id - * - * \return \htri_t - * - * \details Before a dataset gets created, the \ref H5Z_can_apply_func_t - * callbacks for any filters used in the dataset creation property list - * are called with the dataset's dataset creation property list, the - * dataset's datatype and a dataspace describing a chunk (for chunked - * dataset storage). - * - * The \ref H5Z_can_apply_func_t callback must determine if the - * combination of the dataset creation property list setting, the - * datatype and the dataspace represent a valid combination to apply - * this filter to. For example, some cases of invalid combinations may - * involve the filter not operating correctly on certain datatypes (or - * certain datatype sizes), or certain sizes of the chunk dataspace. - * - * The \ref H5Z_can_apply_func_t callback can be the NULL pointer, in - * which case, the library will assume that it can apply to any - * combination of dataset creation property list values, datatypes and - * dataspaces. - * - * The \ref H5Z_can_apply_func_t callback returns positive a valid - * combination, zero for an invalid combination and negative for an - * error. - */ -//! -typedef htri_t (*H5Z_can_apply_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); -//! -/** - * \brief The filter operation callback function, defining a filter's operation - * on data - * - * \dcpl_id - * \type_id - * \space_id - * - * \return \herr_t - * - * \details After the \ref H5Z_can_apply_func_t callbacks are checked for new - * datasets, the \ref H5Z_set_local_func_t callbacks for any filters - * used in the dataset creation property list are called. These - * callbacks receive the dataset's private copy of the dataset creation - * property list passed in to H5Dcreate() (i.e. not the actual property - * list passed in to H5Dcreate()) and the datatype ID passed in to - * H5Dcreate() (which is not copied and should not be modified) and a - * dataspace describing the chunk (for chunked dataset storage) (which - * should also not be modified). - * - * The \ref H5Z_set_local_func_t callback must set any parameters that - * are specific to this dataset, based on the combination of the - * dataset creation property list values, the datatype and the - * dataspace. For example, some filters perform different actions based - * on different datatypes (or datatype sizes) or different number of - * dimensions or dataspace sizes. - * - * The \ref H5Z_set_local_func_t callback can be the NULL pointer, in - * which case, the library will assume that there are no - * dataset-specific settings for this filter. - * - * The \ref H5Z_set_local_func_t callback must return non-negative on - * success and negative for an error. - */ -//! -typedef herr_t (*H5Z_set_local_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); -//! - -/** - * \brief The filter operation callback function, defining a filter's operation - * on data - * - * \param[in] flags Bit vector specifying certain general properties of the filter - * \param[in] cd_nelmts Number of elements in \p cd_values - * \param[in] cd_values Auxiliary data for the filter - * \param[in] nbytes The number of valid bytes in \p buf to be filtered - * \param[in,out] buf_size The size of \p buf - * \param[in,out] buf The filter buffer - * - * \return Returns the number of valid bytes of data contained in \p buf. In the - * case of failure, the return value is 0 (zero) and all pointer - * arguments are left unchanged. - * - * \details A filter gets definition flags and invocation flags (defined - * above), the client data array and size defined when the filter was - * added to the pipeline, the size in bytes of the data on which to - * operate, and pointers to a buffer and its allocated size. - * - * The filter should store the result in the supplied buffer if - * possible, otherwise it can allocate a new buffer, freeing the - * original. The allocated size of the new buffer should be returned - * through the \p buf_size pointer and the new buffer through the \p - * buf pointer. - * - * The return value from the filter is the number of bytes in the - * output buffer. If an error occurs then the function should return - * zero and leave all pointer arguments unchanged. - */ -//! -typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], - size_t nbytes, size_t *buf_size, void **buf); -//! -/** - * The filter table maps filter identification numbers to structs that - * contain a pointers to the filter function and timing statistics. - */ -//! -typedef struct H5Z_class2_t { - int version; /**< Version number of the H5Z_class_t struct */ - H5Z_filter_t id; /**< Filter ID number */ - unsigned encoder_present; /**< Does this filter have an encoder? */ - unsigned decoder_present; /**< Does this filter have a decoder? */ - const char * name; /**< Comment for debugging */ - H5Z_can_apply_func_t can_apply; /**< The "can apply" callback for a filter */ - H5Z_set_local_func_t set_local; /**< The "set local" callback for a filter */ - H5Z_func_t filter; /**< The actual filter function */ -} H5Z_class2_t; -//! - -/** - * \ingroup H5Z - * - * \brief Registers a new filter with the HDF5 library - * - * \param[in] cls A pointer to a buffer for the struct containing the - * filter-definition - * - * \return \herr_t - * - * \details H5Zregister() registers a new filter with the HDF5 library. - * - * \details Making a new filter available to an application is a two-step - * process. The first step is to write the three filter callback - * functions described below: \c can_apply, \c set_local, and \c - * filter. This call to H5Zregister(), registering the filter with the - * library, is the second step. The can_apply and set_local fields can - * be set to NULL if they are not required for the filter being - * registered. - * - * H5Zregister() accepts a single parameter, a pointer to a buffer for - * the \p cls data structure. That data structure must conform to one - * of the following definitions: - * \snippet this H5Z_class1_t_snip - * or - * \snippet this H5Z_class2_t_snip - * - * \c version is a library-defined value reporting the version number - * of the #H5Z_class_t struct. This currently must be set to - * #H5Z_CLASS_T_VERS. - * - * \c id is the identifier for the new filter. This is a user-defined - * value between #H5Z_FILTER_RESERVED and #H5Z_FILTER_MAX. These - * values are defined in the HDF5 source file H5Zpublic.h, but the - * symbols #H5Z_FILTER_RESERVED and #H5Z_FILTER_MAX should always be - * used instead of the literal values. - * - * \c encoder_present is a library-defined value indicating whether - * the filter’s encoding capability is available to the application. - * - * \c decoder_present is a library-defined value indicating whether - * the filter’s encoding capability is available to the application. - * - * \c name is a descriptive comment used for debugging, may contain a - * descriptive name for the filter, and may be the null pointer. - * - * \c can_apply, described in detail below, is a user-defined callback - * function which determines whether the combination of the dataset - * creation property list values, the datatype, and the dataspace - * represent a valid combination to apply this filter to. - * - * \c set_local, described in detail below, is a user-defined callback - * function which sets any parameters that are specific to this - * dataset, based on the combination of the dataset creation property - * list values, the datatype, and the dataspace. - * - * \c filter, described in detail below, is a user-defined callback - * function which performs the action of the filter. - * - * The statistics associated with a filter are not reset by this - * function; they accumulate over the life of the library. - * - * #H5Z_class_t is a macro which maps to either H5Z_class1_t or - * H5Z_class2_t, depending on the needs of the application. To affect - * only this macro, H5Z_class_t_vers may be defined to either 1 or 2. - * Otherwise, it will behave in the same manner as other API - * compatibility macros. See API Compatibility Macros in HDF5 for more - * information. H5Z_class1_t matches the #H5Z_class_t structure that is - * used in the 1.6.x versions of the HDF5 library. - * - * H5Zregister() will automatically detect which structure type has - * been passed in, regardless of the mapping of the #H5Z_class_t macro. - * However, the application must make sure that the fields are filled - * in according to the correct structure definition if the macro is - * used to declare the structure. - * - * \Bold{The callback functions:}\n Before H5Zregister() can link a - * filter into an application, three callback functions must be - * defined as described in the HDF5 library header file H5Zpublic.h. - * - * When a filter is applied to the fractal heap for a group (e.g., - * when compressing group metadata) and if the can apply and set local - * callback functions have been defined for that filter, HDF5 passes - * the value -1 for all parameters for those callback functions. This - * is done to ensure that the filter will not be applied to groups if - * it relies on these parameters, as they are not applicable to group - * fractal heaps; to operate on group fractal heaps, a filter must be - * capable of operating on an opaque block of binary data. - * - * The \Emph{can apply} callback function must return a positive value - * for a valid combination, zero for an invalid combination, and a - * negative value for an error. - * \snippet this H5Z_can_apply_func_t_snip - * - * Before a dataset is created, the \Emph{can apply} callbacks for any - * filters used in the dataset creation property list are called with - * the dataset's dataset creation property list, \c dcpl_id, the - * dataset's datatype, \p type_id, and a dataspace describing a chunk, - * \p space_id, (for chunked dataset storage). - * - * This callback must determine whether the combination of the dataset - * creation property list settings, the datatype, and the dataspace - * represent a valid combination to which to apply this filter. For - * example, an invalid combination may involve the filter not - * operating correctly on certain datatypes, on certain datatype - * sizes, or on certain sizes of the chunk dataspace. If this filter - * is enabled through H5Pset_filter() as optional and the can apply - * function returns 0, the library will skip the filter in the filter - * pipeline. - * - * This callback can be the NULL pointer, in which case the library - * will assume that the filter can be applied to a dataset with any - * combination of dataset creation property list values, datatypes, - * and dataspaces. - * - * The \Emph{set local} callback function is defined as follows: - * \snippet this H5Z_set_local_func_t_snip - * - * After the can apply callbacks are checked for a new dataset, the - * \Emph{set local} callback functions for any filters used in the - * dataset creation property list are called. These callbacks receive - * \c dcpl_id, the dataset's private copy of the dataset creation - * property list passed in to H5Dcreate() (i.e. not the actual - * property list passed in to H5Dcreate()); \c type_id, the datatype - * identifier passed in to H5Dcreate(), which is not copied and should - * not be modified; and \c space_id, a dataspace describing the chunk - * (for chunked dataset storage), which should also not be modified. - * - * The set local callback must set any filter parameters that are - * specific to this dataset, based on the combination of the dataset - * creation property list values, the datatype, and the dataspace. For - * example, some filters perform different actions based on different - * datatypes, datatype sizes, numbers of dimensions, or dataspace - * sizes. - * - * The \Emph{set local} callback may be the NULL pointer, in which - * case, the library will assume that there are no dataset-specific - * settings for this filter. - * - * The \Emph{set local} callback function must return a non-negative - * value on success and a negative value for an error. - * - * The \Emph{filter operation} callback function, defining the - * filter's operation on the data, is defined as follows: - * \snippet this H5Z_func_t_snip - * - * The parameters \c flags, \c cd_nelmts, and \c cd_values are the - * same as for the function H5Pset_filter(). The one exception is that - * an additional flag, #H5Z_FLAG_REVERSE, is set when the filter is - * called as part of the input pipeline. - * - * The parameter \c buf points to the input buffer which has a size of - * \c buf_size bytes, \c nbytes of which are valid data. - * - * The filter should perform the transformation in place if possible. - * If the transformation cannot be done in place, then the filter - * should allocate a new buffer with malloc() and assign it to \c buf, - * assigning the allocated size of that buffer to \c buf_size. The old - * buffer should be freed by calling free(). - * - * If successful, the \Emph{filter operation} callback function - * returns the number of valid bytes of data contained in \c buf. In - * the case of failure, the return value is 0 (zero) and all pointer - * arguments are left unchanged. - * - * \version 1.8.6 Return type for the \Emph{can apply} callback function, - * \ref H5Z_can_apply_func_t, changed to \ref htri_t. - * \version 1.8.5 Semantics of the \Emph{can apply} and \Emph{set local} - * callback functions changed to accommodate the use of filters - * with group fractal heaps. - * \version 1.8.3 #H5Z_class_t renamed to H5Z_class2_t, H5Z_class1_t structure - * introduced for backwards compatibility with release 1.6.x, - * and #H5Z_class_t macro introduced in this release. Function - * modified to accept either structure type. - * \version 1.8.0 The fields \c version, \c encoder_present, and - * \c decoder_present were added to the #H5Z_class_t \c struct - * in this release. - * \version 1.6.0 This function was substantially revised in Release 1.6.0 with - * a new #H5Z_class_t struct and new set local and can apply - * callback functions. - * - */ -H5_DLL herr_t H5Zregister(const void *cls); -/** - * \ingroup H5Z - * - * \brief Unregisters a filter. - * - * \param[in] id Identifier of the filter to be unregistered. - * \return \herr_t - * - * \details H5Zunregister() unregisters the filter specified in \p id. - * - * \details This function first iterates through all opened datasets and - * groups. If an open object that uses this filter is found, the - * function will fail with a message indicating that an object using - * the filter is still open. All open files are then flushed to make - * sure that all cached data that may use this filter are written out. - * - * If the application is a parallel program, all processes that - * participate in collective data write should call this function to - * ensure that all data is flushed. - * - * After a call to H5Zunregister(), the filter specified in filter - * will no longer be available to the application. - * - * \version 1.8.12 Function modified to check for open objects using the - * filter. - * \since 1.6.0 - */ -H5_DLL herr_t H5Zunregister(H5Z_filter_t id); -/** * \ingroup H5Z * * \brief Determines whether a filter is available @@ -662,29 +314,8 @@ H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); */ H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); -/* Symbols defined for compatibility with previous versions of the HDF5 API. - * - * Use of these symbols is deprecated. - */ -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/** - * The filter table maps filter identification numbers to structs that - * contain a pointers to the filter function and timing statistics. - */ -//! -typedef struct H5Z_class1_t { - H5Z_filter_t id; /**< Filter ID number */ - const char * name; /**< Comment for debugging */ - H5Z_can_apply_func_t can_apply; /**< The "can apply" callback for a filter */ - H5Z_set_local_func_t set_local; /**< The "set local" callback for a filter */ - H5Z_func_t filter; /**< The actual filter function */ -} H5Z_class1_t; -//! - -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - #ifdef __cplusplus } #endif -#endif + +#endif /* _H5Zpublic_H */ diff --git a/src/H5err.txt b/src/H5err.txt index 64452ec..d2f1093 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -105,7 +105,7 @@ SECTION, PIPELINE, I/O pipeline errors SECTION, SYSTEM, System level errors SECTION, PLUGIN, Plugin errors SECTION, MAP, Map related errors -SECTION, ASYNC, Asynchronous I/O errors +SECTION, ASYNC, Asynchronous operation errors SECTION, NONE, No error # Minor errors @@ -139,6 +139,7 @@ MINOR, FILEACC, H5E_NOTHDF5, Not an HDF5 file MINOR, FILEACC, H5E_BADFILE, Bad file ID accessed MINOR, FILEACC, H5E_TRUNCATED, File has been truncated MINOR, FILEACC, H5E_MOUNT, File mount error +MINOR, FILEACC, H5E_UNMOUNT, File unmount error MINOR, FILEACC, H5E_CANTDELETEFILE, Unable to delete file MINOR, FILEACC, H5E_CANTLOCKFILE, Unable to lock file MINOR, FILEACC, H5E_CANTUNLOCKFILE, Unable to unlock file @@ -290,6 +291,7 @@ MINOR, MAP, H5E_CANTPUT, Can't put value # Asynchronous operation errors MINOR, ASYNC, H5E_CANTWAIT, Can't wait on operation +MINOR, ASYNC, H5E_CANTCANCEL, Can't cancel operation # No error, for backward compatibility */ MINOR, NONE, H5E_NONE_MINOR, No error diff --git a/src/H5private.h b/src/H5private.h index 0ff4c56..9c2459a 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1598,6 +1598,9 @@ H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); #ifndef HDunlink #define HDunlink(S) unlink(S) #endif /* HDunlink */ +#ifndef HDunsetenv +#define HDunsetenv(S) unsetenv(S) +#endif /* HDsetenv */ #ifndef HDutime #define HDutime(S, T) utime(S, T) #endif /* HDutime */ diff --git a/src/H5system.c b/src/H5system.c index 144e0bc..7dd0b74 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -460,6 +460,9 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz) * Interestingly, getenv *is* available in the Windows * POSIX layer, just not setenv. * + * Note: Passing an empty string ("") for the value will remove + * the variable from the environment (like unsetenv(3)) + * * Return: Success: 0 * Failure: non-zero error code * @@ -471,14 +474,14 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz) int Wsetenv(const char *name, const char *value, int overwrite) { - size_t bufsize; - errno_t err; - /* If we're not overwriting, check if the environment variable exists. * If it does (i.e.: the required buffer size to store the variable's * value is non-zero), then return an error code. */ if (!overwrite) { + size_t bufsize; + errno_t err; + err = getenv_s(&bufsize, NULL, 0, name); if (err || bufsize) return (int)err; diff --git a/src/H5trace.c b/src/H5trace.c index ecb2705..3a5d420 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1083,6 +1083,15 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) } /* end block */ break; + case 'C': /* H5ES_event_complete_func_t */ + { + H5ES_event_complete_func_t cfunc = + (H5ES_event_complete_func_t)HDva_arg(ap, H5ES_event_complete_func_t); + + H5RS_asprintf_cat(rs, "%p", (void *)(uintptr_t)cfunc); + } /* end block */ + break; + case 'd': /* H5E_direction_t */ { H5E_direction_t direction = (H5E_direction_t)HDva_arg(ap, int); @@ -1111,6 +1120,15 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) } /* end block */ break; + case 'I': /* H5ES_event_insert_func_t */ + { + H5ES_event_insert_func_t ifunc = + (H5ES_event_insert_func_t)HDva_arg(ap, H5ES_event_insert_func_t); + + H5RS_asprintf_cat(rs, "%p", (void *)(uintptr_t)ifunc); + } /* end block */ + break; + case 's': /* H5ES_status_t */ { H5ES_status_t status = (H5ES_status_t)HDva_arg(ap, int); @@ -1124,6 +1142,10 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5ES_STATUS_SUCCEED"); break; + case H5ES_STATUS_CANCELED: + H5RS_acat(rs, "H5ES_STATUS_CANCELED"); + break; + case H5ES_STATUS_FAIL: H5RS_acat(rs, "H5ES_STATUS_FAIL"); break; @@ -1467,6 +1489,14 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) } /* end block */ break; + case 'c': /* H5_atclose_func_t */ + { + H5_atclose_func_t cfunc = (H5_atclose_func_t)HDva_arg(ap, H5_atclose_func_t); + + H5RS_asprintf_cat(rs, "%p", (void *)(uintptr_t)cfunc); + } /* end block */ + break; + case 's': /* hssize_t */ { hssize_t hssize = HDva_arg(ap, hssize_t); @@ -2873,6 +2903,10 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5VL_ATTR_DELETE"); break; + case H5VL_ATTR_DELETE_BY_IDX: + H5RS_acat(rs, "H5VL_ATTR_DELETE_BY_IDX"); + break; + case H5VL_ATTR_EXISTS: H5RS_acat(rs, "H5VL_ATTR_EXISTS"); break; @@ -2901,10 +2935,6 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5VL_BLOB_DELETE"); break; - case H5VL_BLOB_GETSIZE: - H5RS_acat(rs, "H5VL_BLOB_GETSIZE"); - break; - case H5VL_BLOB_ISNULL: H5RS_acat(rs, "H5VL_BLOB_ISNULL"); break; @@ -2985,10 +3015,6 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5VL_DATASET_REFRESH"); break; - case H5VL_DATASET_WAIT: - H5RS_acat(rs, "H5VL_DATASET_WAIT"); - break; - default: H5RS_asprintf_cat(rs, "%ld", (long)specific); break; @@ -3001,6 +3027,10 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5VL_datatype_get_t get = (H5VL_datatype_get_t)HDva_arg(ap, int); switch (get) { + case H5VL_DATATYPE_GET_BINARY_SIZE: + H5RS_acat(rs, "H5VL_DATATYPE_GET_BINARY_SIZE"); + break; + case H5VL_DATATYPE_GET_BINARY: H5RS_acat(rs, "H5VL_DATATYPE_GET_BINARY"); break; @@ -3093,14 +3123,6 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5VL_FILE_REOPEN"); break; - case H5VL_FILE_MOUNT: - H5RS_acat(rs, "H5VL_FILE_MOUNT"); - break; - - case H5VL_FILE_UNMOUNT: - H5RS_acat(rs, "H5VL_FILE_UNMOUNT"); - break; - case H5VL_FILE_IS_ACCESSIBLE: H5RS_acat(rs, "H5VL_FILE_IS_ACCESSIBLE"); break; @@ -3113,10 +3135,6 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5VL_FILE_IS_EQUAL"); break; - case H5VL_FILE_WAIT: - H5RS_acat(rs, "H5VL_FILE_WAIT"); - break; - default: H5RS_asprintf_cat(rs, "%ld", (long)specific); break; @@ -3149,6 +3167,14 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5VL_group_specific_t specific = (H5VL_group_specific_t)HDva_arg(ap, int); switch (specific) { + case H5VL_GROUP_MOUNT: + H5RS_acat(rs, "H5VL_GROUP_MOUNT"); + break; + + case H5VL_GROUP_UNMOUNT: + H5RS_acat(rs, "H5VL_GROUP_UNMOUNT"); + break; + case H5VL_GROUP_FLUSH: H5RS_acat(rs, "H5VL_GROUP_FLUSH"); break; @@ -3164,9 +3190,9 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) } /* end block */ break; - case 'k': /* H5VL_link_create_type_t */ + case 'k': /* H5VL_link_create_t */ { - H5VL_link_create_type_t create = (H5VL_link_create_type_t)HDva_arg(ap, int); + H5VL_link_create_t create = (H5VL_link_create_t)HDva_arg(ap, int); switch (create) { case H5VL_LINK_CREATE_HARD: @@ -3334,22 +3360,14 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5VL_request_specific_t specific = (H5VL_request_specific_t)HDva_arg(ap, int); switch (specific) { - case H5VL_REQUEST_WAITANY: - H5RS_acat(rs, "H5VL_REQUEST_WAITANY"); - break; - - case H5VL_REQUEST_WAITSOME: - H5RS_acat(rs, "H5VL_REQUEST_WAITSOME"); - break; - - case H5VL_REQUEST_WAITALL: - H5RS_acat(rs, "H5VL_REQUEST_WAITALL"); - break; - case H5VL_REQUEST_GET_ERR_STACK: H5RS_acat(rs, "H5VL_REQUEST_GET_ERR_STACK"); break; + case H5VL_REQUEST_GET_EXEC_TIME: + H5RS_acat(rs, "H5VL_REQUEST_GET_EXEC_TIME"); + break; + default: H5RS_asprintf_cat(rs, "%ld", (long)specific); break; @@ -3608,6 +3626,7 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG"); break; +#ifdef H5_HAVE_PARALLEL case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: H5RS_acat(rs, "H5VL_NATIVE_FILE_GET_MPI_ATOMICITY"); break; @@ -3615,6 +3634,7 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: H5RS_acat(rs, "H5VL_NATIVE_FILE_SET_MPI_ATOMICITY"); break; +#endif /* H5_HAVE_PARALLEL */ case H5VL_NATIVE_FILE_POST_OPEN: H5RS_acat(rs, "H5VL_NATIVE_FILE_POST_OPEN"); diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 88911b0..3718121 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -101,6 +101,7 @@ H5_DLL int H5_get_win32_times(H5_timevals_t *tvs); #define HDgettimeofday(V, Z) Wgettimeofday(V, Z) #define HDsetenv(N, V, O) Wsetenv(N, V, O) +#define HDunsetenv(N, V, O) Wsetenv(N, "", 1) #define HDflock(F, L) Wflock(F, L) #define HDgetlogin() Wgetlogin() diff --git a/src/Makefile.am b/src/Makefile.am index 51d847f..ce29217 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,12 +105,11 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5Torder.c H5Tref.c H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c \ H5Tvlen.c \ H5TS.c \ - H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \ + H5VL.c H5VLcallback.c H5VLdyn_ops.c H5VLint.c H5VLnative.c \ H5VLnative_attr.c H5VLnative_blob.c H5VLnative_dataset.c \ H5VLnative_datatype.c H5VLnative_file.c H5VLnative_group.c \ H5VLnative_link.c H5VLnative_introspect.c H5VLnative_object.c \ - H5VLnative_token.c \ - H5VLpassthru.c \ + H5VLnative_token.c H5VLpassthru.c H5VLtest.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c H5Zscaleoffset.c \ H5Zszip.c H5Ztrans.c @@ -151,11 +150,15 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5Mpublic.h H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h H5PLpublic.h \ - H5Rpublic.h H5Spublic.h H5Tpublic.h H5TSpublic.h \ + H5Rpublic.h H5Spublic.h H5Tpublic.h \ H5VLconnector.h H5VLconnector_passthru.h \ H5VLnative.h H5VLpassthru.h H5VLpublic.h \ H5Zpublic.h +# Public component author headers +include_HEADERS += hdf5dev.h H5ESdevelop.h H5FDdevelop.h H5Idevelop.h \ + H5Ldevelop.h H5Tdevelop.h H5TSdevelop.h H5Zdevelop.h + # install libhdf5.settings in lib directory settingsdir=$(libdir) settings_DATA=libhdf5.settings diff --git a/src/hdf5.h b/src/hdf5.h index 6edc084..b6b5f59 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -38,7 +38,6 @@ #include "H5Rpublic.h" /* References */ #include "H5Spublic.h" /* Dataspaces */ #include "H5Tpublic.h" /* Datatypes */ -#include "H5TSpublic.h" /* Thread-safety */ #include "H5VLpublic.h" /* Virtual Object Layer */ #include "H5Zpublic.h" /* Data filters */ diff --git a/src/hdf5dev.h b/src/hdf5dev.h new file mode 100644 index 0000000..201442d --- /dev/null +++ b/src/hdf5dev.h @@ -0,0 +1,38 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This is the main public HDF5 include file for component authors. + */ + +#ifndef _HDF5DEV_H +#define _HDF5DEV_H + +/* Include general purpose application developer interfaces */ +#include "hdf5.h" + +/* Application developer headers for various interfaces */ +#include "H5ESdevelop.h" /* Event Sets */ +#include "H5FDdevelop.h" /* File drivers */ +#include "H5Idevelop.h" /* ID management */ +#include "H5Ldevelop.h" /* Links */ +#include "H5PLextern.h" /* Plugins */ +#include "H5Tdevelop.h" /* Datatypes */ +#include "H5TSdevelop.h" /* Threadsafety */ +#include "H5Zdevelop.h" /* Data filters */ + +/* Virtual object layer (VOL) connector developer support */ +#include "H5VLconnector.h" /* VOL connector author routines */ +#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ +#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ + +#endif /* _HDF5DEV_H */ diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 17931cf..e840559 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -402,6 +402,8 @@ set (test_CLEANFILES mirror_rw/* mirror_wo/* event_set_*.h5 + h5s_block.h5 + h5s_plist.h5 ) # Remove any output file left over from previous test run diff --git a/test/Makefile.am b/test/Makefile.am index 4bf9620..d465664 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -175,7 +175,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse zero_chunk.h5 chunk_single.h5 swmr_non_latest.h5 \ earray_hdr_fd.h5 farray_hdr_fd.h5 bt2_hdr_fd.h5 \ storage_size.h5 dls_01_strings.h5 power2up.h5 version_bounds.h5 \ - alloc_0sized.h5 \ + alloc_0sized.h5 h5s_block.h5 h5s_plist.h5 \ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ sys_file1 tfile[1-7].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \ stab.h5 extern_[1-5].h5 extern_[1-4][rw].raw gheap[0-4].h5 \ diff --git a/test/chunk_info.c b/test/chunk_info.c index 7104941..7c6dcc1 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -1676,7 +1676,7 @@ test_basic_query(hid_t fapl) /* iterate over all chunks */ cptr = &(chunk_infos[0]); - if (H5Dchunk_iter(dset, &iter_cb, &cptr) < 0) + if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb, &cptr) < 0) TEST_ERROR; VERIFY(cptr, &(chunk_infos[2]), "Iterator did not iterate all chunks"); @@ -1690,7 +1690,7 @@ test_basic_query(hid_t fapl) /* iterate and stop after one iteration */ cptr = &(chunk_infos[0]); - if (H5Dchunk_iter(dset, &iter_cb_stop, &cptr) < 0) + if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb_stop, &cptr) < 0) TEST_ERROR; VERIFY(cptr, &(chunk_infos[1]), "Verification of halted iterator failed\n"); @@ -1698,7 +1698,7 @@ test_basic_query(hid_t fapl) cptr = &(chunk_infos[0]); H5E_BEGIN_TRY { - ret = H5Dchunk_iter(dset, &iter_cb_fail, &cptr); + ret = H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb_fail, &cptr); } H5E_END_TRY; if (ret >= 0) diff --git a/test/direct_chunk.c b/test/direct_chunk.c index 61e3df9..0d270bd 100644 --- a/test/direct_chunk.c +++ b/test/direct_chunk.c @@ -1990,23 +1990,23 @@ test_read_unallocated_chunk(hid_t file) /* Create the data space with unlimited dimensions. */ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) - goto error; + FAIL_STACK_ERROR; if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) - goto error; + FAIL_STACK_ERROR; /* Modify dataset creation properties, i.e. enable chunking, no compression */ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + FAIL_STACK_ERROR; if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) - goto error; + FAIL_STACK_ERROR; /* Create a new dataset within the file using cparms creation properties. */ if ((dataset = H5Dcreate2(file, DATASETNAME11, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - goto error; + FAIL_STACK_ERROR; /* Write a single chunk to intialize the chunk storage */ HDmemset(direct_buf, 0, CHUNK_NX * CHUNK_NY * sizeof(int)); @@ -2014,7 +2014,7 @@ test_read_unallocated_chunk(hid_t file) offset[1] = 0; if (H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, chunk_nbytes, direct_buf) < 0) - goto error; + FAIL_STACK_ERROR; /* Attempt to read each chunk in the dataset. Chunks are not allocated, * therefore we expect the result of H5Dread_chunk to fail. Chunk idx starts @@ -2034,7 +2034,7 @@ test_read_unallocated_chunk(hid_t file) /* Check that the chunk read call does not succeed. */ if (status != -1) - goto error; + TEST_ERROR /* Query the size of the non-existant chunk */ direct_chunk_nbytes = ULONG_MAX; @@ -2046,18 +2046,23 @@ test_read_unallocated_chunk(hid_t file) /* Check that the chunk storage size call does not succeed. */ if (status != -1) - goto error; - if (direct_chunk_nbytes != 0) - goto error; + TEST_ERROR + if (direct_chunk_nbytes != ULONG_MAX) + TEST_ERROR } } /* Close/release resources. */ - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(mem_space) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(dataspace) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(cparms) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dxpl) < 0) + FAIL_STACK_ERROR; PASSED(); return 0; @@ -2121,103 +2126,100 @@ test_single_chunk(unsigned config) TESTING("Single chunk I/O"); /* Initialize data */ - for (i = 0; i < DIM0; i++) { + for (i = 0; i < DIM0; i++) for (j = 0; j < DIM1; j++) wdata[i][j] = j / CHUNK0; - } /* Create a new file with the latest format */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_LATEST) if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; + FAIL_STACK_ERROR; if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + FAIL_STACK_ERROR; /* Create dataspace */ if ((sid = H5Screate_simple(2, dims, NULL)) < 0) - goto error; + FAIL_STACK_ERROR; /* Create the dataset creation property list and set the chunk size */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Pset_chunk(dcpl, 2, chunk) < 0) - goto error; + FAIL_STACK_ERROR; /* Create the dataset */ if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_DIRECT_WRITE) { /* Write the data directly to the dataset */ if (H5Dwrite_chunk(did, H5P_DEFAULT, 0, offset, CHUNK0 * CHUNK1 * 4, (void *)wdata) < 0) - goto error; + FAIL_STACK_ERROR; } /* end if */ else /* Write the data to the dataset */ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)wdata) < 0) - goto error; + FAIL_STACK_ERROR; /* * Close and release resources. */ if (H5Pclose(dcpl) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_REOPEN_DSET) if (H5Dclose(did) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Sclose(sid) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Pclose(fapl) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_REOPEN_FILE) if (H5Fclose(fid) < 0) - goto error; + FAIL_STACK_ERROR; /* Open the file and dataset with default properties */ if (config & CONFIG_REOPEN_FILE) if ((fid = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_REOPEN_DSET) if ((did = H5Dopen2(fid, DATASET, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; /* Retrieve dataset creation property list */ if ((dcpl = H5Dget_create_plist(did)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_DIRECT_READ) { /* Read the data directly */ if (H5Dread_chunk(did, H5P_DEFAULT, offset, &filters, rdata) < 0) - goto error; + FAIL_STACK_ERROR; /* Verify returned filter mask */ if (filters != 0) - goto error; + TEST_ERROR } /* end if */ else /* Read the data */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) - goto error; + FAIL_STACK_ERROR; /* Verify that the data read was correct. */ - for (i = 0; i < DIM0; i++) { - for (j = 0; j < DIM1; j++) { + for (i = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) if (rdata[i][j] != wdata[i][j]) - goto error; - } - } + TEST_ERROR /* * Close and release resources */ if (H5Pclose(dcpl) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Dclose(did) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Fclose(fid) < 0) - goto error; + FAIL_STACK_ERROR; PASSED(); return 0; diff --git a/test/dsets.c b/test/dsets.c index 96f8b81..cc35fe3 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -83,6 +83,8 @@ const char *FILENAME[] = {"dataset", /* 0 */ "power2up", /* 24 */ "version_bounds", /* 25 */ "alloc_0sized", /* 26 */ + "h5s_block", /* 27 */ + "h5s_plist", /* 28 */ NULL}; #define OHMIN_FILENAME_A "ohdr_min_a" @@ -14963,6 +14965,370 @@ error: } /* end test_object_header_minimization_dcpl() */ /*----------------------------------------------------------------------------- + * Function: test_h5s_block + * + * Purpose: Test the H5S_BLOCK feature. + * + * Return: Success/pass: 0 + * Failure/error: -1 + * + * Programmer: Quincey Koziol + * 3 November 2020 + * + *----------------------------------------------------------------------------- + */ +static herr_t +test_h5s_block(void) +{ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + char filename[FILENAME_BUF_SIZE] = ""; + hid_t dset_id = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dims[1] = {20}; /* Dataset's dataspace size */ + hsize_t start = 2; /* Starting offset of hyperslab selection */ + hsize_t count = 10; /* Count of hyperslab selection */ + hid_t file_space_id = H5I_INVALID_HID; /* File dataspace ID */ + int buf[20]; /* Memory buffer for I/O */ + unsigned u; /* Local index variable */ + herr_t ret; + + TESTING("contiguous memory buffers with H5S_BLOCK"); + + /*********/ + /* SETUP */ + /*********/ + if (NULL == h5_fixname(FILENAME[27], H5P_DEFAULT, filename, sizeof(filename))) + TEST_ERROR + if (H5I_INVALID_HID == (file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))) + FAIL_STACK_ERROR + if ((file_space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR + if ((dset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, file_space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + for (u = 0; u < 20; u++) + buf[u] = (int)u; + + /*********/ + /* TESTS */ + /*********/ + + /* Check error cases */ + H5E_BEGIN_TRY + { + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_BLOCK, H5P_DEFAULT, buf); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + + /* Write the entire dataset */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_ALL, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Reset the memory buffer */ + HDmemset(buf, 0, sizeof(buf)); + + /* Read the entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_ALL, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < 20; u++) + if (buf[u] != (int)u) + TEST_ERROR + + /* Read a hyperslab from the file to the first 10 elements of the buffer */ + if (H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, &start, NULL, &count, NULL) < 0) + FAIL_STACK_ERROR + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, file_space_id, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < count; u++) + if (buf[u] != (int)(u + start)) + TEST_ERROR + + /* Verify that reading 0 elements is handled correctly and doesn't modify buffer */ + if (H5Sselect_none(file_space_id) < 0) + FAIL_STACK_ERROR + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, file_space_id, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < count; u++) + if (buf[u] != (int)(u + start)) + TEST_ERROR + + /************/ + /* TEARDOWN */ + /************/ + if (FAIL == H5Sclose(file_space_id)) + FAIL_STACK_ERROR + if (FAIL == H5Dclose(dset_id)) + FAIL_STACK_ERROR + if (FAIL == H5Fclose(file_id)) + FAIL_STACK_ERROR + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Sclose(file_space_id); + H5Dclose(dset_id); + H5Fclose(file_id); + } + H5E_END_TRY; + + return FAIL; +} /* end test_h5s_block() */ + +/*----------------------------------------------------------------------------- + * Function: test_h5s_plist + * + * Purpose: Test the H5S_PLIST feature. + * + * Return: Success/pass: 0 + * Failure/error: -1 + * + * Programmer: Quincey Koziol + * 28 January 2021 + * + *----------------------------------------------------------------------------- + */ +static herr_t +test_h5s_plist(void) +{ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + char filename[FILENAME_BUF_SIZE] = ""; + hid_t dset_id = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dims[1] = {20}; /* Dataset's dataspace size */ + hid_t dxpl_id = H5I_INVALID_HID; /* Dataset xfer property list ID */ + hid_t dxpl_id_copy = H5I_INVALID_HID; /* Copy of dataset xfer property list ID */ + hsize_t start = 2; /* Starting offset of hyperslab selection */ + hsize_t stride = 1; /* Stride of hyperslab selection */ + hsize_t count = 10; /* Count of hyperslab selection */ + hsize_t start2 = 14; /* Starting offset of hyperslab selection */ + hsize_t count2 = 4; /* Count of hyperslab selection */ + hsize_t block = 1; /* Block size of hyperslab selection */ + hid_t file_space_id = H5I_INVALID_HID; /* File dataspace ID */ + int buf[20]; /* Memory buffer for I/O */ + unsigned u; /* Local index variable */ + herr_t ret; + + TESTING("dataset's dataspace selection for I/O in DXPL with H5S_PLIST"); + + /*********/ + /* SETUP */ + /*********/ + if (NULL == h5_fixname(FILENAME[28], H5P_DEFAULT, filename, sizeof(filename))) + TEST_ERROR + if (H5I_INVALID_HID == (file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))) + FAIL_STACK_ERROR + if ((file_space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR + if ((dset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, file_space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + FAIL_STACK_ERROR + + for (u = 0; u < 20; u++) + buf[u] = (int)u; + + /*********/ + /* TESTS */ + /*********/ + + /* Check error cases */ + H5E_BEGIN_TRY + { + /* Bad rank */ + ret = H5Pset_dataset_io_hyperslab_selection(dxpl_id, 0, H5S_SELECT_SET, &start, &stride, &count, + &block); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + H5E_BEGIN_TRY + { + /* Bad selection operator */ + ret = H5Pset_dataset_io_hyperslab_selection(dxpl_id, 1, H5S_SELECT_NOOP, &start, &stride, &count, + &block); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + H5E_BEGIN_TRY + { + /* Bad start pointer */ + ret = + H5Pset_dataset_io_hyperslab_selection(dxpl_id, 1, H5S_SELECT_SET, NULL, &stride, &count, &block); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + H5E_BEGIN_TRY + { + /* Bad stride value (stride of NULL is OK) */ + stride = 0; + ret = H5Pset_dataset_io_hyperslab_selection(dxpl_id, 1, H5S_SELECT_SET, &start, &stride, &count, + &block); + stride = 1; + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + H5E_BEGIN_TRY + { + /* Bad count pointer */ + ret = + H5Pset_dataset_io_hyperslab_selection(dxpl_id, 1, H5S_SELECT_SET, &start, &stride, NULL, &block); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + + /* Block pointer is allowed to be NULL */ + + H5E_BEGIN_TRY + { + /* H5S_PLIST for memory dataspace */ + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_PLIST, H5S_ALL, H5P_DEFAULT, buf); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + + /* Write the entire dataset */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_ALL, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Reset the memory buffer */ + HDmemset(buf, 0, sizeof(buf)); + + /* Read the entire dataset */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_ALL, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < 20; u++) + if (buf[u] != (int)u) + TEST_ERROR + + /* Reset the memory buffer */ + HDmemset(buf, 0, sizeof(buf)); + + /* Set valid selection in DXPL */ + if (H5Pset_dataset_io_hyperslab_selection(dxpl_id, 1, H5S_SELECT_SET, &start, &stride, &count, &block) < + 0) + FAIL_STACK_ERROR + + /* Read a hyperslab from the file to the first 10 elements of the buffer */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_PLIST, dxpl_id, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < count; u++) + if (buf[u] != (int)(u + start)) + TEST_ERROR + + /* Reset the memory buffer */ + HDmemset(buf, 0, sizeof(buf)); + + /* Check for copying property list w/selection */ + if ((dxpl_id_copy = H5Pcopy(dxpl_id)) < 0) + FAIL_STACK_ERROR + + /* Read a hyperslab from the file to the first 10 elements of the buffer */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_PLIST, dxpl_id_copy, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < count; u++) + if (buf[u] != (int)(u + start)) + TEST_ERROR + + /* Attempt to 'OR' block with invalid dimensions into the selection */ + H5E_BEGIN_TRY + { + ret = H5Pset_dataset_io_hyperslab_selection(dxpl_id_copy, 2, H5S_SELECT_OR, &start, &stride, &count, + &block); + } + H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR + + /* Set new valid selection in DXPL */ + if (H5Pset_dataset_io_hyperslab_selection(dxpl_id_copy, 1, H5S_SELECT_SET, &start, &stride, &count, + &block) < 0) + FAIL_STACK_ERROR + + /* Read a hyperslab from the file to the first 10 elements of the buffer */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_PLIST, dxpl_id_copy, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < count; u++) + if (buf[u] != (int)(u + start)) + TEST_ERROR + + /* Close the copy */ + if (FAIL == H5Pclose(dxpl_id_copy)) + FAIL_STACK_ERROR + dxpl_id_copy = H5I_INVALID_HID; + + /* 'OR' valid block into the existing selection in original DXPL */ + if (H5Pset_dataset_io_hyperslab_selection(dxpl_id, 1, H5S_SELECT_OR, &start2, &stride, &count2, &block) < + 0) + FAIL_STACK_ERROR + + /* Read a disjoint hyperslab from the file to the first 10 elements of the buffer */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_BLOCK, H5S_PLIST, dxpl_id, buf) < 0) + FAIL_STACK_ERROR + + /* Verify the data read in */ + for (u = 0; u < count; u++) + if (buf[u] != (int)(u + start)) + TEST_ERROR + for (u = 0; u < count2; u++) + if (buf[u + count] != (int)(u + start2)) + TEST_ERROR + + /************/ + /* TEARDOWN */ + /************/ + if (FAIL == H5Pclose(dxpl_id)) + FAIL_STACK_ERROR + if (FAIL == H5Sclose(file_space_id)) + FAIL_STACK_ERROR + if (FAIL == H5Dclose(dset_id)) + FAIL_STACK_ERROR + if (FAIL == H5Fclose(file_id)) + FAIL_STACK_ERROR + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dxpl_id_copy); + H5Pclose(dxpl_id); + H5Sclose(file_space_id); + H5Dclose(dset_id); + H5Fclose(file_id); + } + H5E_END_TRY; + + return FAIL; +} /* end test_h5s_plist() */ + +/*----------------------------------------------------------------------------- * Function: test_0sized_dset_metadata_alloc * * Purpose: Tests the metadata allocation for 0-sized datasets. @@ -15407,7 +15773,10 @@ main(void) /* Tests version bounds using its own file */ nerrors += (test_versionbounds() < 0 ? 1 : 0); + /* Tests that use their own file */ nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0); + nerrors += (test_h5s_block() < 0 ? 1 : 0); + nerrors += (test_h5s_plist() < 0 ? 1 : 0); /* Run misc tests */ nerrors += (dls_01_main() < 0 ? 1 : 0); diff --git a/test/event_set.c b/test/event_set.c index 6568663..5df49e9 100644 --- a/test/event_set.c +++ b/test/event_set.c @@ -94,6 +94,71 @@ error: } /*------------------------------------------------------------------------- + * Function: test_es_none + * + * Purpose: Tests for passing H5ES_NONE to H5ES routines + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Friday, February 26, 2021 + * + *------------------------------------------------------------------------- + */ +static int +test_es_none(void) +{ + TESTING("event set H5ES_NONE"); + + /* Wait */ + if (H5ESwait(H5ES_NONE, 0, NULL, NULL) < 0) + TEST_ERROR; + + /* Cancel */ + if (H5EScancel(H5ES_NONE, NULL, NULL) < 0) + TEST_ERROR; + + /* Get count */ + if (H5ESget_count(H5ES_NONE, NULL) < 0) + TEST_ERROR; + + /* Get op counter */ + if (H5ESget_op_counter(H5ES_NONE, NULL) < 0) + TEST_ERROR; + + /* Get error status */ + if (H5ESget_err_status(H5ES_NONE, NULL) < 0) + TEST_ERROR; + + /* Get error count */ + if (H5ESget_err_count(H5ES_NONE, NULL) < 0) + TEST_ERROR; + + /* Get error info */ + if (H5ESget_err_info(H5ES_NONE, 0, NULL, NULL) < 0) + TEST_ERROR; + + /* Register insert function */ + if (H5ESregister_insert_func(H5ES_NONE, NULL, NULL) < 0) + TEST_ERROR; + + /* Register complete function */ + if (H5ESregister_complete_func(H5ES_NONE, NULL, NULL) < 0) + TEST_ERROR; + + /* Close */ + if (H5ESclose(H5ES_NONE) < 0) + TEST_ERROR; + + PASSED(); + return 0; + +error: + return 1; +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests event sets @@ -118,6 +183,7 @@ main(void) /* Tests */ nerrors += test_es_create(); + nerrors += test_es_none(); /* Cleanup */ h5_cleanup(FILENAME, fapl_id); diff --git a/test/filter_plugin1_dsets.c b/test/filter_plugin1_dsets.c index 5d6c1ef..2b1e4d2 100644 --- a/test/filter_plugin1_dsets.c +++ b/test/filter_plugin1_dsets.c @@ -17,7 +17,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define FILTER1_ID 257 diff --git a/test/filter_plugin2_dsets.c b/test/filter_plugin2_dsets.c index d2011d4..0bef1a0 100644 --- a/test/filter_plugin2_dsets.c +++ b/test/filter_plugin2_dsets.c @@ -17,7 +17,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define FILTER2_ID 258 #define MULTIPLIER 3 diff --git a/test/filter_plugin3_dsets.c b/test/filter_plugin3_dsets.c index 618ce06..b9b3b82 100644 --- a/test/filter_plugin3_dsets.c +++ b/test/filter_plugin3_dsets.c @@ -18,7 +18,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define FILTER3_ID 259 diff --git a/test/filter_plugin4_groups.c b/test/filter_plugin4_groups.c index 630dcd6..589347c 100644 --- a/test/filter_plugin4_groups.c +++ b/test/filter_plugin4_groups.c @@ -18,7 +18,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define FILTER4_ID 260 #define SUFFIX_LEN 8 diff --git a/test/h5test.h b/test/h5test.h index 0d7dade..f5c9608 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -22,9 +22,10 @@ /* * Include required headers. This file tests internal library functions, - * so we include the private headers here. + * so we include the private headers here, along with developer routines. */ #include "hdf5.h" +#include "hdf5dev.h" #include "H5private.h" #include "H5Eprivate.h" diff --git a/test/links.c b/test/links.c index b2d0d9a..f022783 100644 --- a/test/links.c +++ b/test/links.c @@ -3507,6 +3507,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -3597,6 +3598,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -13785,6 +13787,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -13876,6 +13879,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -16683,7 +16687,7 @@ obj_exists(hid_t fapl, hbool_t new_format) FAIL_STACK_ERROR /* Hard links */ - /* Verify that H5Oexists_by_name() fails for non-existent link in root group */ + /* Verify that H5Oexists_by_name() returns false for non-existent link in root group */ H5E_BEGIN_TRY { status = H5Oexists_by_name(fid, "foo", H5P_DEFAULT); @@ -16702,7 +16706,7 @@ obj_exists(hid_t fapl, hbool_t new_format) if (TRUE != H5Oexists_by_name(fid, "group", H5P_DEFAULT)) TEST_ERROR - /* Verify that H5Oexists_by_name() fails for non-existent link in non-root group */ + /* Verify that H5Oexists_by_name() returns false for non-existent object in non-root group */ H5E_BEGIN_TRY { status = H5Oexists_by_name(fid, "group/foo", H5P_DEFAULT); diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c index b574a8e..7a1de6c 100644 --- a/test/null_vol_connector.c +++ b/test/null_vol_connector.c @@ -19,7 +19,7 @@ #include "hdf5.h" /* For HDF5 plugin functionality */ -#include "H5PLextern.h" +#include "hdf5dev.h" /* This connector's header */ #include "null_vol_connector.h" diff --git a/test/tfile.c b/test/tfile.c index 6a52392..62f3c73 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1452,6 +1452,7 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, hid_t gid2, case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: ERROR("H5Fget_obj_ids"); diff --git a/test/trefstr.c b/test/trefstr.c index a3f568a..d0575ab 100644 --- a/test/trefstr.c +++ b/test/trefstr.c @@ -186,7 +186,7 @@ test_refstr_cmp(void) H5RS_str_t *rs1; /* Ref-counted string created */ H5RS_str_t *rs2; /* Ref-counted string created */ int cmp; /* Comparison value */ - ssize_t len; /* Length of string */ + size_t len; /* Length of string */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ diff --git a/test/vol.c b/test/vol.c index d975243..c7586d5 100644 --- a/test/vol.c +++ b/test/vol.c @@ -20,6 +20,12 @@ /* Headers needed */ #include "h5test.h" +#include "H5Iprivate.h" /* IDs */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ +#include "H5Tpkg.h" /* Datatypes */ +#define H5VL_FRIEND /* Suppress error about including H5VLpkg */ +#define H5VL_TESTING +#include "H5VLpkg.h" /* Virtual Object Layer */ /* Filename */ const char *FILENAME[] = {"native_vol_test", NULL}; @@ -35,6 +41,136 @@ const char *FILENAME[] = {"native_vol_test", NULL}; #define N_ELEMENTS 10 +/* A VOL class struct to verify registering optional operations */ +static int reg_opt_curr_op_val; +static herr_t reg_opt_op_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); +static herr_t reg_opt_link_optional(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req); +static herr_t reg_opt_datatype_get(void *obj, H5VL_datatype_get_args_t *args, hid_t dxpl_id, void **req); +#define REG_OPT_VOL_NAME "reg_opt" +#define REG_OPT_VOL_VALUE ((H5VL_class_value_t)502) +static const H5VL_class_t reg_opt_vol_g = { + H5VL_VERSION, /* VOL class struct version */ + REG_OPT_VOL_VALUE, /* value */ + REG_OPT_VOL_NAME, /* name */ + 0, /* version */ + 0, /* capability flags */ + NULL, /* initialize */ + NULL, /* terminate */ + { + /* info_cls */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ + }, + { + /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ + }, + { + /* attribute_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + reg_opt_op_optional, /* optional */ + NULL /* close */ + }, + { + /* dataset_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + reg_opt_op_optional, /* optional */ + NULL /* close */ + }, + { + /* datatype_cls */ + NULL, /* commit */ + NULL, /* open */ + reg_opt_datatype_get, /* get */ + NULL, /* specific */ + reg_opt_op_optional, /* optional */ + NULL /* close */ + }, + { + /* file_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + reg_opt_op_optional, /* optional */ + NULL /* close */ + }, + { + /* group_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + reg_opt_op_optional, /* optional */ + NULL /* close */ + }, + { + /* link_cls */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + reg_opt_link_optional /* optional */ + }, + { + /* object_cls */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + reg_opt_link_optional /* optional */ + }, + { + /* introspect_cls */ + NULL, /* get_conn_cls */ + NULL, /* get_cap_flags */ + NULL, /* opt_query */ + }, + { + /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ + }, + { + /* blob_cls */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { + /* token_cls */ + NULL, /* cmp */ + NULL, /* to_str */ + NULL /* from_str */ + }, + NULL /* optional */ +}; + #define FAKE_VOL_NAME "fake" #define FAKE_VOL_VALUE ((H5VL_class_value_t)501) @@ -90,6 +226,136 @@ static const H5VL_class_t fake_vol_g = { }, { /* datatype_cls */ + NULL, /* commit */ + NULL, /* open */ + reg_opt_datatype_get, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { + /* file_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { + /* group_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { + /* link_cls */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { + /* object_cls */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { + /* introspect_cls */ + NULL, /* get_conn_cls */ + NULL, /* get_cap_flags */ + NULL, /* opt_query */ + }, + { + /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ + }, + { + /* blob_cls */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { + /* token_cls */ + NULL, /* cmp */ + NULL, /* to_str */ + NULL /* from_str */ + }, + NULL /* optional */ +}; + +static herr_t fake_async_get_cap_flags(const void *info, unsigned *cap_flags); + +#define FAKE_ASYNC_VOL_NAME "fake_async" +#define FAKE_ASYNC_VOL_VALUE ((H5VL_class_value_t)503) + +/* A VOL class struct that describes a VOL class with no + * functionality except to set the async capability flag. + */ +static const H5VL_class_t fake_async_vol_g = { + H5VL_VERSION, /* VOL class struct version */ + FAKE_ASYNC_VOL_VALUE, /* value */ + FAKE_ASYNC_VOL_NAME, /* name */ + 0, /* connector version */ + H5VL_CAP_FLAG_ASYNC, /* capability flags */ + NULL, /* initialize */ + NULL, /* terminate */ + { + /* info_cls */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ + }, + { + /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ + }, + { + /* attribute_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { + /* dataset_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { + /* datatype_cls */ NULL, /* commit */ NULL, /* open */ NULL, /* get */ @@ -134,8 +400,9 @@ static const H5VL_class_t fake_vol_g = { }, { /* introspect_cls */ - NULL, /* get_conn_cls */ - NULL, /* opt_query */ + NULL, /* get_conn_cls */ + fake_async_get_cap_flags, /* get_cap_flags */ + NULL, /* opt_query */ }, { /* request_cls */ @@ -163,6 +430,146 @@ static const H5VL_class_t fake_vol_g = { }; /*------------------------------------------------------------------------- + * Function: reg_opt_op_optional_verify + * + * Purpose: Common verification routine for dynamic optional operations + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +reg_opt_op_optional_verify(void *obj, H5VL_optional_args_t *args) +{ + int *o = (int *)obj; + int *op_args; + + /* Check for receiving correct operation value */ + if (args->op_type != reg_opt_curr_op_val) + return -1; + + /* Check that the object is correct */ + if ((-1) != *o) + return -1; + + /* Update the object, with the operation value */ + *o = args->op_type; + + /* Check that the argument is correct */ + op_args = args->args; + if (NULL == op_args) + return -1; + if ((-1) != *op_args) + return -1; + + /* Update the argument return parameter */ + *op_args = args->op_type; + + return 0; +} /* end reg_opt_op_optional_verify() */ + +/*------------------------------------------------------------------------- + * Function: reg_opt_op_optional + * + * Purpose: Common callback to perform a connector-specific operation + * on an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +reg_opt_op_optional(void *obj, H5VL_optional_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + /* Invoke the common value verification routine */ + return reg_opt_op_optional_verify(obj, args); +} /* end reg_opt_op_optional() */ + +/*------------------------------------------------------------------------- + * Function: reg_opt_link_optional + * + * Purpose: Callback to perform a connector-specific operation + * on a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +reg_opt_link_optional(void *obj, const H5VL_loc_params_t *loc_params, H5VL_optional_args_t *args, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + /* Check for receiving correct loc_params info */ + if (loc_params->type != H5VL_OBJECT_BY_NAME) + return -1; + if (loc_params->obj_type != H5I_GROUP) + return -1; + if (HDstrcmp(loc_params->loc_data.loc_by_name.name, ".") != 0) + return -1; + if (loc_params->loc_data.loc_by_name.lapl_id != H5P_LINK_ACCESS_DEFAULT) + return -1; + + /* Invoke the common value verification routine */ + return reg_opt_op_optional_verify(obj, args); +} /* end reg_opt_link_optional() */ + +/*------------------------------------------------------------------------- + * Function: reg_opt_datatype_get + * + * Purpose: Handles the datatype get callback + * + * Note: This is _strictly_ a testing fixture to support the + * exercise_reg_opt_oper() testing routine. It fakes just + * enough of the named datatype VOL callback for the + * H5VL_register_using_vol_id() call in that test routine to + * succeed. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +reg_opt_datatype_get(void H5_ATTR_UNUSED *obj, H5VL_datatype_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + if (H5VL_DATATYPE_GET_BINARY_SIZE == args->op_type) { + if (H5Tencode(H5T_NATIVE_INT, NULL, args->args.get_binary_size.size) < 0) + ret_value = FAIL; + } /* end if */ + else if (H5VL_DATATYPE_GET_BINARY == args->op_type) { + if (H5Tencode(H5T_NATIVE_INT, args->args.get_binary.buf, &args->args.get_binary.buf_size) < 0) + ret_value = FAIL; + } /* end if */ + else + ret_value = FAIL; + + return ret_value; +} /* end reg_opt_datatype_get() */ + +/*------------------------------------------------------------------------- + * Function: fake_async_get_cap_flags + * + * Purpose: Return the capability flags for the 'fake async' connector + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +fake_async_get_cap_flags(const void H5_ATTR_UNUSED *info, unsigned *cap_flags) +{ + *cap_flags = fake_async_vol_g.cap_flags; + + return SUCCEED; +} /* end fake_async_get_cap_flags() */ + +/*------------------------------------------------------------------------- * Function: test_vol_registration() * * Purpose: Tests if we can load, register, and close a simple @@ -1176,6 +1583,519 @@ error: } /* end test_basic_datatype_operation() */ +typedef herr_t (*reg_opt_obj_oper_t)(const char *app_file, const char *app_func, unsigned app_line, + hid_t obj_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +typedef herr_t (*reg_opt_link_oper_t)(const char *app_file, const char *app_func, unsigned app_line, + hid_t obj_id, const char *name, hid_t lapl_id, + H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id); +typedef union { + reg_opt_obj_oper_t obj_op; + reg_opt_link_oper_t link_op; +} reg_opt_oper_t; + +/*------------------------------------------------------------------------- + * Function: exercise_reg_opt_oper() + * + * Purpose: Exercise a particular optional operation for a type. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +exercise_reg_opt_oper(hid_t fake_vol_id, hid_t reg_opt_vol_id, H5VL_subclass_t subcls, + const char *subcls_name, H5I_type_t id_type, reg_opt_oper_t reg_opt_op) +{ + char op_name[256]; /* Operation name to register */ + hid_t obj_id = H5I_INVALID_HID; + H5VL_object_t * vol_obj; + H5VL_optional_args_t vol_cb_args; + int fake_obj, fake_arg; + int op_val = -1, op_val2 = -1; + int find_op_val; + herr_t ret = SUCCEED; + + /* Test registering optional operation */ + HDsnprintf(op_name, sizeof(op_name), "%s-op1", subcls_name); + if (H5VLregister_opt_operation(subcls, op_name, &op_val) < 0) + TEST_ERROR; + + /* Verify that the reserved amount of optional operations is obeyed */ + /* (The first optional operation registered should be at the lower limit) */ + if (op_val != H5VL_RESERVED_NATIVE_OPTIONAL) + TEST_ERROR; + + /* Look up 1st registered optional operation */ + find_op_val = 0; + if (H5VLfind_opt_operation(subcls, op_name, &find_op_val) < 0) + TEST_ERROR; + + /* Verify that the operation was looked up successfully */ + if (op_val != find_op_val) + TEST_ERROR; + + /* Test registering second optional operation */ + HDsnprintf(op_name, sizeof(op_name), "%s-op2", subcls_name); + if (H5VLregister_opt_operation(subcls, op_name, &op_val2) < 0) + TEST_ERROR; + + /* Verify that the reserved amount of optional operations is obeyed */ + /* (The 2nd optional operation registered should be at the lower limit + 1) */ + if (op_val2 != (H5VL_RESERVED_NATIVE_OPTIONAL + 1)) + TEST_ERROR; + + /* Look up 2nd registered optional operation */ + find_op_val = 0; + if (H5VLfind_opt_operation(subcls, op_name, &find_op_val) < 0) + TEST_ERROR; + + /* Verify that the operation was looked up successfully */ + if (op_val2 != find_op_val) + TEST_ERROR; + + /* Push a new API context on the stack */ + /* (Necessary for the named datatype construction routines) */ + if (H5VL_SUBCLS_DATATYPE == subcls) + H5CX_push(); + + /* Create fake object on fake VOL connector */ + if (H5I_INVALID_HID == (obj_id = H5VL_register_using_vol_id(id_type, &fake_obj, fake_vol_id, TRUE))) + TEST_ERROR; + + /* Pop the API context off the stack */ + if (H5VL_SUBCLS_DATATYPE == subcls) + H5CX_pop(FALSE); + + /* Attempt to issue operation on fake VOL connector */ + fake_obj = -1; + fake_arg = -1; + vol_cb_args.op_type = op_val; + vol_cb_args.args = &fake_arg; + H5E_BEGIN_TRY + { + if (H5VL_SUBCLS_LINK == subcls || H5VL_SUBCLS_OBJECT == subcls) + ret = (*reg_opt_op.link_op)(__FILE__, __func__, __LINE__, obj_id, ".", H5P_DEFAULT, &vol_cb_args, + H5P_DEFAULT, H5ES_NONE); + else + ret = (*reg_opt_op.obj_op)(__FILE__, __func__, __LINE__, obj_id, &vol_cb_args, H5P_DEFAULT, + H5ES_NONE); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to perform an optional operation with a NULL callback"); + if ((-1) != fake_obj) + FAIL_PUTS_ERROR("'fake_obj' changed during failed operation?"); + if ((-1) != fake_arg) + FAIL_PUTS_ERROR("'fake_arg' changed during failed operation?"); + + /* Named datatypes must be destroyed differently */ + if (H5VL_SUBCLS_DATATYPE == subcls) { + H5T_t *dt; + + /* Destroy fake datatype object */ + if (NULL == (dt = H5I_remove(obj_id))) + TEST_ERROR; + if (H5VL_free_object(dt->vol_obj) < 0) + TEST_ERROR; + dt->vol_obj = NULL; + if (H5T_close(dt) < 0) + TEST_ERROR; + } /* end if */ + else { + /* Destroy fake object */ + if (NULL == (vol_obj = H5I_remove(obj_id))) + TEST_ERROR; + if (H5VL_free_object(vol_obj) < 0) + TEST_ERROR; + } /* end else */ + + /* Push a new API context on the stack */ + /* (Necessary for the named datatype construction routines) */ + if (H5VL_SUBCLS_DATATYPE == subcls) + H5CX_push(); + + /* Create fake object on reg_opt VOL connector */ + if (H5I_INVALID_HID == (obj_id = H5VL_register_using_vol_id(id_type, &fake_obj, reg_opt_vol_id, TRUE))) + TEST_ERROR; + + /* Pop the API context off the stack */ + if (H5VL_SUBCLS_DATATYPE == subcls) + H5CX_pop(FALSE); + + /* Issue first operation */ + fake_obj = -1; + fake_arg = -1; + reg_opt_curr_op_val = op_val; + vol_cb_args.op_type = op_val; + vol_cb_args.args = &fake_arg; + if (H5VL_SUBCLS_LINK == subcls || H5VL_SUBCLS_OBJECT == subcls) + ret = (*reg_opt_op.link_op)(__FILE__, __func__, __LINE__, obj_id, ".", H5P_DEFAULT, &vol_cb_args, + H5P_DEFAULT, H5ES_NONE); + else + ret = + (*reg_opt_op.obj_op)(__FILE__, __func__, __LINE__, obj_id, &vol_cb_args, H5P_DEFAULT, H5ES_NONE); + if (ret < 0) + TEST_ERROR; + + /* Verify that fake object & argument were modified correctly */ + if (op_val != fake_obj) + FAIL_PUTS_ERROR("'fake_obj' not updated"); + if (op_val != fake_arg) + FAIL_PUTS_ERROR("'fake_arg' not updated"); + + /* Issue second operation */ + fake_obj = -1; + fake_arg = -1; + reg_opt_curr_op_val = op_val2; + vol_cb_args.op_type = op_val2; + vol_cb_args.args = &fake_arg; + if (H5VL_SUBCLS_LINK == subcls || H5VL_SUBCLS_OBJECT == subcls) + ret = (*reg_opt_op.link_op)(__FILE__, __func__, __LINE__, obj_id, ".", H5P_DEFAULT, &vol_cb_args, + H5P_DEFAULT, H5ES_NONE); + else + ret = + (*reg_opt_op.obj_op)(__FILE__, __func__, __LINE__, obj_id, &vol_cb_args, H5P_DEFAULT, H5ES_NONE); + if (ret < 0) + TEST_ERROR; + + /* Verify that fake object & argument were modified correctly */ + if (op_val2 != fake_obj) + FAIL_PUTS_ERROR("'fake_obj' not updated"); + if (op_val2 != fake_arg) + FAIL_PUTS_ERROR("'fake_arg' not updated"); + + /* Named datatypes must be destroyed differently */ + if (H5VL_SUBCLS_DATATYPE == subcls) { + H5T_t *dt; + + /* Destroy fake datatype object */ + if (NULL == (dt = H5I_remove(obj_id))) + TEST_ERROR; + if (H5VL_free_object(dt->vol_obj) < 0) + TEST_ERROR; + dt->vol_obj = NULL; + if (H5T_close(dt) < 0) + TEST_ERROR; + } /* end if */ + else { + /* Destroy fake object */ + if (NULL == (vol_obj = H5I_remove(obj_id))) + TEST_ERROR; + if (H5VL_free_object(vol_obj) < 0) + TEST_ERROR; + } /* end else */ + + /* Unregister 2nd registered optional operation */ + if (H5VLunregister_opt_operation(subcls, op_name) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + return FAIL; +} /* end exercise_reg_opt_oper() */ + +/*------------------------------------------------------------------------- + * Function: test_register_opt_operation() + * + * Purpose: Tests if we can load, register, and close a simple + * VOL connector. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_register_opt_operation(void) +{ + hid_t fake_vol_id = H5I_INVALID_HID; + hid_t reg_opt_vol_id = H5I_INVALID_HID; + struct { + H5VL_subclass_t subcls; + const char * subcls_name; + H5I_type_t id_type; + reg_opt_oper_t reg_opt_op; + } test_params[] = {{H5VL_SUBCLS_ATTR, "attr", H5I_ATTR, {.obj_op = H5VLattr_optional_op}}, + {H5VL_SUBCLS_DATASET, "dataset", H5I_DATASET, {.obj_op = H5VLdataset_optional_op}}, + {H5VL_SUBCLS_DATATYPE, "datatype", H5I_DATATYPE, {.obj_op = H5VLdatatype_optional_op}}, + {H5VL_SUBCLS_FILE, "file", H5I_FILE, {.obj_op = H5VLfile_optional_op}}, + {H5VL_SUBCLS_GROUP, "group", H5I_GROUP, {.obj_op = H5VLgroup_optional_op}}, + {H5VL_SUBCLS_LINK, "link", H5I_GROUP, {.link_op = H5VLlink_optional_op}}, + {H5VL_SUBCLS_OBJECT, "object", H5I_GROUP, {.link_op = H5VLobject_optional_op}}}; + int op_val = -1; + unsigned u; + herr_t ret = SUCCEED; + + TESTING("dynamically registering optional operations"); + + /* Register the VOL connectors for testing */ + if ((fake_vol_id = H5VLregister_connector(&fake_vol_g, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((reg_opt_vol_id = H5VLregister_connector(®_opt_vol_g, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Test registering invalid optional VOL subclass operations */ + H5E_BEGIN_TRY + { + ret = H5VLregister_opt_operation(H5VL_SUBCLS_NONE, "fail", &op_val); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to register an optional operation for the 'NONE' VOL subclass"); + if ((-1) != op_val) + FAIL_PUTS_ERROR("'op_val' changed during failed operation?"); + H5E_BEGIN_TRY + { + ret = H5VLregister_opt_operation(H5VL_SUBCLS_INFO, "fail2", &op_val); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to register an optional operation for the 'INFO' VOL subclass"); + if ((-1) != op_val) + FAIL_PUTS_ERROR("'op_val' changed during failed operation?"); + H5E_BEGIN_TRY + { + ret = H5VLregister_opt_operation(H5VL_SUBCLS_WRAP, "fail3", &op_val); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to register an optional operation for the 'WRAP' VOL subclass"); + if ((-1) != op_val) + FAIL_PUTS_ERROR("'op_val' changed during failed operation?"); + H5E_BEGIN_TRY + { + ret = H5VLregister_opt_operation(H5VL_SUBCLS_BLOB, "fail4", &op_val); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to register an optional operation for the 'BLOB' VOL subclass"); + if ((-1) != op_val) + FAIL_PUTS_ERROR("'op_val' changed during failed operation?"); + H5E_BEGIN_TRY + { + ret = H5VLregister_opt_operation(H5VL_SUBCLS_TOKEN, "fail5", &op_val); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to register an optional operation for the 'TOKEN' VOL subclass"); + if ((-1) != op_val) + FAIL_PUTS_ERROR("'op_val' changed during failed operation?"); + + /* Test registering valid optional VOL subclass operation with NULL op_val ptr*/ + H5E_BEGIN_TRY + { + ret = H5VLregister_opt_operation(H5VL_SUBCLS_FILE, "fail6", NULL); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to register an optional operation with a NULL 'op_val'"); + + /* Try finding a non-existent optional VOL subclass operation */ + H5E_BEGIN_TRY + { + ret = H5VLfind_opt_operation(H5VL_SUBCLS_DATASET, "fail", &op_val); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to find a non-existent optional operation"); + + /* Try unregistering a non-existent optional VOL subclass operation */ + H5E_BEGIN_TRY + { + ret = H5VLunregister_opt_operation(H5VL_SUBCLS_DATASET, "fail"); + } + H5E_END_TRY; + if (FAIL != ret) + FAIL_PUTS_ERROR("should not be able to unregister a non-existent optional operation"); + + /* Optional operations on requests are supported (but difficult to test further) */ + if (H5VLregister_opt_operation(H5VL_SUBCLS_REQUEST, "req_op", &op_val) < 0) + TEST_ERROR; + + /* Register & test calling optional operations for each valid VOL subclass */ + /* (Table-driven, with test_params array) */ + for (u = 0; u < NELMTS(test_params); u++) + /* Exercise appropriate callback, for each VOL subclass */ + if (exercise_reg_opt_oper(fake_vol_id, reg_opt_vol_id, test_params[u].subcls, + test_params[u].subcls_name, test_params[u].id_type, + test_params[u].reg_opt_op) < 0) + TEST_ERROR; + + /* Unregister the VOL connectors */ + if (H5VLunregister_connector(fake_vol_id) < 0) + TEST_ERROR; + if (H5VLunregister_connector(reg_opt_vol_id) < 0) + TEST_ERROR; + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5VLunregister_connector(fake_vol_id); + H5VLunregister_connector(reg_opt_vol_id); + } + H5E_END_TRY; + + return FAIL; +} /* end test_register_opt_operation() */ + +/*------------------------------------------------------------------------- + * Function: test_async_vol_props() + * + * Purpose: Test properties related to asynchronous VOL connector operation + * + * Note: Overrides the HDF5_VOL_CONNECTOR environment variable, to + * provide stable testing environment. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_async_vol_props(void) +{ + hid_t fapl_id = H5I_INVALID_HID; + hid_t vol_id = H5I_INVALID_HID; + H5VL_pass_through_info_t passthru_info; + unsigned cap_flags = 0; + char * conn_env_str = NULL; + + TESTING("Async VOL props"); + + /* Retrieve the file access property for testing */ + fapl_id = h5_fileaccess(); + + /* Test 'capability flags' property */ + + /* Test query w/NULL for cap_flags parameter */ + if (H5Pget_vol_cap_flags(fapl_id, NULL) < 0) + FAIL_STACK_ERROR; + + /* Override possible environment variable & re-initialize default VOL connector */ + conn_env_str = HDgetenv("HDF5_VOL_CONNECTOR"); + if (conn_env_str) { + if (NULL == (conn_env_str = HDstrdup(conn_env_str))) + TEST_ERROR + if (HDunsetenv("HDF5_VOL_CONNECTOR") < 0) + TEST_ERROR + if (H5VL__reparse_def_vol_conn_variable_test() < 0) + TEST_ERROR + } /* end if */ + + /* Test query w/default VOL, which should indicate no async, since native connector + * doesn't support async. + */ + if (H5Pget_vol_cap_flags(fapl_id, &cap_flags) < 0) + FAIL_STACK_ERROR; + if ((cap_flags & H5VL_CAP_FLAG_ASYNC) > 0) + TEST_ERROR + if ((cap_flags & H5VL_CAP_FLAG_NATIVE_FILES) == 0) + TEST_ERROR + + /* Close FAPL */ + if (H5Pclose(fapl_id) < 0) + FAIL_STACK_ERROR; + + /* Register a fake VOL connector that sets the async capability flag */ + if ((vol_id = H5VLregister_connector(&fake_async_vol_g, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Set environment variable to use 'fake async' connector & re-init default connector */ + if (HDsetenv("HDF5_VOL_CONNECTOR", "fake_async", TRUE) < 0) + TEST_ERROR + if (H5VL__reparse_def_vol_conn_variable_test() < 0) + TEST_ERROR + + /* Retrieve the file access property again */ + fapl_id = h5_fileaccess(); + + /* Test query w/fake async VOL, which should succeed */ + cap_flags = 0; + if (H5Pget_vol_cap_flags(fapl_id, &cap_flags) < 0) + FAIL_STACK_ERROR; + if ((cap_flags & H5VL_CAP_FLAG_ASYNC) == 0) + TEST_ERROR + if ((cap_flags & H5VL_CAP_FLAG_NATIVE_FILES) > 0) + TEST_ERROR + + /* Reset environment variable & re-init default connector */ + if (HDunsetenv("HDF5_VOL_CONNECTOR") < 0) + TEST_ERROR + if (H5VL__reparse_def_vol_conn_variable_test() < 0) + TEST_ERROR + + /* Close FAPL */ + if (H5Pclose(fapl_id) < 0) + FAIL_STACK_ERROR; + + /* Retrieve the file access property again */ + fapl_id = h5_fileaccess(); + + /* Set the VOL connector for the FAPL to the fake async connector */ + if (H5Pset_vol(fapl_id, vol_id, NULL) < 0) + FAIL_STACK_ERROR; + + /* Test query w/fake async VOL, which should succeed */ + cap_flags = 0; + if (H5Pget_vol_cap_flags(fapl_id, &cap_flags) < 0) + FAIL_STACK_ERROR; + if ((cap_flags & H5VL_CAP_FLAG_ASYNC) == 0) + TEST_ERROR + if ((cap_flags & H5VL_CAP_FLAG_NATIVE_FILES) > 0) + TEST_ERROR + + /* Stack the [internal] passthrough VOL connector on top of the fake async connector */ + passthru_info.under_vol_id = vol_id; + passthru_info.under_vol_info = NULL; + if (H5Pset_vol(fapl_id, H5VL_PASSTHRU, &passthru_info) < 0) + FAIL_STACK_ERROR; + + /* Test query w/passthru -> fake async VOL, which should succeed */ + cap_flags = 0; + if (H5Pget_vol_cap_flags(fapl_id, &cap_flags) < 0) + FAIL_STACK_ERROR; + if ((cap_flags & H5VL_CAP_FLAG_ASYNC) == 0) + TEST_ERROR + if ((cap_flags & H5VL_CAP_FLAG_NATIVE_FILES) > 0) + TEST_ERROR + + /* Unregister the fake async VOL ID */ + if (H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + /* Close FAPL */ + if (H5Pclose(fapl_id) < 0) + FAIL_STACK_ERROR; + + /* Restore environment variable, if there was one */ + if (conn_env_str) { + if (HDsetenv("HDF5_VOL_CONNECTOR", conn_env_str, TRUE) < 0) + TEST_ERROR + HDfree(conn_env_str); + + if (H5VL__reparse_def_vol_conn_variable_test() < 0) + TEST_ERROR + } /* end if */ + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl_id); + H5VLunregister_connector(vol_id); + } + H5E_END_TRY; + HDfree(conn_env_str); + + return FAIL; +} /* end test_async_vol_props() */ + /*------------------------------------------------------------------------- * Function: main * @@ -1201,6 +2121,7 @@ main(void) HDputs("Testing basic Virtual Object Layer (VOL) functionality."); nerrors += test_vol_registration() < 0 ? 1 : 0; + nerrors += test_register_opt_operation() < 0 ? 1 : 0; nerrors += test_native_vol_init() < 0 ? 1 : 0; nerrors += test_basic_file_operation(env_h5_drvr) < 0 ? 1 : 0; nerrors += test_basic_group_operation() < 0 ? 1 : 0; @@ -1209,6 +2130,7 @@ main(void) nerrors += test_basic_object_operation() < 0 ? 1 : 0; nerrors += test_basic_link_operation() < 0 ? 1 : 0; nerrors += test_basic_datatype_operation() < 0 ? 1 : 0; + nerrors += test_async_vol_props() < 0 ? 1 : 0; if (nerrors) { HDprintf("***** %d Virtual Object Layer TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); diff --git a/testpar/t_filters_parallel.c b/testpar/t_filters_parallel.c index 5153bce..50cd306 100644 --- a/testpar/t_filters_parallel.c +++ b/testpar/t_filters_parallel.c @@ -1762,8 +1762,8 @@ test_write_3d_filtered_dataset_overlap(void) WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) / (hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - /* Add the amount that gets added when a rank moves down to its next section vertically in the - dataset */ + /* Add the amount that gets added when a rank moves down to its next + section vertically in the dataset */ + ((hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS) * (i / (hsize_t)(mpi_size * WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)))); @@ -4497,8 +4497,8 @@ test_read_3d_filtered_dataset_overlap(void) READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) / (hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - /* Add the amount that gets added when a rank moves down to its next section vertically in the - dataset */ + /* Add the amount that gets added when a rank moves down to its next + section vertically in the dataset */ + ((hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS) * (i / (hsize_t)(mpi_size * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)))); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index eee9c53..41bea54 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -21,6 +21,7 @@ #include "h5tools_ref.h" #include "h5tools_utils.h" #include "H5private.h" +#include "hdf5dev.h" #ifdef H5_TOOLS_DEBUG /* global debug variables */ diff --git a/tools/test/h5copy/dynlib_copy.c b/tools/test/h5copy/dynlib_copy.c index b954a22..e7d074d 100644 --- a/tools/test/h5copy/dynlib_copy.c +++ b/tools/test/h5copy/dynlib_copy.c @@ -15,7 +15,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 diff --git a/tools/test/h5diff/dynlib_diff.c b/tools/test/h5diff/dynlib_diff.c index 433522d..61abb90 100644 --- a/tools/test/h5diff/dynlib_diff.c +++ b/tools/test/h5diff/dynlib_diff.c @@ -15,7 +15,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c index f03254e..58d6129 100644 --- a/tools/test/h5diff/h5diffgentest.c +++ b/tools/test/h5diff/h5diffgentest.c @@ -13,6 +13,7 @@ #include "hdf5.h" #include "H5private.h" +#include "hdf5dev.h" /* * The output functions need a temporary buffer to hold a piece of the diff --git a/tools/test/h5dump/dynlib_dump.c b/tools/test/h5dump/dynlib_dump.c index 433522d..61abb90 100644 --- a/tools/test/h5dump/dynlib_dump.c +++ b/tools/test/h5dump/dynlib_dump.c @@ -15,7 +15,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 diff --git a/tools/test/h5jam/h5jamgentest.c b/tools/test/h5jam/h5jamgentest.c index 1da6b63..cea4e76 100644 --- a/tools/test/h5jam/h5jamgentest.c +++ b/tools/test/h5jam/h5jamgentest.c @@ -23,6 +23,7 @@ #include "hdf5.h" #include "H5private.h" +#include "hdf5dev.h" /* not used yet #define UBTXT1 "u0.txt" diff --git a/tools/test/h5ls/dynlib_ls.c b/tools/test/h5ls/dynlib_ls.c index 433522d..61abb90 100644 --- a/tools/test/h5ls/dynlib_ls.c +++ b/tools/test/h5ls/dynlib_ls.c @@ -15,7 +15,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define H5Z_FILTER_DYNLIBUD 300 #define MULTIPLIER 3 diff --git a/tools/test/h5repack/dynlib_rpk.c b/tools/test/h5repack/dynlib_rpk.c index b228344..0fa0642 100644 --- a/tools/test/h5repack/dynlib_rpk.c +++ b/tools/test/h5repack/dynlib_rpk.c @@ -18,7 +18,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define H5Z_FILTER_DYNLIB1 257 diff --git a/tools/test/h5repack/dynlib_vrpk.c b/tools/test/h5repack/dynlib_vrpk.c index 5eac4f2..454ae49 100644 --- a/tools/test/h5repack/dynlib_vrpk.c +++ b/tools/test/h5repack/dynlib_vrpk.c @@ -15,7 +15,7 @@ #include #include -#include "H5PLextern.h" +#include "hdf5dev.h" #define H5Z_FILTER_DYNLIB4 260 diff --git a/tools/test/perform/chunk.c b/tools/test/perform/chunk.c index 1b08e95..209fd43 100644 --- a/tools/test/perform/chunk.c +++ b/tools/test/perform/chunk.c @@ -21,8 +21,8 @@ */ /* See H5private.h for how to include headers */ -#undef NDEBUG #include "hdf5.h" +#include "hdf5dev.h" #include #include diff --git a/utils/mirror_vfd/mirror_remote.h b/utils/mirror_vfd/mirror_remote.h index 6f37b0b..7a72372 100644 --- a/utils/mirror_vfd/mirror_remote.h +++ b/utils/mirror_vfd/mirror_remote.h @@ -16,6 +16,7 @@ */ #include "hdf5.h" +#include "hdf5dev.h" #include "H5private.h" #ifdef H5_HAVE_MIRROR_VFD -- cgit v0.12