diff options
Diffstat (limited to 'src')
77 files changed, 2124 insertions, 984 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 565e030..2a31609 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT (HDF5_SRC C CXX) #----------------------------------------------------------------------------- # Apply Definitions to compiler in this directory and below #----------------------------------------------------------------------------- -add_definitions (${HDF5_EXTRA_C_FLAGS}) +add_definitions (${HDF_EXTRA_C_FLAGS}) #----------------------------------------------------------------------------- # List Source Files @@ -783,8 +783,16 @@ set (H5_PRIVATE_HEADERS # Setup the H5Detect utility which generates H5Tinit with platform # specific type checks inside #----------------------------------------------------------------------------- -add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) -TARGET_C_PROPERTIES (H5detect " " " ") +#add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) +#TARGET_C_PROPERTIES (H5detect " " " ") +IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + SET (LOCAL_OPT_FLAG "-O0") +ELSE (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + SET (LOCAL_OPT_FLAG " ") +ENDIF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +ADD_EXECUTABLE (H5detect ${HDF5_SRC_DIR}/H5detect.c) +TARGET_C_PROPERTIES (H5detect ${LOCAL_OPT_FLAG} " ") + if (MSVC OR MINGW) target_link_libraries (H5detect "ws2_32.lib") endif (MSVC OR MINGW) @@ -812,26 +820,43 @@ add_custom_command ( WORKING_DIRECTORY ${HDF5_BINARY_DIR} ) -add_custom_command ( - TARGET ${HDF5_BINARY_DIR}/H5Edefin.h - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E perl ${HDF5_SOURCE_DIR}/bin/make_err ${HDF5_SOURCE_DIR}/src/H5err.txt - COMMENT " Creating err headers" -) - -add_custom_command ( - TARGET ${HDF5_BINARY_DIR}/H5version.h - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E perl ${HDF5_SOURCE_DIR}/bin/make_vers ${HDF5_SOURCE_DIR}/src/H5vers.txt - COMMENT " Creating API version macro" -) - -add_custom_command ( - TARGET ${HDF5_BINARY_DIR}/H5overflow.h - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E perl ${HDF5_SOURCE_DIR}/bin/make_overflow ${HDF5_SOURCE_DIR}/src/H5overflow.txt - COMMENT " Creating Assignment overflow macro" -) +if (GENERATE_ERROR_HEADERS) + find_pacakge (Perl) + if (PERL_FOUND) + add_custom_command ( + OUTPUT ${HDF5_BINARY_DIR}/H5Edefin.h + PRE_BUILD + COMMAND ${PERL_EXECUTABLE} + ARGS ${HDF5_SOURCE_DIR}/bin/make_err ${HDF5_SOURCE_DIR}/src/H5err.txt + DEPENDS ${HDF5_SOURCE_DIR}/src/H5err.txt + COMMENT " Creating err header" + ) + + add_custom_command ( + OUTPUT ${HDF5_BINARY_DIR}/H5version.h + PRE_BUILD + COMMAND ${PERL_EXECUTABLE} + ARGS ${HDF5_SOURCE_DIR}/bin/make_vers ${HDF5_SOURCE_DIR}/src/H5vers.txt + DEPENDS ${HDF5_SOURCE_DIR}/src/H5vers.txt + COMMENT " Creating API version macro" + ) + + add_custom_command ( + OUTPUT ${HDF5_BINARY_DIR}/H5overflow.h + PRE_BUILD + COMMAND ${PERL_EXECUTABLE} + ARGS ${HDF5_SOURCE_DIR}/bin/make_overflow ${HDF5_SOURCE_DIR}/src/H5overflow.txt + DEPENDS ${HDF5_SOURCE_DIR}/src/H5overflow.txt + COMMENT " Creating Assignment overflow macro" + ) + + add_custom_target(run_perl_scripts ALL + DEPENDS ${HDF5_BINARY_DIR}/H5Edefin.h ${HDF5_BINARY_DIR}/H5version.h ${HDF5_BINARY_DIR}/H5overflow.h + ) + else (PERL_FOUND) + message (STATUS "Cannot generate headers - perl not found") + endif (PERL_FOUND) +endif (GENERATE_ERROR_HEADERS) #----------------------------------------------------------------------------- # Add H5Tinit source to build - generated by H5Detect/CMake at configure time @@ -152,13 +152,23 @@ H5_init_library(void) #endif /* - * Install atexit() library cleanup routine unless the H5dont_atexit() + * Install atexit() library cleanup routines unless the H5dont_atexit() * has been called. Once we add something to the atexit() list it stays * there permanently, so we set H5_dont_atexit_g after we add it to prevent * adding it again later if the library is cosed and reopened. */ if (!H5_dont_atexit_g) { - (void)HDatexit(H5_term_library); + +#if defined(H5_HAVE_THREADSAFE) && defined(H5_HAVE_WIN_THREADS) + /* Clean up Win32 thread resources. Pthreads automatically cleans up. + * This must be entered before the library cleanup code so it's + * executed in LIFO order (i.e., last). + */ + (void)HDatexit(H5TS_win32_process_exit); +#endif /* H5_HAVE_THREADSAFE && H5_HAVE_WIN_THREADS */ + + /* Normal library termination code */ + (void)HDatexit(H5_term_library); H5_dont_atexit_g = TRUE; } /* end if */ @@ -333,7 +343,7 @@ H5_term_library(void) done: #ifdef H5_HAVE_THREADSAFE H5_API_UNLOCK -#endif +#endif /* H5_HAVE_THREADSAFE */ return; } /* end H5_term_library() */ @@ -834,3 +844,60 @@ H5free_memory(void *mem) FUNC_LEAVE_API(SUCCEED) } /* end H5free_memory() */ + +#ifdef H5_HAVE_WIN32_API +/*------------------------------------------------------------------------- + * Function: DllMain + * + * Purpose: Handles various conditions in the library on Windows. + * + * NOTE: The main purpose of this is for handling Win32 thread cleanup + * on thread/process detach. + * + * Return: TRUE on success, FALSE on failure + * + *------------------------------------------------------------------------- + */ +BOOL WINAPI +DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved) +{ + /* Don't add our function enter/leave macros since this function will be + * called before the library is initialized. + * + * NOTE: Do NOT call any CRT functions in DllMain! + * This includes any functions that are called by from here! + */ + + BOOL fOkay = TRUE; + + switch(fdwReason) + { + case DLL_PROCESS_ATTACH: + break; + + case DLL_PROCESS_DETACH: + break; + + case DLL_THREAD_ATTACH: +#ifdef H5_HAVE_WIN_THREADS + if(H5TS_win32_thread_enter() < 0) + fOkay = FALSE; +#endif /* H5_HAVE_WIN_THREADS */ + break; + + case DLL_THREAD_DETACH: +#ifdef H5_HAVE_WIN_THREADS + if(H5TS_win32_thread_exit() < 0) + fOkay = FALSE; +#endif /* H5_HAVE_WIN_THREADS */ + break; + + default: + /* Shouldn't get here */ + fOkay = FALSE; + break; + } + + return fOkay; +} +#endif /* H5_HAVE_WIN32_API */ @@ -183,6 +183,9 @@ H5A_term_interface(void) if((n = H5I_nmembers(H5I_ATTR))>0) { (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); } else { + /* Close deprecated interface */ + n += H5A__term_deprec_interface(); + (void)H5I_dec_type_ref(H5I_ATTR); H5_interface_initialize_g = 0; n = 1; @@ -810,7 +813,7 @@ H5Aget_create_plist(hid_t attr_id) FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", attr_id); - HDassert(H5P_LST_ATTRIBUTE_CREATE_g != -1); + HDassert(H5P_LST_ATTRIBUTE_CREATE_ID_g != -1); /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id))) @@ -820,7 +823,8 @@ H5Aget_create_plist(hid_t attr_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") /* get the acpl through the VOL */ - if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_ACPL, H5AC_dxpl_id, H5_EVENT_STACK_NULL, &ret_value) < 0) + if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_ACPL, H5AC_dxpl_id, + H5_EVENT_STACK_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get acpl") done: @@ -114,6 +114,7 @@ static hid_t H5AC_noblock_dxpl_id=(-1); /* Dataset transfer property list for independent metadata I/O calls */ /* (just "library internal" set - i.e. independent transfer mode) */ /* (Global variable definition, declaration is in H5ACprivate.h also) */ +H5P_genplist_t *H5AC_ind_dxpl_g = NULL; hid_t H5AC_ind_dxpl_id=(-1); @@ -165,8 +166,7 @@ static herr_t H5AC_log_moved_entry(const H5F_t * f, haddr_t old_addr, haddr_t new_addr); -static herr_t H5AC_log_inserted_entry(H5F_t * f, - H5AC_t * cache_ptr, +static herr_t H5AC_log_inserted_entry(H5AC_t * cache_ptr, H5AC_info_t * entry_ptr); static herr_t H5AC_propagate_and_apply_candidate_list(H5F_t * f, @@ -256,30 +256,25 @@ static herr_t H5AC_init_interface(void) { #ifdef H5_HAVE_PARALLEL - H5P_genclass_t *xfer_pclass; /* Dataset transfer property list class object */ H5P_genplist_t *xfer_plist; /* Dataset transfer property list object */ unsigned block_before_meta_write; /* "block before meta write" property value */ unsigned coll_meta_write; /* "collective metadata write" property value */ - unsigned library_internal=1; /* "library internal" property value */ - H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode property value */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned library_internal = 1; /* "library internal" property value */ +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT +#ifdef H5_HAVE_PARALLEL /* Sanity check */ - HDassert(H5P_CLS_DATASET_XFER_g!=(-1)); - - /* Get the dataset transfer property list class object */ - if (NULL == (xfer_pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) - HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list class") - + HDassert(H5P_CLS_DATASET_XFER_g != NULL); /* Get an ID for the blocking, collective H5AC dxpl */ - if ((H5AC_dxpl_id=H5P_create_id(xfer_pclass,FALSE)) < 0) + if((H5AC_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ - if (NULL == (xfer_plist = H5I_object(H5AC_dxpl_id))) + if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'block before metadata write' property */ @@ -301,11 +296,11 @@ H5AC_init_interface(void) /* Get an ID for the non-blocking, collective H5AC dxpl */ - if ((H5AC_noblock_dxpl_id=H5P_create_id(xfer_pclass,FALSE)) < 0) + if((H5AC_noblock_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ - if (NULL == (xfer_plist = H5I_object(H5AC_noblock_dxpl_id))) + if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_noblock_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'block before metadata write' property */ @@ -327,45 +322,45 @@ H5AC_init_interface(void) /* Get an ID for the non-blocking, independent H5AC dxpl */ - if ((H5AC_ind_dxpl_id=H5P_create_id(xfer_pclass,FALSE)) < 0) + if((H5AC_ind_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ - if (NULL == (xfer_plist = H5I_object(H5AC_ind_dxpl_id))) + if(NULL == (H5AC_ind_dxpl_g = (H5P_genplist_t *)H5I_object(H5AC_ind_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'block before metadata write' property */ block_before_meta_write=0; - if(H5P_insert(xfer_plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,H5AC_BLOCK_BEFORE_META_WRITE_SIZE,&block_before_meta_write, - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) + if(H5P_insert(H5AC_ind_dxpl_g, H5AC_BLOCK_BEFORE_META_WRITE_NAME, H5AC_BLOCK_BEFORE_META_WRITE_SIZE, &block_before_meta_write, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Insert 'library internal' property */ - if(H5P_insert(xfer_plist,H5AC_LIBRARY_INTERNAL_NAME,H5AC_LIBRARY_INTERNAL_SIZE,&library_internal, - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) + if(H5P_insert(H5AC_ind_dxpl_g, H5AC_LIBRARY_INTERNAL_NAME, H5AC_LIBRARY_INTERNAL_SIZE, &library_internal, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") /* Insert 'collective metadata write' property */ coll_meta_write = 0; - if(H5P_insert(xfer_plist, H5AC_COLLECTIVE_META_WRITE_NAME, H5AC_COLLECTIVE_META_WRITE_SIZE, &coll_meta_write, + if(H5P_insert(H5AC_ind_dxpl_g, H5AC_COLLECTIVE_META_WRITE_NAME, H5AC_COLLECTIVE_META_WRITE_SIZE, &coll_meta_write, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property") -done: - FUNC_LEAVE_NOAPI(ret_value) - #else /* H5_HAVE_PARALLEL */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Sanity check */ - HDassert(H5P_LST_DATASET_XFER_g!=(-1)); + HDassert(H5P_LST_DATASET_XFER_ID_g!=(-1)); H5AC_dxpl_id = H5P_DATASET_XFER_DEFAULT; H5AC_noblock_dxpl_id = H5P_DATASET_XFER_DEFAULT; H5AC_ind_dxpl_id = H5P_DATASET_XFER_DEFAULT; - FUNC_LEAVE_NOAPI(SUCCEED) + /* Get the property list objects for the IDs */ + if (NULL == (H5AC_ind_dxpl_g = (H5P_genplist_t *)H5I_object(H5AC_ind_dxpl_id))) + HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list object") #endif /* H5_HAVE_PARALLEL */ + +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_init_interface() */ @@ -1013,7 +1008,7 @@ H5AC_insert_entry(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t add if(NULL != (aux_ptr = (H5AC_aux_t *)f->shared->cache->aux_ptr)) { /* Log the new entry */ - if(H5AC_log_inserted_entry(f, f->shared->cache, (H5AC_info_t *)thing) < 0) + if(H5AC_log_inserted_entry(f->shared->cache, (H5AC_info_t *)thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC_log_inserted_entry() failed") /* Check if we should try to flush */ @@ -1631,7 +1626,6 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, hbool_t dirtied; hbool_t deleted; #ifdef H5_HAVE_PARALLEL - hbool_t size_changed = FALSE; H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ #if H5AC__TRACE_FILE_ENABLED @@ -1746,7 +1740,7 @@ H5AC_set_sync_point_done_callback(H5C_t * cache_ptr, { H5AC_aux_t * aux_ptr; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(cache_ptr && (cache_ptr->magic == H5C__H5C_T_MAGIC)); @@ -1783,7 +1777,7 @@ H5AC_set_write_done_callback(H5C_t * cache_ptr, { H5AC_aux_t * aux_ptr; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(cache_ptr && (cache_ptr->magic == H5C__H5C_T_MAGIC)); @@ -2631,7 +2625,6 @@ H5AC_broadcast_candidate_list(H5AC_t * cache_ptr, int * num_entries_ptr, haddr_t ** haddr_buf_ptr_ptr) { - herr_t result; hbool_t success = FALSE; H5AC_aux_t * aux_ptr = NULL; haddr_t * haddr_buf_ptr = NULL; @@ -2801,7 +2794,7 @@ H5AC_broadcast_clean_list(H5AC_t * cache_ptr) */ if ( aux_ptr->sync_point_done != NULL ) { - addr_buf_ptr = H5MM_malloc((size_t)(num_entries * sizeof(haddr_t))); + addr_buf_ptr = H5MM_malloc((size_t)num_entries * sizeof(haddr_t)); if ( addr_buf_ptr == NULL ) { @@ -2899,7 +2892,7 @@ done: if(buf_ptr != NULL) buf_ptr = (MPI_Offset *)H5MM_xfree((void *)buf_ptr); if(addr_buf_ptr != NULL) - addr_buf_ptr = (MPI_Offset *)H5MM_xfree((void *)addr_buf_ptr); + addr_buf_ptr = (haddr_t *)H5MM_xfree((void *)addr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_broadcast_clean_list() */ @@ -3633,8 +3626,7 @@ done: */ #ifdef H5_HAVE_PARALLEL static herr_t -H5AC_log_inserted_entry(H5F_t * f, - H5AC_t * cache_ptr, +H5AC_log_inserted_entry(H5AC_t * cache_ptr, H5AC_info_t * entry_ptr) { H5AC_aux_t * aux_ptr; diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 3060a70..ad768ef 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -70,8 +70,6 @@ #define H5AC__MAX_DIRTY_BYTES_THRESHOLD (int32_t) \ (H5C__MAX_MAX_CACHE_SIZE / 4) -#define H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ - H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED /**************************************************************************** * diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index a2224af..ca6dcbf 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -34,6 +34,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Cprivate.h" /* Cache */ #include "H5Fprivate.h" /* File access */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_METADATA_TRACE_FILE #define H5AC__TRACE_FILE_ENABLED 1 @@ -222,6 +223,7 @@ extern hid_t H5AC_dxpl_id; /* Dataset transfer property list for independent metadata I/O calls */ /* (just "library internal" set - i.e. independent transfer mode) */ /* (Global variable declaration, definition is in H5AC.c) */ +H5_DLLVAR H5P_genplist_t *H5AC_ind_dxpl_g; H5_DLLVAR hid_t H5AC_ind_dxpl_id; diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index e36ca69..45e5e05 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -106,6 +106,30 @@ H5A__init_deprec_interface(void) FUNC_LEAVE_NOAPI(H5A_init()) } /* H5A__init_deprec_interface() */ + +/*-------------------------------------------------------------------------- +NAME + H5A__term_deprec_interface -- Terminate interface +USAGE + herr_t H5A__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5A__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5A__term_deprec_interface() */ + #ifndef H5_NO_DEPRECATED_SYMBOLS /*-------------------------------------------------------------------------- diff --git a/src/H5Aint.c b/src/H5Aint.c index ba900d9..e78376d 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -820,7 +820,7 @@ H5A_get_create_plist(H5A_t* attr) hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT - if(NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_g))) + if(NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_ID_g))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get default ACPL") /* Create the property list object to return */ diff --git a/src/H5Apkg.h b/src/H5Apkg.h index c9411d5..4fd8c6e 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -187,6 +187,7 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1]; H5_DLL herr_t H5A_init(void); H5_DLL H5A_t *H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id); +H5_DLL herr_t H5A__term_deprec_interface(void); H5_DLL H5A_t *H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, hid_t lapl_id, hid_t dxpl_id); H5_DLL H5A_t *H5A_open_by_idx(const H5G_loc_t *loc, const char *obj_name, @@ -1240,8 +1240,8 @@ H5C_create(size_t max_cache_size, (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; - (cache_ptr->resize_ctl).flash_multiple = 1.0; - (cache_ptr->resize_ctl).flash_threshold = 0.25; + (cache_ptr->resize_ctl).flash_multiple = 1.0f; + (cache_ptr->resize_ctl).flash_threshold = 0.25f; (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; @@ -2392,7 +2392,7 @@ H5C_get_cache_hit_rate(H5C_t * cache_ptr, } else { - *hit_rate_ptr = 0.0; + *hit_rate_ptr = 0.0f; } done: @@ -4273,8 +4273,8 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, break; case H5C_incr__threshold: - if ( ( config_ptr->lower_hr_threshold <= 0.0 ) || - ( config_ptr->increment <= 1.0 ) || + if ( ( config_ptr->lower_hr_threshold <= (double)0.0f ) || + ( config_ptr->increment <= (double)1.0f ) || ( ( config_ptr->apply_max_increment ) && ( config_ptr->max_increment <= 0 ) ) ) { @@ -4298,8 +4298,8 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, break; case H5C_decr__threshold: - if ( ( config_ptr->upper_hr_threshold >= 1.0 ) || - ( config_ptr->decrement >= 1.0 ) || + if ( ( config_ptr->upper_hr_threshold >= (double)1.0f ) || + ( config_ptr->decrement >= (double)1.0f ) || ( ( config_ptr->apply_max_decrement ) && ( config_ptr->max_decrement <= 0 ) ) ) { @@ -4309,7 +4309,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, case H5C_decr__age_out: if ( ( ( config_ptr->apply_empty_reserve ) && - ( config_ptr->empty_reserve >= 1.0 ) ) || + ( config_ptr->empty_reserve >= (double)1.0f ) ) || ( ( config_ptr->apply_max_decrement ) && ( config_ptr->max_decrement <= 0 ) ) ) { @@ -4319,10 +4319,10 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, case H5C_decr__age_out_with_threshold: if ( ( ( config_ptr->apply_empty_reserve ) && - ( config_ptr->empty_reserve >= 1.0 ) ) || + ( config_ptr->empty_reserve >= (double)1.0f ) ) || ( ( config_ptr->apply_max_decrement ) && ( config_ptr->max_decrement <= 0 ) ) || - ( config_ptr->upper_hr_threshold >= 1.0 ) ) { + ( config_ptr->upper_hr_threshold >= (double)1.0f ) ) { cache_ptr->size_decrease_possible = FALSE; } @@ -5814,8 +5814,8 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, "initial_size must be in the interval [min_size, max_size]"); } - if ( ( config_ptr->min_clean_fraction < 0.0 ) || - ( config_ptr->min_clean_fraction > 1.0 ) ) { + if ( ( config_ptr->min_clean_fraction < (double)0.0f ) || + ( config_ptr->min_clean_fraction > (double)1.0f ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "min_clean_fraction must be in the interval [0.0, 1.0]"); @@ -5843,14 +5843,14 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, if ( config_ptr->incr_mode == H5C_incr__threshold ) { - if ( ( config_ptr->lower_hr_threshold < 0.0 ) || - ( config_ptr->lower_hr_threshold > 1.0 ) ) { + if ( ( config_ptr->lower_hr_threshold < (double)0.0f ) || + ( config_ptr->lower_hr_threshold > (double)1.0f ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "lower_hr_threshold must be in the range [0.0, 1.0]"); } - if ( config_ptr->increment < 1.0 ) { + if ( config_ptr->increment < (double)1.0f ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "increment must be greater than or equal to 1.0"); @@ -5875,15 +5875,15 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, break; case H5C_flash_incr__add_space: - if ( ( config_ptr->flash_multiple < 0.1 ) || - ( config_ptr->flash_multiple > 10.0 ) ) { + if ( ( config_ptr->flash_multiple < (double)0.1f ) || + ( config_ptr->flash_multiple > (double)10.0f ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "flash_multiple must be in the range [0.1, 10.0]"); } - if ( ( config_ptr->flash_threshold < 0.1 ) || - ( config_ptr->flash_threshold > 1.0 ) ) { + if ( ( config_ptr->flash_threshold < (double)0.1f ) || + ( config_ptr->flash_threshold > (double)1.0f ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "flash_threshold must be in the range [0.1, 1.0]"); @@ -5911,14 +5911,14 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, if ( config_ptr->decr_mode == H5C_decr__threshold ) { - if ( config_ptr->upper_hr_threshold > 1.0 ) { + if ( config_ptr->upper_hr_threshold > (double)1.0f ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "upper_hr_threshold must be <= 1.0"); } - if ( ( config_ptr->decrement > 1.0 ) || - ( config_ptr->decrement < 0.0 ) ) { + if ( ( config_ptr->decrement > (double)1.0f ) || + ( config_ptr->decrement < (double)0.0f ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "decrement must be in the interval [0.0, 1.0]"); @@ -5953,8 +5953,8 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, } if ( ( config_ptr->apply_empty_reserve ) && - ( ( config_ptr->empty_reserve > 1.0 ) || - ( config_ptr->empty_reserve < 0.0 ) ) ) { + ( ( config_ptr->empty_reserve > (double)1.0f ) || + ( config_ptr->empty_reserve < (double)0.0f ) ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "empty_reserve must be in the interval [0.0, 1.0]"); @@ -5967,8 +5967,8 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, if ( config_ptr->decr_mode == H5C_decr__age_out_with_threshold ) { - if ( ( config_ptr->upper_hr_threshold > 1.0 ) || - ( config_ptr->upper_hr_threshold < 0.0 ) ) { + if ( ( config_ptr->upper_hr_threshold > (double)1.0f ) || + ( config_ptr->upper_hr_threshold < (double)0.0f ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "upper_hr_threshold must be in the interval [0.0, 1.0]"); @@ -6399,8 +6399,8 @@ H5C__auto_adjust_cache_size(H5F_t * f, HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length ); - HDassert( 0.0 <= (cache_ptr->resize_ctl).min_clean_fraction ); - HDassert( (cache_ptr->resize_ctl).min_clean_fraction <= 100.0 ); + HDassert( (double)0.0f <= (cache_ptr->resize_ctl).min_clean_fraction ); + HDassert( (cache_ptr->resize_ctl).min_clean_fraction <= (double)100.0f ); if ( !cache_ptr->resize_enabled ) { @@ -6415,7 +6415,7 @@ H5C__auto_adjust_cache_size(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate.") } - HDassert( ( 0.0 <= hit_rate ) && ( hit_rate <= 1.0 ) ); + HDassert( ( (double)0.0f <= hit_rate ) && ( hit_rate <= (double)1.0f ) ); switch ( (cache_ptr->resize_ctl).incr_mode ) { @@ -83,12 +83,16 @@ H5CS_get_stack(void) fstack = H5TS_get_thread_local_value(H5TS_funcstk_key_g); if (!fstack) { - /* no associated value with current thread - create one */ - fstack = (H5CS_t *)HDmalloc(sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ + /* No associated value with current thread - create one */ +#ifdef H5_HAVE_WIN_THREADS + fstack = (H5CS_t *)LocalAlloc(LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ +#else + fstack = (H5CS_t *)HDmalloc(sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ +#endif /* H5_HAVE_WIN_THREADS */ HDassert(fstack); /* Set the thread-specific info */ - fstack->nused=0; + fstack->nused=0; /* (It's not necessary to release this in this API, it is * released by the "key destructor" set up in the H5TS diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 7fde69b..433411f 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -905,20 +905,20 @@ typedef struct H5C_cache_entry_t #define H5C__MAX_EPOCH_MARKERS 10 -#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999 -#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9 +#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999f +#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9f #define H5C__DEF_AR_MAX_SIZE ((size_t)(16 * 1024 * 1024)) #define H5C__DEF_AR_INIT_SIZE ((size_t)( 1 * 1024 * 1024)) #define H5C__DEF_AR_MIN_SIZE ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5 -#define H5C__DEF_AR_INCREMENT 2.0 +#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5f +#define H5C__DEF_AR_INCREMENT 2.0f #define H5C__DEF_AR_MAX_INCREMENT ((size_t)( 2 * 1024 * 1024)) -#define H5C__DEF_AR_FLASH_MULTIPLE 1.0 -#define H5C__DEV_AR_FLASH_THRESHOLD 0.25 -#define H5C__DEF_AR_DECREMENT 0.9 +#define H5C__DEF_AR_FLASH_MULTIPLE 1.0f +#define H5C__DEV_AR_FLASH_THRESHOLD 0.25f +#define H5C__DEF_AR_DECREMENT 0.9f #define H5C__DEF_AR_MAX_DECREMENT ((size_t)( 1 * 1024 * 1024)) #define H5C__DEF_AR_EPCHS_B4_EVICT 3 -#define H5C__DEF_AR_EMPTY_RESERVE 0.05 +#define H5C__DEF_AR_EMPTY_RESERVE 0.05f #define H5C__MIN_AR_EPOCH_LENGTH 100 #define H5C__DEF_AR_EPOCH_LENGTH 50000 #define H5C__MAX_AR_EPOCH_LENGTH 1000000 @@ -104,6 +104,30 @@ done: } /* H5D__init_pub_interface() */ +/*-------------------------------------------------------------------------- +NAME + H5D__term_pub_interface -- Terminate interface +USAGE + herr_t H5D__term_pub_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5D__term_pub_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5D__term_pub_interface() */ + + /*------------------------------------------------------------------------- * Function: H5Dcreate2 * @@ -645,6 +669,7 @@ H5Dget_access_plist(hid_t dset_id) if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_DAPL, H5AC_dxpl_id, H5_EVENT_STACK_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset access properties") + done: FUNC_LEAVE_API(ret_value) @@ -905,7 +930,6 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, H5S_t *mspace = NULL; /* Memory dataspace */ char bogus; /* bogus value to pass to H5Diterate() */ H5S_t *space; /* Dataspace for iteration */ - H5P_genclass_t *pclass; /* Property class */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value; /* Return value */ @@ -952,12 +976,8 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, if(NULL == (vlen_bufsize.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") - /* Get the pointer to the dataset transfer class */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(H5P_CLS_DATASET_XFER_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") - /* Change to the custom memory allocation routines for reading VL data */ - if((vlen_bufsize.xfer_pid = H5P_create_id(pclass, FALSE)) < 0) + if((vlen_bufsize.xfer_pid = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "no dataset xfer plists available") /* Get the property list struct */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 92db446..e93d627 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -385,10 +385,9 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, data_size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data to file") - done: FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} +} /* end H5D__chunk_direct_write() */ /*------------------------------------------------------------------------- @@ -2798,7 +2797,7 @@ void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax) { - const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ + const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ const H5O_pline_t *pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info - always equal to the pline passed to H5D__chunk_alloc */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index a972eca..1a4d0e6 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -106,6 +106,30 @@ H5D__init_deprec_interface(void) FUNC_LEAVE_NOAPI(H5D_init()) } /* H5D__init_deprec_interface() */ + +/*-------------------------------------------------------------------------- +NAME + H5D__term_deprec_interface -- Terminate interface +USAGE + herr_t H5D__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5D__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5D__term_deprec_interface() */ + #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- diff --git a/src/H5Dint.c b/src/H5Dint.c index c55609a..12ae05b 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -181,7 +181,7 @@ H5D__init_interface(void) /* Get the default dataset creation property list values and initialize the * default dataset with them. */ - if(NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_g))) + if(NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_ID_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") /* Get the default data storage layout */ @@ -256,6 +256,12 @@ H5D_term_interface(void) */ H5I_clear_type(H5I_DATASET, TRUE, FALSE); } else { + /* Close public interface */ + n += H5D__term_pub_interface(); + + /* Close deprecated interface */ + n += H5D__term_deprec_interface(); + H5I_dec_type_ref(H5I_DATASET); H5_interface_initialize_g = 0; n = 1; /*H5I*/ @@ -2603,17 +2609,17 @@ H5D_get_access_plist(H5D_t *dset) { H5P_genplist_t *old_plist; /* Default DAPL */ H5P_genplist_t *new_plist; /* New DAPL */ - hid_t new_id = FAIL; + hid_t new_dapl_id = FAIL; hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT /* Make a copy of the default dataset access property list */ - if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_g))) + if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if ((new_id = H5P_copy_plist(old_plist, TRUE)) < 0) + if ((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy dataset access property list") - if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* If the dataset is chunked then copy the rdcc parameters */ @@ -2627,12 +2633,12 @@ H5D_get_access_plist(H5D_t *dset) } /* end if */ /* Set the return value */ - ret_value = new_id; + ret_value = new_dapl_id; done: if(ret_value < 0) { - if(new_id > 0) - if(H5I_dec_app_ref(new_id) < 0) + if(new_dapl_id > 0) + if(H5I_dec_app_ref(new_dapl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") } /* end if */ diff --git a/src/H5Dio.c b/src/H5Dio.c index b717ee0..b83ed88 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -120,8 +120,8 @@ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/) { - H5VL_t *vol_plugin; - void *dset; + H5VL_t *vol_plugin = NULL; + void *dset = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -312,7 +312,7 @@ H5D__pre_write(H5D_t *dset, hid_t mem_type_id, const H5S_t *mem_space, /* write raw data */ if(H5D__write(dset, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") - } + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -362,6 +362,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ + char fake_char; /* Temporary variable for NULL buffer pointers */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, dataset->oloc.addr, FAIL) @@ -397,6 +398,19 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") + /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ + if(NULL == buf) { + /* Check for any elements selected (which is invalid) */ + if(nelmts > 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") + + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ + buf = &fake_char; + } /* end if */ + /* Make sure that both selections have their extents set */ if(!(H5S_has_extent(file_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") @@ -564,6 +578,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ + char fake_char; /* Temporary variable for NULL buffer pointers */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dataset->oloc.addr, FAIL) @@ -629,6 +644,33 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(!mem_space) mem_space = file_space; + if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") + H5_ASSIGN_OVERFLOW(nelmts, snelmts, hssize_t, hsize_t); + + /* Make certain that the number of elements in each selection is the same */ + if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") + + /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ + if(NULL == buf) { + /* Check for any elements selected (which is invalid) */ + if(nelmts > 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") + + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ + buf = &fake_char; + } /* end if */ + + /* Make sure that both selections have their extents set */ + if(!(H5S_has_extent(file_space))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") + if(!(H5S_has_extent(mem_space))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") + /* H5S_select_shape_same() has been modified to accept topologically * identical selections with different rank as having the same shape * (if the most rapidly changing coordinates match up), but the I/O @@ -659,20 +701,6 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, buf = adj_buf; } /* end if */ - if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") - H5_ASSIGN_OVERFLOW(nelmts, snelmts, hssize_t, hsize_t); - - /* Make certain that the number of elements in each selection is the same */ - if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") - - /* Make sure that both selections have their extents set */ - if(!(H5S_has_extent(file_space))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") - if(!(H5S_has_extent(mem_space))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") - /* Retrieve dataset properties */ /* <none needed currently> */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index c294e42..a5e8903 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -1308,8 +1308,6 @@ done: } /* end H5D__multi_chunk_collective_io */ - - /*------------------------------------------------------------------------- * Function: H5D__inter_collective_io * diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 6e8ca09..5713ee3 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -525,6 +525,8 @@ H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_BTREE[1]; /* Package Private Prototypes */ /******************************/ +H5_DLL herr_t H5D__term_pub_interface(void); +H5_DLL herr_t H5D__term_deprec_interface(void); H5_DLL H5D_t *H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id); H5_DLL H5D_t *H5D__create_named(const H5G_loc_t *loc, const char *name, diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 4309d64..e7ae3ae 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -30,9 +30,9 @@ /*****************/ /* Macros used to "unset" chunk cache configuration parameters */ -#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t) -1) +#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t) -1) #define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t) -1) -#define H5D_CHUNK_CACHE_W0_DEFAULT -1. +#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f) /* Property names for H5LTDdirect_chunk_write */ #define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" @@ -325,6 +325,9 @@ H5E_term_interface(void) } /* end if */ } /* end if */ else { + /* Close deprecated interface */ + n += H5E__term_deprec_interface(); + /* Destroy the error class, message, and stack id groups */ H5I_dec_type_ref(H5I_ERROR_STACK); H5I_dec_type_ref(H5I_ERROR_CLASS); @@ -366,8 +369,12 @@ H5E_get_stack(void) estack = (H5E_t *)H5TS_get_thread_local_value(H5TS_errstk_key_g); if(!estack) { - /* no associated value with current thread - create one */ + /* No associated value with current thread - create one */ +#ifdef H5_HAVE_WIN_THREADS + estack = (H5E_t *)LocalAlloc(LPTR, sizeof(H5E_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ +#else estack = (H5E_t *)H5FL_MALLOC(H5E_t); +#endif /* H5_HAVE_WIN_THREADS */ HDassert(estack); /* Set the thread-specific info */ @@ -48,7 +48,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5EApkg.h" /* Extensible Arrays */ #include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 0d3083b..3e9444b 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -34,7 +34,7 @@ #define H5E_PACKAGE /*suppress error about including H5Epkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5E_init_deprec_interface +#define H5_INTERFACE_INIT_FUNC H5E__init_deprec_interface /***********/ @@ -82,13 +82,12 @@ /*******************/ -#ifndef H5_NO_DEPRECATED_SYMBOLS /*-------------------------------------------------------------------------- NAME - H5E_init_deprec_interface -- Initialize interface-specific information + H5E__init_deprec_interface -- Initialize interface-specific information USAGE - herr_t H5E_init_deprec_interface() + herr_t H5E__init_deprec_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -97,13 +96,38 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5E_init_deprec_interface(void) +H5E__init_deprec_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5E_init()) -} /* H5E_init_deprec_interface() */ +} /* H5E__init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5E__term_deprec_interface -- Terminate interface +USAGE + herr_t H5E__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5E__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + FUNC_LEAVE_NOAPI(0) +} /* H5E__term_deprec_interface() */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- * Function: H5Eget_major diff --git a/src/H5Epkg.h b/src/H5Epkg.h index 9a1163a..bfaaf9d 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -132,6 +132,7 @@ H5_DLLVAR H5E_t H5E_stack_g[1]; /******************************/ /* Package Private Prototypes */ /******************************/ +H5_DLL herr_t H5E__term_deprec_interface(void); #ifdef H5_HAVE_THREADSAFE H5_DLL H5E_t *H5E_get_stack(void); #endif /* H5_HAVE_THREADSAFE */ @@ -146,5 +147,5 @@ H5_DLL herr_t H5E_set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data); H5_DLL herr_t H5E_pop(H5E_t *err_stack, size_t count); -#endif /* _H5HFpkg_H */ +#endif /* _H5Epkg_H */ @@ -171,6 +171,9 @@ H5F_term_interface(void) /* Make certain we've cleaned up all the shared file objects */ H5F_sfile_assert_num(0); + /* Close deprecated interface */ + n += H5F__term_deprec_interface(); + H5I_dec_type_ref(H5I_FILE); H5_interface_initialize_g = 0; n = 1; /*H5I*/ @@ -289,6 +292,7 @@ H5F_get_all_count_cb(void UNUSED *obj_ptr, hid_t UNUSED obj_id, void *key) *(udata->obj_count) = *(udata->obj_count)+1; +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_get_all_count_cb */ @@ -553,7 +557,7 @@ H5Fis_accessible(const char *name, hid_t fapl_id) if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") - if(H5VL_file_misc(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5AC_dxpl_id, H5_EVENT_STACK_NULL, + if(H5VL_file_misc(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5AC_ind_dxpl_g, H5_EVENT_STACK_NULL, fapl_id, name, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle") @@ -1653,15 +1653,14 @@ done: * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dxpl; /* DXPL object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiazx", file, type, dxpl_id, addr, size, buf); @@ -1679,9 +1678,13 @@ H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size if(!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer") + /* Get the DXPL plist object for DXPL ID */ + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Do the real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_read(file, dxpl_id, type, addr - file->base_addr, size, buf) < 0) + if(H5FD_read(file, dxpl, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") done: @@ -1704,15 +1707,14 @@ done: * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dxpl; /* DXPL object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiaz*x", file, type, dxpl_id, addr, size, buf); @@ -1729,9 +1731,13 @@ H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz if(!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer") + /* Get the DXPL plist object for DXPL ID */ + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* The real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_write(file, dxpl_id, type, addr - file->base_addr, size, buf) < 0) + if(H5FD_write(file, dxpl, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") done: diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 74aeed3..d1d4337 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -25,19 +25,26 @@ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface - #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDcore.h" /* Core file driver */ +#include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_CORE_g = 0; +/* The skip list node type. Represents a region in the file. */ +typedef struct H5FD_core_region_t { + haddr_t start; /* Start address of the region */ + haddr_t end; /* End address of the region */ +} H5FD_core_region_t; + /* The description of a file belonging to this driver. The 'eoa' and 'eof' * determine the amount of hdf5 address space in use and the high-water mark * of the file (the current size of the underlying memory). @@ -50,6 +57,7 @@ typedef struct H5FD_core_t { haddr_t eof; /* current allocated size */ size_t increment; /* multiples for mem allocation */ hbool_t backing_store; /* write to file name on flush */ + size_t bstore_page_size; /* backing store page size */ int fd; /* backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ #ifndef H5_HAVE_WIN32_API @@ -85,6 +93,7 @@ typedef struct H5FD_core_t { #endif /* H5_HAVE_WIN32_API */ hbool_t dirty; /* changes not saved? */ H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */ + H5SL_t *dirty_list; /* dirty parts of the file */ } H5FD_core_t; /* Driver-specific file access properties */ @@ -117,6 +126,9 @@ typedef struct H5FD_core_fapl_t { (size_t)((A)+(Z))<(size_t)(A)) /* Prototypes */ +static herr_t H5FD_core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); +static herr_t H5FD_core_destroy_dirty_list(H5FD_core_t *file); +static herr_t H5FD_core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size); static herr_t H5FD_core_term(void); static void *H5FD_core_fapl_get(H5FD_t *_file); static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, @@ -170,6 +182,251 @@ static const H5FD_class_t H5FD_core_g = { H5FD_FLMAP_DICHOTOMY /* fl_map */ }; +/* Define a free list to manage the region type */ +H5FL_DEFINE(H5FD_core_region_t); + + +/*------------------------------------------------------------------------- + * Function: H5FD_core_add_dirty_region + * + * Purpose: Add a new dirty region to the list for later flushing + * to the backing store. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) +{ + H5FD_core_region_t *b_item = NULL; + H5FD_core_region_t *a_item = NULL; + H5FD_core_region_t *item = NULL; + haddr_t b_addr = 0; + haddr_t a_addr = 0; + hbool_t create_new_node = TRUE; + herr_t ret_value = SUCCEED; +#ifdef DER + hbool_t was_adjusted = FALSE; +#endif + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(file); + HDassert(file->dirty_list); + HDassert(start <= end); + +#ifdef DER +fprintf(stderr, "Add region: (%llu, %llu)\n", start, end); +#endif + + /* Adjust the dirty region to the nearest block boundaries */ + if(start % file->bstore_page_size != 0) { + start = (start / file->bstore_page_size) * file->bstore_page_size; +#ifdef DER + was_adjusted = TRUE; +#endif + } + if(end % file->bstore_page_size != (file->bstore_page_size - 1)) { + end = (((end / file->bstore_page_size) + 1) * file->bstore_page_size) - 1; + if(end > file->eof){ +#ifdef DER +fprintf(stderr, "Adjusted to EOF\n"); +#endif + end = file->eof - 1; + } +#ifdef DER + was_adjusted = TRUE; +#endif + } + +#ifdef DER +if(was_adjusted) + fprintf(stderr, "Adjusted region: (%llu, %llu)\n", start, end); +#endif + + /* Get the regions before and after the intended insertion point */ + b_addr = start +1; + a_addr = end + 2; + b_item = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &b_addr); + a_item = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &a_addr); + + /* Check to see if we need to extend the upper end of the NEW region */ + if(a_item) { + if(start < a_item->start && end < a_item->end) { + + /* Extend the end of the NEW region to match the existing AFTER region */ + end = a_item->end; + } + } + /* Attempt to extend the PREV region */ + if(b_item) { + if(start <= b_item->end + 1) { + + /* Need to set this for the delete algorithm */ + start = b_item->start; + + /* We won't need to insert a new node since we can + * just update an existing one instead. + */ + create_new_node = FALSE; + } + } + + /* Remove any old nodes that are no longer needed */ + while(a_item && a_item->start > start) { + + H5FD_core_region_t *less; + haddr_t key = a_item->start - 1; + + /* Save the previous node before we trash this one */ + less = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &key); + + /* Delete this node */ + a_item = (H5FD_core_region_t *)H5SL_remove(file->dirty_list, &a_item->start); + a_item = H5FL_FREE(H5FD_core_region_t, a_item); + + /* Set up to check the next node */ + if(less) + a_item = less; + } + + /* Insert the new node */ + if(create_new_node) { + if(NULL == (item = (H5FD_core_region_t *)H5SL_search(file->dirty_list, &start))) { + /* Ok to insert. No pre-existing node with that key. */ + item = (H5FD_core_region_t *)H5FL_CALLOC(H5FD_core_region_t); + item->start = start; + item->end = end; + if(H5SL_insert(file->dirty_list, item, &item->start) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't insert new dirty region: (%llu, %llu)\n", start, end) + } + else { + /* Store the new item endpoint if it's bigger */ + item->end = (item->end < end) ? end : item->end; + } + } + else { + /* Update the size of the before region */ + if(b_item->end < end) + b_item->end = end; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_core_add_dirty_region() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_core_destroy_dirty_list + * + * Purpose: Completely destroy the dirty list. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_core_destroy_dirty_list(H5FD_core_t *file) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(file); + + /* Destroy the list, including any remaining list elements */ + if(file->dirty_list) { + H5FD_core_region_t *region = NULL; + +#ifdef DER +{ +size_t count = H5SL_count(file->dirty_list); +if(count != 0) + fprintf(stderr, "LIST NOT EMPTY AT DESTROY\n"); +} +#endif + while(NULL != (region = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) + region = H5FL_FREE(H5FD_core_region_t, region); + + if(H5SL_close(file->dirty_list) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CLOSEERROR, FAIL, "can't close core vfd dirty list") + file->dirty_list = NULL; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_core_destroy_dirty_list() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_core_write_to_bstore + * + * Purpose: Write data to the backing store. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t H5FD_core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) +{ + unsigned char *ptr = file->mem + addr; /* mutable pointer into the + * buffer (can't change mem) + */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(file); + + /* Write to backing store */ + if((off_t)addr != HDlseek(file->fd, (off_t)addr, SEEK_SET)) + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store") + + while (size > 0) { + + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + + /* Trying to write more bytes than the return type can handle is + * undefined behavior in POSIX. + */ + if(size > H5_POSIX_MAX_IO_BYTES) + bytes_in = H5_POSIX_MAX_IO_BYTES; + else + bytes_in = (h5_posix_io_t)size; + +#ifdef DER +fprintf(stderr, "\nNEW\n"); +#endif + do { + bytes_wrote = HDwrite(file->fd, ptr, bytes_in); +#ifdef DER +fprintf(stderr, "bytes wrote: %lu\n", bytes_wrote); +#endif + } while(-1 == bytes_wrote && EINTR == errno); + + if(-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); + HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); + + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset); + } /* end if */ + + HDassert(bytes_wrote > 0); + HDassert((size_t)bytes_wrote <= size); + + size -= (size_t)bytes_wrote; + ptr = (unsigned char *)ptr + bytes_wrote; + + } /* end while */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_core_write_to_bstore() */ + /*------------------------------------------------------------------------- * Function: H5FD_core_init_interface @@ -566,6 +823,40 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) } /* end if */ } /* end if */ + /* Set up write tracking if the backing store is on */ + file->dirty_list = NULL; + if(fa->backing_store) { + hbool_t write_tracking_flag = FALSE; /* what the user asked for */ + hbool_t use_write_tracking = FALSE; /* what we're actually doing */ + + /* Get the write tracking flag */ + if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &write_tracking_flag) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking flag"); + + /* Get the page size */ + if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &(file->bstore_page_size)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking page size"); + + /* default is to have write tracking OFF for create (hence the check to see + * if the user explicitly set a page size) and ON with the default page size + * on open (when not read-only). + */ + /* Only use write tracking if the file is open for writing */ + use_write_tracking = + TRUE == write_tracking_flag /* user asked for write tracking */ + && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ + && file->bstore_page_size != 0; /* page size is not zero */ + + /* initialize the dirty list */ + if(use_write_tracking) { + if(NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, NULL, "can't create core vfd dirty region list"); +#ifdef DER +fprintf(stderr, "\n"); +#endif + } /* end if */ + } /* end if */ + /* Set return value */ ret_value = (H5FD_t *)file; @@ -604,7 +895,12 @@ H5FD_core_close(H5FD_t *_file) /* Flush any changed buffers */ if(H5FD_core_flush(_file, (hid_t)-1, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush core vfd backing store") + + /* Destroy the dirty region list */ + if(file->dirty_list) + if(H5FD_core_destroy_dirty_list(file) != SUCCEED) + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free core vfd dirty region list") /* Release resources */ if(file->fd >= 0) @@ -1025,6 +1321,14 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had file->eof = new_eof; } /* end if */ + /* Add the buffer region to the dirty list if using that optimization */ + if(file->dirty_list) { + haddr_t start = addr; + haddr_t end = addr + (haddr_t)size - 1; + if(H5FD_core_add_dirty_region(file, start, end) != SUCCEED) + HGOTO_ERROR(H5E_VFL, H5E_CANTINSERT, FAIL, "unable to add core VFD dirty region during write call - addresses: start=%llu end=%llu", start, end) + } + /* Write from BUF to memory */ HDmemcpy(file->mem + addr, buf, size); @@ -1059,45 +1363,51 @@ H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) /* Write to backing store */ if (file->dirty && file->fd >= 0 && file->backing_store) { - haddr_t size = file->eof; - unsigned char *ptr = file->mem; - if(0 != HDlseek(file->fd, (off_t)0, SEEK_SET)) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store") - - while (size > 0) { + /* Use the dirty list, if available */ + if(file->dirty_list) { + H5FD_core_region_t *item = NULL; + size_t size; - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ +#ifdef DER + fprintf(stderr, "FLUSHING. DIRTY LIST:\n"); +#endif + while(NULL != (item = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) { - /* Trying to write more bytes than the return type can handle is - * undefined behavior in POSIX. - */ - if(size > H5_POSIX_MAX_IO_BYTES) - bytes_in = H5_POSIX_MAX_IO_BYTES; - else - bytes_in = (h5_posix_io_t)size; - - do { - bytes_wrote = HDwrite(file->fd, ptr, bytes_in); - } while(-1 == bytes_wrote && EINTR == errno); - - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); - HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset); - } /* end if */ - - HDassert(bytes_wrote > 0); - HDassert((size_t)bytes_wrote <= size); + /* The file may have been truncated, so check for that + * and skip or adjust as necessary. + */ + if(item->start < file->eof) { + if(item->end >= file->eof) + item->end = file->eof - 1; + + + size = (size_t)((item->end - item->start) + 1); +#ifdef DER +fprintf(stderr, "(%llu, %llu : %lu)\n", item->start, item->end, size); +#endif + if(H5FD_core_write_to_bstore(file, item->start, size) != SUCCEED) + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") + } /* end if */ + + item = H5FL_FREE(H5FD_core_region_t, item); + } /* end while */ + +#ifdef DER +fprintf(stderr, "EOF: %llu\n", file->eof); +fprintf(stderr, "EOA: %llu\n", file->eoa); +if(file->eoa > file->eof) + fprintf(stderr, "*** EOA BADNESS ***\n"); +fprintf(stderr, "\n"); +#endif + } + /* Otherwise, write the entire file out at once */ + else { + if(H5FD_core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") - size -= (size_t)bytes_wrote; - ptr = (unsigned char *)ptr + bytes_wrote; - } /* end while */ - + file->dirty = FALSE; } @@ -1221,6 +1531,10 @@ H5FD_core_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t closing) if(-1 == HDftruncate(file->fd, (HDoff_t)new_eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ + +#ifdef DER +fprintf(stderr, "OLD: Truncated to: %llu\n", file->eoa); +#endif } /* end if */ /* Update the eof value */ @@ -1231,3 +1545,4 @@ H5FD_core_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t closing) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_truncate() */ + diff --git a/src/H5FDint.c b/src/H5FDint.c index c9e9a67..9f02a25 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -42,7 +42,6 @@ #include "H5Fprivate.h" /* File access */ #include "H5FDpkg.h" /* File Drivers */ #include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ /****************/ @@ -104,6 +103,70 @@ H5FD_int_init_interface(void) /*------------------------------------------------------------------------- + * Function: H5FD_locate_signature + * + * Purpose: Finds the HDF5 superblock signature in a file. The + * signature can appear at address 0, or any power of two + * beginning with 512. + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Robb Matzke + * Friday, November 7, 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FD_locate_signature(H5FD_t *file, const H5P_genplist_t *dxpl, haddr_t *sig_addr) +{ + haddr_t addr, eoa; + uint8_t buf[H5F_SIGNATURE_LEN]; + unsigned n, maxpow; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Find the least N such that 2^N is larger than the file size */ + if(HADDR_UNDEF == (addr = H5FD_get_eof(file)) || HADDR_UNDEF == (eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER))) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value") + for(maxpow = 0; addr; maxpow++) + addr >>= 1; + maxpow = MAX(maxpow, 9); + + /* + * Search for the file signature at format address zero followed by + * powers of two larger than 9. + */ + for(n = 8; n < maxpow; n++) { + addr = (8 == n) ? 0 : (haddr_t)1 << n; + if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature") + if(H5FD_read(file, dxpl, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature") + if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) + break; + } /* end for */ + + /* + * If the signature was not found then reset the EOA value and return + * HADDR_UNDEF. + */ + if(n >= maxpow) { + if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value") + *sig_addr = HADDR_UNDEF; + } /* end if */ + else + /* Set return value */ + *sig_addr = addr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_locate_signature() */ + + +/*------------------------------------------------------------------------- * Function: H5FD_read * * Purpose: Private version of H5FDread() @@ -117,7 +180,7 @@ H5FD_int_init_interface(void) *------------------------------------------------------------------------- */ herr_t -H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, +H5FD_read(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) { herr_t ret_value = SUCCEED; /* Return value */ @@ -125,8 +188,7 @@ H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, FUNC_ENTER_NOAPI(FAIL) HDassert(file && file->cls); - HDassert(H5I_GENPROP_LST == H5I_get_type(dxpl_id)); - HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(TRUE == H5P_class_isa(H5P_CLASS(dxpl), H5P_CLS_DATASET_XFER_g)); HDassert(buf); #ifndef H5_HAVE_PARALLEL @@ -138,7 +200,7 @@ H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, #endif /* H5_HAVE_PARALLEL */ /* Dispatch to driver */ - if((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if((file->cls->read)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") done: @@ -160,7 +222,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, +H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { herr_t ret_value = SUCCEED; /* Return value */ @@ -168,8 +230,7 @@ H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, FUNC_ENTER_NOAPI(FAIL) HDassert(file && file->cls); - HDassert(H5I_GENPROP_LST == H5I_get_type(dxpl_id)); - HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); + HDassert(TRUE == H5P_class_isa(H5P_CLASS(dxpl), H5P_CLS_DATASET_XFER_g)); HDassert(buf); #ifndef H5_HAVE_PARALLEL @@ -181,7 +242,7 @@ H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, #endif /* H5_HAVE_PARALLEL */ /* Dispatch to driver */ - if((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if((file->cls->write)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") done: diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 6e4df22..33332d7 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -24,6 +24,7 @@ #include "H5FDpublic.h" /* Private headers needed by this file */ +#include "H5Pprivate.h" /* Property lists */ /* * The MPI drivers are needed because there are @@ -108,6 +109,7 @@ struct H5P_genplist_t; struct H5F_t; H5_DLL int H5FD_term_interface(void); +H5_DLL herr_t H5FD_locate_signature(H5FD_t *file, const H5P_genplist_t *dxpl, haddr_t *sig_addr); H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); @@ -132,9 +134,9 @@ H5_DLL haddr_t H5FD_get_eof(const H5FD_t *file); H5_DLL haddr_t H5FD_get_maxaddr(const H5FD_t *file); H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags); H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map); -H5_DLL herr_t H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, +H5_DLL herr_t H5FD_read(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, +H5_DLL herr_t H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 037c085..7eb75bd 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -40,7 +40,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ @@ -94,7 +94,7 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); /*------------------------------------------------------------------------- - * Function: H5F_accum_read + * Function: H5F__accum_read * * Purpose: Attempts to read some data from the metadata accumulator for * a file into a buffer. @@ -112,106 +112,111 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); *------------------------------------------------------------------------- */ herr_t -H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, +H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) { H5FD_mem_t map_type; /* Mapped memory type */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE - HDassert(f); - HDassert(f->shared); + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(fio_info->dxpl); HDassert(buf); /* Treat global heap as raw data */ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; /* Check if this information is in the metadata accumulator */ - if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + + /* Set up alias for file's metadata accumulator info */ + accum = &fio_info->f->shared->accum; + if(size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ - HDassert(!f->shared->accum.buf || (f->shared->accum.alloc_size >= f->shared->accum.size)); + HDassert(!accum->buf || (accum->alloc_size >= accum->size)); /* Current read adjoins or overlaps with metadata accumulator */ - if(H5F_addr_overlap(addr, size, f->shared->accum.loc, f->shared->accum.size) - || ((addr + size) == f->shared->accum.loc) - || (f->shared->accum.loc + f->shared->accum.size) == addr) { + if(H5F_addr_overlap(addr, size, accum->loc, accum->size) + || ((addr + size) == accum->loc) + || (accum->loc + accum->size) == addr) { size_t amount_before; /* Amount to read before current accumulator */ haddr_t new_addr; /* New address of the accumulator buffer */ size_t new_size; /* New size of the accumulator buffer */ /* Compute new values for accumulator */ - new_addr = MIN(addr, f->shared->accum.loc); - new_size = (size_t)(MAX((addr + size), (f->shared->accum.loc + f->shared->accum.size)) - - new_addr); + new_addr = MIN(addr, accum->loc); + new_size = (size_t)(MAX((addr + size), (accum->loc + accum->size)) - new_addr); /* Check if we need more buffer space */ - if(new_size > f->shared->accum.alloc_size) { + if(new_size > accum->alloc_size) { size_t new_alloc_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(new_size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_alloc_size))) + if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ - f->shared->accum.alloc_size = new_alloc_size; + accum->alloc_size = new_alloc_size; #ifdef H5_CLEAR_MEMORY - HDmemset(f->shared->accum.buf + f->shared->accum.size, 0, (f->shared->accum.alloc_size - f->shared->accum.size)); + HDmemset(accum->buf + accum->size, 0, (accum->alloc_size - accum->size)); #endif /* H5_CLEAR_MEMORY */ } /* end if */ /* Read the part before the metadata accumulator */ - if(addr < f->shared->accum.loc) { + if(addr < accum->loc) { /* Set the amount to read */ - H5_ASSIGN_OVERFLOW(amount_before, (f->shared->accum.loc - addr), hsize_t, size_t); + H5_ASSIGN_OVERFLOW(amount_before, (accum->loc - addr), hsize_t, size_t); /* Make room for the metadata to read in */ - HDmemmove(f->shared->accum.buf + amount_before, f->shared->accum.buf, f->shared->accum.size); + HDmemmove(accum->buf + amount_before, accum->buf, accum->size); /* Adjust dirty region tracking info, if present */ - if(f->shared->accum.dirty) - f->shared->accum.dirty_off += amount_before; + if(accum->dirty) + accum->dirty_off += amount_before; /* Dispatch to driver */ - if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, amount_before, f->shared->accum.buf) < 0) + if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, amount_before, accum->buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ else amount_before = 0; /* Read the part after the metadata accumulator */ - if((addr + size) > (f->shared->accum.loc + f->shared->accum.size)) { + if((addr + size) > (accum->loc + accum->size)) { size_t amount_after; /* Amount to read at a time */ /* Set the amount to read */ - H5_ASSIGN_OVERFLOW(amount_after, ((addr + size) - (f->shared->accum.loc + f->shared->accum.size)), hsize_t, size_t); + H5_ASSIGN_OVERFLOW(amount_after, ((addr + size) - (accum->loc + accum->size)), hsize_t, size_t); /* Dispatch to driver */ - if(H5FD_read(f->shared->lf, dxpl_id, map_type, (f->shared->accum.loc + f->shared->accum.size), amount_after, (f->shared->accum.buf + f->shared->accum.size + amount_before)) < 0) + if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, (accum->loc + accum->size), amount_after, (accum->buf + accum->size + amount_before)) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ /* Copy the data out of the buffer */ - HDmemcpy(buf, f->shared->accum.buf + (addr - new_addr), size); + HDmemcpy(buf, accum->buf + (addr - new_addr), size); /* Adjust the accumulator address & size */ - f->shared->accum.loc = new_addr; - f->shared->accum.size = new_size; + accum->loc = new_addr; + accum->size = new_size; } /* end if */ /* Current read doesn't overlap with metadata accumulator, read it from file */ else { /* Dispatch to driver */ - if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) + if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ } /* end if */ else { /* Read the data */ - if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) + if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") /* Check for overlap w/dirty accumulator */ @@ -219,9 +224,9 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, * information in the accumulator with [some of] the information * just read in. -QAK) */ - if(f->shared->accum.dirty && - H5F_addr_overlap(addr, size, f->shared->accum.loc + f->shared->accum.dirty_off, f->shared->accum.dirty_len)) { - haddr_t dirty_loc = f->shared->accum.loc + f->shared->accum.dirty_off; /* File offset of dirty information */ + if(accum->dirty && + H5F_addr_overlap(addr, size, accum->loc + accum->dirty_off, accum->dirty_len)) { + haddr_t dirty_loc = accum->loc + accum->dirty_off; /* File offset of dirty information */ size_t buf_off; /* Offset of dirty region in buffer */ size_t dirty_off; /* Offset within dirty region */ size_t overlap_size; /* Size of overlap with dirty region */ @@ -235,36 +240,36 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, dirty_off = 0; /* Check for read ending within dirty region */ - if(H5F_addr_lt(addr + size, dirty_loc + f->shared->accum.dirty_len)) + if(H5F_addr_lt(addr + size, dirty_loc + accum->dirty_len)) overlap_size = (size_t)((addr + size) - buf_off); else /* Access covers whole dirty region */ - overlap_size = f->shared->accum.dirty_len; + overlap_size = accum->dirty_len; } /* end if */ else { /* Read starts after beginning of dirty region */ /* Compute dirty offset within buffer and overlap size */ buf_off = 0; dirty_off = (size_t)(addr - dirty_loc); - overlap_size = (size_t)((dirty_loc + f->shared->accum.dirty_len) - addr); + overlap_size = (size_t)((dirty_loc + accum->dirty_len) - addr); } /* end else */ /* Copy the dirty region to buffer */ - HDmemcpy((unsigned char *)buf + buf_off, (unsigned char *)f->shared->accum.buf + f->shared->accum.dirty_off + dirty_off, overlap_size); + HDmemcpy((unsigned char *)buf + buf_off, (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size); } /* end if */ } /* end else */ } /* end if */ else { /* Read the data */ - if(H5FD_read(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) + if(H5FD_read(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_accum_read() */ +} /* end H5F__accum_read() */ /*------------------------------------------------------------------------- - * Function: H5F_accum_adjust + * Function: H5F__accum_adjust * * Purpose: Adjust accumulator size, if necessary * @@ -277,15 +282,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F_accum_adjust(H5F_meta_accum_t *accum, H5FD_t *lf, hid_t dxpl_id, +H5F__accum_adjust(H5F_meta_accum_t *accum, const H5F_io_info_t *fio_info, H5F_accum_adjust_t adjust, size_t size) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(accum); - HDassert(lf); + HDassert(fio_info); HDassert(H5F_ACCUM_APPEND == adjust || H5F_ACCUM_PREPEND == adjust); HDassert(size > 0); HDassert(size <= H5F_ACCUM_MAX_SIZE); @@ -343,7 +348,7 @@ H5F_accum_adjust(H5F_meta_accum_t *accum, H5FD_t *lf, hid_t dxpl_id, /* Check if the dirty region overlaps the region to eliminate from the accumulator */ if((accum->size - shrink_size) < (accum->dirty_off + accum->dirty_len)) { /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(lf, dxpl_id, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -354,7 +359,7 @@ H5F_accum_adjust(H5F_meta_accum_t *accum, H5FD_t *lf, hid_t dxpl_id, /* Check if the dirty region overlaps the region to eliminate from the accumulator */ if(shrink_size > accum->dirty_off) { /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(lf, dxpl_id, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -398,11 +403,11 @@ HDmemset(accum->buf + accum->size, 0, (accum->alloc_size - (accum->size + size)) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_accum_adjust() */ +} /* end H5F__accum_adjust() */ /*------------------------------------------------------------------------- - * Function: H5F_accum_write + * Function: H5F__accum_write * * Purpose: Attempts to write some data to the metadata accumulator for * a file from a buffer. @@ -416,7 +421,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, +H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { H5FD_mem_t map_type; /* Mapped memory type */ @@ -424,355 +429,359 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, FUNC_ENTER_NOAPI(FAIL) - HDassert(f); - HDassert(f->shared); - HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(H5F_INTENT(fio_info->f) & H5F_ACC_RDWR); + HDassert(fio_info->dxpl); HDassert(buf); /* Treat global heap as raw data */ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; /* Check for accumulating metadata */ - if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + + /* Set up alias for file's metadata accumulator info */ + accum = &fio_info->f->shared->accum; + if(size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ - HDassert(!f->shared->accum.buf || (f->shared->accum.alloc_size >= f->shared->accum.size)); + HDassert(!accum->buf || (accum->alloc_size >= accum->size)); /* Check if there is already metadata in the accumulator */ - if(f->shared->accum.size > 0) { + if(accum->size > 0) { /* Check if the new metadata adjoins the beginning of the current accumulator */ - if((addr + size) == f->shared->accum.loc) { + if((addr + size) == accum->loc) { /* Check if we need to adjust accumulator size */ - if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_PREPEND, size) < 0) + if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_PREPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Move the existing metadata to the proper location */ - HDmemmove(f->shared->accum.buf + size, f->shared->accum.buf, f->shared->accum.size); + HDmemmove(accum->buf + size, accum->buf, accum->size); /* Copy the new metadata at the front */ - HDmemcpy(f->shared->accum.buf, buf, size); + HDmemcpy(accum->buf, buf, size); /* Set the new size & location of the metadata accumulator */ - f->shared->accum.loc = addr; - f->shared->accum.size += size; + accum->loc = addr; + accum->size += size; /* Adjust the dirty region and mark accumulator dirty */ - if(f->shared->accum.dirty) - f->shared->accum.dirty_len = size + f->shared->accum.dirty_off - + f->shared->accum.dirty_len; + if(accum->dirty) + accum->dirty_len = size + accum->dirty_off + accum->dirty_len; else { - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ - f->shared->accum.dirty_off = 0; + accum->dirty_off = 0; } /* end if */ /* Check if the new metadata adjoins the end of the current accumulator */ - else if(addr == (f->shared->accum.loc + f->shared->accum.size)) { + else if(addr == (accum->loc + accum->size)) { /* Check if we need to adjust accumulator size */ - if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_APPEND, size) < 0) + if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_APPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Copy the new metadata to the end */ - HDmemcpy(f->shared->accum.buf + f->shared->accum.size, buf, size); + HDmemcpy(accum->buf + accum->size, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - if(f->shared->accum.dirty) - f->shared->accum.dirty_len = size + (f->shared->accum.size - - f->shared->accum.dirty_off); + if(accum->dirty) + accum->dirty_len = size + (accum->size - accum->dirty_off); else { - f->shared->accum.dirty_off = f->shared->accum.size; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = accum->size; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ /* Set the new size of the metadata accumulator */ - f->shared->accum.size += size; + accum->size += size; } /* end if */ /* Check if the piece of metadata being written overlaps the metadata accumulator */ - else if(H5F_addr_overlap(addr, size, f->shared->accum.loc, f->shared->accum.size)) { + else if(H5F_addr_overlap(addr, size, accum->loc, accum->size)) { size_t add_size; /* New size of the accumulator buffer */ /* Check if the new metadata is entirely within the current accumulator */ - if(addr >= f->shared->accum.loc && (addr + size) <= (f->shared->accum.loc + f->shared->accum.size)) { - size_t dirty_off = (size_t)(addr - f->shared->accum.loc); + if(addr >= accum->loc && (addr + size) <= (accum->loc + accum->size)) { + size_t dirty_off = (size_t)(addr - accum->loc); /* Copy the new metadata to the proper location within the accumulator */ - HDmemcpy(f->shared->accum.buf + dirty_off, buf, size); + HDmemcpy(accum->buf + dirty_off, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - if(f->shared->accum.dirty) { + if(accum->dirty) { /* Check for new metadata starting before current dirty region */ - if(dirty_off <= f->shared->accum.dirty_off) { - if((dirty_off + size) <= (f->shared->accum.dirty_off + f->shared->accum.dirty_len)) - f->shared->accum.dirty_len = (f->shared->accum.dirty_off + f->shared->accum.dirty_len) - dirty_off; + if(dirty_off <= accum->dirty_off) { + if((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) + accum->dirty_len = (accum->dirty_off + accum->dirty_len) - dirty_off; else - f->shared->accum.dirty_len = size; - f->shared->accum.dirty_off = dirty_off; + accum->dirty_len = size; + accum->dirty_off = dirty_off; } /* end if */ else { - if((dirty_off + size) <= (f->shared->accum.dirty_off + f->shared->accum.dirty_len)) - ; /* f->shared->accum.dirty_len doesn't change */ + if((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) + ; /* accum->dirty_len doesn't change */ else - f->shared->accum.dirty_len = (dirty_off + size) - f->shared->accum.dirty_off; + accum->dirty_len = (dirty_off + size) - accum->dirty_off; } /* end else */ } /* end if */ else { - f->shared->accum.dirty_off = dirty_off; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = dirty_off; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ } /* end if */ /* Check if the new metadata overlaps the beginning of the current accumulator */ - else if(addr < f->shared->accum.loc && (addr + size) <= (f->shared->accum.loc + f->shared->accum.size)) { + else if(addr < accum->loc && (addr + size) <= (accum->loc + accum->size)) { size_t old_offset; /* Offset of old data within the accumulator buffer */ /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */ - H5_ASSIGN_OVERFLOW(add_size, (f->shared->accum.loc - addr), hsize_t, size_t); + H5_ASSIGN_OVERFLOW(add_size, (accum->loc - addr), hsize_t, size_t); /* Check if we need to adjust accumulator size */ - if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_PREPEND, add_size) < 0) + if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_PREPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Calculate the proper offset of the existing metadata */ - H5_ASSIGN_OVERFLOW(old_offset, (addr + size) - f->shared->accum.loc, hsize_t, size_t); + H5_ASSIGN_OVERFLOW(old_offset, (addr + size) - accum->loc, hsize_t, size_t); /* Move the existing metadata to the proper location */ - HDmemmove(f->shared->accum.buf + size, f->shared->accum.buf + old_offset, (f->shared->accum.size - old_offset)); + HDmemmove(accum->buf + size, accum->buf + old_offset, (accum->size - old_offset)); /* Copy the new metadata at the front */ - HDmemcpy(f->shared->accum.buf, buf, size); + HDmemcpy(accum->buf, buf, size); /* Set the new size & location of the metadata accumulator */ - f->shared->accum.loc = addr; - f->shared->accum.size += add_size; + accum->loc = addr; + accum->size += add_size; /* Adjust the dirty region and mark accumulator dirty */ - if(f->shared->accum.dirty) { - size_t curr_dirty_end = add_size + f->shared->accum.dirty_off + f->shared->accum.dirty_len; + if(accum->dirty) { + size_t curr_dirty_end = add_size + accum->dirty_off + accum->dirty_len; - f->shared->accum.dirty_off = 0; + accum->dirty_off = 0; if(size <= curr_dirty_end) - f->shared->accum.dirty_len = curr_dirty_end; + accum->dirty_len = curr_dirty_end; else - f->shared->accum.dirty_len = size; + accum->dirty_len = size; } /* end if */ else { - f->shared->accum.dirty_off = 0; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = 0; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ } /* end if */ /* Check if the new metadata overlaps the end of the current accumulator */ - else if(addr >= f->shared->accum.loc && (addr + size) > (f->shared->accum.loc + f->shared->accum.size)) { + else if(addr >= accum->loc && (addr + size) > (accum->loc + accum->size)) { size_t dirty_off; /* Offset of dirty region */ /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */ - H5_ASSIGN_OVERFLOW(add_size, (addr + size) - (f->shared->accum.loc + f->shared->accum.size), hsize_t, size_t); + H5_ASSIGN_OVERFLOW(add_size, (addr + size) - (accum->loc + accum->size), hsize_t, size_t); /* Check if we need to adjust accumulator size */ - if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_APPEND, add_size) < 0) + if(H5F__accum_adjust(accum, fio_info, H5F_ACCUM_APPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Compute offset of dirty region (after adjusting accumulator) */ - dirty_off = (size_t)(addr - f->shared->accum.loc); + dirty_off = (size_t)(addr - accum->loc); /* Copy the new metadata to the end */ - HDmemcpy(f->shared->accum.buf + dirty_off, buf, size); + HDmemcpy(accum->buf + dirty_off, buf, size); /* Set the new size of the metadata accumulator */ - f->shared->accum.size += add_size; + accum->size += add_size; /* Adjust the dirty region and mark accumulator dirty */ - if(f->shared->accum.dirty) { + if(accum->dirty) { /* Check for new metadata starting before current dirty region */ - if(dirty_off <= f->shared->accum.dirty_off) { - f->shared->accum.dirty_off = dirty_off; - f->shared->accum.dirty_len = size; + if(dirty_off <= accum->dirty_off) { + accum->dirty_off = dirty_off; + accum->dirty_len = size; } /* end if */ else { - f->shared->accum.dirty_len = (dirty_off + size) - f->shared->accum.dirty_off; + accum->dirty_len = (dirty_off + size) - accum->dirty_off; } /* end else */ } /* end if */ else { - f->shared->accum.dirty_off = dirty_off; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = dirty_off; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ } /* end if */ /* New metadata overlaps both ends of the current accumulator */ else { /* Check if we need more buffer space */ - if(size > f->shared->accum.alloc_size) { + if(size > accum->alloc_size) { size_t new_alloc_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_alloc_size))) + if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ - f->shared->accum.alloc_size = new_alloc_size; + accum->alloc_size = new_alloc_size; #ifdef H5_CLEAR_MEMORY -HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); +HDmemset(accum->buf + size, 0, (accum->alloc_size - size)); #endif /* H5_CLEAR_MEMORY */ } /* end if */ /* Copy the new metadata to the buffer */ - HDmemcpy(f->shared->accum.buf, buf, size); + HDmemcpy(accum->buf, buf, size); /* Set the new size & location of the metadata accumulator */ - f->shared->accum.loc = addr; - f->shared->accum.size = size; + accum->loc = addr; + accum->size = size; /* Adjust the dirty region and mark accumulator dirty */ - f->shared->accum.dirty_off = 0; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = 0; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ } /* end if */ /* New piece of metadata doesn't adjoin or overlap the existing accumulator */ else { /* Write out the existing metadata accumulator, with dispatch to driver */ - if(f->shared->accum.dirty) { - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, f->shared->accum.loc + f->shared->accum.dirty_off, f->shared->accum.dirty_len, f->shared->accum.buf + f->shared->accum.dirty_off) < 0) + if(accum->dirty) { + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, accum->dirty_len, accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ - f->shared->accum.dirty = FALSE; + accum->dirty = FALSE; } /* end if */ /* Cache the new piece of metadata */ /* Check if we need to resize the buffer */ - if(size > f->shared->accum.alloc_size) { + if(size > accum->alloc_size) { size_t new_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Grow the metadata accumulator buffer */ - if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_size))) + if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ - f->shared->accum.alloc_size = new_size; + accum->alloc_size = new_size; #ifdef H5_CLEAR_MEMORY { -size_t clear_size = MAX(f->shared->accum.size, size); -HDmemset(f->shared->accum.buf + clear_size, 0, (f->shared->accum.alloc_size - clear_size)); +size_t clear_size = MAX(accum->size, size); +HDmemset(accum->buf + clear_size, 0, (accum->alloc_size - clear_size)); } #endif /* H5_CLEAR_MEMORY */ } /* end if */ else { /* Check if we should shrink the accumulator buffer */ - if(size < (f->shared->accum.alloc_size / H5F_ACCUM_THROTTLE) && - f->shared->accum.alloc_size > H5F_ACCUM_THRESHOLD) { - size_t tmp_size = (f->shared->accum.alloc_size / H5F_ACCUM_THROTTLE); /* New size of accumulator buffer */ + if(size < (accum->alloc_size / H5F_ACCUM_THROTTLE) && + accum->alloc_size > H5F_ACCUM_THRESHOLD) { + size_t tmp_size = (accum->alloc_size / H5F_ACCUM_THROTTLE); /* New size of accumulator buffer */ /* Shrink the accumulator buffer */ - if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, tmp_size))) + if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, tmp_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ - f->shared->accum.alloc_size = tmp_size; + accum->alloc_size = tmp_size; } /* end if */ } /* end else */ /* Update the metadata accumulator information */ - f->shared->accum.loc = addr; - f->shared->accum.size = size; + accum->loc = addr; + accum->size = size; /* Store the piece of metadata in the accumulator */ - HDmemcpy(f->shared->accum.buf, buf, size); + HDmemcpy(accum->buf, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - f->shared->accum.dirty_off = 0; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = 0; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ } /* end if */ /* No metadata in the accumulator, grab this piece and keep it */ else { /* Check if we need to reallocate the buffer */ - if(size > f->shared->accum.alloc_size) { + if(size > accum->alloc_size) { size_t new_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_size))) + if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ - f->shared->accum.alloc_size = new_size; + accum->alloc_size = new_size; #ifdef H5_CLEAR_MEMORY -HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); +HDmemset(accum->buf + size, 0, (accum->alloc_size - size)); #endif /* H5_CLEAR_MEMORY */ } /* end if */ /* Update the metadata accumulator information */ - f->shared->accum.loc = addr; - f->shared->accum.size = size; + accum->loc = addr; + accum->size = size; /* Store the piece of metadata in the accumulator */ - HDmemcpy(f->shared->accum.buf, buf, size); + HDmemcpy(accum->buf, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - f->shared->accum.dirty_off = 0; - f->shared->accum.dirty_len = size; - f->shared->accum.dirty = TRUE; + accum->dirty_off = 0; + accum->dirty_len = size; + accum->dirty = TRUE; } /* end else */ } /* end if */ else { /* Write the data */ - if(H5FD_write(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Check for overlap w/accumulator */ /* (Note that this could be improved by updating the accumulator * with [some of] the information just read in. -QAK) */ - if(H5F_addr_overlap(addr, size, f->shared->accum.loc, f->shared->accum.size)) { + if(H5F_addr_overlap(addr, size, accum->loc, accum->size)) { /* Check for write starting before beginning of accumulator */ - if(H5F_addr_le(addr, f->shared->accum.loc)) { + if(H5F_addr_le(addr, accum->loc)) { /* Check for write ending within accumulator */ - if(H5F_addr_le(addr + size, f->shared->accum.loc + f->shared->accum.size)) { + if(H5F_addr_le(addr + size, accum->loc + accum->size)) { size_t overlap_size; /* Size of overlapping region */ /* Compute overlap size */ - overlap_size = (size_t)((addr + size) - f->shared->accum.loc); + overlap_size = (size_t)((addr + size) - accum->loc); /* Check for dirty region */ - if(f->shared->accum.dirty) { - haddr_t dirty_start = f->shared->accum.loc + f->shared->accum.dirty_off; /* File address of start of dirty region */ - haddr_t dirty_end = dirty_start + f->shared->accum.dirty_len; /* File address of end of dirty region */ + if(accum->dirty) { + haddr_t dirty_start = accum->loc + accum->dirty_off; /* File address of start of dirty region */ + haddr_t dirty_end = dirty_start + accum->dirty_len; /* File address of end of dirty region */ /* Check if entire dirty region is overwritten */ if(H5F_addr_le(dirty_end, addr + size)) { - f->shared->accum.dirty = FALSE; - f->shared->accum.dirty_len = 0; + accum->dirty = FALSE; + accum->dirty_len = 0; } /* end if */ else { /* Check for dirty region falling after write */ if(H5F_addr_le(addr + size, dirty_start)) - f->shared->accum.dirty_off = overlap_size; + accum->dirty_off = overlap_size; else { /* Dirty region overlaps w/written region */ - f->shared->accum.dirty_off = 0; - f->shared->accum.dirty_len -= (size_t)((addr + size) - dirty_start); + accum->dirty_off = 0; + accum->dirty_len -= (size_t)((addr + size) - dirty_start); } /* end else */ } /* end if */ } /* end if */ /* Trim bottom of accumulator off */ - f->shared->accum.loc += overlap_size; - f->shared->accum.size -= overlap_size; - HDmemmove(f->shared->accum.buf, f->shared->accum.buf + overlap_size, f->shared->accum.size); + accum->loc += overlap_size; + accum->size -= overlap_size; + HDmemmove(accum->buf, accum->buf + overlap_size, accum->size); } /* end if */ else { /* Access covers whole accumulator */ /* Reset accumulator, but don't flush */ - if(H5F_accum_reset(f, dxpl_id, FALSE) < 0) + if(H5F__accum_reset(fio_info, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") } /* end else */ } /* end if */ @@ -780,49 +789,49 @@ HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); size_t overlap_size; /* Size of overlapping region */ /* Sanity check */ - HDassert(H5F_addr_gt(addr + size, f->shared->accum.loc + f->shared->accum.size)); + HDassert(H5F_addr_gt(addr + size, accum->loc + accum->size)); /* Compute overlap size */ - overlap_size = (size_t)((f->shared->accum.loc + f->shared->accum.size) - addr); + overlap_size = (size_t)((accum->loc + accum->size) - addr); /* Check for dirty region */ - if(f->shared->accum.dirty) { - haddr_t dirty_start = f->shared->accum.loc + f->shared->accum.dirty_off; /* File address of start of dirty region */ - haddr_t dirty_end = dirty_start + f->shared->accum.dirty_len; /* File address of end of dirty region */ + if(accum->dirty) { + haddr_t dirty_start = accum->loc + accum->dirty_off; /* File address of start of dirty region */ + haddr_t dirty_end = dirty_start + accum->dirty_len; /* File address of end of dirty region */ /* Check if entire dirty region is overwritten */ if(H5F_addr_ge(dirty_start, addr)) { - f->shared->accum.dirty = FALSE; - f->shared->accum.dirty_len = 0; + accum->dirty = FALSE; + accum->dirty_len = 0; } /* end if */ else { /* Check for dirty region falling before write */ if(H5F_addr_le(dirty_end, addr)) ; /* noop */ else /* Dirty region overlaps w/written region */ - f->shared->accum.dirty_len = (size_t)(addr - dirty_start); + accum->dirty_len = (size_t)(addr - dirty_start); } /* end if */ } /* end if */ /* Trim top of accumulator off */ - f->shared->accum.size -= overlap_size; + accum->size -= overlap_size; } /* end else */ } /* end if */ } /* end else */ } /* end if */ else { /* Write the data */ - if(H5FD_write(f->shared->lf, dxpl_id, map_type, addr, size, buf) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_accum_write() */ +} /* end H5F__accum_write() */ /*------------------------------------------------------------------------- - * Function: H5F_accum_free + * Function: H5F__accum_free * * Purpose: Check for free space invalidating [part of] a metadata * accumulator. @@ -836,19 +845,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr, +H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t UNUSED type, haddr_t addr, hsize_t size) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* check arguments */ - HDassert(f); + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(fio_info->dxpl); + + /* Set up alias for file's metadata accumulator info */ + accum = &fio_info->f->shared->accum; /* Adjust the metadata accumulator to remove the freed block, if it overlaps */ - if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) - && H5F_addr_overlap(addr, size, f->shared->accum.loc, f->shared->accum.size)) { + if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) + && H5F_addr_overlap(addr, size, accum->loc, accum->size)) { size_t overlap_size; /* Size of overlap with accumulator */ /* Sanity check */ @@ -857,57 +872,57 @@ H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr, HDassert(H5FD_MEM_GHEAP != type); /* (global heap data is being treated as raw data currently) */ /* Check for overlapping the beginning of the accumulator */ - if(H5F_addr_le(addr, f->shared->accum.loc)) { + if(H5F_addr_le(addr, accum->loc)) { /* Check for completely overlapping the accumulator */ - if(H5F_addr_ge(addr + size, f->shared->accum.loc + f->shared->accum.size)) { + if(H5F_addr_ge(addr + size, accum->loc + accum->size)) { /* Reset the accumulator, but don't free buffer */ - f->shared->accum.loc = HADDR_UNDEF; - f->shared->accum.size = 0; - f->shared->accum.dirty = FALSE; + accum->loc = HADDR_UNDEF; + accum->size = 0; + accum->dirty = FALSE; } /* end if */ /* Block to free must end within the accumulator */ else { size_t new_accum_size; /* Size of new accumulator buffer */ /* Calculate the size of the overlap with the accumulator, etc. */ - H5_ASSIGN_OVERFLOW(overlap_size, (addr + size) - f->shared->accum.loc, haddr_t, size_t); - new_accum_size = f->shared->accum.size - overlap_size; + H5_ASSIGN_OVERFLOW(overlap_size, (addr + size) - accum->loc, haddr_t, size_t); + new_accum_size = accum->size - overlap_size; /* Move the accumulator buffer information to eliminate the freed block */ - HDmemmove(f->shared->accum.buf, f->shared->accum.buf + overlap_size, new_accum_size); + HDmemmove(accum->buf, accum->buf + overlap_size, new_accum_size); /* Adjust the accumulator information */ - f->shared->accum.loc += overlap_size; - f->shared->accum.size = new_accum_size; + accum->loc += overlap_size; + accum->size = new_accum_size; /* Adjust the dirty region and possibly mark accumulator clean */ - if(f->shared->accum.dirty) { + if(accum->dirty) { /* Check if block freed is entirely before dirty region */ - if(overlap_size < f->shared->accum.dirty_off) - f->shared->accum.dirty_off -= overlap_size; + if(overlap_size < accum->dirty_off) + accum->dirty_off -= overlap_size; else { /* Check if block freed ends within dirty region */ - if(overlap_size < (f->shared->accum.dirty_off + f->shared->accum.dirty_len)) { - f->shared->accum.dirty_len = (f->shared->accum.dirty_off + f->shared->accum.dirty_len) - overlap_size; - f->shared->accum.dirty_off = 0; + if(overlap_size < (accum->dirty_off + accum->dirty_len)) { + accum->dirty_len = (accum->dirty_off + accum->dirty_len) - overlap_size; + accum->dirty_off = 0; } /* end if */ /* Block freed encompasses dirty region */ else - f->shared->accum.dirty = FALSE; + accum->dirty = FALSE; } /* end else */ } /* end if */ } /* end else */ } /* end if */ /* Block to free must start within the accumulator */ else { - haddr_t dirty_end = f->shared->accum.loc + f->shared->accum.dirty_off + f->shared->accum.dirty_len; - haddr_t dirty_start = f->shared->accum.loc + f->shared->accum.dirty_off; + haddr_t dirty_end = accum->loc + accum->dirty_off + accum->dirty_len; + haddr_t dirty_start = accum->loc + accum->dirty_off; /* Calculate the size of the overlap with the accumulator */ - H5_ASSIGN_OVERFLOW(overlap_size, (f->shared->accum.loc + f->shared->accum.size) - addr, haddr_t, size_t); + H5_ASSIGN_OVERFLOW(overlap_size, (accum->loc + accum->size) - addr, haddr_t, size_t); /* Check if block to free begins before end of dirty region */ - if(f->shared->accum.dirty && H5F_addr_lt(addr, dirty_end)) { + if(accum->dirty && H5F_addr_lt(addr, dirty_end)) { haddr_t tail_addr; /* Calculate the address of the tail to write */ @@ -918,7 +933,7 @@ H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr, /* Check if block to free is entirely before dirty region */ if(H5F_addr_le(tail_addr, dirty_start)) { /* Write out the entire dirty region of the accumulator */ - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, dirty_start, f->shared->accum.dirty_len, f->shared->accum.buf + f->shared->accum.dirty_off) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Block to free overlaps with some/all of dirty region */ @@ -928,17 +943,17 @@ H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr, size_t dirty_delta; write_size = (size_t)(dirty_end - tail_addr); - dirty_delta = f->shared->accum.dirty_len - write_size; + dirty_delta = accum->dirty_len - write_size; HDassert(write_size > 0); /* Write out the unfreed dirty region of the accumulator */ - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, f->shared->accum.buf + f->shared->accum.dirty_off + dirty_delta) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Reset dirty flag */ - f->shared->accum.dirty = FALSE; + accum->dirty = FALSE; } /* end if */ /* Block to free begins at beginning of or in middle of dirty region */ else { @@ -948,40 +963,40 @@ H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr, size_t dirty_delta; write_size = (size_t)(dirty_end - tail_addr); - dirty_delta = f->shared->accum.dirty_len - write_size; + dirty_delta = accum->dirty_len - write_size; HDassert(write_size > 0); /* Write out the unfreed end of the dirty region of the accumulator */ - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, f->shared->accum.buf + f->shared->accum.dirty_off + dirty_delta) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Check for block to free beginning at same location as dirty region */ if(H5F_addr_eq(addr, dirty_start)) { /* Reset dirty flag */ - f->shared->accum.dirty = FALSE; + accum->dirty = FALSE; } /* end if */ /* Block to free eliminates end of dirty region */ else { - f->shared->accum.dirty_len = (size_t)(addr - dirty_start); + accum->dirty_len = (size_t)(addr - dirty_start); } /* end else */ } /* end else */ } /* end if */ /* Adjust the accumulator information */ - f->shared->accum.size = f->shared->accum.size - overlap_size; + accum->size = accum->size - overlap_size; } /* end else */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_accum_free() */ +} /* end H5F__accum_free() */ /*------------------------------------------------------------------------- - * Function: H5F_accum_flush + * Function: H5F__accum_flush * * Purpose: Flush the metadata accumulator to the file * @@ -994,32 +1009,33 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_accum_flush(const H5F_t *f, hid_t dxpl_id) +H5F__accum_flush(const H5F_io_info_t *fio_info) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert(f); - HDassert(f->shared); + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(fio_info->dxpl); /* Check if we need to flush out the metadata accumulator */ - if((f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && f->shared->accum.dirty) { + if((fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && fio_info->f->shared->accum.dirty) { /* Flush the metadata contents */ - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, f->shared->accum.loc + f->shared->accum.dirty_off, f->shared->accum.dirty_len, f->shared->accum.buf + f->shared->accum.dirty_off) < 0) + if(H5FD_write(fio_info->f->shared->lf, fio_info->dxpl, H5FD_MEM_DEFAULT, fio_info->f->shared->accum.loc + fio_info->f->shared->accum.dirty_off, fio_info->f->shared->accum.dirty_len, fio_info->f->shared->accum.buf + fio_info->f->shared->accum.dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset the dirty flag */ - f->shared->accum.dirty = FALSE; + fio_info->f->shared->accum.dirty = FALSE; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_accum_flush() */ +} /* end H5F__accum_flush() */ /*------------------------------------------------------------------------- - * Function: H5F_accum_reset + * Function: H5F__accum_reset * * Purpose: Reset the metadata accumulator for the file * @@ -1032,37 +1048,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_accum_reset(const H5F_t *f, hid_t dxpl_id, hbool_t flush) +H5F__accum_reset(const H5F_io_info_t *fio_info, hbool_t flush) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE - HDassert(f); - HDassert(f->shared); + HDassert(fio_info); + HDassert(fio_info->f); + HDassert(fio_info->dxpl); /* Flush any dirty data in accumulator, if requested */ if(flush) - if(H5F_accum_flush(f, dxpl_id) < 0) + if(H5F__accum_flush(fio_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "can't flush metadata accumulator") /* Check if we need to reset the metadata accumulator information */ - if(f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { + if(fio_info->f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { /* Sanity check */ - HDassert(!f->closing || FALSE == f->shared->accum.dirty); + HDassert(!fio_info->f->closing || FALSE == fio_info->f->shared->accum.dirty); /* Free the buffer */ - if(f->shared->accum.buf) - f->shared->accum.buf = H5FL_BLK_FREE(meta_accum, f->shared->accum.buf); + if(fio_info->f->shared->accum.buf) + fio_info->f->shared->accum.buf = H5FL_BLK_FREE(meta_accum, fio_info->f->shared->accum.buf); /* Reset the buffer sizes & location */ - f->shared->accum.alloc_size = f->shared->accum.size = 0; - f->shared->accum.loc = HADDR_UNDEF; - f->shared->accum.dirty = FALSE; - f->shared->accum.dirty_len = 0; + fio_info->f->shared->accum.alloc_size = fio_info->f->shared->accum.size = 0; + fio_info->f->shared->accum.loc = HADDR_UNDEF; + fio_info->f->shared->accum.dirty = FALSE; + fio_info->f->shared->accum.dirty_len = 0; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_accum_reset() */ +} /* end H5F__accum_reset() */ diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index ef28e13..258f5fb 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -34,7 +34,7 @@ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5F_init_deprec_interface +#define H5_INTERFACE_INIT_FUNC H5F__init_deprec_interface /***********/ @@ -85,9 +85,9 @@ /*-------------------------------------------------------------------------- NAME - H5F_init_deprec_interface -- Initialize interface-specific information + H5F__init_deprec_interface -- Initialize interface-specific information USAGE - herr_t H5F_init_deprec_interface() + herr_t H5F__init_deprec_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -96,12 +96,36 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5F_init_deprec_interface(void) +H5F__init_deprec_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5F_init()) -} /* H5F_init_deprec_interface() */ +} /* H5F__init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5F__term_deprec_interface -- Terminate interface +USAGE + herr_t H5F__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5F__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5F__term_deprec_interface() */ #ifndef H5_NO_DEPRECATED_SYMBOLS diff --git a/src/H5Fint.c b/src/H5Fint.c index c8cb425..c6f68cb 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -130,7 +130,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HDassert(f); /* Make a copy of the default file access property list */ - if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_g))) + if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list") @@ -606,7 +606,7 @@ H5F_is_hdf5(const char *name) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") /* The file is an hdf5 file if the hdf5 file signature can be found */ - if(H5F_locate_signature(file, H5AC_ind_dxpl_id, &sig_addr) < 0) + if(H5FD_locate_signature(file, H5AC_ind_dxpl_g, &sig_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") ret_value = (HADDR_UNDEF != sig_addr); @@ -825,6 +825,8 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) HDassert(f->shared); if(1 == f->shared->nrefs) { + H5F_io_info_t fio_info; /* I/O info for operation */ + /* Flush at this point since the file will be closed. * Only try to flush the file if it was opened with write access, and if * the caller requested a flush. @@ -894,8 +896,13 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) f->shared->root_grp = NULL; } /* end if */ + /* Set up I/O info for operation */ + fio_info.f = f; + if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Destroy other components of the file */ - if(H5F_accum_reset(f, dxpl_id, TRUE) < 0) + if(H5F__accum_reset(&fio_info, TRUE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") if(H5FO_dest(f) < 0) @@ -1211,6 +1218,7 @@ done: herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing) { + H5F_io_info_t fio_info; /* I/O info for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1238,8 +1246,13 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") + /* Set up I/O info for operation */ + fio_info.f = f; + if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Flush out the metadata accumulator */ - if(H5F_accum_flush(f, dxpl_id) < 0) + if(H5F__accum_flush(&fio_info) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator") @@ -1932,7 +1945,6 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) if(HDstrcmp(fd_ptr->cls->name, "family") == 0) 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, FAIL, "unable to get file size") @@ -1952,7 +1964,7 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) /* read in the file image */ /* (Note compensation for base address addition in internal routine) */ - if(H5FD_read(fd_ptr, H5AC_ind_dxpl_id, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) + if(H5FD_read(fd_ptr, H5AC_ind_dxpl_g, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "file image read request failed") } /* end if */ diff --git a/src/H5Fio.c b/src/H5Fio.c index d494488..1d05cd0 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -38,6 +38,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ /****************/ @@ -95,6 +96,7 @@ herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/) { + H5F_io_info_t fio_info; /* I/O info for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -108,8 +110,13 @@ H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, if(H5F_addr_le(f->shared->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") + /* Set up I/O info for operation */ + fio_info.f = f; + if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Pass through metadata accumulator layer */ - if(H5F_accum_read(f, dxpl_id, type, addr, size, buf) < 0) + if(H5F__accum_read(&fio_info, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through metadata accumulator failed") done: @@ -136,6 +143,7 @@ herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, const void *buf) { + H5F_io_info_t fio_info; /* I/O info for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -153,8 +161,13 @@ HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size); if(H5F_addr_le(f->shared->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") + /* Set up I/O info for operation */ + fio_info.f = f; + if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Pass through metadata accumulator layer */ - if(H5F_accum_write(f, dxpl_id, type, addr, size, buf) < 0) + if(H5F__accum_write(&fio_info, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through metadata accumulator failed") done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 7b62d01..e543015 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -54,10 +54,6 @@ # undef H5F_DEBUG #endif -/* Define the HDF5 file signature */ -#define H5F_SIGNATURE "\211HDF\r\n\032\n" -#define H5F_SIGNATURE_LEN 8 - /* Superblock status flags */ #define H5F_SUPER_WRITE_ACCESS 0x01 #define H5F_SUPER_FILE_OK 0x02 @@ -296,7 +292,7 @@ H5_DLLVAR const H5AC_class_t H5AC_SUPERBLOCK[1]; /* General routines */ H5_DLL herr_t H5F_init(void); -H5_DLL herr_t H5F_locate_signature(H5FD_t *file, hid_t dxpl_id, haddr_t *sig_addr); +H5_DLL herr_t H5F__term_deprec_interface(void); H5_DLL herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing); /* File mount related routines */ @@ -320,14 +316,14 @@ H5_DLL herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id, hbool_t was_created); /* Metadata accumulator routines */ -H5_DLL herr_t H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, +H5_DLL herr_t H5F__accum_read(const H5F_io_info_t *fio_info, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); -H5_DLL herr_t H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, +H5_DLL herr_t H5F__accum_write(const H5F_io_info_t *fio_info, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, +H5_DLL herr_t H5F__accum_free(const H5F_io_info_t *fio_info, H5FD_mem_t type, haddr_t addr, hsize_t size); -H5_DLL herr_t H5F_accum_flush(const H5F_t *f, hid_t dxpl_id); -H5_DLL herr_t H5F_accum_reset(const H5F_t *f, hid_t dxpl_id, hbool_t flush); +H5_DLL herr_t H5F__accum_flush(const H5F_io_info_t *fio_info); +H5_DLL herr_t H5F__accum_reset(const H5F_io_info_t *fio_info, hbool_t flush); /* Shared file list related routines */ H5_DLL herr_t H5F_sfile_add(H5F_file_t *shared); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index a8c8ee4..b459476 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -29,16 +29,9 @@ /* Private headers needed by this file */ #include "H5VMprivate.h" /* Vectors and arrays */ -/****************************/ -/* Library Private Typedefs */ -/****************************/ - -/* Main file structure */ -typedef struct H5F_t H5F_t; -typedef struct H5F_file_t H5F_file_t; - -/* Block aggregation structure */ -typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; +/**************************/ +/* Library Private Macros */ +/**************************/ /* User data for traversal routine to get ID counts */ typedef struct { @@ -476,6 +469,8 @@ typedef struct { #define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ #define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ #define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */ +#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME "core_write_tracking_flag" /* Whether or not core VFD backing store write tracking is enabled */ +#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME "core_write_tracking_page_size" /* The page size in kiB when core VFD write tracking is enabled */ /* ======================== File Mount properties ====================*/ #define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */ @@ -486,6 +481,10 @@ typedef struct { #define H5_PAR_META_WRITE 0 #endif /* H5_HAVE_PARALLEL */ +/* Define the HDF5 file signature */ +#define H5F_SIGNATURE "\211HDF\r\n\032\n" +#define H5F_SIGNATURE_LEN 8 + /* Version #'s of the major components of the file format */ #define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ #define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */ @@ -561,12 +560,43 @@ typedef struct { #define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ -/* Forward declarations for prototype arguments */ +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/* Forward declarations (for prototypes & type definitions) */ struct H5B_class_t; struct H5UC_t; struct H5O_loc_t; struct H5HG_heap_t; struct H5VL_class_t; +struct H5P_genplist_t; + +/* Forward declarations for anonymous H5F objects */ + +/* Main file structures */ +typedef struct H5F_t H5F_t; +typedef struct H5F_file_t H5F_file_t; + +/* Block aggregation structure */ +typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; + +/* I/O Info for an operation */ +typedef struct H5F_io_info_t { + const H5F_t *f; /* File object */ + const struct H5P_genplist_t *dxpl; /* DXPL object */ +} H5F_io_info_t; + + +/*****************************/ +/* Library-private Variables */ +/*****************************/ + + +/***************************************/ +/* Library-private Function Prototypes */ +/***************************************/ + /* Private functions */ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index a1c67ec..dd80a46 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -100,70 +100,6 @@ H5F_init_super_interface(void) /*------------------------------------------------------------------------- - * Function: H5F_locate_signature - * - * Purpose: Finds the HDF5 superblock signature in a file. The - * signature can appear at address 0, or any power of two - * beginning with 512. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - *------------------------------------------------------------------------- - */ -herr_t -H5F_locate_signature(H5FD_t *file, hid_t dxpl_id, haddr_t *sig_addr) -{ - haddr_t addr, eoa; - uint8_t buf[H5F_SIGNATURE_LEN]; - unsigned n, maxpow; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Find the least N such that 2^N is larger than the file size */ - if(HADDR_UNDEF == (addr = H5FD_get_eof(file)) || HADDR_UNDEF == (eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER))) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value") - for(maxpow = 0; addr; maxpow++) - addr >>= 1; - maxpow = MAX(maxpow, 9); - - /* - * Search for the file signature at format address zero followed by - * powers of two larger than 9. - */ - for(n = 8; n < maxpow; n++) { - addr = (8 == n) ? 0 : (haddr_t)1 << n; - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature") - if(H5FD_read(file, dxpl_id, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature") - if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) - break; - } /* end for */ - - /* - * If the signature was not found then reset the EOA value and return - * HADDR_UNDEF. - */ - if(n >= maxpow) { - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value") - *sig_addr = HADDR_UNDEF; - } /* end if */ - else - /* Set return value */ - *sig_addr = addr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_locate_signature() */ - - -/*------------------------------------------------------------------------- * Function: H5F_super_ext_create * * Purpose: Create the superblock extension @@ -320,6 +256,7 @@ done: herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id) { + H5P_genplist_t *dxpl; /* DXPL object */ H5F_super_t * sblock = NULL; /* superblock structure */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ haddr_t super_addr; /* Absolute address of superblock */ @@ -329,8 +266,12 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id) FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL) + /* Get the DXPL plist object for DXPL ID */ + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Find the superblock */ - if(H5F_locate_signature(f->shared->lf, dxpl_id, &super_addr) < 0) + if(H5FD_locate_signature(f->shared->lf, dxpl, &super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") if(HADDR_UNDEF == super_addr) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found") diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 48fd139..45fad37 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -116,6 +116,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) H5F_super_t *sblock = NULL; /* File's superblock */ haddr_t base_addr = HADDR_UNDEF; /* Base address of file */ uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Buffer for superblock */ + H5P_genplist_t *dxpl; /* DXPL object */ H5P_genplist_t *c_plist; /* File creation property list */ H5F_file_t *shared; /* shared part of `file' */ H5FD_t *lf; /* file driver part of `shared' */ @@ -159,12 +160,16 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) sblock->cache_info.flush_me_collectively = TRUE; #endif + /* Get the DXPL plist object for DXPL ID */ + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get property list") + /* Read fixed-size portion of the superblock */ p = sbuf; H5_CHECK_OVERFLOW(fixed_size, size_t, haddr_t); if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, (haddr_t)fixed_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, fixed_size, p) < 0) + if(H5FD_read(lf, dxpl, H5FD_MEM_SUPER, (haddr_t)0, fixed_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Skip over signature (already checked when locating the superblock) */ @@ -191,7 +196,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) /* Read in variable-sized portion of superblock */ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, (haddr_t)(fixed_size + variable_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)fixed_size, variable_size, p) < 0) + if(H5FD_read(lf, dxpl, H5FD_MEM_SUPER, (haddr_t)fixed_size, variable_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read superblock") /* Check for older version of superblock format */ @@ -345,7 +350,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) p = dbuf; if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, sblock->driver_addr, (size_t)H5F_DRVINFOBLOCK_HDR_SIZE, p) < 0) + if(H5FD_read(lf, dxpl, H5FD_MEM_SUPER, sblock->driver_addr, (size_t)H5F_DRVINFOBLOCK_HDR_SIZE, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read driver information block") /* Version number */ @@ -377,7 +382,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) /* Read in variable-sized portion of driver info block */ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE, drv_variable_size, p) < 0) + if(H5FD_read(lf, dxpl, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE, drv_variable_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read file driver information") /* Decode driver information */ @@ -655,11 +660,12 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr, #endif if(sblock->cache_info.is_dirty) { + H5P_genplist_t *dxpl; /* DXPL object */ uint8_t buf[H5F_MAX_SUPERBLOCK_SIZE + H5F_MAX_DRVINFOBLOCK_SIZE]; /* Superblock & driver info blockencoding buffer */ - uint8_t *p; /* Ptr into encoding buffer */ - haddr_t rel_eoa; /* Relative EOA for file */ - size_t superblock_size; /* Size of superblock, in bytes */ - size_t driver_size; /* Size of driver info block (bytes)*/ + uint8_t *p; /* Ptr into encoding buffer */ + haddr_t rel_eoa; /* Relative EOA for file */ + size_t superblock_size; /* Size of superblock, in bytes */ + size_t driver_size; /* Size of driver info block (bytes)*/ /* Encode the common portion of the file superblock for all versions */ p = buf; @@ -783,9 +789,13 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr, /* Double check we didn't overrun the block (unlikely) */ HDassert(superblock_size <= sizeof(buf)); + /* Get the DXPL plist object for DXPL ID */ + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Write superblock */ /* (always at relative address 0) */ - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, superblock_size, buf) < 0) + if(H5FD_write(f->shared->lf, dxpl, H5FD_MEM_SUPER, (haddr_t)0, superblock_size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock") /* Check for newer version of superblock format & superblock extension */ @@ -226,16 +226,19 @@ H5G_term_interface(void) FUNC_ENTER_NOAPI_NOINIT_NOERR if(H5_interface_initialize_g) { - if((n = H5I_nmembers(H5I_GROUP))) - H5I_clear_type(H5I_GROUP, FALSE, FALSE); - else { - /* Destroy the group object id group */ - H5I_dec_type_ref(H5I_GROUP); - - /* Mark closed */ - H5_interface_initialize_g = 0; - n = 1; /*H5I*/ - } /* end else */ + if((n = H5I_nmembers(H5I_GROUP))) + H5I_clear_type(H5I_GROUP, FALSE, FALSE); + else { + /* Close deprecated interface */ + n += H5G__term_deprec_interface(); + + /* Destroy the group object id group */ + H5I_dec_type_ref(H5I_GROUP); + + /* Mark closed */ + H5_interface_initialize_g = 0; + n = 1; /*H5I*/ + } /* end else */ } /* end if */ FUNC_LEAVE_NOAPI(n) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index e4fed3e..285c823 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -34,7 +34,7 @@ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5G_init_deprec_interface +#define H5_INTERFACE_INIT_FUNC H5G__init_deprec_interface /***********/ @@ -105,9 +105,9 @@ static H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, /*-------------------------------------------------------------------------- NAME - H5G_init_deprec_interface -- Initialize interface-specific information + H5G__init_deprec_interface -- Initialize interface-specific information USAGE - herr_t H5G_init_deprec_interface() + herr_t H5G__init_deprec_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -116,12 +116,36 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5G_init_deprec_interface(void) +H5G__init_deprec_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5G__init()) -} /* H5G_init_deprec_interface() */ +} /* H5G__init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5G__term_deprec_interface -- Terminate interface +USAGE + herr_t H5G__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5G__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5G__term_deprec_interface() */ #ifndef H5_NO_DEPRECATED_SYMBOLS diff --git a/src/H5Gint.c b/src/H5Gint.c index 5531cc5..d31737a 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -1216,7 +1216,7 @@ H5G_get_create_plist(H5G_t *grp) FUNC_ENTER_NOAPI(FAIL) /* Copy the default group creation property list */ - if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_g))) + if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index e2180c0..b194adb 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -352,6 +352,7 @@ H5_DLL herr_t H5G__traverse_special(const H5G_loc_t *grp_loc, * Utility functions */ H5_DLL herr_t H5G__init(void); +H5_DLL herr_t H5G__term_deprec_interface(void); H5_DLL const char *H5G__component(const char *name, size_t *size_p); /* @@ -38,8 +38,9 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ #include "H5MFpkg.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ @@ -600,6 +601,7 @@ herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, haddr_t addr, hsize_t size) { + H5F_io_info_t fio_info; /* I/O info for operation */ H5MF_free_section_t *node = NULL; /* Free space section pointer */ H5MF_sect_ud_t udata; /* User data for callback */ H5FD_mem_t fs_type; /* Free space type (mapped from allocation type) */ @@ -620,8 +622,13 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN if(H5F_addr_le(f->shared->tmp_addr, addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space") + /* Set up I/O info for operation */ + fio_info.f = f; + if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Check if the space to free intersects with the file's metadata accumulator */ - if(H5F_accum_free(f, dxpl_id, alloc_type, addr, size) < 0) + if(H5F__accum_free(&fio_info, alloc_type, addr, size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't check free space intersection w/metadata accumulator") /* Get free space type from allocation type */ @@ -843,7 +850,7 @@ H5MF_get_freespace(H5F_t *f, hid_t dxpl_id, hsize_t *tot_space, hsize_t *meta_si hsize_t tot_fs_size = 0; /* Amount of all free space managed */ hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ H5FD_mem_t type; /* Memory type for iteration */ - H5FD_mem_t fs_started[H5FD_MEM_NTYPES]; /* Indicate whether the free-space manager has been started */ + hbool_t fs_started[H5FD_MEM_NTYPES]; /* Indicate whether the free-space manager has been started */ hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ herr_t ret_value = SUCCEED; /* Return value */ @@ -25,7 +25,7 @@ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5P_init_pub_interface +#define H5_INTERFACE_INIT_FUNC H5P__init_pub_interface /***********/ @@ -75,9 +75,9 @@ typedef struct { /*-------------------------------------------------------------------------- NAME - H5P_init_pub_interface -- Initialize interface-specific information + H5P__init_pub_interface -- Initialize interface-specific information USAGE - herr_t H5P_init_pub_interface() + herr_t H5P__init_pub_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -86,12 +86,36 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5P_init_pub_interface(void) +H5P__init_pub_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5P_init()) -} /* H5P_init_pub_interface() */ +} /* H5P__init_pub_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5P__term_pub_interface -- Terminate interface +USAGE + herr_t H5P__term_pub_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5P__term_pub_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5P__term_pub_interface() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index df972b2..180c877 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -71,10 +71,13 @@ static herr_t H5P_acrt_reg_prop(H5P_genclass_t *pclass); const H5P_libclass_t H5P_CLS_ACRT[1] = {{ "attribute create", /* Class name for debugging */ H5P_TYPE_ATTRIBUTE_CREATE, /* Class type */ - &H5P_CLS_STRING_CREATE_g, /* Parent class ID */ - &H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class ID */ - &H5P_LST_ATTRIBUTE_CREATE_g, /* Pointer to default property list ID */ + + &H5P_CLS_STRING_CREATE_g, /* Parent class */ + &H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class */ + &H5P_CLS_ATTRIBUTE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_ATTRIBUTE_CREATE_ID_g, /* Pointer to default property list ID */ H5P_acrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 5239fba..93d16bb 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -88,10 +88,13 @@ static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass); const H5P_libclass_t H5P_CLS_DACC[1] = {{ "dataset access", /* Class name for debugging */ H5P_TYPE_DATASET_ACCESS, /* Class type */ - &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ - &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class ID */ - &H5P_LST_DATASET_ACCESS_g, /* Pointer to default property list ID */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ H5P__dacc_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -195,7 +198,7 @@ H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double /* Check arguments. Note that we allow negative values - they are * considered to "unset" the property. */ - if(rdcc_w0 > 1.0) + if(rdcc_w0 > (double)1.0f) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); /* Get the plist structure */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index acd48af..c510843 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -144,10 +144,13 @@ static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, s const H5P_libclass_t H5P_CLS_DCRT[1] = {{ "dataset create", /* Class name for debugging */ H5P_TYPE_DATASET_CREATE, /* Class type */ - &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ - &H5P_CLS_DATASET_CREATE_g, /* Pointer to class ID */ - &H5P_LST_DATASET_CREATE_g, /* Pointer to default property list ID */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_DATASET_CREATE_g, /* Pointer to class */ + &H5P_CLS_DATASET_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_CREATE_ID_g, /* Pointer to default property list ID */ H5P__dcrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ H5P__dcrt_copy, /* Class copy callback */ @@ -2024,7 +2027,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P_get_fill_value(H5P_genplist_t *plist, H5T_t *type, void *value/*out*/, +H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/, hid_t dxpl_id) { H5O_fill_t fill; /* Fill value to retrieve */ diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index cb5e10f..e4e91ac 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -34,7 +34,7 @@ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5P_init_deprec_interface +#define H5_INTERFACE_INIT_FUNC H5P__init_deprec_interface /***********/ @@ -42,6 +42,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5Iprivate.h" /* IDs */ #include "H5Ppkg.h" /* Property lists */ @@ -84,9 +85,9 @@ /*-------------------------------------------------------------------------- NAME - H5P_init_deprec_interface -- Initialize interface-specific information + H5P__init_deprec_interface -- Initialize interface-specific information USAGE - herr_t H5P_init_deprec_interface() + herr_t H5P__init_deprec_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -95,12 +96,36 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5P_init_deprec_interface(void) +H5P__init_deprec_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5P_init()) -} /* H5P_init_deprec_interface() */ +} /* H5P__init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5P__term_deprec_interface -- Terminate interface +USAGE + herr_t H5P__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5P__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + + FUNC_LEAVE_NOAPI(0) +} /* H5P__term_deprec_interface() */ #ifndef H5_NO_DEPRECATED_SYMBOLS diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 472700a..ab96c4e 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -214,10 +214,13 @@ static herr_t H5P__dxfr_xform_close(const char* name, size_t size, void* value); const H5P_libclass_t H5P_CLS_DXFR[1] = {{ "data transfer", /* Class name for debugging */ H5P_TYPE_DATASET_XFER, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_DATASET_XFER_g, /* Pointer to class ID */ - &H5P_LST_DATASET_XFER_g, /* Pointer to default property list ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_DATASET_XFER_g, /* Pointer to class */ + &H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */ H5P__dxfr_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index 0c70c6c..3285ae3 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -24,8 +24,10 @@ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ +#ifdef NOT_YET /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5P_init_encdec_interface +#endif /* NOT_YET */ /***********/ @@ -33,9 +35,11 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppkg.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -78,6 +82,7 @@ typedef struct { /*******************/ +#ifdef NOT_YET /*-------------------------------------------------------------------------- NAME @@ -98,6 +103,7 @@ H5P_init_encdec_interface(void) FUNC_LEAVE_NOAPI(H5P_init()) } /* H5P_init_encdec_interface() */ +#endif /* NOT_YET */ /*------------------------------------------------------------------------- diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 59c0a2e..6181b88 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -36,11 +36,11 @@ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ +#include "H5Fprivate.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5VLprivate.h" /* VOL plugins */ #include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory Management */ +#include "H5MMprivate.h" /* Memory Management */ #include "H5Ppkg.h" /* Property lists */ /* Includes needed to set as default file driver */ @@ -51,7 +51,7 @@ #include "H5VLnative.h" /* Native H5 VOL plugin */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Windows buffered I/O */ +#include "H5FDwindows.h" /* Windows buffered I/O */ #endif /****************/ @@ -171,6 +171,16 @@ #define H5F_ACS_FILE_IMAGE_INFO_DEL H5P_file_image_info_del #define H5F_ACS_FILE_IMAGE_INFO_COPY H5P_file_image_info_copy #define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P_file_image_info_close +/* Definition of core VFD write tracking flag */ +#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE sizeof(hbool_t) +#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF FALSE +#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC H5P__encode_hbool_t +#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC H5P__decode_hbool_t +/* Definition of core VFD write tracking page size */ +#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF 524288 +#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC H5P__decode_size_t /******************/ /* Local Typedefs */ @@ -214,10 +224,13 @@ static herr_t H5P__facc_multi_type_dec(const void **_pp, void *value); const H5P_libclass_t H5P_CLS_FACC[1] = {{ "file access", /* Class name for debugging */ H5P_TYPE_FILE_ACCESS, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_FILE_ACCESS_g, /* Pointer to class ID */ - &H5P_LST_FILE_ACCESS_g, /* Pointer to default property list ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_FILE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */ H5P_facc_reg_prop, /* Default property registration routine */ + H5P_facc_create, /* Class creation callback */ NULL, /* Class creation callback info */ H5P_facc_copy, /* Class copy callback */ @@ -256,8 +269,9 @@ static const H5FD_mem_t H5F_def_mem_type_g = H5F_ACS_MULTI_TYPE_DEF; static const hbool_t H5F_def_latest_format_g = H5F_ACS_LATEST_FORMAT_DEF; /* Default setting for "use the latest version of the format" flag */ static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ -static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ - +static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ +static const hbool_t H5F_def_core_write_tracking_flag_g = H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF; /* Default setting for core VFD write tracking */ +static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF; /* Default core VFD write tracking page size */ /*------------------------------------------------------------------------- @@ -419,6 +433,18 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, NULL, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the core VFD backing store write tracking flag */ + if(H5P_register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE, &H5F_def_core_write_tracking_flag_g , + NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC, H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the size of the core VFD backing store page size */ + if(H5P_register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE, &H5F_def_core_write_tracking_page_size_g , + NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_facc_reg_prop() */ @@ -1170,7 +1196,7 @@ H5Pset_cache(hid_t plist_id, int UNUSED mdc_nelmts, rdcc_w0); /* Check arguments */ - if(rdcc_w0 < 0.0 || rdcc_w0 > 1.0) + if(rdcc_w0 < (double)0.0f || rdcc_w0 > (double)1.0f) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive") /* Get the plist structure */ @@ -3212,3 +3238,76 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_multi_type_dec() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_core_write_tracking + * + * Purpose: Enables/disables core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Set values */ + if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &is_enabled) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking flag") + if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &page_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking page size") + +done: + FUNC_LEAVE_API(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_core_write_tracking + * + * Purpose: Gets information about core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get values */ + if(is_enabled) { + if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, is_enabled) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking flag") + } /* end if */ + + if(page_size) { + if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, page_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking page size") + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 3eb9c5b..aca589c 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -140,10 +140,13 @@ static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *value); const H5P_libclass_t H5P_CLS_FCRT[1] = {{ "file create", /* Class name for debugging */ H5P_TYPE_FILE_CREATE, /* Class type */ - &H5P_CLS_GROUP_CREATE_g, /* Parent class ID */ - &H5P_CLS_FILE_CREATE_g, /* Pointer to class ID */ - &H5P_LST_FILE_CREATE_g, /* Pointer to default property list ID */ + + &H5P_CLS_GROUP_CREATE_g, /* Parent class */ + &H5P_CLS_FILE_CREATE_g, /* Pointer to class */ + &H5P_CLS_FILE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_CREATE_ID_g, /* Pointer to default property list ID */ H5P_fcrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Pfmpl.c b/src/H5Pfmpl.c index 1c4d3f4..875f101 100644 --- a/src/H5Pfmpl.c +++ b/src/H5Pfmpl.c @@ -35,6 +35,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5Iprivate.h" /* IDs */ #include "H5Ppkg.h" /* Property lists */ @@ -75,10 +76,13 @@ static herr_t H5P_fmnt_reg_prop(H5P_genclass_t *pclass); const H5P_libclass_t H5P_CLS_FMNT[1] = {{ "file mount", /* Class name for debugging */ H5P_TYPE_FILE_MOUNT, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_FILE_MOUNT_g, /* Pointer to class ID */ - &H5P_LST_FILE_MOUNT_g, /* Pointer to default property list ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_FILE_MOUNT_g, /* Pointer to class */ + &H5P_CLS_FILE_MOUNT_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_MOUNT_ID_g, /* Pointer to default property list ID */ H5P_fmnt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 1d7d184..6de7a42 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -34,7 +34,9 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ #include "H5Ppkg.h" /* Property lists */ @@ -81,10 +83,13 @@ static herr_t H5P__gcrt_link_info_dec(const void **_pp, void *value); const H5P_libclass_t H5P_CLS_GCRT[1] = {{ "group create", /* Class name for debugging */ H5P_TYPE_GROUP_CREATE, /* Class type */ - &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ - &H5P_CLS_GROUP_CREATE_g, /* Pointer to class ID */ - &H5P_LST_GROUP_CREATE_g, /* Pointer to default property list ID */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_GROUP_CREATE_g, /* Pointer to class */ + &H5P_CLS_GROUP_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_GROUP_CREATE_ID_g, /* Pointer to default property list ID */ H5P__gcrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 8837363..4ad8ca0 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -98,51 +98,71 @@ static int H5P_cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2); * Predefined property list classes. These are initialized at runtime by * H5P_init_interface() in this source file. */ -hid_t H5P_CLS_ROOT_g = FAIL; -hid_t H5P_CLS_OBJECT_CREATE_g = FAIL; -hid_t H5P_CLS_FILE_CREATE_g = FAIL; -hid_t H5P_CLS_FILE_ACCESS_g = FAIL; -hid_t H5P_CLS_DATASET_CREATE_g = FAIL; -hid_t H5P_CLS_DATASET_ACCESS_g = FAIL; -hid_t H5P_CLS_DATASET_XFER_g = FAIL; -hid_t H5P_CLS_FILE_MOUNT_g = FAIL; -hid_t H5P_CLS_GROUP_CREATE_g = FAIL; -hid_t H5P_CLS_GROUP_ACCESS_g = FAIL; -hid_t H5P_CLS_DATATYPE_CREATE_g = FAIL; -hid_t H5P_CLS_DATATYPE_ACCESS_g = FAIL; -hid_t H5P_CLS_ATTRIBUTE_CREATE_g = FAIL; -hid_t H5P_CLS_OBJECT_COPY_g = FAIL; -hid_t H5P_CLS_LINK_CREATE_g = FAIL; -hid_t H5P_CLS_LINK_ACCESS_g = FAIL; -hid_t H5P_CLS_STRING_CREATE_g = FAIL; +hid_t H5P_CLS_ROOT_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_ROOT_g = NULL; +hid_t H5P_CLS_OBJECT_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; +hid_t H5P_CLS_FILE_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; +hid_t H5P_CLS_FILE_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; +hid_t H5P_CLS_DATASET_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_XFER_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL; +hid_t H5P_CLS_FILE_MOUNT_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL; +hid_t H5P_CLS_GROUP_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; +hid_t H5P_CLS_GROUP_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL; +hid_t H5P_CLS_DATATYPE_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; +hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; +hid_t H5P_CLS_OBJECT_COPY_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; +hid_t H5P_CLS_LINK_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; +hid_t H5P_CLS_LINK_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; +hid_t H5P_CLS_STRING_CREATE_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; /* * Predefined property lists for each predefined class. These are initialized * at runtime by H5P_init_interface() in this source file. */ -hid_t H5P_LST_FILE_CREATE_g = FAIL; -hid_t H5P_LST_FILE_ACCESS_g = FAIL; -hid_t H5P_LST_DATASET_CREATE_g = FAIL; -hid_t H5P_LST_DATASET_ACCESS_g = FAIL; -hid_t H5P_LST_DATASET_XFER_g = FAIL; -hid_t H5P_LST_FILE_MOUNT_g = FAIL; -hid_t H5P_LST_GROUP_CREATE_g = FAIL; -hid_t H5P_LST_GROUP_ACCESS_g = FAIL; -hid_t H5P_LST_DATATYPE_CREATE_g = FAIL; -hid_t H5P_LST_DATATYPE_ACCESS_g = FAIL; -hid_t H5P_LST_ATTRIBUTE_CREATE_g = FAIL; -hid_t H5P_LST_OBJECT_COPY_g = FAIL; -hid_t H5P_LST_LINK_CREATE_g = FAIL; -hid_t H5P_LST_LINK_ACCESS_g = FAIL; +hid_t H5P_LST_FILE_CREATE_ID_g = FAIL; +hid_t H5P_LST_FILE_ACCESS_ID_g = FAIL; +hid_t H5P_LST_DATASET_CREATE_ID_g = FAIL; +hid_t H5P_LST_DATASET_ACCESS_ID_g = FAIL; +hid_t H5P_LST_DATASET_XFER_ID_g = FAIL; +hid_t H5P_LST_FILE_MOUNT_ID_g = FAIL; +hid_t H5P_LST_GROUP_CREATE_ID_g = FAIL; +hid_t H5P_LST_GROUP_ACCESS_ID_g = FAIL; +hid_t H5P_LST_DATATYPE_CREATE_ID_g = FAIL; +hid_t H5P_LST_DATATYPE_ACCESS_ID_g = FAIL; +hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = FAIL; +hid_t H5P_LST_OBJECT_COPY_ID_g = FAIL; +hid_t H5P_LST_LINK_CREATE_ID_g = FAIL; +hid_t H5P_LST_LINK_ACCESS_ID_g = FAIL; /* Root property list class library initialization object */ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ "root", /* Class name for debugging */ H5P_TYPE_ROOT, /* Class type */ - NULL, /* Parent class ID */ - &H5P_CLS_ROOT_g, /* Pointer to class ID */ + + NULL, /* Parent class */ + &H5P_CLS_ROOT_g, /* Pointer to class */ + &H5P_CLS_ROOT_ID_g, /* Pointer to class ID */ NULL, /* Pointer to default property list ID */ NULL, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -156,10 +176,13 @@ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ const H5P_libclass_t H5P_CLS_GACC[1] = {{ "group access", /* Class name for debugging */ H5P_TYPE_GROUP_ACCESS, /* Class type */ - &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ - &H5P_CLS_GROUP_ACCESS_g, /* Pointer to class ID */ - &H5P_LST_GROUP_ACCESS_g, /* Pointer to default property list ID */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_GROUP_ACCESS_g, /* Pointer to class */ + &H5P_CLS_GROUP_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_GROUP_ACCESS_ID_g, /* Pointer to default property list ID */ NULL, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -173,10 +196,13 @@ const H5P_libclass_t H5P_CLS_GACC[1] = {{ const H5P_libclass_t H5P_CLS_TCRT[1] = {{ "datatype create", /* Class name for debugging */ H5P_TYPE_DATATYPE_CREATE, /* Class type */ - &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ - &H5P_CLS_DATATYPE_CREATE_g, /* Pointer to class ID */ - &H5P_LST_DATATYPE_CREATE_g, /* Pointer to default property list ID */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_DATATYPE_CREATE_g, /* Pointer to class */ + &H5P_CLS_DATATYPE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_DATATYPE_CREATE_ID_g, /* Pointer to default property list ID */ NULL, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -190,10 +216,13 @@ const H5P_libclass_t H5P_CLS_TCRT[1] = {{ const H5P_libclass_t H5P_CLS_TACC[1] = {{ "datatype access", /* Class name for debugging */ H5P_TYPE_DATATYPE_ACCESS, /* Class type */ - &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ - &H5P_CLS_DATATYPE_ACCESS_g, /* Pointer to class ID */ - &H5P_LST_DATATYPE_ACCESS_g, /* Pointer to default property list ID */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATATYPE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATATYPE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATATYPE_ACCESS_ID_g, /* Pointer to default property list ID */ NULL, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -428,37 +457,27 @@ H5P_init_interface(void) /* Check if the current class hasn't been initialized and can be now */ HDassert(lib_class->class_id); - if(*lib_class->class_id == (-1) && (lib_class->par_class_id == NULL - || *lib_class->par_class_id > 0)) { - H5P_genclass_t *par_pclass = NULL; /* Parent class of new class */ - H5P_genclass_t *new_pclass; /* New property list class created */ - + if(*lib_class->class_id == (-1) && (lib_class->par_pclass == NULL + || *lib_class->par_pclass != NULL)) { /* Sanity check - only the root class is not allowed to have a parent class */ - HDassert(lib_class->par_class_id || lib_class == H5P_CLS_ROOT); - - /* Check for parent class */ - if(lib_class->par_class_id) { - /* Get the pointer to the parent class */ - if(NULL == (par_pclass = (H5P_genclass_t *)H5I_object(*lib_class->par_class_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") - } /* end if */ + HDassert(lib_class->par_pclass || lib_class == H5P_CLS_ROOT); /* Allocate the new class */ - if(NULL == (new_pclass = H5P_create_class(par_pclass, lib_class->name, lib_class->type, lib_class->create_func, lib_class->create_data, lib_class->copy_func, lib_class->copy_data, lib_class->close_func, lib_class->close_data))) + if(NULL == (*lib_class->pclass = H5P_create_class(lib_class->par_pclass ? *lib_class->par_pclass : NULL, lib_class->name, lib_class->type, lib_class->create_func, lib_class->create_data, lib_class->copy_func, lib_class->copy_data, lib_class->close_func, lib_class->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed") /* Call routine to register properties for class */ - if(lib_class->reg_prop_func && (*lib_class->reg_prop_func)(new_pclass) < 0) + if(lib_class->reg_prop_func && (*lib_class->reg_prop_func)(*lib_class->pclass) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register properties") /* Register the new class */ - if((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, new_pclass, FALSE)) < 0) + if((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, *lib_class->pclass, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class") /* Only register the default property list if it hasn't been created yet */ if(lib_class->def_plist_id && *lib_class->def_plist_id == (-1)) { /* Register the default property list for the new class*/ - if((*lib_class->def_plist_id = H5P_create_id(new_pclass, FALSE)) < 0) + if((*lib_class->def_plist_id = H5P_create_id(*lib_class->pclass, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list for class") } /* end if */ @@ -519,20 +538,20 @@ H5P_term_interface(void) /* Reset the default property lists, if they've been closed */ if(H5I_nmembers(H5I_GENPROP_LST)==0) { - H5P_LST_FILE_CREATE_g = - H5P_LST_FILE_ACCESS_g = - H5P_LST_DATASET_CREATE_g = - H5P_LST_DATASET_ACCESS_g = - H5P_LST_DATASET_XFER_g = - H5P_LST_GROUP_CREATE_g = - H5P_LST_GROUP_ACCESS_g = - H5P_LST_DATATYPE_CREATE_g = - H5P_LST_DATATYPE_ACCESS_g = - H5P_LST_ATTRIBUTE_CREATE_g = - H5P_LST_OBJECT_COPY_g = - H5P_LST_LINK_CREATE_g = - H5P_LST_LINK_ACCESS_g = - H5P_LST_FILE_MOUNT_g = (-1); + H5P_LST_FILE_CREATE_ID_g = + H5P_LST_FILE_ACCESS_ID_g = + H5P_LST_DATASET_CREATE_ID_g = + H5P_LST_DATASET_ACCESS_ID_g = + H5P_LST_DATASET_XFER_ID_g = + H5P_LST_GROUP_CREATE_ID_g = + H5P_LST_GROUP_ACCESS_ID_g = + H5P_LST_DATATYPE_CREATE_ID_g = + H5P_LST_DATATYPE_ACCESS_ID_g = + H5P_LST_ATTRIBUTE_CREATE_ID_g = + H5P_LST_OBJECT_COPY_ID_g = + H5P_LST_LINK_CREATE_ID_g = + H5P_LST_LINK_ACCESS_ID_g = + H5P_LST_FILE_MOUNT_ID_g = (-1); } /* end if */ } /* end if */ @@ -558,10 +577,34 @@ H5P_term_interface(void) H5P_CLS_OBJECT_COPY_g = H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = - H5P_CLS_FILE_MOUNT_g = (-1); + H5P_CLS_FILE_MOUNT_g = NULL; + + H5P_CLS_ROOT_ID_g = + H5P_CLS_OBJECT_CREATE_ID_g = + H5P_CLS_FILE_CREATE_ID_g = + H5P_CLS_FILE_ACCESS_ID_g = + H5P_CLS_DATASET_CREATE_ID_g = + H5P_CLS_DATASET_ACCESS_ID_g = + H5P_CLS_DATASET_XFER_ID_g = + H5P_CLS_GROUP_CREATE_ID_g = + H5P_CLS_GROUP_ACCESS_ID_g = + H5P_CLS_DATATYPE_CREATE_ID_g = + H5P_CLS_DATATYPE_ACCESS_ID_g = + H5P_CLS_STRING_CREATE_ID_g = + H5P_CLS_ATTRIBUTE_CREATE_ID_g = + H5P_CLS_OBJECT_COPY_ID_g = + H5P_CLS_LINK_CREATE_ID_g = + H5P_CLS_LINK_ACCESS_ID_g = + H5P_CLS_FILE_MOUNT_ID_g = (-1); } /* end if */ } /* end if */ } else { + /* Close public interface */ + n += H5P__term_pub_interface(); + + /* Close deprecated interface */ + n += H5P__term_deprec_interface(); + H5I_dec_type_ref(H5I_GENPROP_LST); n++; /*H5I*/ H5I_dec_type_ref(H5I_GENPROP_CLS); @@ -2885,41 +2928,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5P_get_class - PURPOSE - Internal routine to query the class of a generic property list - USAGE - H5P_genclass_t *H5P_get_class(plist) - H5P_genplist_t *plist; IN: Property list to check - RETURNS - Success: Pointer to the class for a property list - Failure: NULL - DESCRIPTION - This routine retrieves a pointer to the class for a property list. - - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5P_genclass_t * -H5P_get_class(const H5P_genplist_t *plist) -{ - H5P_genclass_t *ret_value; /* return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(plist); - - /* Get property size */ - ret_value = plist->pclass; - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get_class() */ - - -/*-------------------------------------------------------------------------- - NAME H5P_get_nprops_plist PURPOSE Internal routine to query the number of properties in a property list @@ -3350,12 +3358,12 @@ done: /*-------------------------------------------------------------------------- NAME - H5P_isa_class_real + H5P_class_isa PURPOSE Internal routine to query whether a property class is the same as another class. USAGE - htri_t H5P_isa_class_real(pclass1, pclass2) + htri_t H5P_class_isa(pclass1, pclass2) H5P_genclass_t *pclass1; IN: Property class to check H5P_genclass_t *pclass2; IN: Property class to compare with RETURNS @@ -3371,12 +3379,12 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static htri_t -H5P_isa_class_real(H5P_genclass_t *pclass1, H5P_genclass_t *pclass2) +htri_t +H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { htri_t ret_value; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_NOAPI(FAIL) HDassert(pclass1); HDassert(pclass2); @@ -3387,14 +3395,14 @@ H5P_isa_class_real(H5P_genclass_t *pclass1, H5P_genclass_t *pclass2) } else { /* Check if the class is derived, and walk up the chain, if so */ if(pclass1->parent != NULL) - ret_value = H5P_isa_class_real(pclass1->parent, pclass2); + ret_value = H5P_class_isa(pclass1->parent, pclass2); else HGOTO_DONE(FALSE); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_isa_class_real() */ +} /* H5P_class_isa() */ /*-------------------------------------------------------------------------- @@ -3438,7 +3446,7 @@ H5P_isa_class(hid_t plist_id, hid_t pclass_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class") /* Compare the property list's class against the other class */ - if((ret_value = H5P_isa_class_real(plist->pclass, pclass)) < 0) + if((ret_value = H5P_class_isa(plist->pclass, pclass)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes") done: @@ -5018,67 +5026,67 @@ H5P__new_plist_of_type(H5P_plist_type_t type) /* Instantiate a property list of the proper type */ switch(type) { case H5P_TYPE_OBJECT_CREATE: - class_id = H5P_CLS_OBJECT_CREATE_g; + class_id = H5P_CLS_OBJECT_CREATE_ID_g; break; case H5P_TYPE_FILE_CREATE: - class_id = H5P_CLS_FILE_CREATE_g; + class_id = H5P_CLS_FILE_CREATE_ID_g; break; case H5P_TYPE_FILE_ACCESS: - class_id = H5P_CLS_FILE_ACCESS_g; + class_id = H5P_CLS_FILE_ACCESS_ID_g; break; case H5P_TYPE_DATASET_CREATE: - class_id = H5P_CLS_DATASET_CREATE_g; + class_id = H5P_CLS_DATASET_CREATE_ID_g; break; case H5P_TYPE_DATASET_ACCESS: - class_id = H5P_CLS_DATASET_ACCESS_g; + class_id = H5P_CLS_DATASET_ACCESS_ID_g; break; case H5P_TYPE_DATASET_XFER: - class_id = H5P_CLS_DATASET_XFER_g; + class_id = H5P_CLS_DATASET_XFER_ID_g; break; case H5P_TYPE_FILE_MOUNT: - class_id = H5P_CLS_FILE_MOUNT_g; + class_id = H5P_CLS_FILE_MOUNT_ID_g; break; case H5P_TYPE_GROUP_CREATE: - class_id = H5P_CLS_GROUP_CREATE_g; + class_id = H5P_CLS_GROUP_CREATE_ID_g; break; case H5P_TYPE_GROUP_ACCESS: - class_id = H5P_CLS_GROUP_ACCESS_g; + class_id = H5P_CLS_GROUP_ACCESS_ID_g; break; case H5P_TYPE_DATATYPE_CREATE: - class_id = H5P_CLS_DATATYPE_CREATE_g; + class_id = H5P_CLS_DATATYPE_CREATE_ID_g; break; case H5P_TYPE_DATATYPE_ACCESS: - class_id = H5P_CLS_DATATYPE_ACCESS_g; + class_id = H5P_CLS_DATATYPE_ACCESS_ID_g; break; case H5P_TYPE_STRING_CREATE: - class_id = H5P_CLS_STRING_CREATE_g; + class_id = H5P_CLS_STRING_CREATE_ID_g; break; case H5P_TYPE_ATTRIBUTE_CREATE: - class_id = H5P_CLS_ATTRIBUTE_CREATE_g; + class_id = H5P_CLS_ATTRIBUTE_CREATE_ID_g; break; case H5P_TYPE_OBJECT_COPY: - class_id = H5P_CLS_OBJECT_COPY_g; + class_id = H5P_CLS_OBJECT_COPY_ID_g; break; case H5P_TYPE_LINK_CREATE: - class_id = H5P_CLS_LINK_CREATE_g; + class_id = H5P_CLS_LINK_CREATE_ID_g; break; case H5P_TYPE_LINK_ACCESS: - class_id = H5P_CLS_LINK_ACCESS_g; + class_id = H5P_CLS_LINK_ACCESS_ID_g; break; case H5P_TYPE_USER: /* shut compiler warnings up */ @@ -5100,3 +5108,59 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__new_plist_of_type() */ + +/*------------------------------------------------------------------------- + * Function: H5P_get_plist_id + * + * Purpose: Quick and dirty routine to retrieve property list ID from + * property list structure. + * (Mainly added to stop non-file routines from poking about in the + * H5P_genplist_t data structure) + * + * Return: Success: Non-negative ID of property list. + * Failure: negative. + * + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * April 22, 2014 + * + *------------------------------------------------------------------------- + */ +hid_t +H5P_get_plist_id(const H5P_genplist_t *plist) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(plist); + + FUNC_LEAVE_NOAPI(plist->plist_id) +} /* end H5P_get_plist_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5P_get_class + * + * Purpose: Quick and dirty routine to retrieve property list class from + * property list structure. + * (Mainly added to stop non-file routines from poking about in the + * H5P_genplist_t data structure) + * + * Return: Success: Non-NULL class of property list. + * Failure: NULL + * + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * April 22, 2014 + * + *------------------------------------------------------------------------- + */ +H5P_genclass_t * +H5P_get_class(const H5P_genplist_t *plist) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(plist); + + FUNC_LEAVE_NOAPI(plist->pclass) +} /* end H5P_get_class() */ + diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 676b574..0d39b6c 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -123,10 +123,13 @@ static herr_t H5P_lacc_elink_fapl_close(const char* name, size_t size, void* val const H5P_libclass_t H5P_CLS_LACC[1] = {{ "link access", /* Class name for debugging */ H5P_TYPE_LINK_ACCESS, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_LINK_ACCESS_g, /* Pointer to class ID */ - &H5P_LST_LINK_ACCESS_g, /* Pointer to default property list ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ + &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ H5P_lacc_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index a16a005..72f5b6b 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -102,10 +102,13 @@ static herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass); const H5P_libclass_t H5P_CLS_LCRT[1] = {{ "link create", /* Class name for debugging */ H5P_TYPE_LINK_CREATE, /* Class type */ - &H5P_CLS_STRING_CREATE_g, /* Parent class ID */ - &H5P_CLS_LINK_CREATE_g, /* Pointer to class ID */ - &H5P_LST_LINK_CREATE_g, /* Pointer to default property list ID */ + + &H5P_CLS_STRING_CREATE_g, /* Parent class */ + &H5P_CLS_LINK_CREATE_g, /* Pointer to class */ + &H5P_CLS_LINK_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_LINK_CREATE_ID_g, /* Pointer to default property list ID */ H5P_lcrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index df4ebb6..37beb90 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -104,10 +104,13 @@ static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, const H5P_libclass_t H5P_CLS_OCRT[1] = {{ "object create", /* Class name for debugging */ H5P_TYPE_OBJECT_CREATE, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */ + &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */ NULL, /* Pointer to default property list ID */ H5P__ocrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ H5P__ocrt_copy, /* Class copy callback */ diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index e5e5f51..fd4d968 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -38,6 +38,7 @@ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ #include "H5Ppkg.h" /* Property lists */ @@ -100,10 +101,13 @@ static herr_t H5P__ocpy_merge_comm_dt_list_close(const char* name, size_t size, const H5P_libclass_t H5P_CLS_OCPY[1] = {{ "object copy", /* Class name for debugging */ H5P_TYPE_OBJECT_COPY, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_OBJECT_COPY_g, /* Pointer to class ID */ - &H5P_LST_OBJECT_COPY_g, /* Pointer to default property list ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_OBJECT_COPY_g, /* Pointer to class */ + &H5P_CLS_OBJECT_COPY_ID_g, /* Pointer to class ID */ + &H5P_LST_OBJECT_COPY_ID_g, /* Pointer to default property list ID */ H5P__ocpy_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index 9d48c60..2942a4d 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -127,7 +127,8 @@ typedef struct H5P_libclass_t { const char *name; /* Class name */ H5P_plist_type_t type; /* Class type */ - hid_t const * const par_class_id; /* Pointer to global parent class property list class ID */ + H5P_genclass_t * * par_pclass; /* Pointer to global parent class property list class */ + H5P_genclass_t * * pclass; /* Pointer to global property list class */ hid_t * const class_id; /* Pointer to global property list class ID */ hid_t * const def_plist_id; /* Pointer to global default property list ID */ H5P_reg_prop_func_t reg_prop_func; /* Register class's properties */ @@ -144,6 +145,9 @@ typedef struct H5P_libclass_t { /* Property list/class iterator callback function pointer */ typedef int (*H5P_iterate_int_t)(H5P_genprop_t *prop, void *udata); +/* Forward declarations (for prototypes & struct definitions) */ +struct H5Z_filter_info_t; + /*****************************/ /* Package Private Variables */ /*****************************/ @@ -154,6 +158,8 @@ typedef int (*H5P_iterate_int_t)(H5P_genprop_t *prop, void *udata); /******************************/ /* Private functions, not part of the publicly documented API */ +H5_DLL herr_t H5P__term_pub_interface(void); +H5_DLL herr_t H5P__term_deprec_interface(void); H5_DLL H5P_genclass_t *H5P_create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t type, H5P_cls_create_func_t cls_create, void *create_data, @@ -181,7 +187,6 @@ H5_DLL herr_t H5P_get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size); H5_DLL herr_t H5P_get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size); -H5_DLL H5P_genclass_t *H5P_get_class(const H5P_genplist_t *plist); H5_DLL herr_t H5P_get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops); H5_DLL int H5P_cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); H5_DLL herr_t H5P_cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, @@ -197,9 +202,6 @@ H5_DLL char *H5P_get_class_path(H5P_genclass_t *pclass); H5_DLL H5P_genclass_t *H5P_open_class_path(const char *path); H5_DLL H5P_genclass_t *H5P_get_class_parent(const H5P_genclass_t *pclass); H5_DLL herr_t H5P_close_class(void *_pclass); -H5_DLL herr_t H5P_get_filter(const H5Z_filter_info_t *filter, - unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], - size_t namelen, char name[], unsigned *filter_config); H5_DLL H5P_genprop_t *H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name); H5_DLL hid_t H5P__new_plist_of_type(H5P_plist_type_t type); @@ -220,6 +222,11 @@ H5_DLL herr_t H5P__decode_uint8_t(const void **_pp, void *value); H5_DLL herr_t H5P__decode_hbool_t(const void **_pp, void *value); H5_DLL herr_t H5P__decode_double(const void **_pp, void *value); +/* Private OCPL routines */ +H5_DLL herr_t H5P_get_filter(const struct H5Z_filter_info_t *filter, + unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], + size_t namelen, char name[], unsigned *filter_config); + /* Testing functions */ #ifdef H5P_TESTING H5_DLL char *H5P_get_class_path_test(hid_t pclass_id); diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 0c3b5aa..a0ede84 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -26,7 +26,6 @@ /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ -#include "H5Oprivate.h" /* Object headers */ /**************************/ /* Library Private Macros */ @@ -35,11 +34,24 @@ /* ======== String creation property names ======== */ #define H5P_STRCRT_CHAR_ENCODING_NAME "character_encoding" /* Character set encoding for string */ +/* If the module using this macro is allowed access to the private variables, access them directly */ +#ifdef H5P_PACKAGE +#define H5P_PLIST_ID(P) ((P)->plist_id) +#define H5P_CLASS(P) ((P)->pclass) +#else /* H5F_PACKAGE */ +#define H5P_PLIST_ID(P) (H5P_get_plist_id(P)) +#define H5P_CLASS(P) (H5P_get_class(P)) +#endif /* H5P_PACKAGE */ + /****************************/ /* Library Private Typedefs */ /****************************/ +/* Forward declarations (for prototypes & type definitions) */ +struct H5O_fill_t; +struct H5T_t; + /* Forward declarations for anonymous H5P objects */ typedef struct H5P_genplist_t H5P_genplist_t; typedef struct H5P_genclass_t H5P_genclass_t; @@ -70,6 +82,25 @@ typedef enum H5P_plist_type_t { /* Library Private Variables */ /*****************************/ +/* Predefined property list classes. */ +H5_DLLVAR H5P_genclass_t *H5P_CLS_ROOT_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_FILE_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_FILE_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_DATASET_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_DATASET_XFER_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_FILE_MOUNT_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_OBJECT_COPY_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_LINK_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_LINK_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_STRING_CREATE_g; + /******************************/ /* Library Private Prototypes */ @@ -91,6 +122,7 @@ H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name); +H5_DLL htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass); H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); @@ -103,7 +135,7 @@ H5_DLL void * H5P_get_vol_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); -H5_DLL herr_t H5P_is_fill_value_defined(const H5O_fill_t *fill, +H5_DLL herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *status); H5_DLL int H5P_fill_value_cmp(const void *value1, const void *value2, size_t size); @@ -114,6 +146,10 @@ H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, size_t namelen, char name[], unsigned *filter_config); H5_DLL htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id); +/* Query internal fields of the property list struct */ +H5_DLL hid_t H5P_get_plist_id(const H5P_genplist_t *plist); +H5_DLL H5P_genclass_t *H5P_get_class(const H5P_genplist_t *plist); + /* *SPECIAL* Don't make more of these! -QAK */ H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id); H5_DLL H5P_genplist_t *H5P_object_verify(hid_t plist_id, hid_t pclass_id); @@ -127,7 +163,7 @@ H5_DLL size_t H5P_peek_size_t(H5P_genplist_t *plist, const char *name); /* Private DCPL routines */ H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status); -H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, H5T_t *type, +H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, const struct H5T_t *type, void *value, hid_t dxpl_id); #endif /* _H5Pprivate_H */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 4d60c5c..f13f70d 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -52,41 +52,41 @@ * The library's property list classes */ -#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_g) -#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_g) -#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_g) -#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_g) -#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_g) -#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_g) -#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_g) -#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_g) -#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_g) -#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_g) -#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_g) -#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_g) -#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_g) -#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_g) -#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_g) -#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_g) -#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_g) +#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) +#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) +#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) +#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) +#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) +#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) /* * The library's default property lists */ -#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_g) -#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_g) -#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_g) -#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_g) -#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_g) -#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_g) -#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_g) -#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_g) -#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_g) -#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_g) -#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_g) -#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_g) -#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_g) -#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_g) +#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) +#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) +#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) /* Common creation order flags (for links in groups and attributes on objects) */ #define H5P_CRT_ORDER_TRACKED 0x0001 @@ -172,40 +172,40 @@ typedef enum H5D_mpio_no_collective_cause_t { /* Property list class IDs */ /* (Internal to library, do not use! Use macros above) */ -H5_DLLVAR hid_t H5P_CLS_ROOT_g; -H5_DLLVAR hid_t H5P_CLS_OBJECT_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_FILE_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_FILE_ACCESS_g; -H5_DLLVAR hid_t H5P_CLS_DATASET_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_DATASET_ACCESS_g; -H5_DLLVAR hid_t H5P_CLS_DATASET_XFER_g; -H5_DLLVAR hid_t H5P_CLS_FILE_MOUNT_g; -H5_DLLVAR hid_t H5P_CLS_GROUP_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_GROUP_ACCESS_g; -H5_DLLVAR hid_t H5P_CLS_DATATYPE_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_DATATYPE_ACCESS_g; -H5_DLLVAR hid_t H5P_CLS_STRING_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_g; -H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_g; -H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_g; +H5_DLLVAR hid_t H5P_CLS_ROOT_ID_g; +H5_DLLVAR hid_t H5P_CLS_OBJECT_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_FILE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_FILE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_DATASET_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_DATASET_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_DATASET_XFER_ID_g; +H5_DLLVAR hid_t H5P_CLS_FILE_MOUNT_ID_g; +H5_DLLVAR hid_t H5P_CLS_GROUP_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_GROUP_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_DATATYPE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_DATATYPE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_STRING_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_ID_g; +H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_ID_g; /* Default roperty list IDs */ /* (Internal to library, do not use! Use macros above) */ -H5_DLLVAR hid_t H5P_LST_FILE_CREATE_g; -H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_g; -H5_DLLVAR hid_t H5P_LST_DATASET_CREATE_g; -H5_DLLVAR hid_t H5P_LST_DATASET_ACCESS_g; -H5_DLLVAR hid_t H5P_LST_DATASET_XFER_g; -H5_DLLVAR hid_t H5P_LST_FILE_MOUNT_g; -H5_DLLVAR hid_t H5P_LST_GROUP_CREATE_g; -H5_DLLVAR hid_t H5P_LST_GROUP_ACCESS_g; -H5_DLLVAR hid_t H5P_LST_DATATYPE_CREATE_g; -H5_DLLVAR hid_t H5P_LST_DATATYPE_ACCESS_g; -H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_g; -H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_g; -H5_DLLVAR hid_t H5P_LST_LINK_CREATE_g; -H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_g; +H5_DLLVAR hid_t H5P_LST_FILE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_DATASET_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_DATASET_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_DATASET_XFER_ID_g; +H5_DLLVAR hid_t H5P_LST_FILE_MOUNT_ID_g; +H5_DLLVAR hid_t H5P_LST_GROUP_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_GROUP_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_DATATYPE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_DATATYPE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g; +H5_DLLVAR hid_t H5P_LST_LINK_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_ID_g; /*********************/ /* Public Prototypes */ @@ -296,7 +296,6 @@ H5_DLL herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list H5_DLL herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold); H5_DLL herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold); - /* File access property list (FAPL) routines */ H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment); @@ -352,6 +351,9 @@ H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); +H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size); +H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); + /* Dataset creation property list (DCPL) routines */ H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); H5_DLL H5D_layout_t H5Pget_layout(hid_t plist_id); diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index bedacb0..3ba625e 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -34,6 +34,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5Iprivate.h" /* IDs */ #include "H5Ppkg.h" /* Property lists */ @@ -80,10 +81,13 @@ static herr_t H5P__strcrt_char_encoding_dec(const void **_pp, void *value); const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ "string create", /* Class name for debugging */ H5P_TYPE_STRING_CREATE, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_STRING_CREATE_g, /* Pointer to class ID */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_STRING_CREATE_g, /* Pointer to class */ + &H5P_CLS_STRING_CREATE_ID_g, /* Pointer to class ID */ NULL, /* Pointer to default property list ID */ H5P__strcrt_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -161,6 +161,9 @@ H5R_term_interface(void) if ((n=H5I_nmembers(H5I_REFERENCE))) { H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); } else { + /* Close deprecated interface */ + n += H5R__term_deprec_interface(); + H5I_dec_type_ref(H5I_REFERENCE); H5_interface_initialize_g = 0; n = 1; /*H5I*/ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 86dbca7..763b553 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -34,7 +34,7 @@ #define H5R_PACKAGE /*suppress error about including H5Rpkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5R_init_deprec_interface +#define H5_INTERFACE_INIT_FUNC H5R__init_deprec_interface /***********/ @@ -50,7 +50,7 @@ #include "H5Ppublic.h" /* for using H5P_DATASET_ACCESS_DEFAULT */ #include "H5VLprivate.h" /* VOL plugins */ -#ifndef H5_NO_DEPRECATED_SYMBOLS + /****************/ /* Local Macros */ /****************/ @@ -89,9 +89,9 @@ /*-------------------------------------------------------------------------- NAME - H5R_init_deprec_interface -- Initialize interface-specific information + H5R__init_deprec_interface -- Initialize interface-specific information USAGE - herr_t H5R_init_deprec_interface() + herr_t H5R__init_deprec_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -100,13 +100,38 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5R_init_deprec_interface(void) +H5R__init_deprec_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5R_init()) -} /* H5R_init_deprec_interface() */ +} /* H5R__init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5R__term_deprec_interface -- Terminate interface +USAGE + herr_t H5R__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5R__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + FUNC_LEAVE_NOAPI(0) +} /* H5R__term_deprec_interface() */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS /*-------------------------------------------------------------------------- NAME diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index 26a2d02..f2e9e1a 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -56,6 +56,7 @@ /* General functions */ H5_DLL herr_t H5R_init(void); +H5_DLL herr_t H5R__term_deprec_interface(void); H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, H5O_type_t *obj_type); H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type, @@ -772,7 +772,6 @@ H5T_init_interface(void) hsize_t dim[1]={1}; /* Dimension info for array datatype */ herr_t status; unsigned copied_dtype=1; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ - H5P_genclass_t *crt_pclass; /* Property list class for datatype creation properties */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1349,21 +1348,17 @@ H5T_init_interface(void) if (status<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)") - /* ========== Datatype Creation Property Class Initialization ============*/ - HDassert(H5P_CLS_DATATYPE_CREATE_g!=-1); - - /* Get the pointer to group creation class */ - if(NULL == (crt_pclass = (H5P_genclass_t *)H5I_object(H5P_CLS_DATATYPE_CREATE_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") - /* Register datatype creation property class properties here. See similar * code in H5D_init_interface(), etc. for example. */ /* Only register the default property list if it hasn't been created yet */ - if(H5P_LST_DATATYPE_CREATE_g == (-1)) { + if(H5P_LST_DATATYPE_CREATE_ID_g == (-1)) { + /* ========== Datatype Creation Property Class Initialization ============*/ + HDassert(H5P_CLS_DATATYPE_CREATE_g != NULL); + /* Register the default datatype creation property list */ - if((H5P_LST_DATATYPE_CREATE_g = H5P_create_id(crt_pclass, FALSE)) < 0) + if((H5P_LST_DATATYPE_CREATE_ID_g = H5P_create_id(H5P_CLS_DATATYPE_CREATE_g, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ @@ -1489,6 +1484,10 @@ H5T_term_interface(void) /* Unlock all datatypes, then free them */ /* note that we are ignoring the return value from H5I_iterate() */ H5I_iterate(H5I_DATATYPE, H5T_unlock_cb, NULL, FALSE); + + /* Close deprecated interface */ + n += H5T__term_deprec_interface(); + H5I_dec_type_ref(H5I_DATATYPE); /* Reset all the datatype IDs */ @@ -56,8 +56,6 @@ H5TS_key_t H5TS_cancel_key_g; * PROGRAMMER: Quincey Koziol * February 7, 2003 * - * MODIFICATIONS: - * *-------------------------------------------------------------------------- */ static void @@ -68,39 +66,9 @@ H5TS_key_destructor(void *key_val) HDfree(key_val); } -#ifdef H5_HAVE_WIN_THREADS -/*-------------------------------------------------------------------------- - * NAME - * H5TS_win32_first_thread_init - * - * USAGE - * H5TS_win32_first_thread_init() - * - * RETURNS - * - * DESCRIPTION - * Special function on windows needed to call the H5TS_first_thread_init - * function. - * - * PROGRAMMER: Mike McGreevy - * September 1, 2010 - * - * MODIFICATIONS: - * - *-------------------------------------------------------------------------- - */ -BOOL CALLBACK -H5TS_win32_first_thread_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) -{ - InitializeCriticalSection ( &H5_g.init_lock.CriticalSection ); - H5TS_errstk_key_g = TlsAlloc(); - H5TS_funcstk_key_g = TlsAlloc(); - H5TS_cancel_key_g = TlsAlloc(); +#ifndef H5_HAVE_WIN_THREADS - return TRUE; -} /* H5TS_win32_first_thread_init() */ -#else /* H5_HAVE_WIN_THREADS */ /*-------------------------------------------------------------------------- * NAME * H5TS_pthread_first_thread_init @@ -118,8 +86,6 @@ H5TS_win32_first_thread_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpCont * PROGRAMMER: Chee Wai LEE * May 2, 2000 * - * MODIFICATIONS: - * *-------------------------------------------------------------------------- */ void @@ -149,6 +115,7 @@ H5TS_pthread_first_thread_init(void) } #endif /* H5_HAVE_WIN_THREADS */ + /*-------------------------------------------------------------------------- * NAME * H5TS_mutex_lock @@ -167,11 +134,6 @@ H5TS_pthread_first_thread_init(void) * PROGRAMMER: Chee Wai LEE * May 2, 2000 * - * MODIFICATIONS: - * - * 19 May 2000, Bill Wendling - * Changed (*foo). form of accessing structure members to the -> form. - * *-------------------------------------------------------------------------- */ herr_t @@ -203,6 +165,7 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) #endif /* H5_HAVE_WIN_THREADS */ } + /*-------------------------------------------------------------------------- * NAME * H5TS_mutex_unlock @@ -221,12 +184,6 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) * PROGRAMMER: Chee Wai LEE * May 2, 2000 * - * MODIFICATIONS: - * - * 19 May 2000, Bill Wendling - * Changed (*foo). form of accessing structure members to the -> form. - * Also gave the function a return value. - * *-------------------------------------------------------------------------- */ herr_t @@ -258,6 +215,7 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) #endif /* H5_HAVE_WIN_THREADS */ } /* H5TS_mutex_unlock */ + /*-------------------------------------------------------------------------- * NAME * H5TS_cancel_count_inc @@ -280,12 +238,6 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) * PROGRAMMER: Chee Wai LEE * May 2, 2000 * - * MODIFICATIONS: - * - * 19 May 2000, Bill Wendling - * Changed function to return a value. Also changed the malloc() call to - * the H5MM_malloc() call and checked the returned pointer. - * *-------------------------------------------------------------------------- */ herr_t @@ -328,6 +280,7 @@ H5TS_cancel_count_inc(void) #endif /* H5_HAVE_WIN_THREADS */ } + /*-------------------------------------------------------------------------- * NAME * H5TS_cancel_count_dec @@ -348,11 +301,6 @@ H5TS_cancel_count_inc(void) * PROGRAMMER: Chee Wai LEE * May 2, 2000 * - * MODIFICATIONS: - * - * 19 May 2000, Bill Wendling - * Changed so that function returns a value. May be of limited usefulness. - * *-------------------------------------------------------------------------- */ herr_t @@ -377,6 +325,154 @@ H5TS_cancel_count_dec(void) } +#ifdef H5_HAVE_WIN_THREADS +/*-------------------------------------------------------------------------- + * NAME + * H5TS_win32_process_enter + * + * RETURNS + * SUCCEED/FAIL + * + * DESCRIPTION + * Per-process setup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +H5_DLL BOOL CALLBACK +H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) +{ + BOOL ret_value = TRUE; + + /* Initialize the critical section (can't fail) */ + InitializeCriticalSection(&H5_g.init_lock.CriticalSection); + + /* Set up thread local storage */ + if(TLS_OUT_OF_INDEXES == (H5TS_errstk_key_g = TlsAlloc())) + ret_value = FALSE; + +#ifdef H5_HAVE_CODESTACK + if(TLS_OUT_OF_INDEXES == (H5TS_funcstk_key_g = TlsAlloc())) + ret_value = FALSE; +#endif /* H5_HAVE_CODESTACK */ + + return ret_value; +} /* H5TS_win32_process_enter() */ +#endif /* H5_HAVE_WIN_THREADS */ + + +#ifdef H5_HAVE_WIN_THREADS +/*-------------------------------------------------------------------------- + * NAME + * H5TS_win32_thread_enter + * + * RETURNS + * SUCCEED/FAIL + * + * DESCRIPTION + * Per-thread setup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_win32_thread_enter(void) +{ + herr_t ret_value = SUCCEED; + + /* Currently a placeholder function. TLS setup is performed + * elsewhere in the library. + * + * WARNING: Do NOT use C standard library functions here. + * CRT functions are not allowed in DllMain, which is where this code + * is used. + */ + + return ret_value; +} /* H5TS_win32_thread_enter() */ +#endif /* H5_HAVE_WIN_THREADS */ + + +#ifdef H5_HAVE_WIN_THREADS +/*-------------------------------------------------------------------------- + * NAME + * H5TS_win32_process_exit + * + * RETURNS + * SUCCEED/FAIL + * + * DESCRIPTION + * Per-process cleanup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +void +H5TS_win32_process_exit(void) +{ + + /* Windows uses a different thread local storage mechanism which does + * not support auto-freeing like pthreads' keys. + * + * This function is currently registered via atexit() and is called + * AFTER H5_term_library(). + */ + + /* Clean up critical section resources (can't fail) */ + DeleteCriticalSection(&H5_g.init_lock.CriticalSection); + + /* Clean up per-process thread local storage */ + TlsFree(H5TS_errstk_key_g); + +#ifdef H5_HAVE_CODESTACK + TlsFree(H5TS_funcstk_key_g); +#endif /* H5_HAVE_CODESTACK */ + + return; +} /* H5TS_win32_process_exit() */ +#endif /* H5_HAVE_WIN_THREADS */ + + +#ifdef H5_HAVE_WIN_THREADS +/*-------------------------------------------------------------------------- + * NAME + * H5TS_win32_thread_exit + * + * RETURNS + * SUCCEED/FAIL + * + * DESCRIPTION + * Per-thread cleanup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_win32_thread_exit(void) +{ + LPVOID lpvData; + herr_t ret_value = SUCCEED; + + /* Windows uses a different thread local storage mechanism which does + * not support auto-freeing like pthreads' keys. + * + * WARNING: Do NOT use C standard library functions here. + * CRT functions are not allowed in DllMain, which is where this code + * is used. + */ + + /* Clean up per-thread thread local storage */ + lpvData = TlsGetValue(H5TS_errstk_key_g); + if(lpvData) + LocalFree((HLOCAL)lpvData); + +#ifdef H5_HAVE_CODESTACK + lpvData = TlsGetValue(H5TS_funcstk_key_g); + if(lpvData) + LocalFree((HLOCAL)lpvData); +#endif /* H5_HAVE_CODESTACK */ + + return ret_value; +} /* H5TS_win32_thread_exit() */ +#endif /* H5_HAVE_WIN_THREADS */ + + /*-------------------------------------------------------------------------- * NAME * H5TS_create_thread @@ -399,16 +495,17 @@ H5TS_create_thread(void *func, H5TS_attr_t *attr, void *udata) #ifdef H5_HAVE_WIN_THREADS - /* When calling C runtime functions, you have to use _beginthread or + /* When calling C runtime functions, you should use _beginthread or * _beginthreadex instead of CreateThread. Threads created with - * CreateThread risk being killed in low-memory situations. - * We use _beginthread instead of _begintheadex because the latter - * requires a stdcall function (and we don't need the more advanced - * features it exposes). + * CreateThread risk being killed in low-memory situations. Since we + * only create threads in our test code, this is unlikely to be an issue + * and we'll use the easier-to-deal-with CreateThread for now. * - * NOTE: No error checks here! ret_value will be -1L on errors. + * NOTE: _beginthread() auto-recycles its handle when execution completes + * so you can't wait on it, making it unsuitable for the existing + * test code. */ - ret_value = _beginthread(func, 0 /* stack size */, udata); + ret_value = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, udata, 0, NULL); #else /* H5_HAVE_WIN_THREADS */ diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index 7f55f4f..cc22f96 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -51,6 +51,7 @@ typedef INIT_ONCE H5TS_once_t; /* not used on windows side, but need to be defined to something */ #define H5TS_SCOPE_SYSTEM 0 #define H5TS_SCOPE_PROCESS 0 +#define H5TS_CALL_CONV WINAPI /* Functions */ #define H5TS_get_thread_local_value(key) TlsGetValue( key ) @@ -63,8 +64,13 @@ typedef INIT_ONCE H5TS_once_t; #define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) #define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) -H5_DLL BOOL CALLBACK -H5TS_win32_first_thread_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); +/* Functions called from DllMain */ +H5_DLL BOOL CALLBACK H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); +H5_DLL void H5TS_win32_process_exit(void); +H5_DLL herr_t H5TS_win32_thread_enter(void); +H5_DLL herr_t H5TS_win32_thread_exit(void); + + #else /* H5_HAVE_WIN_THREADS */ @@ -86,6 +92,7 @@ typedef pthread_once_t H5TS_once_t; /* Scope Definitions */ #define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM #define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +#define H5TS_CALL_CONV /* unused - Windows only */ /* Functions */ #define H5TS_get_thread_local_value(key) pthread_getspecific( key ) @@ -117,8 +124,6 @@ H5_DLL herr_t H5TS_cancel_count_inc(void); H5_DLL herr_t H5TS_cancel_count_dec(void); H5_DLL H5TS_thread_t H5TS_create_thread(void * func, H5TS_attr_t * attr, void *udata); - - #if defined c_plusplus || defined __cplusplus } #endif /* c_plusplus || __cplusplus */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index a483df7..3986a5c 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -679,7 +679,7 @@ H5Tget_create_plist(hid_t dtype_id) creation property list and return that. */ if(FALSE == status) { /* Copy the default datatype creation property list */ - if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_g))) + if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list") if((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 267852b..0b6ff5a 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -34,7 +34,7 @@ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_deprec_interface +#define H5_INTERFACE_INIT_FUNC H5T__init_deprec_interface /***********/ @@ -49,7 +49,6 @@ #include "H5Tpkg.h" /* Datatypes */ #include "H5VLprivate.h" /* VOL plugins */ -#ifndef H5_NO_DEPRECATED_SYMBOLS /****************/ /* Local Macros */ /****************/ @@ -88,9 +87,9 @@ /*-------------------------------------------------------------------------- NAME - H5T_init_deprec_interface -- Initialize interface-specific information + H5T__init_deprec_interface -- Initialize interface-specific information USAGE - herr_t H5T_init_deprec_interface() + herr_t H5T__init_deprec_interface() RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -99,13 +98,38 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t -H5T_init_deprec_interface(void) +H5T__init_deprec_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(H5T_init()) -} /* H5T_init_deprec_interface() */ +} /* H5T__init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- +NAME + H5T__term_deprec_interface -- Terminate interface +USAGE + herr_t H5T__term_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Terminates interface. (Just resets H5_interface_initialize_g + currently). + +--------------------------------------------------------------------------*/ +herr_t +H5T__term_deprec_interface(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Mark closed */ + H5_interface_initialize_g = 0; + FUNC_LEAVE_NOAPI(0) +} /* H5T__term_deprec_interface() */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- * Function: H5Tcommit1 diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 0553d19..adc70a6 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -509,6 +509,7 @@ H5FL_EXTERN(H5T_t); H5FL_EXTERN(H5T_shared_t); /* Common functions */ +H5_DLL herr_t H5T__term_deprec_interface(void); H5_DLL H5T_t *H5T__create(H5T_class_t type, size_t size); H5_DLL herr_t H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id); H5_DLL herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 0343f53..9df9eb9 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -1273,7 +1273,7 @@ H5VL_native_datatype_get(void *obj, H5VL_datatype_get_t get_type, hid_t tcpl_id; /* Copy the default datatype creation property list */ - if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_g))) + if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list") if((tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") @@ -1488,7 +1488,6 @@ H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, H5D_t *dset = (H5D_t *)obj; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; - char fake_char; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1497,6 +1496,9 @@ H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, if(NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(mem_space_id < 0 || file_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(H5S_ALL != mem_space_id) { if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") @@ -1514,16 +1516,6 @@ H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } /* end if */ - if(!buf && (NULL == file_space || H5S_GET_SELECT_NPOINTS(file_space) != 0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ - if(!buf) - buf = &fake_char; - /* read raw data */ if(H5D__read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") @@ -1553,7 +1545,6 @@ H5VL_native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, H5D_t *dset = (H5D_t *)obj; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; - char fake_char; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1562,33 +1553,26 @@ H5VL_native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, if(NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(mem_space_id < 0 || file_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(H5S_ALL != mem_space_id) { - if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - /* Check for valid selection */ + /* Check for valid selection */ if(H5S_SELECT_VALID(mem_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "memory selection+offset not within extent") } /* end if */ if(H5S_ALL != file_space_id) { - if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if(H5S_SELECT_VALID(file_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "file selection+offset not within extent") } /* end if */ - if(!buf && (NULL == file_space || H5S_GET_SELECT_NPOINTS(file_space) != 0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ - if(!buf) - buf = &fake_char; - if(H5D__pre_write(dset, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't prepare for writing data") diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index bd5bef0..73d85ac 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -51,7 +51,7 @@ /****************************/ /* Structure to store information about each filter's parameters */ -typedef struct { +typedef struct H5Z_filter_info_t { H5Z_filter_t id; /*filter identification number */ unsigned flags; /*defn and invocation flags */ char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 76de6c6..82925bf 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -58,6 +58,9 @@ /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM +/* Define to 1 if you have the `asprintf' function. */ +#undef HAVE_ASPRINTF + /* Define if the __attribute__(()) extension is present */ #undef HAVE_ATTRIBUTE diff --git a/src/H5private.h b/src/H5private.h index 89bff47..5eae84b 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -542,6 +542,9 @@ typedef struct { #ifndef HDasin #define HDasin(X) asin(X) #endif /* HDasin */ +#ifndef HDasprintf + #define HDasprintf asprintf /*varargs*/ +#endif /* HDasprintf */ #ifndef HDassert #define HDassert(X) assert(X) #endif /* HDassert */ @@ -1741,7 +1744,7 @@ typedef struct H5_api_struct { /* Macro for first thread initialization */ #ifdef H5_HAVE_WIN_THREADS -#define H5_FIRST_THREAD_INIT InitOnceExecuteOnce(&H5TS_first_init_g, H5TS_win32_first_thread_init, NULL, NULL); +#define H5_FIRST_THREAD_INIT InitOnceExecuteOnce(&H5TS_first_init_g, H5TS_win32_process_enter, NULL, NULL); #else #define H5_FIRST_THREAD_INIT pthread_once(&H5TS_first_init_g, H5TS_pthread_first_thread_init); #endif diff --git a/src/H5public.h b/src/H5public.h index 9312f15..2465639 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -94,10 +94,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 176 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 184 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.176" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.184" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/Makefile.in b/src/Makefile.in index 5e002b4..728f315 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -563,7 +563,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ @@ -734,7 +733,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 166 +LT_VERS_REVISION = 174 LT_VERS_AGE = 0 # Our main target, the HDF5 library |