diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/H5Dmpio.c | 2 | ||||
-rw-r--r-- | src/H5Eprivate.h | 13 | ||||
-rw-r--r-- | src/H5FDlog.c | 236 | ||||
-rw-r--r-- | src/H5FDmpio.c | 324 | ||||
-rw-r--r-- | src/H5FDmulti.c | 44 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 10 | ||||
-rw-r--r-- | src/H5MM.c | 15 | ||||
-rw-r--r-- | src/H5Pfapl.c | 11 | ||||
-rw-r--r-- | src/H5R.c | 2 | ||||
-rw-r--r-- | src/H5Rdeprec.c | 2 | ||||
-rw-r--r-- | src/H5ST.c | 779 | ||||
-rw-r--r-- | src/H5STprivate.h | 63 | ||||
-rw-r--r-- | src/Makefile.am | 1 |
14 files changed, 358 insertions, 1155 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9eef06..60d78eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -596,14 +596,6 @@ set (H5SM_HDRS IDE_GENERATED_PROPERTIES ("H5SM" "${H5SM_HDRS}" "${H5SM_SOURCES}" ) -set (H5ST_SOURCES - ${HDF5_SRC_DIR}/H5ST.c -) -set (H5ST_HDRS -) -IDE_GENERATED_PROPERTIES ("H5ST" "${H5ST_HDRS}" "${H5ST_SOURCES}" ) - - set (H5T_SOURCES ${HDF5_SRC_DIR}/H5T.c ${HDF5_SRC_DIR}/H5Tarray.c @@ -793,7 +785,6 @@ set (common_SRCS ${H5S_SOURCES} ${H5SL_SOURCES} ${H5SM_SOURCES} - ${H5ST_SOURCES} ${H5T_SOURCES} ${H5TS_SOURCES} ${H5VL_SOURCES} @@ -948,8 +939,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5SMpkg.h ${HDF5_SRC_DIR}/H5SMprivate.h - ${HDF5_SRC_DIR}/H5STprivate.h - ${HDF5_SRC_DIR}/H5Tpkg.h ${HDF5_SRC_DIR}/H5Tprivate.h diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index b51b39a..752c144 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -410,7 +410,7 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, co * collective I/O */ if (MPI_SUCCESS != - (mpi_code = MPI_Allreduce(&local_cause, &global_cause, 2, MPI_UNSIGNED, MPI_BOR, io_info->comm))) + (mpi_code = MPI_Allreduce(local_cause, global_cause, 2, MPI_UNSIGNED, MPI_BOR, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) } /* end else */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index c3c440f..4cd8b70 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -168,20 +168,15 @@ typedef struct H5E_t H5E_t; extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; extern int H5E_mpi_error_str_len; -#define HMPI_ERROR(mpierr) \ - { \ - MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ - HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ - } #define HMPI_DONE_ERROR(retcode, str, mpierr) \ { \ - HMPI_ERROR(mpierr); \ - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ + MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ + HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, "%s: MPI error string is '%s'", str, H5E_mpi_error_str); \ } #define HMPI_GOTO_ERROR(retcode, str, mpierr) \ { \ - HMPI_ERROR(mpierr); \ - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ + MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ + HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, "%s: MPI error string is '%s'", str, H5E_mpi_error_str); \ } #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index aa2d6db..7214b75 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -326,12 +326,15 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sULz", fapl_id, logfile, flags, buf_size); + /* Do this first, so that we don't try to free a wild pointer if + * H5P_object_verify() fails. + */ + HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); + /* Check arguments */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); - /* Duplicate the log file string * A little wasteful, since this string will just be copied later, but * passing it in as a pointer sets off a chain of impossible-to-resolve @@ -426,7 +429,7 @@ done: if (new_fa->logfile) new_fa->logfile = (char *)H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_fapl_copy() */ @@ -484,8 +487,8 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - H5_timer_t open_timer = {{0}, {0}, {0}, FALSE}; /* Timer for open() call */ - H5_timer_t stat_timer = {{0}, {0}, {0}, FALSE}; /* Timer for stat() call */ + H5_timer_t open_timer; /* Timer for open() call */ + H5_timer_t stat_timer; /* Timer for stat() call */ h5_stat_t sb; H5FD_t * ret_value = NULL; /* Return value */ @@ -502,6 +505,10 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") + /* Initialize timers */ + H5_timer_init(&open_timer); + H5_timer_init(&stat_timer); + /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; if (H5F_ACC_TRUNC & flags) @@ -518,10 +525,8 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Start timer for open() call */ - if (fa->flags & H5FD_LOG_TIME_OPEN) { - H5_timer_init(&open_timer); + if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_start(&open_timer); - } /* end if */ /* Open the file */ if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { @@ -531,17 +536,15 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); - } /* end if */ + } /* Stop timer for open() call */ if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_stop(&open_timer); /* Start timer for stat() call */ - if (fa->flags & H5FD_LOG_TIME_STAT) { - H5_timer_init(&stat_timer); + if (fa->flags & H5FD_LOG_TIME_STAT) H5_timer_start(&stat_timer); - } /* end if */ /* Get the file stats */ if (HDfstat(fd, &sb) < 0) @@ -594,15 +597,15 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (file->fa.flags & H5FD_LOG_FILE_READ) { file->nread = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nread); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_FILE_WRITE) { file->nwrite = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nwrite); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_FLAVOR) { file->flavor = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->flavor); - } /* end if */ + } /* Set the log file pointer */ if (fa->logfile) @@ -616,14 +619,14 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5_timer_get_times(open_timer, &open_times); HDfprintf(file->logfp, "Open took: (%f s)\n", open_times.elapsed); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_TIME_STAT) { H5_timevals_t stat_times; /* Elapsed time for stat() call */ H5_timer_get_times(stat_timer, &stat_times); HDfprintf(file->logfp, "Stat took: (%f s)\n", stat_times.elapsed); - } /* end if */ - } /* end if */ + } + } /* Check the file locking flags in the fapl */ if (ignore_disabled_file_locks_s != FAIL) @@ -645,7 +648,7 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") - } /* end if */ + } /* Set return value */ ret_value = (H5FD_t *)file; @@ -656,7 +659,7 @@ done: HDclose(fd); if (file) file = H5FL_FREE(H5FD_log_t, file); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_open() */ @@ -677,20 +680,21 @@ done: static herr_t H5FD__log_close(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - H5_timer_t close_timer = {{0}, {0}, {0}, FALSE}; /* Timer for close() call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + H5_timer_t close_timer; /* Timer for close() call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); + /* Initialize timer */ + H5_timer_init(&close_timer); + /* Start timer for close() call */ - if (file->fa.flags & H5FD_LOG_TIME_CLOSE) { - H5_timer_init(&close_timer); + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) H5_timer_start(&close_timer); - } /* end if */ /* Close the underlying file */ if (HDclose(file->fd) < 0) @@ -711,7 +715,7 @@ H5FD__log_close(H5FD_t *_file) H5_timer_get_times(close_timer, &close_times); HDfprintf(file->logfp, "Close took: (%f s)\n", close_times.elapsed); - } /* end if */ + } /* Dump the total number of seek/read/write operations */ if (file->fa.flags & H5FD_LOG_NUM_READ) @@ -746,13 +750,13 @@ H5FD__log_close(H5FD_t *_file) last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); last_val = file->nwrite[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } /* Dump the read I/O information */ if (file->fa.flags & H5FD_LOG_FILE_READ) { @@ -767,13 +771,13 @@ H5FD__log_close(H5FD_t *_file) last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); last_val = file->nread[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } /* Dump the I/O flavor information */ if (file->fa.flags & H5FD_LOG_FLAVOR) { @@ -788,12 +792,12 @@ H5FD__log_close(H5FD_t *_file) last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); last_val = file->flavor[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); - } /* end if */ + } /* Free the logging information */ if (file->fa.flags & H5FD_LOG_FILE_WRITE) @@ -920,7 +924,7 @@ H5FD__log_query(const H5FD_t *_file, unsigned long *flags /* out */) if (file && file->fam_to_single) *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_query() */ @@ -959,13 +963,13 @@ H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hs HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], (int)type, (size_t)size); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_ALLOC) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Allocated\n", addr, (haddr_t)((addr + size) - 1), size, flavors[type]); - } /* end if */ + } /* Set return value */ ret_value = addr; @@ -998,13 +1002,13 @@ H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the file memory freed */ if (file->fa.flags & H5FD_LOG_FREE) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Freed\n", addr, (haddr_t)((addr + size) - 1), size, flavors[type]); - } /* end if */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_free() */ @@ -1065,14 +1069,14 @@ H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); - } /* end if */ + } /* Log the extension like an allocation */ if (file->fa.flags & H5FD_LOG_ALLOC) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); - } /* end if */ + } /* Check for decreasing file size */ if (H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { @@ -1083,15 +1087,15 @@ H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) HDassert((addr + size) < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the shrink like a free */ if (file->fa.flags & H5FD_LOG_FREE) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Freed\n", file->eoa, addr, size, flavors[type]); - } /* end if */ - } /* end if */ + } + } file->eoa = addr; @@ -1174,23 +1178,22 @@ static herr_t H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) { - H5FD_log_t * file = (H5FD_log_t *)_file; - size_t orig_size = size; /* Save the original size for later */ - haddr_t orig_addr = addr; - H5_timer_t read_timer = {{0}, {0}, {0}, FALSE}; /* Timer for read operation */ - H5_timevals_t read_times; /* Elapsed time for read operation */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t * file = (H5FD_log_t *)_file; + size_t orig_size = size; /* Save the original size for later */ + haddr_t orig_addr = addr; + H5_timer_t read_timer; /* Timer for read operation */ + H5_timevals_t read_times; /* Elapsed time for read operation */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&read_timer); + /* Check for overflow conditions */ if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) @@ -1207,17 +1210,22 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert((addr + size) < file->iosize); while (tmp_size-- > 0) file->nread[tmp_addr++]++; - } /* end if */ - } /* end if */ + } + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ if (addr != file->pos || OP_READ != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if (file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1234,7 +1242,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ if (file->fa.flags & H5FD_LOG_LOC_SEEK) { @@ -1248,15 +1256,13 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } + } +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for read operation */ - if (file->fa.flags & H5FD_LOG_TIME_READ) { - H5_timer_init(&read_timer); + if (file->fa.flags & H5FD_LOG_TIME_READ) H5_timer_start(&read_timer); - } /* end if */ /* * Read data, being careful of interrupted system calls, partial results, @@ -1301,13 +1307,13 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); - } /* end if */ + } if (0 == bytes_read) { - /* end of file but not end of format address space */ + /* End of file but not end of format address space */ HDmemset(buf, 0, size); break; - } /* end if */ + } HDassert(bytes_read >= 0); HDassert((size_t)bytes_read <= size); @@ -1315,8 +1321,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had size -= (size_t)bytes_read; addr += (haddr_t)bytes_read; buf = (char *)buf + bytes_read; - - } /* end while */ + } /* Stop timer for read operation */ if (file->fa.flags & H5FD_LOG_TIME_READ) @@ -1330,7 +1335,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if (file->fa.flags & H5FD_LOG_TIME_READ) { H5_timer_get_times(read_timer, &read_times); file->total_read_time += read_times.elapsed; - } /* end if */ + } /* Log information about the read */ if (file->fa.flags & H5FD_LOG_LOC_READ) { @@ -1344,7 +1349,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + } /* Add the read time, if we're tracking that. * Note that the read time is NOT emitted for when just H5FD_LOG_TIME_READ @@ -1354,7 +1359,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, " (%fs @ %f)\n", read_times.elapsed, read_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position */ file->pos = addr; @@ -1365,7 +1370,7 @@ done: /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_read() */ @@ -1388,17 +1393,13 @@ static herr_t H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_log_t * file = (H5FD_log_t *)_file; - size_t orig_size = size; /* Save the original size for later */ - haddr_t orig_addr = addr; - H5_timer_t write_timer = {{0}, {0}, {0}, FALSE}; /* Timer for write operation */ - H5_timevals_t write_times; /* Elapsed time for write operation */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t * file = (H5FD_log_t *)_file; + size_t orig_size = size; /* Save the original size for later */ + haddr_t orig_addr = addr; + H5_timer_t write_timer; /* Timer for write operation */ + H5_timevals_t write_times; /* Elapsed time for write operation */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1406,13 +1407,16 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDassert(size > 0); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&write_timer); + /* Verify that we are writing out the type of data we allocated in this location */ if (file->flavor) { HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + } /* Check for overflow conditions */ if (!H5F_addr_defined(addr)) @@ -1430,16 +1434,21 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDassert((addr + size) < file->iosize); while (tmp_size-- > 0) file->nwrite[tmp_addr++]++; - } /* end if */ + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ if (addr != file->pos || OP_WRITE != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if (file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1456,7 +1465,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ if (file->fa.flags & H5FD_LOG_LOC_SEEK) { @@ -1470,15 +1479,13 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } + } +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for write operation */ - if (file->fa.flags & H5FD_LOG_TIME_WRITE) { - H5_timer_init(&write_timer); + if (file->fa.flags & H5FD_LOG_TIME_WRITE) H5_timer_start(&write_timer); - } /* end if */ /* * Write the data, being careful of interrupted system calls and partial @@ -1545,7 +1552,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha if (file->fa.flags & H5FD_LOG_TIME_WRITE) { H5_timer_get_times(write_timer, &write_times); file->total_write_time += write_times.elapsed; - } /* end if */ + } /* Log information about the write */ if (file->fa.flags & H5FD_LOG_LOC_WRITE) { @@ -1558,8 +1565,8 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha if ((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { HDmemset(&file->flavor[orig_addr], (int)type, orig_size); HDfprintf(file->logfp, " (fresh)"); - } /* end if */ - } /* end if */ + } + } /* Add the write time, if we're tracking that. * Note that the write time is NOT emitted for when just H5FD_LOG_TIME_WRITE @@ -1569,7 +1576,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDfprintf(file->logfp, " (%fs @ %f)\n", write_times.elapsed, write_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position and eof */ file->pos = addr; @@ -1582,7 +1589,7 @@ done: /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_write() */ @@ -1612,14 +1619,15 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ /* Extend the file to make sure it's large enough */ if (!H5F_addr_eq(file->eoa, file->eof)) { - H5_timer_t trunc_timer = {{0}, {0}, {0}, FALSE}; /* Timer for truncate operation */ - H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + H5_timer_t trunc_timer; /* Timer for truncate operation */ + H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + + /* Initialize timer */ + H5_timer_init(&trunc_timer); /* Start timer for truncate operation */ - if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { - H5_timer_init(&trunc_timer); + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) H5_timer_start(&trunc_timer); - } /* end if */ #ifdef H5_HAVE_WIN32_API { @@ -1643,7 +1651,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ dwError = GetLastError(); if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") - } /* end if */ + } if (0 == SetEndOfFile(file->hFile)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") @@ -1666,7 +1674,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { H5_timer_get_times(trunc_timer, &trunc_times); file->total_truncate_time += trunc_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual truncate events. */ if (file->fa.flags & H5FD_LOG_TRUNCATE) { @@ -1680,7 +1688,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ HDfprintf(file->logfp, " (%fs @ %f)\n", trunc_times.elapsed, trunc_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update the eof value */ file->eof = file->eoa; diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 576120b..c0b14ce 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -42,7 +42,7 @@ static hid_t H5FD_MPIO_g = 0; /* Whether to allow collective I/O operations */ -/* (Value can be set from environment variable also) */ +/* (Can be changed by setting "HDF5_MPI_OPT_TYPES" environment variable to '0' or '1') */ hbool_t H5FD_mpi_opt_types_g = TRUE; /* @@ -133,23 +133,26 @@ static const H5FD_class_mpi_t H5FD_mpio_g = { }; #ifdef H5FDmpio_DEBUG -/* Flags to control debug actions in H5Fmpio. - * Meant to be indexed by characters. - * - * 'c' show result of MPI_Get_count after read - * 'r' show read offset and size - * 't' trace function entry and exit - * 'w' show write offset and size +/* Flags to control debug actions in the MPI-IO VFD. + * (Meant to be indexed by characters) + * + * These flags can be set with either (or both) the environment variable + * "H5FD_mpio_Debug" set to a string containing one or more characters + * (flags) or by setting them as a string value for the + * "H5F_mpio_debug_key" MPI Info key. + * + * Supported characters in 'H5FD_mpio_Debug' string: + * 't' trace function entry and exit + * 'r' show read offset and size + * 'w' show write offset and size + * '0'-'9' only show output from a single MPI rank (ranks 0-9 supported) */ -static int H5FD_mpio_Debug[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static int H5FD_mpio_debug_flags_s[256]; +static int H5FD_mpio_debug_rank_s = -1; + +/* Indicate if this rank should output tracing info */ +#define H5FD_MPIO_TRACE_THIS_RANK(file) \ + (H5FD_mpio_debug_rank_s < 0 || H5FD_mpio_debug_rank_s == (file)->mpi_rank) #endif /*-------------------------------------------------------------------------- @@ -181,6 +184,41 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ +#ifdef H5FDmpio_DEBUG + +/*--------------------------------------------------------------------------- + * Function: H5FD__mpio_parse_debug_str + * + * Purpose: Parse a string for debugging flags + * + * Returns: N/A + * + * Programmer: Quincey Koziol + * Wednesday, Aug 12, 2020 + * + *--------------------------------------------------------------------------- + */ +static void +H5FD__mpio_parse_debug_str(const char *s) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(s); + + /* Set debug mask */ + while (*s) { + if ((int)(*s) >= (int)'0' && (int)(*s) <= (int)'9') + H5FD_mpio_debug_rank_s = ((int)*s) - (int)'0'; + else + H5FD_mpio_debug_flags_s[(int)*s]++; + s++; + } /* end while */ + + FUNC_LEAVE_NOAPI_VOID +} /* end H5FD__mpio_parse_debug_str() */ +#endif /* H5FDmpio_DEBUG */ + /*------------------------------------------------------------------------- * Function: H5FD_mpio_init * @@ -198,11 +236,8 @@ done: hid_t H5FD_mpio_init(void) { -#ifdef H5FDmpio_DEBUG static int H5FD_mpio_Debug_inited = 0; -#endif /* H5FDmpio_DEBUG */ - const char *s; /* String for environment variables */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -210,28 +245,27 @@ H5FD_mpio_init(void) if (H5I_VFL != H5I_get_type(H5FD_MPIO_g)) H5FD_MPIO_g = H5FD_register((const H5FD_class_t *)&H5FD_mpio_g, sizeof(H5FD_class_mpi_t), FALSE); - /* Allow MPI buf-and-file-type optimizations? */ - s = HDgetenv("HDF5_MPI_OPT_TYPES"); - if (s && HDisdigit(*s)) { - long env_val = HDstrtol(s, NULL, 0); - H5FD_mpi_opt_types_g = (0 == env_val) ? FALSE : TRUE; - } + if (!H5FD_mpio_Debug_inited) { + const char *s; /* String for environment variables */ + + /* Allow MPI buf-and-file-type optimizations? */ + s = HDgetenv("HDF5_MPI_OPT_TYPES"); + if (s && HDisdigit(*s)) + H5FD_mpi_opt_types_g = (0 == HDstrtol(s, NULL, 0)) ? FALSE : TRUE; #ifdef H5FDmpio_DEBUG - if (!H5FD_mpio_Debug_inited) { + /* Clear the flag buffer */ + HDmemset(H5FD_mpio_debug_flags_s, 0, sizeof(H5FD_mpio_debug_flags_s)); + /* Retrieve MPI-IO debugging environment variable */ s = HDgetenv("H5FD_mpio_Debug"); - if (s) { - /* Set debug mask */ - while (*s) { - H5FD_mpio_Debug[(int)*s]++; - s++; - } /* end while */ - } /* end if */ - H5FD_mpio_Debug_inited++; - } /* end if */ + if (s) + H5FD__mpio_parse_debug_str(s); #endif /* H5FDmpio_DEBUG */ + H5FD_mpio_Debug_inited++; + } /* end if */ + /* Set return value */ ret_value = H5FD_MPIO_g; @@ -655,30 +689,27 @@ herr_t H5FD_set_mpio_atomicity(H5FD_t *_file, hbool_t flag) { H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - int mpi_code; /* MPI return code */ - int temp_flag; - herr_t ret_value = SUCCEED; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif - if (FALSE == flag) - temp_flag = 0; - else - temp_flag = 1; - /* set atomicity value */ - if (MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, temp_flag))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, (int)(flag != FALSE)))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_atomicity", mpi_code) done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -700,15 +731,18 @@ herr_t H5FD_get_mpio_atomicity(H5FD_t *_file, hbool_t *flag) { H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - int mpi_code; /* MPI return code */ int temp_flag; - herr_t ret_value = SUCCEED; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Get atomicity value */ @@ -722,8 +756,8 @@ H5FD_get_mpio_atomicity(H5FD_t *_file, hbool_t *flag) done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -759,17 +793,14 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR int mpi_amode; /* MPI file access flags */ int mpi_rank = INT_MAX; /* MPI rank of this process */ int mpi_size; /* Total number of MPI processes */ - int mpi_code; /* MPI return code */ MPI_Offset file_size; /* File size (of existing files) */ - H5FD_t * ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", FUNC, - name, flags, (int)fapl_id, (unsigned long)maxaddr); + hbool_t H5FD_mpio_debug_t_flag = FALSE; #endif + int mpi_code; /* MPI return code */ + H5FD_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC /* Get a pointer to the fapl */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) @@ -787,6 +818,14 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR if (MPI_SUCCESS != (mpi_code = MPI_Comm_size(comm, &mpi_size))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) +#ifdef H5FDmpio_DEBUG + H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && + (H5FD_mpio_debug_rank_s < 0 || H5FD_mpio_debug_rank_s == mpi_rank)); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", + FUNC, mpi_rank, name, flags, (int)fapl_id, (unsigned long)maxaddr); +#endif + /* Convert HDF5 flags to MPI-IO flags */ /* Some combinations are illegal; let MPI-IO figure it out */ mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; @@ -802,14 +841,9 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR int flag; MPI_Info_get(info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); - if (flag) { - int i; - - HDfprintf(stdout, "H5FD_mpio debug flags = '%s'\n", debug_str); - for (i = 0; debug_str[i] /*end of string*/ && i < 128 /*just in case*/; ++i) - H5FD_mpio_Debug[(int)debug_str[i]] = 1; - } /* end if */ - } /* end if */ + if (flag) + H5FD__mpio_parse_debug_str(debug_str); + } /* end if */ #endif if (MPI_SUCCESS != (mpi_code = MPI_File_open(comm, name, mpi_amode, info, &fh))) @@ -836,6 +870,7 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR /* Determine if the file should be truncated */ if (file_size && (flags & H5F_ACC_TRUNC)) { + /* Truncate the file */ if (MPI_SUCCESS != (mpi_code = MPI_File_set_size(fh, (MPI_Offset)0))) HMPI_GOTO_ERROR(NULL, "MPI_File_set_size failed", mpi_code) @@ -867,8 +902,8 @@ done: } /* end if */ #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -890,14 +925,18 @@ static herr_t H5FD__mpio_close(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); + int mpi_rank = file->mpi_rank; +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -915,8 +954,8 @@ H5FD__mpio_close(H5FD_t *_file) done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -948,7 +987,7 @@ H5FD__mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ *flags |= H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default - VFD */ + VFD */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) @@ -1110,7 +1149,6 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU H5FD_mpio_t *file = (H5FD_mpio_t *)_file; MPI_Offset mpi_off; MPI_Status mpi_stat; /* Status from I/O operation */ - int mpi_code; /* mpi return code */ MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ int size_i; /* Integer copy of 'size' to read */ #if MPI_VERSION >= 3 @@ -1126,13 +1164,18 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU #endif hbool_t use_view_this_time = FALSE; hbool_t rank0_bcast = FALSE; /* If read-with-rank0-and-bcast flag was used */ - herr_t ret_value = SUCCEED; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); + hbool_t H5FD_mpio_debug_r_flag = (H5FD_mpio_debug_flags_s[(int)'r'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -1151,8 +1194,9 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) mpi_off = %ld size_i = %d\n", FUNC, file->mpi_rank, (long)mpi_off, + size_i); #endif /* Only look for MPI views for raw data transfers */ @@ -1198,8 +1242,8 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) using MPIO collective mode\n", FUNC, file->mpi_rank); #endif /* Get the collective_opt property to check whether the application wants to do IO individually. */ if (H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) @@ -1207,14 +1251,14 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU if (coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing MPI collective IO\n", FUNC, file->mpi_rank); #endif /* Check whether we should read from rank 0 and broadcast to other ranks */ if (H5CX_get_mpio_rank0_bcast()) { #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: doing read-rank0-and-MPI_Bcast\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing read-rank0-and-MPI_Bcast\n", FUNC, file->mpi_rank); #endif /* Indicate path we've taken */ rank0_bcast = TRUE; @@ -1235,8 +1279,8 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU } /* end if */ else { #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); #endif /* Perform independent read operation */ @@ -1252,10 +1296,16 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ - else + else { +#ifdef H5FDmpio_DEBUG + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); +#endif + /* Perform independent read operation */ if (MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) + } /* end else */ /* Only retrieve bytes read if this rank _actually_ participated in I/O */ if (!rank0_bcast || (rank0_bcast && file->mpi_rank == 0)) { @@ -1301,8 +1351,8 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -1337,7 +1387,6 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h MPI_Offset mpi_off; MPI_Status mpi_stat; /* Status from I/O operation */ MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ - int mpi_code; /* MPI return code */ #if MPI_VERSION >= 3 MPI_Count bytes_written; MPI_Count type_size; /* MPI datatype used for I/O's size */ @@ -1351,13 +1400,18 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h hbool_t use_view_this_time = FALSE; hbool_t derived_type = FALSE; H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ - herr_t ret_value = SUCCEED; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); + hbool_t H5FD_mpio_debug_w_flag = (H5FD_mpio_debug_flags_s[(int)'w'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -1377,8 +1431,9 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h size_i = (int)size; #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'w']) - HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) mpi_off = %ld size_i = %d\n", FUNC, file->mpi_rank, (long)mpi_off, + size_i); #endif /* Get the transfer mode from the API context */ @@ -1433,8 +1488,8 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'w']) - HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) using MPIO collective mode\n", FUNC, file->mpi_rank); #endif /* Get the collective_opt property to check whether the application wants to do IO individually. */ @@ -1443,8 +1498,8 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h if (coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'w']) - HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) doing MPI collective IO\n", FUNC, file->mpi_rank); #endif /* Perform collective write operation */ if (MPI_SUCCESS != @@ -1455,9 +1510,10 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h if (type != H5FD_MEM_DRAW) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Metadata Coll opt property should be collective at this point") + #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'w']) - HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); #endif /* Perform independent write operation */ if (MPI_SUCCESS != @@ -1470,12 +1526,18 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ - else + else { +#ifdef H5FDmpio_DEBUG + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); +#endif + /* Perform independent write operation */ if (MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) + } /* end else */ - /* How many bytes were actually written? */ + /* How many bytes were actually written? */ #if MPI_VERSION >= 3 if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_written))) #else @@ -1514,8 +1576,8 @@ done: MPI_Type_free(&buf_type); #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving, proc %d: ret_value = %d\n", FUNC, file->mpi_rank, ret_value); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving: ret_value = %d\n", FUNC, file->mpi_rank, ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -1537,14 +1599,17 @@ static herr_t H5FD__mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - int mpi_code; /* mpi return code */ - herr_t ret_value = SUCCEED; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -1558,8 +1623,8 @@ H5FD__mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -1591,14 +1656,17 @@ done: static herr_t H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -1666,8 +1734,8 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 168bbe1..9226624 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -35,6 +35,15 @@ #define TRUE 1 #endif +/* Windows doesn't like some POSIX names and redefines them with an + * underscore + */ +#ifdef _WIN32 +#define my_strdup _strdup +#else +#define my_strdup strdup +#endif + /* Loop through all mapped files */ #define UNIQUE_MEMBERS_CORE(MAP, ITER, SEEN, LOOPVAR) \ { \ @@ -103,9 +112,8 @@ typedef struct H5FD_multi_dxpl_t { } H5FD_multi_dxpl_t; /* Private functions */ -static char *my_strdup(const char *s); -static int compute_next(H5FD_multi_t *file); -static int open_members(H5FD_multi_t *file); +static int compute_next(H5FD_multi_t *file); +static int open_members(H5FD_multi_t *file); /* Callback prototypes */ static herr_t H5FD_multi_term(void); @@ -172,36 +180,6 @@ static const H5FD_class_t H5FD_multi_g = { }; /*------------------------------------------------------------------------- - * Function: my_strdup - * - * Purpose: Private version of strdup() - * - * Return: Success: Ptr to new copy of string - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Friday, August 13, 1999 - * - *------------------------------------------------------------------------- - */ -static char * -my_strdup(const char *s) -{ - char * x; - size_t str_len; - - if (!s) - return NULL; - str_len = strlen(s) + 1; - if (NULL == (x = (char *)malloc(str_len))) - return NULL; - memcpy(x, s, str_len); - - return x; -} - -/*------------------------------------------------------------------------- * Function: H5FD_multi_init * * Purpose: Initialize this driver by registering the driver with the diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index b5a42c0..037669b 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -141,10 +141,10 @@ H5G_map_obj_type(H5O_type_t obj_type) * specified NAME. The group is opened for write access * and it's object ID is returned. * - * The optional SIZE_HINT specifies how much file space to - * reserve to store the names that will appear in this - * group. If a non-positive value is supplied for the SIZE_HINT - * then a default size is chosen. + * The SIZE_HINT parameter specifies how much file space to reserve + * to store the names that will appear in this group. This number + * must be less than or equal to UINT32_MAX. If zero is supplied + * for the SIZE_HINT then a default size is chosen. * * Note: Deprecated in favor of H5Gcreate2 * @@ -174,6 +174,8 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name given") + if (size_hint > UINT32_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "size_hint cannot be larger than UINT32_MAX") /* Check if we need to create a non-standard GCPL */ if (size_hint > 0) { @@ -449,11 +449,17 @@ H5MM_xstrdup(const char *s) FUNC_ENTER_NOAPI(NULL) +#if defined H5_MEMORY_ALLOC_SANITY_CHECK if (s) { if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); - } /* end if */ + } +#else + if (s) + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) @@ -483,10 +489,15 @@ H5MM_strdup(const char *s) FUNC_ENTER_NOAPI(NULL) if (!s) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "NULL string not allowed") +#if defined H5_MEMORY_ALLOC_SANITY_CHECK if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); +#else + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 1dbb552..f0fc39f 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -4220,7 +4220,7 @@ herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access) { H5P_genplist_t *plist; /* Property list pointer */ - char * tmp_location; /* Working location pointer */ + char * new_location; /* Working location pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -4236,19 +4236,14 @@ H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list") - /* Get the current location string and free it */ - if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current log location") - H5MM_xfree(tmp_location); - /* Make a copy of the passed-in location */ - if (NULL == (tmp_location = H5MM_xstrdup(location))) + if (NULL == (new_location = H5MM_xstrdup(location))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location") /* Set values */ if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag") - if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) + if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &new_location) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location") if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag") @@ -175,7 +175,7 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if ((space_id == H5I_BADID) || (space_id == H5S_ALL)) + if ((space_id == H5I_INVALID_HID) || (space_id == H5S_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 32bd035..f78460d 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -449,7 +449,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Retrieve space */ - if (space_id == H5I_BADID) + if (space_id == H5I_INVALID_HID) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") diff --git a/src/H5ST.c b/src/H5ST.c deleted file mode 100644 index 0b7b858..0000000 --- a/src/H5ST.c +++ /dev/null @@ -1,779 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* TERNARY SEARCH TREE ALGS - This code is described in "Ternary Search Trees" by Jon -Bentley and Robert Sedgewick in the April, 1998, Dr. Dobb's Journal. -*/ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5STprivate.h" /* Ternary search trees */ - -#ifdef H5ST_DEBUG -static herr_t H5ST__dump_internal(H5ST_ptr_t p); -#endif /* H5ST_DEBUG */ - -/* Declare a free list to manage the H5ST_node_t struct */ -H5FL_DEFINE_STATIC(H5ST_node_t); - -/* Declare a free list to manage the H5ST_tree_t struct */ -H5FL_DEFINE_STATIC(H5ST_tree_t); - -/*-------------------------------------------------------------------------- - NAME - H5ST_create - PURPOSE - Create a TST - USAGE - H5ST_ptr_t H5ST_create() - - RETURNS - Returns a pointer to the new TST tree on success, NULL on failure. - DESCRIPTION - Create a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_tree_t * -H5ST_create(void) -{ - H5ST_tree_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Allocate wrapper for TST */ - if (NULL == (ret_value = H5FL_MALLOC(H5ST_tree_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* Set the internal fields */ - ret_value->root = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_create() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__close_internal - PURPOSE - Close a TST, deallocating it. - USAGE - herr_t H5ST_close(p) - H5ST_ptr_t p; IN/OUT: Root of TST to free - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a TST, freeing all nodes. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__close_internal(H5ST_ptr_t p) -{ - FUNC_ENTER_STATIC_NOERR - - /* Recursively free TST */ - if (p) { - H5ST__close_internal(p->lokid); - if (p->splitchar) - H5ST__close_internal(p->eqkid); - H5ST__close_internal(p->hikid); - p = H5FL_FREE(H5ST_node_t, p); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__close_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_close - PURPOSE - Close a TST, deallocating it. - USAGE - herr_t H5ST_close(tree) - H5ST_tree_t *tree; IN/OUT: TST tree to free - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a TST, freeing all nodes. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_close(H5ST_tree_t *tree) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if (NULL == tree) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid TST") - - /* Free the TST itself */ - if (H5ST__close_internal(tree->root) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTFREE, FAIL, "can't free TST") - - /* Free root node itself */ - tree = H5FL_FREE(H5ST_tree_t, tree); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_close() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_insert - PURPOSE - Insert a string/object pair into a TST - USAGE - herr_t H5ST_insert(tree,s,obj) - H5ST_tree_t *tree; IN/OUT: TST to insert string into - const char *s; IN: String to use as key for object - void *obj; IN: Pointer to object to insert - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Insert a key (string)/object pair into a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_insert(H5ST_tree_t *tree, const char *s, void *obj) -{ - int d; /* Comparison value */ - H5ST_ptr_t pp, *p; /* Pointer to current node and pointer to that */ - H5ST_ptr_t parent = NULL; /* Pointer to parent node */ - H5ST_ptr_t up = NULL; /* Pointer to up node */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Find the correct location to insert object */ - p = &tree->root; - while ((pp = *p)) { - /* If this node matches the character in the key, then drop down to the lower tree */ - if (0 == (d = *s - pp->splitchar)) { - if (*s++ == 0) - HGOTO_ERROR(H5E_TST, H5E_EXISTS, FAIL, "key already in tree") - up = pp; - p = &(pp->eqkid); - } /* end if */ - else { - /* Walk through the current tree, searching for the matching character */ - parent = pp; - if (d < 0) - p = &(pp->lokid); - else - p = &(pp->hikid); - } /* end else */ - } /* end while */ - - /* Finish walking through the key string, adding nodes until the end */ - for (;;) { - if (NULL == (*p = H5FL_MALLOC(H5ST_node_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - pp = *p; - pp->splitchar = *s; - pp->up = up; - pp->parent = parent; - pp->lokid = pp->eqkid = pp->hikid = NULL; - - /* If this is the end of the key string, break out */ - if (*s++ == 0) { - pp->eqkid = (H5ST_ptr_t)obj; - break; - } /* end if */ - - /* Continue to next character */ - parent = NULL; - up = pp; - p = &(pp->eqkid); - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_insert() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_search - PURPOSE - Determine if a key is in the TST - USAGE - hbool_t H5ST_search(tree,s) - H5ST_tree_t *tree; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: TRUE if key string in TST, FALSE if not - Failure: negative - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5ST_search(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t p; /* Temporary pointer to TST node */ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - p = tree->root; - while (p) { - if (*s < p->splitchar) - p = p->lokid; - else if (*s == p->splitchar) { - if (*s++ == 0) - HGOTO_DONE(TRUE); - p = p->eqkid; - } - else - p = p->hikid; - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_search() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__find_internal - PURPOSE - Find the node matching a particular key string - USAGE - H5ST_ptr_t H5ST_find(p,s) - H5ST_ptr_t p; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__find_internal(H5ST_ptr_t p, const char *s) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - while (p) { - if (*s < p->splitchar) - p = p->lokid; - else if (*s == p->splitchar) { - if (*s++ == 0) - HGOTO_DONE(p); - p = p->eqkid; - } - else - p = p->hikid; - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__find_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_find - PURPOSE - Find the node matching a particular key string - USAGE - H5ST_ptr_t H5ST_find(tree,s) - H5ST_tree_t *tree; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_find(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if (NULL == (ret_value = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_find() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_locate - PURPOSE - Find an object in a TST - USAGE - void *H5ST_locate(tree,s) - H5ST_tree_t *tree; IN: TST to locate object within - const char *s; IN: String of key for object to locate - RETURNS - Success: Non-NULL, pointer to object stored for key - Failure: Negative - DESCRIPTION - Locate a node in a TST, returning the object from the node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -void * -H5ST_locate(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t node; /* Pointer to node located */ - void * ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Locate the node to remove */ - if (NULL == (node = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - - /* Get the pointer to the object to return */ - ret_value = node->eqkid; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5ST_locate() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__findfirst_internal - PURPOSE - Find the first node in a TST - USAGE - H5ST_ptr_t H5ST__findfirst_internal(p) - H5ST_ptr_t p; IN: TST to locate first node within - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the first (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__findfirst_internal(H5ST_ptr_t p) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - while (p) { - /* Find least node in current tree */ - while (p->lokid) - p = p->lokid; - - /* Is least node '\0'? */ - if (p->splitchar == '\0') { - /* Return it */ - HGOTO_DONE(p); - } /* end if */ - else { - /* Go down to next level of tree */ - p = p->eqkid; - } /* end else */ - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__findfirst_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_findfirst - PURPOSE - Find the first node in a TST - USAGE - H5ST_ptr_t H5ST_findfirst(tree) - H5ST_tree_t *tree; IN: TST to locate first node within - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the first (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_findfirst(H5ST_tree_t *tree) -{ - H5ST_ptr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if (NULL == (ret_value = H5ST__findfirst_internal(tree->root))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "no nodes in TST"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_findfirst() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__getnext - PURPOSE - Internal routine to find the next node in a given level of a TST - USAGE - H5ST_ptr_t H5ST__getnext(p) - H5ST_ptr_t *p; IN: Pointer to node to find next node from - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the next (lexicographically) node in the current level of a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__getnext(H5ST_ptr_t p) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* If the node to continue from has higher-valued nodes attached */ - if (p->hikid) { - /* Go to first higher-valued node */ - p = p->hikid; - - /* Find least node from here */ - while (p->lokid) - p = p->lokid; - HGOTO_DONE(p); - } /* end if */ - else { - H5ST_ptr_t q; /* Temporary TST node pointer */ - - /* Go up one level in current tree */ - q = p->parent; - if (q == NULL) - HGOTO_DONE(NULL); - - /* While the previous node was the higher-valued node, keep backing up the tree */ - while (q->hikid == p) { - p = q; - q = p->parent; - if (NULL == q) - HGOTO_DONE(NULL); - } /* end while */ - HGOTO_DONE(q); - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__getnext() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_findnext - PURPOSE - Find the next node from a node in a TST - USAGE - H5ST_ptr_t H5ST_findnext(p) - H5ST_ptr_t p; IN: Current node to continue from - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the next (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_findnext(H5ST_ptr_t p) -{ - H5ST_ptr_t q; /* Temporary pointer to TST node */ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Find the next node at the current level, or go back up the tree */ - do { - q = H5ST__getnext(p); - if (q) { - HGOTO_DONE(H5ST__findfirst_internal(q->eqkid)); - } /* end if */ - else - p = p->up; - } while (p); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_findnext() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__delete_internal - PURPOSE - Delete a node from a TST - USAGE - herr_t H5ST__delete_internal(root,p) - H5ST_ptr_t *root; IN/OUT: Root of TST to delete node from - H5ST_ptr_t p; IN: Node to delete - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Delete a node from a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This should be the final node for a string. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) -{ - H5ST_ptr_t q, /* Temporary pointer to TST node */ - newp; /* Pointer to node which will replace deleted node in tree */ - - FUNC_ENTER_STATIC_NOERR - - /* Find node to replace one being deleted */ - if (p->lokid) { - /* If the deleted node has lo & hi kids, attach them together */ - if (p->hikid) { - q = p->lokid; - while (q->hikid) - q = q->hikid; - q->hikid = p->hikid; - p->hikid->parent = q; - } /* end if */ - newp = p->lokid; - } /* end if */ - else if (p->hikid) { - newp = p->hikid; - } /* end if */ - else { - newp = NULL; - } /* end else */ - - /* Deleted node is in middle of tree */ - if (p->parent) { - /* Attach new node to correct side of parent */ - if (p == p->parent->lokid) - p->parent->lokid = newp; - else - p->parent->hikid = newp; - if (newp) - newp->parent = p->parent; - } /* end if */ - else { - if (newp) - newp->parent = p->parent; - if (p->up) { - p->up->eqkid = newp; - - /* If we deleted the last node in the TST, delete the upper node also */ - if (NULL == newp) - H5ST__delete_internal(root, p->up); - } /* end if */ - else /* Deleted last node at top level of tree */ - *root = newp; - } /* end else */ - - p = H5FL_FREE(H5ST_node_t, p); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__delete_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_delete - PURPOSE - Delete a node from a TST - USAGE - herr_t H5ST_delete(tree,p) - H5ST_tree_t *tree; IN/OUT: TST to delete node from - H5ST_ptr_t p; IN: Node to delete - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Delete a node from a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This should be the final node for a string. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_delete(H5ST_tree_t *tree, H5ST_ptr_t p) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if (H5ST__delete_internal(&tree->root, p) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, FAIL, "can't delete node from TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_delete() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_remove - PURPOSE - Remove a node from a TST - USAGE - void *H5ST_remove(tree,s) - H5ST_tree_t *tree; IN/OUT: TST to remove node from - const char *s; IN: String of key for node to remove - RETURNS - Success: Non-NULL, pointer to object stored for key - Failure: Negative - DESCRIPTION - Remove a node from a TST, returning the object from the node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -void * -H5ST_remove(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t node; /* Pointer to node to remove */ - void * ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Locate the node to remove */ - if (NULL == (node = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - - /* Get the pointer to the object to return */ - ret_value = node->eqkid; - - /* Remove the node from the TST */ - if (H5ST__delete_internal(&tree->root, node) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, NULL, "can't delete node from TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5ST_remove() */ - -#ifdef H5ST_DEBUG - -/*-------------------------------------------------------------------------- - NAME - H5ST__dump_internal - PURPOSE - Dump all the nodes of a TST - USAGE - herr_t H5ST_dump(p) - H5ST_ptr_t p; IN: Root of TST to dump - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Dump information for a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__dump_internal(H5ST_ptr_t p) -{ - FUNC_ENTER_STATIC_NOERR - - if (p) { - HDprintf("p=%p\n", (void *)p); - HDprintf("\tp->up=%p\n", (void *)p->up); - HDprintf("\tp->parent=%p\n", (void *)p->parent); - HDprintf("\tp->lokid=%p\n", (void *)p->lokid); - HDprintf("\tp->hikid=%p\n", (void *)p->hikid); - HDprintf("\tp->eqkid=%p\n", (void *)p->eqkid); - HDprintf("\tp->splitchar=%c\n", p->splitchar); - - H5ST__dump_internal(p->lokid); - if (p->splitchar) - H5ST__dump_internal(p->eqkid); - else - HDprintf("%s\n", (char *)p->eqkid); - H5ST__dump_internal(p->hikid); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__dump_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_dump - PURPOSE - Dump all the nodes of a TST - USAGE - herr_t H5ST_dump(tree) - H5ST_tree_t *tree; IN: TST to dump - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Dump information for a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_dump(H5ST_tree_t *tree) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Dump the tree */ - H5ST__dump_internal(tree->root); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST_dump() */ -#endif /* H5ST_DEBUG */ diff --git a/src/H5STprivate.h b/src/H5STprivate.h deleted file mode 100644 index 2d009fa..0000000 --- a/src/H5STprivate.h +++ /dev/null @@ -1,63 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * This file contains private information about the H5ST module - */ -#ifndef H5STprivate_H -#define H5STprivate_H - -#ifdef LATER -#include "H5STpublic.h" -#endif /* LATER */ - -/* Private headers needed by this file */ -#include "H5private.h" - -/* Typedefs */ - -/* Internal nodes for TST */ -typedef struct H5ST_node *H5ST_ptr_t; -typedef struct H5ST_node { - char splitchar; /* Character represented at node */ - H5ST_ptr_t up; /* Pointer to the node in the tree above (before) this node */ - H5ST_ptr_t parent; /* Pointer to the next higher tree node in this tree */ - H5ST_ptr_t lokid; /* Pointer to the lower node from this one, in this tree */ - H5ST_ptr_t eqkid; /* Pointer to the parent node in the next tree down (after) this node */ - H5ST_ptr_t hikid; /* Pointer to the higher node from this one, in this tree */ -} H5ST_node_t; - -/* Wrapper about TST */ -typedef struct { - H5ST_ptr_t root; /* Pointer to actual TST */ -} H5ST_tree_t; - -/* Macro to access "data" pointer in H5ST_node_t's returned from functions */ -#define H5ST_NODE_DATA(p) ((void *)(p->eqkid)) - -/* Private routines */ -H5_DLL H5ST_tree_t *H5ST_create(void); -H5_DLL herr_t H5ST_close(H5ST_tree_t *p); -H5_DLL herr_t H5ST_insert(H5ST_tree_t *root, const char *s, void *obj); -H5_DLL htri_t H5ST_search(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_find(H5ST_tree_t *root, const char *s); -H5_DLL void * H5ST_locate(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *p); -H5_DLL H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p); -H5_DLL void * H5ST_remove(H5ST_tree_t *root, const char *s); -H5_DLL herr_t H5ST_delete(H5ST_tree_t *root, H5ST_ptr_t p); -#ifdef H5ST_DEBUG -H5_DLL herr_t H5ST_dump(H5ST_tree_t *tree); -#endif /* H5ST_DEBUG */ - -#endif /* H5STprivate_H */ diff --git a/src/Makefile.am b/src/Makefile.am index a4d57ec..ab9e13a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,7 +98,6 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5Sselect.c H5Stest.c \ H5SL.c \ H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ - H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c H5Tfixed.c \ H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c H5Topaque.c \ |