summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c2
-rw-r--r--src/H5Bdbg.c10
-rw-r--r--src/H5C.c52
-rw-r--r--src/H5Cimage.c5
-rw-r--r--src/H5Cmpio.c6
-rw-r--r--src/H5Dchunk.c86
-rw-r--r--src/H5Dcontig.c12
-rw-r--r--src/H5Dint.c10
-rw-r--r--src/H5Dio.c26
-rw-r--r--src/H5Dmpio.c16
-rw-r--r--src/H5Dpkg.h10
-rw-r--r--src/H5Dprivate.h2
-rw-r--r--src/H5Dselect.c4
-rw-r--r--src/H5FD.c8
-rw-r--r--src/H5FDmpio.c2
-rw-r--r--src/H5Gent.c5
-rw-r--r--src/H5Gint.c2
-rw-r--r--src/H5Gloc.c22
-rw-r--r--src/H5Gpkg.h4
-rw-r--r--src/H5Gprivate.h2
-rw-r--r--src/H5Idbg.c8
-rw-r--r--src/H5Oflush.c15
-rw-r--r--src/H5Oint.c2
-rw-r--r--src/H5Pfapl.c2
-rw-r--r--src/H5Shyper.c9
-rw-r--r--src/H5Smpio.c93
-rw-r--r--src/H5Sprivate.h6
-rw-r--r--src/H5Sselect.c50
-rw-r--r--src/H5T.c45
-rw-r--r--src/H5Tconv.c32
-rw-r--r--src/H5Tnative.c351
-rw-r--r--src/H5Tpkg.h37
-rw-r--r--src/H5Tprivate.h2
-rw-r--r--src/H5Tref.c13
-rw-r--r--src/H5Tvlen.c16
-rw-r--r--src/H5VLdyn_ops.c7
-rw-r--r--src/H5detect.c687
37 files changed, 689 insertions, 972 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 60f0230..31caf90 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -2432,7 +2432,7 @@ done:
/*------------------------------------------------------------------------------
* Function: H5AC_expunge_tag_type_metadata()
*
- * Purpose: Wrapper for cache level function which expunge entries with
+ * Purpose: Wrapper for cache level function which expunges entries with
* a specific tag and type id.
*
* Return: SUCCEED on success, FAIL otherwise.
diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c
index 23d0a8f..de07442 100644
--- a/src/H5Bdbg.c
+++ b/src/H5Bdbg.c
@@ -110,20 +110,20 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5
*/
for (u = 0; u < bt->nchildren; u++) {
HDfprintf(stream, "%*sChild %d...\n", indent, "", u);
- HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(0, fwidth - 3),
+ HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(3, fwidth) - 3,
"Address:", bt->child[u]);
/* If there is a key debugging routine, use it to display the left & right keys */
if (type->debug_key) {
/* Decode the 'left' key & print it */
- HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:");
+ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(3, fwidth) - 3, "Left Key:");
HDassert(H5B_NKEY(bt, shared, u));
- (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u), udata);
+ (void)(type->debug_key)(stream, indent + 6, MAX(6, fwidth) - 6, H5B_NKEY(bt, shared, u), udata);
/* Decode the 'right' key & print it */
- HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:");
+ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(3, fwidth) - 3, "Right Key:");
HDassert(H5B_NKEY(bt, shared, u + 1));
- (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u + 1),
+ (void)(type->debug_key)(stream, indent + 6, MAX(6, fwidth) - 6, H5B_NKEY(bt, shared, u + 1),
udata);
} /* end if */
} /* end for */
diff --git a/src/H5C.c b/src/H5C.c
index fa20165..067acfa 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -61,16 +61,16 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Cpkg.h" /* Cache */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* Files */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MFprivate.h" /* File memory management */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5Cpkg.h" /* Cache */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* Files */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
/****************/
/* Local Macros */
@@ -4667,10 +4667,11 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr)
cache_ptr->epoch_marker_ringbuf_first =
(cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1);
+ if (cache_ptr->epoch_marker_ringbuf_size <= 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow")
+
cache_ptr->epoch_marker_ringbuf_size -= 1;
- if (cache_ptr->epoch_marker_ringbuf_size < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow")
if ((cache_ptr->epoch_marker_active)[i] != TRUE)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?")
@@ -4690,11 +4691,11 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr)
(cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i;
- cache_ptr->epoch_marker_ringbuf_size += 1;
-
- if (cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS)
+ if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow")
+ cache_ptr->epoch_marker_ringbuf_size += 1;
+
H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr,
(cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (FAIL))
done:
@@ -4965,13 +4966,13 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr)
(cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i;
- cache_ptr->epoch_marker_ringbuf_size += 1;
-
- if (cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS) {
+ if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) {
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow")
}
+ cache_ptr->epoch_marker_ringbuf_size += 1;
+
H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr,
(cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (FAIL))
@@ -5019,11 +5020,11 @@ H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr)
cache_ptr->epoch_marker_ringbuf_first =
(cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1);
- cache_ptr->epoch_marker_ringbuf_size -= 1;
-
- if (cache_ptr->epoch_marker_ringbuf_size < 0)
+ if (cache_ptr->epoch_marker_ringbuf_size <= 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow")
+ cache_ptr->epoch_marker_ringbuf_size -= 1;
+
if ((cache_ptr->epoch_marker_active)[i] != TRUE)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?")
@@ -5092,10 +5093,11 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr)
cache_ptr->epoch_marker_ringbuf_first =
(cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1);
+ if (cache_ptr->epoch_marker_ringbuf_size <= 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow")
+
cache_ptr->epoch_marker_ringbuf_size -= 1;
- if (cache_ptr->epoch_marker_ringbuf_size < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow")
if ((cache_ptr->epoch_marker_active)[i] != TRUE)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?")
@@ -5523,8 +5525,8 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags)
hbool_t restart_slist_scan;
uint32_t protected_entries = 0;
int32_t i;
- int32_t cur_ring_pel_len;
- int32_t old_ring_pel_len;
+ uint32_t cur_ring_pel_len;
+ uint32_t old_ring_pel_len;
unsigned cooked_flags;
unsigned evict_flags;
H5SL_node_t * node_ptr = NULL;
diff --git a/src/H5Cimage.c b/src/H5Cimage.c
index ddf5f94..899d6d7 100644
--- a/src/H5Cimage.c
+++ b/src/H5Cimage.c
@@ -2690,10 +2690,11 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr)
*/
if (entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID) {
image_entries[u].type_id = entry_ptr->prefetch_type_id;
- image_entries[u].age = entry_ptr->age + 1;
- if (image_entries[u].age > H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX)
+ if (entry_ptr->age >= H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX)
image_entries[u].age = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX;
+ else
+ image_entries[u].age = entry_ptr->age + 1;
} /* end if */
else {
image_entries[u].type_id = entry_ptr->type->id;
diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c
index ba6ff56..a0cc6bb 100644
--- a/src/H5Cmpio.c
+++ b/src/H5Cmpio.c
@@ -898,7 +898,11 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial)
H5C_cache_entry_t *entry_ptr = NULL;
herr_t ret_value = SUCCEED;
+#if H5C_DO_SANITY_CHECKS
FUNC_ENTER_NOAPI_NOINIT
+#else
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+#endif
entry_ptr = cache_ptr->coll_tail_ptr;
clear_cnt = (partial ? cache_ptr->coll_list_len / 2 : cache_ptr->coll_list_len);
@@ -919,7 +923,7 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial)
entry_ptr = prev_ptr;
} /* end while */
-#ifdef H5C_DO_SANITY_CHECKS
+#if H5C_DO_SANITY_CHECKS
done:
#endif /* H5C_DO_SANITY_CHECKS */
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 9167085..2075498 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -1143,8 +1143,7 @@ done:
fm->mem_space = NULL;
if (file_space_normalized == TRUE)
- if (H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) <
- 0) /* (Casting away const OK -QAK) */
+ if (H5S_hyper_denormalize_offset(file_space, old_offset) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1371,15 +1370,16 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline)
+H5D__chunk_mem_alloc(size_t size, void *pline)
{
- void *ret_value = NULL; /* Return value */
+ H5O_pline_t *_pline = (H5O_pline_t *)pline;
+ void * ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
HDassert(size);
- if (pline && pline->nused)
+ if (_pline && _pline->nused)
ret_value = H5MM_malloc(size);
else
ret_value = H5FL_BLK_MALLOC(chunk, size);
@@ -1402,14 +1402,14 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline)
*-------------------------------------------------------------------------
*/
void *
-H5D__chunk_mem_xfree(void *chk, const void *_pline)
+H5D__chunk_mem_xfree(void *chk, const void *pline)
{
- const H5O_pline_t *pline = (const H5O_pline_t *)_pline;
+ const H5O_pline_t *_pline = (const H5O_pline_t *)pline;
FUNC_ENTER_PACKAGE_NOERR
if (chk) {
- if (pline && pline->nused)
+ if (_pline && _pline->nused)
H5MM_xfree(chk);
else
chk = H5FL_BLK_FREE(chunk, chk);
@@ -1426,9 +1426,9 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline)
*-------------------------------------------------------------------------
*/
void
-H5D__chunk_mem_free(void *chk, const void *_pline)
+H5D__chunk_mem_free(void *chk, void *pline)
{
- (void)H5D__chunk_mem_xfree(chk, _pline);
+ (void)H5D__chunk_mem_xfree(chk, pline);
}
/*-------------------------------------------------------------------------
@@ -1580,8 +1580,7 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t
chunk_info->fspace_shared = TRUE;
/* Just point at the memory dataspace & selection */
- /* (Casting away const OK -QAK) */
- chunk_info->mspace = (H5S_t *)fm->mem_space;
+ chunk_info->mspace = fm->mem_space;
/* Indicate that the chunk's memory dataspace is shared */
chunk_info->mspace_shared = TRUE;
@@ -1856,7 +1855,6 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Iterate through each chunk in the dataset */
while (sel_points) {
/* Check for intersection of current chunk and file selection */
- /* (Casting away const OK - QAK) */
if (TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) {
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
hsize_t chunk_points; /* Number of elements in chunk selection */
@@ -2015,8 +2013,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
HDassert(chunk_info);
/* Just point at the memory dataspace & selection */
- /* (Casting away const OK -QAK) */
- chunk_info->mspace = (H5S_t *)fm->mem_space;
+ chunk_info->mspace = fm->mem_space;
/* Indicate that the chunk's memory space is shared */
chunk_info->mspace_shared = TRUE;
@@ -2138,8 +2135,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm)
HDassert(chunk_info);
/* Just point at the memory dataspace & selection */
- /* (Casting away const OK -QAK) */
- chunk_info->mspace = (H5S_t *)fm->mem_space;
+ chunk_info->mspace = fm->mem_space;
/* Indicate that the chunk's memory space is shared */
chunk_info->mspace_shared = TRUE;
@@ -4104,11 +4100,11 @@ done:
static void *
H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, hbool_t prev_unfilt_chunk)
{
- const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */
- const H5O_pline_t *pline =
+ const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */
+ H5O_pline_t *pline =
&(dset->shared->dcpl_cache
.pline); /* I/O pipeline info - always equal to the pline passed to H5D__chunk_mem_alloc */
- const H5O_pline_t * old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */
+ H5O_pline_t * old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */
const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */
const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */
H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */
@@ -4688,18 +4684,18 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const
coordinates) */
hsize_t max_unalloc[H5O_LAYOUT_NDIMS]; /* Last chunk in each dimension that is unallocated (in scaled
coordinates) */
- hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */
- size_t orig_chunk_size; /* Original size of chunk in bytes */
- size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */
- unsigned filter_mask = 0; /* Filter mask for chunks that have them */
- H5O_layout_t * layout = &(dset->shared->layout); /* Dataset layout */
- const H5O_pline_t *pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */
- const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */
- const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */
- H5D_fill_value_t fill_status; /* The fill value status */
- hbool_t should_fill = FALSE; /* Whether fill values should be written */
- void * unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */
- void ** fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */
+ hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */
+ size_t orig_chunk_size; /* Original size of chunk in bytes */
+ size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */
+ unsigned filter_mask = 0; /* Filter mask for chunks that have them */
+ H5O_layout_t * layout = &(dset->shared->layout); /* Dataset layout */
+ H5O_pline_t * pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */
+ H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */
+ const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */
+ H5D_fill_value_t fill_status; /* The fill value status */
+ hbool_t should_fill = FALSE; /* Whether fill values should be written */
+ void * unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */
+ void ** fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */
#ifdef H5_HAVE_PARALLEL
hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */
hbool_t using_mpi =
@@ -4804,10 +4800,9 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const
if (should_fill) {
/* Initialize the fill value buffer */
/* (delay allocating fill buffer for VL datatypes until refilling) */
- /* (casting away const OK - QAK) */
- if (H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, (void *)pline,
- (H5MM_free_t)H5D__chunk_mem_free, (void *)pline, &dset->shared->dcpl_cache.fill,
- dset->shared->type, dset->shared->type_id, (size_t)0, orig_chunk_size) < 0)
+ if (H5D__fill_init(&fb_info, NULL, H5D__chunk_mem_alloc, pline, H5D__chunk_mem_free, pline,
+ &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id,
+ (size_t)0, orig_chunk_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info")
fb_info_init = TRUE;
@@ -8094,13 +8089,13 @@ H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata)
*-------------------------------------------------------------------------
*/
herr_t
-H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
+H5D__chunk_iter(H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
{
- const H5O_layout_t *layout = NULL; /* Dataset layout */
- const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */
- H5D_rdcc_ent_t * ent; /* Cache entry index */
- H5D_chk_idx_info_t idx_info; /* Chunked index info */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */
+ H5O_layout_t * layout = NULL; /* Dataset layout */
+ H5D_rdcc_ent_t * ent; /* Cache entry index */
+ H5D_chk_idx_info_t idx_info; /* Chunked index info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr)
@@ -8124,8 +8119,8 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
/* Compose chunked index info struct */
idx_info.f = dset->oloc.file;
idx_info.pline = &dset->shared->dcpl_cache.pline;
- idx_info.layout = &dset->shared->layout.u.chunk;
- idx_info.storage = &dset->shared->layout.storage.u.chunk;
+ idx_info.layout = &layout->u.chunk;
+ idx_info.storage = &layout->storage.u.chunk;
/* If the dataset is not written, return without errors */
if (H5F_addr_defined(idx_info.storage->idx_addr)) {
@@ -8136,8 +8131,7 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
ud.op_data = op_data;
/* Iterate over the allocated chunks calling the iterator callback */
- if ((ret_value =
- (dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0)
+ if ((ret_value = (layout->storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0)
HERROR(H5E_DATASET, H5E_CANTNEXT, "chunk iteration failed");
} /* end if H5F_addr_defined */
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index e02d91a..b03ad47 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -605,23 +605,25 @@ done:
static htri_t
H5D__contig_may_use_select_io(const H5D_io_info_t *io_info, H5D_io_op_type_t op_type)
{
- const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */
- htri_t ret_value = FAIL; /* Return value */
+ const H5D_t *dataset = NULL; /* Local pointer to dataset info */
+ htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(io_info);
- HDassert(dataset);
+ HDassert(io_info->dset);
HDassert(op_type == H5D_IO_OP_READ || op_type == H5D_IO_OP_WRITE);
+ dataset = io_info->dset;
+
/* Don't use selection I/O if it's globally disabled, if there is a type
* conversion, or if it's not a contiguous dataset, or if the sieve buffer
* exists (write) or is dirty (read) */
if (!H5_use_selection_io_g || io_info->io_ops.single_read != H5D__select_read ||
io_info->layout_ops.readvv != H5D__contig_readvv ||
- (op_type == H5D_IO_OP_READ && io_info->dset->shared->cache.contig.sieve_dirty) ||
- (op_type == H5D_IO_OP_WRITE && io_info->dset->shared->cache.contig.sieve_buf))
+ (op_type == H5D_IO_OP_READ && dataset->shared->cache.contig.sieve_dirty) ||
+ (op_type == H5D_IO_OP_WRITE && dataset->shared->cache.contig.sieve_buf))
ret_value = FALSE;
else {
hbool_t page_buf_enabled;
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 3896584..3b6b884 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -75,7 +75,7 @@ typedef struct {
/* General stuff */
static H5D_shared_t *H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type);
-static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type);
+static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, H5T_t *type);
static herr_t H5D__cache_dataspace_info(const H5D_t *dset);
static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space);
static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id);
@@ -488,7 +488,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type)
+H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, H5T_t *type)
{
htri_t relocatable; /* Flag whether the type is relocatable */
htri_t immutable; /* Flag whether the type is immutable */
@@ -544,8 +544,8 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type)
/* Use existing datatype */
dset->shared->type_id = type_id;
- dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */
- } /* end else */
+ dset->shared->type = type;
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2192,7 +2192,7 @@ H5D_oloc(H5D_t *dataset)
*-------------------------------------------------------------------------
*/
H5G_name_t *
-H5D_nameof(const H5D_t *dataset)
+H5D_nameof(H5D_t *dataset)
{
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
diff --git a/src/H5Dio.c b/src/H5Dio.c
index f8a6978..470b245 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -174,21 +174,21 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_space
*/
if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
- const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
- /* to the beginning of the projected mem space. */
+ ptrdiff_t buf_adj = 0;
/* Attempt to construct projected dataspace for memory dataspace */
if (H5S_select_construct_projection(mem_space, &projected_mem_space,
- (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf,
- type_info.dst_type_size) < 0)
+ (unsigned)H5S_GET_EXTENT_NDIMS(file_space),
+ type_info.dst_type_size, &buf_adj) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace")
HDassert(projected_mem_space);
- HDassert(adj_buf);
+
+ /* Adjust the buffer by the given amount */
+ buf = (void *)(((uint8_t *)buf) + buf_adj);
/* Switch to using projected memory dataspace & adjusted buffer */
mem_space = projected_mem_space;
- buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */
- } /* end if */
+ } /* end if */
/* Retrieve dataset properties */
/* <none needed in the general case> */
@@ -407,20 +407,20 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_spac
*/
if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
- const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
- /* to the beginning of the projected mem space. */
+ ptrdiff_t buf_adj = 0;
/* Attempt to construct projected dataspace for memory dataspace */
if (H5S_select_construct_projection(mem_space, &projected_mem_space,
- (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf,
- type_info.src_type_size) < 0)
+ (unsigned)H5S_GET_EXTENT_NDIMS(file_space),
+ type_info.src_type_size, &buf_adj) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace")
HDassert(projected_mem_space);
- HDassert(adj_buf);
+
+ /* Adjust the buffer by the given amount */
+ buf = (const void *)(((const uint8_t *)buf) + buf_adj);
/* Switch to using projected memory dataspace & adjusted buffer */
mem_space = projected_mem_space;
- buf = adj_buf;
} /* end if */
/* Retrieve dataset properties */
diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c
index cb6f5c3..0620459 100644
--- a/src/H5Dmpio.c
+++ b/src/H5Dmpio.c
@@ -302,7 +302,7 @@ static herr_t H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_ty
static herr_t H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
H5D_chunk_map_t *fm, int mpi_rank, int mpi_size);
static herr_t H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- const H5S_t *file_space, const H5S_t *mem_space);
+ H5S_t *file_space, H5S_t *mem_space);
static herr_t H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
hsize_t nelmts, MPI_Datatype mpi_file_type, MPI_Datatype mpi_buf_type);
static herr_t H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm,
@@ -2372,8 +2372,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space,
- const H5S_t *mem_space)
+H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5S_t *file_space,
+ H5S_t *mem_space)
{
int mpi_buf_count; /* # of MPI types */
hbool_t mbt_is_derived = FALSE;
@@ -3467,8 +3467,9 @@ done:
static herr_t
H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chunk_list,
size_t *num_chunks_assigned_map, hbool_t all_ranks_involved,
- const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm,
- int mpi_rank, int mpi_size)
+ const H5D_io_info_t * io_info,
+ const H5D_chunk_map_t H5_ATTR_NDEBUG_UNUSED *fm, int mpi_rank,
+ int mpi_size)
{
MPI_Datatype struct_type;
MPI_Datatype packed_type;
@@ -3797,7 +3798,8 @@ done:
static herr_t
H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk_list,
size_t *chunk_list_num_entries, H5D_io_info_t *io_info,
- const H5D_type_info_t *type_info, int mpi_rank, int mpi_size,
+ const H5D_type_info_t *type_info, int mpi_rank,
+ int H5_ATTR_NDEBUG_UNUSED mpi_size,
H5D_filtered_collective_io_info_t **chunk_hash_table,
unsigned char ***chunk_msg_bufs, int *chunk_msg_bufs_len)
{
@@ -4547,7 +4549,7 @@ H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *ch
H5D_filtered_collective_io_info_t *chunk_hash_table,
unsigned char **chunk_msg_bufs, int chunk_msg_bufs_len,
const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- int mpi_rank, int mpi_size)
+ int H5_ATTR_NDEBUG_UNUSED mpi_rank, int mpi_size)
{
H5D_fill_buf_info_t fb_info;
H5D_chunk_info_t * chunk_info = NULL;
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 0e0eb08..3df9dde 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -566,7 +566,7 @@ H5_DLL herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t *space, hsize_
unsigned *filter_mask, haddr_t *offset, hsize_t *size);
H5_DLL herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *coord, unsigned *filter_mask,
haddr_t *addr, hsize_t *size);
-H5_DLL herr_t H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data);
+H5_DLL herr_t H5D__chunk_iter(H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data);
H5_DLL haddr_t H5D__get_offset(const H5D_t *dset);
H5_DLL herr_t H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size);
H5_DLL herr_t H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id,
@@ -594,8 +594,8 @@ H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_inf
hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space);
/* Functions that perform direct copying between memory buffers */
-H5_DLL herr_t H5D_select_io_mem(void *dst_buf, const H5S_t *dst_space, const void *src_buf,
- const H5S_t *src_space, size_t elmt_size, size_t nelmts);
+H5_DLL herr_t H5D_select_io_mem(void *dst_buf, H5S_t *dst_space, const void *src_buf, H5S_t *src_space,
+ size_t elmt_size, size_t nelmts);
/* Functions that perform scatter-gather serial I/O operations */
H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf);
@@ -641,8 +641,8 @@ H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_ov
const hsize_t old_dim[]);
H5_DLL herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk,
H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled);
-H5_DLL void * H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline);
-H5_DLL void H5D__chunk_mem_free(void *chk, const void *_pline);
+H5_DLL void * H5D__chunk_mem_alloc(size_t size, void *pline);
+H5_DLL void H5D__chunk_mem_free(void *chk, void *pline);
H5_DLL void * H5D__chunk_mem_xfree(void *chk, const void *pline);
H5_DLL void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline);
H5_DLL herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]);
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index ad9794d..515c739 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -164,7 +164,7 @@ H5_DLL herr_t H5D_close(H5D_t *dataset);
H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id);
H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset);
H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset);
-H5_DLL H5G_name_t *H5D_nameof(const H5D_t *dataset);
+H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset);
H5_DLL herr_t H5D_flush_all(H5F_t *f);
H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset);
H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset);
diff --git a/src/H5Dselect.c b/src/H5Dselect.c
index 1a6292c..ef33ea7 100644
--- a/src/H5Dselect.c
+++ b/src/H5Dselect.c
@@ -274,8 +274,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_select_io_mem(void *dst_buf, const H5S_t *dst_space, const void *src_buf, const H5S_t *src_space,
- size_t elmt_size, size_t nelmts)
+H5D_select_io_mem(void *dst_buf, H5S_t *dst_space, const void *src_buf, H5S_t *src_space, size_t elmt_size,
+ size_t nelmts)
{
H5S_sel_iter_t *dst_sel_iter = NULL; /* Destination dataspace iteration info */
H5S_sel_iter_t *src_sel_iter = NULL; /* Source dataspace iteration info */
diff --git a/src/H5FD.c b/src/H5FD.c
index 3597050..6584843 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -2193,7 +2193,7 @@ H5FD_ctl(H5FD_t *file, uint64_t op_code, uint64_t flags, const void *input, void
else if (flags & H5FD_CTL__FAIL_IF_UNKNOWN_FLAG) {
HGOTO_ERROR(H5E_VFL, H5E_FCNTL, FAIL,
- "VFD ctl request failed (no ctl and fail if unknown flag is set)")
+ "VFD ctl request failed (no ctl callback and fail if unknown flag is set)")
}
done:
@@ -2261,8 +2261,10 @@ H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle /*out*/)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver")
done:
- if (FAIL == ret_value)
- *file_handle = NULL;
+ if (FAIL == ret_value) {
+ if (file_handle)
+ *file_handle = NULL;
+ }
FUNC_LEAVE_API(ret_value)
} /* end H5FDget_vfd_handle() */
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index fe9a3c2..1be4779 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -1914,7 +1914,7 @@ H5FD__mpio_vector_build_types(uint32_t count, H5FD_mem_t types[], haddr_t addrs[
if (!sub_types) {
HDassert(!sub_types_created);
- if (NULL == (sub_types = (int *)HDmalloc((size_t)count * sizeof(MPI_Datatype))))
+ if (NULL == (sub_types = HDmalloc((size_t)count * sizeof(MPI_Datatype))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't alloc sub types array")
if (NULL == (sub_types_created = (uint8_t *)HDcalloc((size_t)count, 1))) {
H5MM_free(sub_types);
diff --git a/src/H5Gent.c b/src/H5Gent.c
index 2f1a2b4..2e06092 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -300,7 +300,7 @@ done:
*-------------------------------------------------------------------------
*/
void
-H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth)
+H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth)
{
FUNC_ENTER_PACKAGE_NOERR
@@ -318,8 +318,7 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth)
;
}
else if (depth == H5_COPY_SHALLOW) {
- /* Discarding 'const' qualifier OK - QAK */
- H5G__ent_reset((H5G_entry_t *)src);
+ H5G__ent_reset(src);
} /* end if */
FUNC_LEAVE_NOAPI_VOID
diff --git a/src/H5Gint.c b/src/H5Gint.c
index 0c4bee2..34711dd 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -689,7 +689,7 @@ H5G_oloc(H5G_t *grp)
*-------------------------------------------------------------------------
*/
H5G_name_t *
-H5G_nameof(const H5G_t *grp)
+H5G_nameof(H5G_t *grp)
{
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index 346ecdc..fb94685 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -559,8 +559,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type,
- const void *crt_info)
+H5G__loc_insert(H5G_loc_t *grp_loc, char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info)
{
H5O_link_t lnk; /* Link for object to insert */
herr_t ret_value = SUCCEED; /* Return value */
@@ -577,9 +576,8 @@ H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_ty
lnk.cset = H5F_DEFAULT_CSET;
lnk.corder = 0; /* Will be reset if the group is tracking creation order */
lnk.corder_valid = FALSE; /* Indicate that the creation order isn't valid (yet) */
- /* Casting away const OK -QAK */
- lnk.name = (char *)name;
- lnk.u.hard.addr = obj_loc->oloc->addr;
+ lnk.name = name;
+ lnk.u.hard.addr = obj_loc->oloc->addr;
/* Insert new group into current group's symbol table */
if (H5G_obj_insert(grp_loc->oloc, name, &lnk, TRUE, obj_type, crt_info) < 0)
@@ -904,10 +902,10 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_
const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/,
H5G_own_loc_t *own_loc /*out*/)
{
- H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */
- H5O_name_t comment; /* Object header "comment" message */
- htri_t exists; /* Whether a "comment" message already exists */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */
+ H5O_name_t comment = {0}; /* Object header "comment" message */
+ htri_t exists; /* Whether a "comment" message already exists */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -927,13 +925,15 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_
/* Add the new message */
if (udata->comment && *udata->comment) {
- /* Casting away const OK -QAK */
- comment.s = (char *)udata->comment;
+ if (NULL == (comment.s = HDstrdup(udata->comment)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't copy group comment")
if (H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message")
} /* end if */
done:
+ HDfree(comment.s);
+
/* Indicate that this callback didn't take ownership of the group *
* location for the object */
*own_loc = H5G_OWN_NONE;
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index d108b03..6939d2f 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -373,7 +373,7 @@ H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab);
/*
* Functions that understand symbol table entries.
*/
-H5_DLL void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth);
+H5_DLL void H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth);
H5_DLL void H5G__ent_reset(H5G_entry_t *ent);
H5_DLL herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5G_entry_t *ent,
unsigned n);
@@ -465,7 +465,7 @@ H5_DLL herr_t H5G__name_init(H5G_name_t *name, const char *path);
/*
* These functions operate on group "locations"
*/
-H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type,
+H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type,
const void *crt_info);
H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/);
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index d1725f6..d8cd6e8 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -191,7 +191,7 @@ typedef struct H5G_entry_t H5G_entry_t;
*/
H5_DLL herr_t H5G_init(void);
H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp);
-H5_DLL H5G_name_t *H5G_nameof(const H5G_t *grp);
+H5_DLL H5G_name_t *H5G_nameof(H5G_t *grp);
H5_DLL H5F_t *H5G_fileof(H5G_t *grp);
H5_DLL H5G_t * H5G_open(const H5G_loc_t *loc);
H5_DLL herr_t H5G_close(H5G_t *grp);
diff --git a/src/H5Idbg.c b/src/H5Idbg.c
index 37232c5..6b4a979 100644
--- a/src/H5Idbg.c
+++ b/src/H5Idbg.c
@@ -78,7 +78,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID node */
H5I_type_t type = *(H5I_type_t *)_udata; /* User data */
const H5G_name_t *path = NULL; /* Path to file object */
- const void * object = NULL; /* Pointer to VOL connector object */
+ void * object = NULL; /* Pointer to VOL connector object */
FUNC_ENTER_PACKAGE_NOERR
@@ -94,7 +94,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
object = H5VL_object_data(vol_obj);
if (H5_VOL_NATIVE == vol_obj->connector->cls->value)
- path = H5G_nameof((const H5G_t *)object);
+ path = H5G_nameof(object);
break;
}
@@ -103,7 +103,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
object = H5VL_object_data(vol_obj);
if (H5_VOL_NATIVE == vol_obj->connector->cls->value)
- path = H5D_nameof((const H5D_t *)object);
+ path = H5D_nameof(object);
break;
}
@@ -114,7 +114,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
object = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */
H5_GCC_CLANG_DIAG_ON("cast-qual")
- path = H5T_nameof((const H5T_t *)object);
+ path = H5T_nameof(object);
break;
}
diff --git a/src/H5Oflush.c b/src/H5Oflush.c
index 5d5c5da..116a04b 100644
--- a/src/H5Oflush.c
+++ b/src/H5Oflush.c
@@ -37,7 +37,6 @@
#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Errors */
-#include "H5ESprivate.h" /* Event Sets */
#include "H5Fprivate.h" /* Files */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
@@ -195,8 +194,9 @@ done:
herr_t
H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid)
{
- H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */
- hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */
+ H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */
+ hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */
+ H5F_t * file = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -209,6 +209,11 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid)
H5O_shared_t cached_H5O_shared;
H5VL_t * connector = NULL;
+ /* Hold a copy of the object's file pointer, since closing the object will
+ * invalidate the file pointer in the oloc.
+ */
+ file = oloc->file;
+
/* Create empty object location */
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
@@ -257,8 +262,8 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid)
} /* end if */
done:
- if (objs_incr)
- H5F_decr_nopen_objs(oloc->file);
+ if (objs_incr && file)
+ H5F_decr_nopen_objs(file);
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5O_refresh_metadata() */
diff --git a/src/H5Oint.c b/src/H5Oint.c
index 93501a2..70661ad 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -3014,7 +3014,7 @@ H5O_get_proxy(const H5O_t *oh)
*-------------------------------------------------------------------------
*/
herr_t
-H5O__free(H5O_t *oh, hbool_t force)
+H5O__free(H5O_t *oh, hbool_t H5_ATTR_NDEBUG_UNUSED force)
{
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index a3ce2f7..d8221a3 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -1636,7 +1636,7 @@ H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size)
size_t config_str_len = HDstrlen(config_str);
if (config_buf) {
- HDstrncpy(config_buf, config_str, MIN(config_str_len + 1, buf_size));
+ HDstrncpy(config_buf, config_str, buf_size);
if (config_str_len >= buf_size)
config_buf[buf_size - 1] = '\0';
}
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 7b87d7b..86aaef2 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -160,7 +160,7 @@ static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t max
static herr_t H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem,
size_t *nseq, size_t *nelem, hsize_t *off, size_t *len);
static herr_t H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata);
-static herr_t H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info,
+static herr_t H5S__hyper_proj_int_iterate(H5S_hyper_span_info_t * ss_span_info,
const H5S_hyper_span_info_t *sis_span_info, hsize_t count,
unsigned depth, H5S_hyper_project_intersect_ud_t *udata);
static void H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, hsize_t *block,
@@ -11332,9 +11332,8 @@ sis_span_info unsigned depth; IN: Depth of iteration (in terms of rank)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info,
- const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth,
- H5S_hyper_project_intersect_ud_t *udata)
+H5S__hyper_proj_int_iterate(H5S_hyper_span_info_t *ss_span_info, const H5S_hyper_span_info_t *sis_span_info,
+ hsize_t count, unsigned depth, H5S_hyper_project_intersect_ud_t *udata)
{
const H5S_hyper_span_t *ss_span; /* Current span in source space */
const H5S_hyper_span_t *sis_span; /* Current span in source intersect space */
@@ -11597,7 +11596,7 @@ H5S__hyper_project_intersection(H5S_t *src_space, H5S_t *dst_space, H5S_t *src_i
H5S_t *proj_space, hbool_t share_selection)
{
H5S_hyper_project_intersect_ud_t udata; /* User data for subroutines */
- const H5S_hyper_span_info_t * ss_span_info;
+ H5S_hyper_span_info_t * ss_span_info;
const H5S_hyper_span_info_t * ds_span_info;
H5S_hyper_span_info_t * ss_span_info_buf = NULL;
H5S_hyper_span_info_t * ds_span_info_buf = NULL;
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index 0c14129..a9108a5 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -73,10 +73,10 @@ static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_poin
static herr_t H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count,
hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map,
hbool_t *is_permuted);
-static herr_t H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute_map,
+static herr_t H5S__mpio_permute_type(H5S_t *space, size_t elmt_size, hsize_t **permute_map,
MPI_Datatype *new_type, int *count, hbool_t *is_derived_type);
-static herr_t H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,
- int *count, hbool_t *is_derived_type);
+static herr_t H5S__mpio_reg_hyper_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count,
+ hbool_t *is_derived_type);
static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type,
int *count, hbool_t *is_derived_type);
static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list);
@@ -95,6 +95,9 @@ static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *
/* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */
H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t);
+/* Declare a free list to manage dataspace selection iterators */
+H5FL_EXTERN(H5S_sel_iter_t);
+
/*-------------------------------------------------------------------------
* Function: H5S__mpio_all_type
*
@@ -501,17 +504,19 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, MPI_Datatype *new_type,
- int *count, hbool_t *is_derived_type)
+H5S__mpio_permute_type(H5S_t *space, size_t elmt_size, hsize_t **permute, MPI_Datatype *new_type, int *count,
+ hbool_t *is_derived_type)
{
- MPI_Aint * disp = NULL; /* Datatype displacement for each point*/
- H5S_sel_iter_t sel_iter; /* Selection iteration info */
- hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */
- hssize_t snum_points; /* Signed number of elements in selection */
- hsize_t num_points; /* Number of points in the selection */
- size_t max_elem; /* Maximum number of elements allowed in sequences */
- hsize_t u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ MPI_Aint * disp = NULL; /* Datatype displacement for each point*/
+ H5S_sel_iter_t *sel_iter = NULL; /* Selection iteration info */
+ hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */
+ hssize_t snum_points; /* Signed number of elements in selection */
+ hsize_t num_points; /* Number of points in the selection */
+ hsize_t * off = NULL;
+ size_t * len = NULL;
+ size_t max_elem; /* Maximum number of elements allowed in sequences */
+ hsize_t u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -527,8 +532,18 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
if (NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements")
+ /* Allocate arrays to hold sequence offsets and lengths */
+ if (NULL == (off = H5MM_malloc(H5D_IO_VECTOR_SIZE * sizeof(*off))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate sequence offsets array")
+ if (NULL == (len = H5MM_malloc(H5D_IO_VECTOR_SIZE * sizeof(*len))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate sequence lengths array")
+
+ /* Allocate a selection iterator for iterating over the dataspace */
+ if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "couldn't allocate dataspace selection iterator")
+
/* Initialize selection iterator */
- if (H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
+ if (H5S_select_iter_init(sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sel_iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -538,14 +553,12 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
/* Loop, while elements left in selection */
u = 0;
while (max_elem > 0) {
- hsize_t off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
- size_t len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
- size_t nelem; /* Number of elements used in sequences */
- size_t nseq; /* Number of sequences generated */
- size_t curr_seq; /* Current sequence being worked on */
+ size_t nelem; /* Number of elements used in sequences */
+ size_t nseq; /* Number of sequences generated */
+ size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */
- if (H5S_SELECT_ITER_GET_SEQ_LIST(&sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off,
+ if (H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off,
len) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
@@ -602,9 +615,14 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
done:
/* Release selection iterator */
- if (sel_iter_init)
- if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0)
+ if (sel_iter) {
+ if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter);
+ }
+
+ H5MM_free(len);
+ H5MM_free(off);
/* Free memory */
if (disp)
@@ -634,11 +652,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count,
+H5S__mpio_reg_hyper_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count,
hbool_t *is_derived_type)
{
- H5S_sel_iter_t sel_iter; /* Selection iteration info */
- hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */
+ H5S_sel_iter_t *sel_iter = NULL; /* Selection iteration info */
+ hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */
struct dim { /* less hassle than malloc/free & ilk */
hssize_t start;
@@ -668,32 +686,37 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new
HDassert(sizeof(MPI_Aint) >= sizeof(elmt_size));
bigio_count = H5_mpi_get_bigio_count();
+
+ /* Allocate a selection iterator for iterating over the dataspace */
+ if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "couldn't allocate dataspace selection iterator")
+
/* Initialize selection iterator */
- if (H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
+ if (H5S_select_iter_init(sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sel_iter_init = TRUE; /* Selection iteration info has been initialized */
/* Abbreviate args */
- diminfo = sel_iter.u.hyp.diminfo;
+ diminfo = sel_iter->u.hyp.diminfo;
HDassert(diminfo);
/* Make a local copy of the dimension info so we can operate with them */
/* Check if this is a "flattened" regular hyperslab selection */
- if (sel_iter.u.hyp.iter_rank != 0 && sel_iter.u.hyp.iter_rank < space->extent.rank) {
+ if (sel_iter->u.hyp.iter_rank != 0 && sel_iter->u.hyp.iter_rank < space->extent.rank) {
/* Flattened selection */
- rank = sel_iter.u.hyp.iter_rank;
+ rank = sel_iter->u.hyp.iter_rank;
#ifdef H5S_DEBUG
if (H5DEBUG(S))
HDfprintf(H5DEBUG(S), "%s: Flattened selection\n", __func__);
#endif
for (u = 0; u < rank; ++u) {
H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t)
- d[u].start = (hssize_t)diminfo[u].start + sel_iter.u.hyp.sel_off[u];
+ d[u].start = (hssize_t)diminfo[u].start + sel_iter->u.hyp.sel_off[u];
d[u].strid = diminfo[u].stride;
d[u].block = diminfo[u].block;
d[u].count = diminfo[u].count;
- d[u].xtent = sel_iter.u.hyp.size[u];
+ d[u].xtent = sel_iter->u.hyp.size[u];
#ifdef H5S_DEBUG
if (H5DEBUG(S)) {
@@ -951,9 +974,11 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new
done:
/* Release selection iterator */
- if (sel_iter_init)
- if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0)
+ if (sel_iter) {
+ if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter);
+ }
#ifdef H5S_DEBUG
if (H5DEBUG(S))
@@ -1364,7 +1389,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count,
+H5S_mpio_space_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count,
hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted)
{
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 8a14563..2c31ba9 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -246,8 +246,8 @@ H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_sele
H5_DLL htri_t H5S_select_shape_same(H5S_t *space1, H5S_t *space2);
H5_DLL htri_t H5S_select_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end);
H5_DLL herr_t H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr,
- unsigned new_space_rank, const void *buf,
- void const **adj_buf_ptr, hsize_t element_size);
+ unsigned new_space_rank, hsize_t element_size,
+ ptrdiff_t *buf_adj);
H5_DLL herr_t H5S_select_release(H5S_t *ds);
H5_DLL hssize_t H5S_select_serial_size(H5S_t *space);
H5_DLL herr_t H5S_select_serialize(H5S_t *space, uint8_t **p);
@@ -299,7 +299,7 @@ H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter);
H5_DLL herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter);
#ifdef H5_HAVE_PARALLEL
-H5_DLL herr_t H5S_mpio_space_type(const H5S_t *space, size_t elmt_size,
+H5_DLL herr_t H5S_mpio_space_type(H5S_t *space, size_t elmt_size,
/* out: */ MPI_Datatype *new_type, int *count, hbool_t *is_derived_type,
hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted);
#endif /* H5_HAVE_PARALLEL */
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index c931304..87ac308 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -2170,27 +2170,24 @@ done:
Note that if m > n, it is possible that the starting point in the
buffer associated with the memory dataspace will have to be
- adjusted to match the projected dataspace. If the buf parameter
- is not NULL, the function must return an adjusted buffer base
- address in *adj_buf_ptr.
+ adjusted to match the projected dataspace. In this case, the amount
+ of adjustment to be applied to the buffer will be returned via the
+ buf_adj parameter, if supplied.
USAGE
htri_t H5S_select_construct_projection(base_space,
new_space_ptr,
new_space_rank,
- buf,
- adj_buf_ptr)
+ element_size,
+ buf_adj)
const H5S_t *base_space; IN: Ptr to Dataspace to project
H5S_t ** new_space_ptr; OUT: Ptr to location in which to return
the address of the projected space
int new_space_rank; IN: Rank of the projected space.
- const void * buf; IN: Base address of the buffer
- associated with the base space.
- May be NULL.
- void ** adj_buf_ptr; OUT: If buf != NULL, store the base
- address of the section of buf
- that is described by *new_space_ptr
- in *adj_buf_ptr.
+ hsize_t element_size; IN: size of each element in the selection
+ ptrdiff_t buf_adj; OUT: amount of adjustment to be applied
+ to buffer associated with memory
+ dataspace
RETURNS
Non-negative on success/Negative on failure.
@@ -2200,9 +2197,6 @@ done:
projection of the supplied dataspace and associated selection into
the specified rank. Return it in *new_space_ptr.
- If buf is supplied, computes the base address of the projected
- selection in buf, and stores the base address in *adj_buf_ptr.
-
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
The selection in the supplied base_space has thickness 1 in all
@@ -2214,7 +2208,7 @@ done:
--------------------------------------------------------------------------*/
herr_t
H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank,
- const void *buf, void const **adj_buf_ptr, hsize_t element_size)
+ hsize_t element_size, ptrdiff_t *buf_adj)
{
H5S_t * new_space = NULL; /* New dataspace constructed */
hsize_t base_space_dims[H5S_MAX_RANK]; /* Current dimensions of base dataspace */
@@ -2233,7 +2227,6 @@ H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsign
HDassert(new_space_ptr != NULL);
HDassert((new_space_rank != 0) || (H5S_GET_SELECT_NPOINTS(base_space) <= 1));
HDassert(new_space_rank <= H5S_MAX_RANK);
- HDassert((buf == NULL) || (adj_buf_ptr != NULL));
HDassert(element_size > 0);
/* Get the extent info for the base dataspace */
@@ -2396,26 +2389,15 @@ H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsign
/* load the address of the new space into *new_space_ptr */
*new_space_ptr = new_space;
- /* now adjust the buffer if required */
- if (buf != NULL) {
+ /* return the buffer adjustment amount if required */
+ if (buf_adj != NULL) {
if (new_space_rank < base_space_rank) {
- /* a bit of pointer magic here:
- *
- * Since we can't do pointer arithmetic on void pointers, we first
- * cast buf to a pointer to byte -- i.e. uint8_t.
- *
- * We then multiply the projected space element offset we
- * calculated earlier by the supplied element size, add this
- * value to the type cast buf pointer, cast the result back
- * to a pointer to void, and assign the result to *adj_buf_ptr.
- */
- *adj_buf_ptr = (const void *)(((const uint8_t *)buf) +
- ((size_t)(projected_space_element_offset * element_size)));
- } /* end if */
+ *buf_adj = (ptrdiff_t)(projected_space_element_offset * element_size);
+ }
else
/* No adjustment necessary */
- *adj_buf_ptr = buf;
- } /* end if */
+ *buf_adj = 0;
+ }
done:
/* Cleanup on error */
diff --git a/src/H5T.c b/src/H5T.c
index 27de0e4..e0dc993 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -473,35 +473,21 @@ hid_t H5T_NATIVE_INT_FAST64_g = FAIL;
hid_t H5T_NATIVE_UINT_FAST64_g = FAIL;
/*
- * Alignment constraints for native types. These are initialized at run time
- * in H5Tinit.c. These alignments are mainly for offsets in HDF5 compound
- * datatype or C structures, which are different from the alignments for memory
- * address below this group of variables.
+ * Alignment constraints for HDF5 types. Accessing objects of these
+ * types with improper alignment invokes C undefined behavior, so the
+ * library lays out objects with correct alignment, always.
+ *
+ * A value of N indicates that the data must be aligned on an address
+ * ADDR such that 0 == ADDR mod N. When N=1 no alignment is required;
+ * N=0 implies that alignment constraints were not calculated. These
+ * values are used for structure alignment.
*/
-size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0;
-size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g = 0;
-
-size_t H5T_POINTER_COMP_ALIGN_g = 0;
-size_t H5T_HVL_COMP_ALIGN_g = 0;
-size_t H5T_HOBJREF_COMP_ALIGN_g = 0;
-size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0;
-size_t H5T_REF_COMP_ALIGN_g = 0;
+size_t H5T_POINTER_ALIGN_g = 0;
+size_t H5T_HVL_ALIGN_g = 0;
+size_t H5T_HOBJREF_ALIGN_g = 0;
+size_t H5T_HDSETREGREF_ALIGN_g = 0;
+size_t H5T_REF_ALIGN_g = 0;
-/*
- * Alignment constraints for native types. These are initialized at run time
- * in H5Tinit.c
- */
size_t H5T_NATIVE_SCHAR_ALIGN_g = 0;
size_t H5T_NATIVE_UCHAR_ALIGN_g = 0;
size_t H5T_NATIVE_SHORT_ALIGN_g = 0;
@@ -777,6 +763,9 @@ H5T_init(void)
if (H5T__init_native() < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface")
+ if (H5T__init_native_internal() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize integers")
+
/* Get the atomic datatype structures needed by the initialization code below */
if (NULL == (native_schar = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object")
@@ -5533,7 +5522,7 @@ done:
*-------------------------------------------------------------------------
*/
H5G_name_t *
-H5T_nameof(const H5T_t *dt)
+H5T_nameof(H5T_t *dt)
{
H5G_name_t *ret_value = NULL;
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 26ecff5..de836dc 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -3266,9 +3266,10 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
/* If we're down to the last few elements, just wrap up */
/* with a "real" reverse copy */
if (safe < 2) {
- s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
- d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
- b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
+ s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
+ d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
+ if (bkg)
+ b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s_stride = -s_stride;
d_stride = -d_stride;
b_stride = -b_stride;
@@ -3278,7 +3279,8 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
else {
s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride;
- b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
+ if (bkg)
+ b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
} /* end else */
} /* end if */
else {
@@ -3406,8 +3408,8 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
/* For nested VL case, free leftover heap objects from the deeper level if the
* length of new data elements is shorter than the old data elements.*/
if (nested && seq_len < bg_seq_len) {
- const uint8_t *tmp;
- size_t u;
+ uint8_t *tmp;
+ size_t u;
/* Sanity check */
HDassert(write_to_file);
@@ -3426,7 +3428,9 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si
/* Advance pointers */
s += s_stride;
d += d_stride;
- b += b_stride;
+
+ if (b)
+ b += b_stride;
} /* end for */
/* Decrement number of elements left to convert */
@@ -3716,9 +3720,10 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
/* If we're down to the last few elements, just wrap up */
/* with a "real" reverse copy */
if (safe < 2) {
- s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
- d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
- b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
+ s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
+ d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
+ if (bkg)
+ b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s_stride = -s_stride;
d_stride = -d_stride;
b_stride = -b_stride;
@@ -3728,7 +3733,8 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
else {
s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride;
- b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
+ if (bkg)
+ b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
} /* end else */
} /* end if */
else {
@@ -3796,7 +3802,9 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
/* Advance pointers */
s += s_stride;
d += d_stride;
- b += b_stride;
+
+ if (b)
+ b += b_stride;
} /* end for */
/* Decrement number of elements left to convert */
diff --git a/src/H5Tnative.c b/src/H5Tnative.c
index e75d1df..114e0a3 100644
--- a/src/H5Tnative.c
+++ b/src/H5Tnative.c
@@ -177,13 +177,13 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
if (H5T_IS_VL_STRING(dtype->shared)) {
/* Update size, offset and compound alignment for parent. */
- if (H5T__cmp_offset(comp_size, offset, sizeof(char *), (size_t)1, H5T_POINTER_COMP_ALIGN_g,
+ if (H5T__cmp_offset(comp_size, offset, sizeof(char *), (size_t)1, H5T_POINTER_ALIGN_g,
struct_align) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
} /* end if */
else {
/* Update size, offset and compound alignment for parent. */
- if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g,
+ if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_ALIGN_g,
struct_align) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
} /* end else */
@@ -208,7 +208,7 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type")
/* Update size, offset and compound alignment for parent. */
- if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g,
+ if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_ALIGN_g,
struct_align) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
break;
@@ -227,7 +227,7 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
/* Update size, offset and compound alignment for parent. */
if (0 == H5T_cmp(ret_value, dt, FALSE)) {
- align = H5T_HOBJREF_COMP_ALIGN_g;
+ align = H5T_HOBJREF_ALIGN_g;
ref_size = sizeof(hobj_ref_t);
} /* end if */
else {
@@ -236,12 +236,12 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
if (0 == H5T_cmp(ret_value, dt, FALSE)) {
- align = H5T_HDSETREGREF_COMP_ALIGN_g;
+ align = H5T_HDSETREGREF_ALIGN_g;
ref_size = sizeof(hdset_reg_ref_t);
} /* end if */
else {
/* Only pointers to underlying opaque reference types */
- align = H5T_REF_COMP_ALIGN_g;
+ align = H5T_REF_ALIGN_g;
ref_size = sizeof(H5R_ref_t);
} /* end else */
} /* end else */
@@ -479,7 +479,7 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
/* Update size, offset and compound alignment for parent compound type directly. */
- vl_align = H5T_HVL_COMP_ALIGN_g;
+ vl_align = H5T_HVL_ALIGN_g;
vl_size = sizeof(hvl_t);
if (H5T__cmp_offset(comp_size, offset, vl_size, (size_t)1, vl_align, struct_align) < 0)
@@ -625,7 +625,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
else
tid = H5T_NATIVE_UCHAR;
- align = H5T_NATIVE_SCHAR_COMP_ALIGN_g;
+ align = H5T_NATIVE_SCHAR_ALIGN_g;
break;
case H5T_NATIVE_INT_MATCH_SHORT:
@@ -633,7 +633,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
tid = H5T_NATIVE_SHORT;
else
tid = H5T_NATIVE_USHORT;
- align = H5T_NATIVE_SHORT_COMP_ALIGN_g;
+ align = H5T_NATIVE_SHORT_ALIGN_g;
break;
case H5T_NATIVE_INT_MATCH_INT:
@@ -642,7 +642,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
else
tid = H5T_NATIVE_UINT;
- align = H5T_NATIVE_INT_COMP_ALIGN_g;
+ align = H5T_NATIVE_INT_ALIGN_g;
break;
case H5T_NATIVE_INT_MATCH_LONG:
@@ -651,7 +651,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
else
tid = H5T_NATIVE_ULONG;
- align = H5T_NATIVE_LONG_COMP_ALIGN_g;
+ align = H5T_NATIVE_LONG_ALIGN_g;
break;
case H5T_NATIVE_INT_MATCH_LLONG:
@@ -660,7 +660,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
else
tid = H5T_NATIVE_ULLONG;
- align = H5T_NATIVE_LLONG_COMP_ALIGN_g;
+ align = H5T_NATIVE_LLONG_ALIGN_g;
break;
case H5T_NATIVE_INT_MATCH_UNKNOWN:
@@ -764,17 +764,17 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali
switch (match) {
case H5T_NATIVE_FLOAT_MATCH_FLOAT:
tid = H5T_NATIVE_FLOAT;
- align = H5T_NATIVE_FLOAT_COMP_ALIGN_g;
+ align = H5T_NATIVE_FLOAT_ALIGN_g;
break;
case H5T_NATIVE_FLOAT_MATCH_DOUBLE:
tid = H5T_NATIVE_DOUBLE;
- align = H5T_NATIVE_DOUBLE_COMP_ALIGN_g;
+ align = H5T_NATIVE_DOUBLE_ALIGN_g;
break;
case H5T_NATIVE_FLOAT_MATCH_LDOUBLE:
tid = H5T_NATIVE_LDOUBLE;
- align = H5T_NATIVE_LDOUBLE_COMP_ALIGN_g;
+ align = H5T_NATIVE_LDOUBLE_ALIGN_g;
break;
case H5T_NATIVE_FLOAT_MATCH_UNKNOWN:
@@ -940,3 +940,324 @@ H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nele
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5T__cmp_offset() */
+
+#define TAG_ALIGNMENT(tag) (offsetof(alignments_t, tag.x) - offsetof(alignments_t, tag))
+
+/* clang-format off */
+#define NATIVE_ENTRY_INITIALIZER(tag, type, precision, has_sign) { \
+ .alignmentp = &H5T_NATIVE_##tag##_ALIGN_g \
+, .alignment = TAG_ALIGNMENT(tag) \
+, .hidp = &H5T_NATIVE_##tag##_g \
+, .size = sizeof(type) \
+, .atomic = { \
+ .offset = 0 \
+ , .prec = (precision != 0) ? precision : (sizeof(type) * 8) \
+ , .lsb_pad = H5T_PAD_ZERO \
+ , .msb_pad = H5T_PAD_ZERO \
+ , .u.i.sign = has_sign ? H5T_SGN_2 : H5T_SGN_NONE \
+ } \
+}
+/* clang-format on */
+
+static H5T_order_t
+get_host_byte_order(void)
+{
+ static const union {
+ uint64_t u64;
+ char byte[8];
+ } endian_exemplar = {.byte = {1}};
+
+ return (endian_exemplar.u64 == 1) ? H5T_ORDER_LE : H5T_ORDER_BE;
+}
+
+/* Establish `H5T_t`s for C99 integer types including fixed- and
+ * minimum-width types (uint16_t, uint_least16_t, uint_fast16_t, ...).
+ *
+ * Also establish alignment for some miscellaneous types: pointers,
+ * HDF5 references, and so on.
+ */
+herr_t
+H5T__init_native_internal(void)
+{
+ /* Here we construct a type that lets us find alignment constraints
+ * without using the alignof operator, which is not available in C99.
+ *
+ * Between each sub-struct's `char` member `c` and member `x`, the
+ * compiler must insert padding to ensure proper alignment of `x`.
+ * We can find the alignment constraint of each `x` by looking at
+ * its offset from the beginning of its sub-struct.
+ */
+ typedef struct {
+ struct {
+ char c;
+ signed char x;
+ } SCHAR;
+ struct {
+ char c;
+ unsigned char x;
+ } UCHAR;
+ struct {
+ char c;
+ short x;
+ } SHORT;
+ struct {
+ char c;
+ unsigned short x;
+ } USHORT;
+ struct {
+ char c;
+ int x;
+ } INT;
+ struct {
+ char c;
+ unsigned int x;
+ } UINT;
+ struct {
+ char c;
+ long x;
+ } LONG;
+ struct {
+ char c;
+ unsigned long x;
+ } ULONG;
+ struct {
+ char c;
+ long long x;
+ } LLONG;
+ struct {
+ char c;
+ unsigned long long x;
+ } ULLONG;
+ struct {
+ char c;
+ int8_t x;
+ } INT8;
+ struct {
+ char c;
+ uint8_t x;
+ } UINT8;
+ struct {
+ char c;
+ int_least8_t x;
+ } INT_LEAST8;
+ struct {
+ char c;
+ uint_least8_t x;
+ } UINT_LEAST8;
+ struct {
+ char c;
+ int_fast8_t x;
+ } INT_FAST8;
+ struct {
+ char c;
+ uint_fast8_t x;
+ } UINT_FAST8;
+ struct {
+ char c;
+ int16_t x;
+ } INT16;
+ struct {
+ char c;
+ uint16_t x;
+ } UINT16;
+ struct {
+ char c;
+ int_least16_t x;
+ } INT_LEAST16;
+ struct {
+ char c;
+ uint_least16_t x;
+ } UINT_LEAST16;
+ struct {
+ char c;
+ int_fast16_t x;
+ } INT_FAST16;
+ struct {
+ char c;
+ uint_fast16_t x;
+ } UINT_FAST16;
+ struct {
+ char c;
+ int32_t x;
+ } INT32;
+ struct {
+ char c;
+ uint32_t x;
+ } UINT32;
+ struct {
+ char c;
+ int_least32_t x;
+ } INT_LEAST32;
+ struct {
+ char c;
+ uint_least32_t x;
+ } UINT_LEAST32;
+ struct {
+ char c;
+ int_fast32_t x;
+ } INT_FAST32;
+ struct {
+ char c;
+ uint_fast32_t x;
+ } UINT_FAST32;
+ struct {
+ char c;
+ int64_t x;
+ } INT64;
+ struct {
+ char c;
+ uint64_t x;
+ } UINT64;
+ struct {
+ char c;
+ int_least64_t x;
+ } INT_LEAST64;
+ struct {
+ char c;
+ uint_least64_t x;
+ } UINT_LEAST64;
+ struct {
+ char c;
+ int_fast64_t x;
+ } INT_FAST64;
+ struct {
+ char c;
+ uint_fast64_t x;
+ } UINT_FAST64;
+ struct {
+ char c;
+ void *x;
+ } pointer;
+ struct {
+ char c;
+ hvl_t x;
+ } hvl;
+ struct {
+ char c;
+ hobj_ref_t x;
+ } hobjref;
+ struct {
+ char c;
+ hdset_reg_ref_t x;
+ } hdsetregref;
+ struct {
+ char c;
+ H5R_ref_t x;
+ } ref;
+ } alignments_t;
+
+ /* Describe a C99 type, `type`, and tell where to write its
+ * H5T_t identifier and alignment. Tables of these descriptions
+ * drive the initialization of `H5T_t`s.
+ */
+ typedef struct {
+ /* Pointer to the global variable that receives the
+ * alignment of `type`:
+ */
+ size_t *alignmentp;
+ size_t alignment; // natural alignment of `type`
+ /* Pointer to the global variable that receives the
+ * identifier for `type`'s H5T_t:
+ */
+ hid_t * hidp;
+ size_t size; // sizeof(`type`)
+ H5T_atomic_t atomic; // `type` facts such as signedness
+ } native_int_t;
+
+ typedef struct {
+ const native_int_t *table;
+ size_t nelmts;
+ } native_int_table_t;
+
+ /* clang-format off */
+
+ /* The library compiles with a limit on `static` object size, so
+ * I broke this table into three.
+ */
+ static const native_int_t table1[] = {
+ NATIVE_ENTRY_INITIALIZER(SCHAR, signed char, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UCHAR, unsigned char, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(SHORT, short, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(USHORT, unsigned short, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT, int, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT, unsigned int, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT, int, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT, unsigned int, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(LONG, long, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(ULONG, unsigned long, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(LLONG, long long, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(ULLONG, unsigned long long, 0, false)
+ };
+ static const native_int_t table2[] = {
+ NATIVE_ENTRY_INITIALIZER(INT8, int8_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT8, uint8_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_LEAST8, int_least8_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_LEAST8, uint_least8_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_FAST8, int_fast8_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_FAST8, uint_fast8_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT16, int16_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT16, uint16_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_LEAST16, int_least16_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_LEAST16, uint_least16_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_FAST16, int_fast16_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_FAST16, uint_fast16_t, 0, false)
+ };
+ static const native_int_t table3[] = {
+ NATIVE_ENTRY_INITIALIZER(INT32, int32_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT32, uint32_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_LEAST32, int_least32_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_LEAST32, uint_least32_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_FAST32, int_fast32_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_FAST32, uint_fast32_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT64, int64_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT64, uint64_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_LEAST64, int_least64_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_LEAST64, uint_least64_t, 0, false)
+ , NATIVE_ENTRY_INITIALIZER(INT_FAST64, int_fast64_t, 0, true)
+ , NATIVE_ENTRY_INITIALIZER(UINT_FAST64, uint_fast64_t, 0, false)
+ };
+ static const native_int_table_t table_table[] = {
+ {table1, NELMTS(table1)}
+ , {table2, NELMTS(table2)}
+ , {table3, NELMTS(table3)}
+ };
+ /* clang-format on */
+
+ size_t i, j;
+ H5T_order_t byte_order = get_host_byte_order();
+
+ for (i = 0; i < NELMTS(table_table); i++) {
+ const native_int_t *table = table_table[i].table;
+ size_t nelmts = table_table[i].nelmts;
+
+ /* For each C99 type in `table`, create its H5T_t,
+ * register a hid_t for the H5T_t, and record the type's
+ * alignment and hid_t in the variables named by the
+ * table.
+ */
+ for (j = 0; j < nelmts; j++) {
+ H5T_t *dt;
+
+ if (NULL == (dt = H5T__alloc()))
+ return FAIL;
+
+ dt->shared->state = H5T_STATE_IMMUTABLE;
+ dt->shared->type = H5T_INTEGER;
+ dt->shared->size = table[j].size;
+ dt->shared->u.atomic = table[j].atomic;
+ dt->shared->u.atomic.order = byte_order;
+ *table[j].alignmentp = table[j].alignment;
+
+ if ((*table[j].hidp = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)
+ return FAIL;
+ }
+ }
+
+ H5T_POINTER_ALIGN_g = TAG_ALIGNMENT(pointer);
+ H5T_HVL_ALIGN_g = TAG_ALIGNMENT(hvl);
+ H5T_HOBJREF_ALIGN_g = TAG_ALIGNMENT(hobjref);
+ H5T_HDSETREGREF_ALIGN_g = TAG_ALIGNMENT(hdsetregref);
+ H5T_REF_ALIGN_g = TAG_ALIGNMENT(ref);
+
+ return SUCCEED;
+}
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 4062cbe..520b44d 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -287,7 +287,7 @@ typedef herr_t (*H5T_vlen_setnull_func_t)(H5VL_object_t *file, void *_vl, void *
typedef herr_t (*H5T_vlen_read_func_t)(H5VL_object_t *file, void *_vl, void *buf, size_t len);
typedef herr_t (*H5T_vlen_write_func_t)(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info,
void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size);
-typedef herr_t (*H5T_vlen_delete_func_t)(H5VL_object_t *file, const void *_vl);
+typedef herr_t (*H5T_vlen_delete_func_t)(H5VL_object_t *file, void *_vl);
/* VL datatype callbacks */
typedef struct H5T_vlen_class_t {
@@ -388,26 +388,22 @@ typedef herr_t (*H5T_operator_t)(H5T_t *dt, void *op_data /*in,out*/);
H5_DLLVAR const unsigned H5O_dtype_ver_bounds[H5F_LIBVER_NBOUNDS];
/*
- * Alignment information for native types. A value of N indicates that the
- * data must be aligned on an address ADDR such that 0 == ADDR mod N. When
- * N=1 no alignment is required; N=0 implies that alignment constraints were
- * not calculated. These alignment info is only for H5Tget_native_type.
- * These values are used for structure alignment.
+ * Alignment constraints for HDF5 types. Accessing objects of these
+ * types with improper alignment invokes C undefined behavior, so the
+ * library lays out objects with correct alignment, always.
+ *
+ * A value of N indicates that the data must be aligned on an address
+ * ADDR such that 0 == ADDR mod N. When N=1 no alignment is required;
+ * N=0 implies that alignment constraints were not calculated. These
+ * values are used for structure alignment.
+ *
+ * This alignment info is only for H5Tget_native_type.
*/
-H5_DLLVAR size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_SHORT_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_INT_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g;
-
-H5_DLLVAR size_t H5T_POINTER_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_HVL_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_HOBJREF_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_HDSETREGREF_COMP_ALIGN_g;
-H5_DLLVAR size_t H5T_REF_COMP_ALIGN_g;
+H5_DLLVAR size_t H5T_POINTER_ALIGN_g;
+H5_DLLVAR size_t H5T_HVL_ALIGN_g;
+H5_DLLVAR size_t H5T_HOBJREF_ALIGN_g;
+H5_DLLVAR size_t H5T_HDSETREGREF_ALIGN_g;
+H5_DLLVAR size_t H5T_REF_ALIGN_g;
/*
* Alignment information for native types. A value of N indicates that the
@@ -473,6 +469,7 @@ H5FL_EXTERN(H5T_shared_t);
/* Common functions */
H5_DLL herr_t H5T__init_native(void);
+H5_DLL herr_t H5T__init_native_internal(void);
H5_DLL H5T_t *H5T__create(H5T_class_t type, size_t size);
H5_DLL H5T_t *H5T__alloc(void);
H5_DLL herr_t H5T__free(H5T_t *dt);
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 9731379..aaa7202 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -125,7 +125,7 @@ H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc);
H5_DLL H5T_t * H5T_decode(size_t buf_size, const unsigned char *buf);
H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE *stream);
H5_DLL struct H5O_loc_t * H5T_oloc(H5T_t *dt);
-H5_DLL struct H5G_name_t *H5T_nameof(const H5T_t *dt);
+H5_DLL struct H5G_name_t *H5T_nameof(H5T_t *dt);
H5_DLL htri_t H5T_is_immutable(const H5T_t *dt);
H5_DLL htri_t H5T_is_named(const H5T_t *dt);
H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f);
diff --git a/src/H5Tref.c b/src/H5Tref.c
index 967f48d..e8cab02 100644
--- a/src/H5Tref.c
+++ b/src/H5Tref.c
@@ -638,8 +638,8 @@ done:
*/
static herr_t
H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type,
- H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size,
- void H5_ATTR_UNUSED *bg_buf)
+ H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf,
+ size_t H5_ATTR_NDEBUG_UNUSED dst_size, void H5_ATTR_UNUSED *bg_buf)
{
H5F_t * src_f = NULL;
hid_t file_id = H5I_INVALID_HID;
@@ -753,6 +753,14 @@ done:
*
*-------------------------------------------------------------------------
*/
+/*
+ * It is the correct thing to do to have the reference buffer
+ * be const-qualified here, but the VOL "blob specific" routine
+ * needs a non-const pointer since an operation might modify
+ * the "blob". Disable this warning here (at least temporarily)
+ * for this reason.
+ */
+H5_GCC_CLANG_DIAG_OFF("cast-qual")
static herr_t
H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull)
{
@@ -792,6 +800,7 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_disk_isnull() */
+H5_GCC_CLANG_DIAG_ON("cast-qual")
/*-------------------------------------------------------------------------
* Function: H5T__ref_disk_setnull
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index 39d33d4..4823940 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -76,7 +76,7 @@ static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *_bg);
static herr_t H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len);
static herr_t H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl,
void *_buf, void *_bg, size_t seq_len, size_t base_size);
-static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl);
+static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, void *_vl);
/*********************/
/* Public Variables */
@@ -917,9 +917,9 @@ static herr_t
H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info,
void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size)
{
- uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */
- const uint8_t *bg = (const uint8_t *)_bg; /* Pointer to the old data hvl_t */
- herr_t ret_value = SUCCEED; /* Return value */
+ uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */
+ uint8_t *bg = (uint8_t *)_bg; /* Pointer to the old data hvl_t */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -957,10 +957,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl)
+H5T__vlen_disk_delete(H5VL_object_t *file, void *_vl)
{
- const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */
- herr_t ret_value = SUCCEED; /* Return value */
+ uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -981,7 +981,7 @@ H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl)
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_BLOB_DELETE;
- if (H5VL_blob_specific(file, (void *)vl, &vol_cb_args) < 0) /* Casting away 'const' OK -QAK */
+ if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob")
} /* end if */
} /* end if */
diff --git a/src/H5VLdyn_ops.c b/src/H5VLdyn_ops.c
index e175246..7889224 100644
--- a/src/H5VLdyn_ops.c
+++ b/src/H5VLdyn_ops.c
@@ -166,9 +166,12 @@ H5VL__term_opt_operation(void)
FUNC_ENTER_PACKAGE_NOERR
/* Iterate over the VOL subclasses */
- for (subcls = 0; subcls < NELMTS(H5VL_opt_vals_g); subcls++)
- if (H5VL_opt_ops_g[subcls])
+ for (subcls = 0; subcls < NELMTS(H5VL_opt_vals_g); subcls++) {
+ if (H5VL_opt_ops_g[subcls]) {
H5SL_destroy(H5VL_opt_ops_g[subcls], H5VL__term_opt_operation_cb, NULL);
+ H5VL_opt_ops_g[subcls] = NULL;
+ }
+ }
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5VL__term_opt_operation() */
diff --git a/src/H5detect.c b/src/H5detect.c
index e72d7a0..cf92398 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -49,11 +49,6 @@ static const char *FileHeader = "\n\
#include "H5Tpublic.h"
#include "H5Rpublic.h"
-/* Disable warning about cast increasing the alignment of the target type,
- * that's _exactly_ what this code is probing. -QAK
- */
-H5_GCC_CLANG_DIAG_OFF("cast-align")
-
#if defined(__has_attribute)
#if __has_attribute(no_sanitize_address)
#define HDF_NO_UBSAN __attribute__((no_sanitize_address))
@@ -66,30 +61,6 @@ H5_GCC_CLANG_DIAG_OFF("cast-align")
#define MAXDETECT 64
-/* The ALIGNMENT test code may generate the SIGBUS, SIGSEGV, or SIGILL signals.
- * We use setjmp/longjmp in the signal handlers for recovery. But setjmp/longjmp
- * do not necessary restore the signal blocking status while sigsetjmp/siglongjmp
- * do. If sigsetjmp/siglongjmp are not supported, need to use sigprocmask to
- * unblock the signal before doing longjmp.
- */
-/* Define H5SETJMP/H5LONGJMP depending on if sigsetjmp/siglongjmp are */
-/* supported. */
-#if defined(H5_HAVE_SIGSETJMP) && defined(H5_HAVE_SIGLONGJMP)
-/* Always save blocked signals to be restored by siglongjmp. */
-#define H5JMP_BUF sigjmp_buf
-#define H5SETJMP(buf) HDsigsetjmp(buf, 1)
-#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val)
-#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */
-#else
-#define H5JMP_BUF jmp_buf
-#define H5SETJMP(buf) HDsetjmp(buf)
-#define H5LONGJMP(buf, val) HDlongjmp(buf, val)
-#endif
-
-/* ALIGNMENT and signal-handling status codes */
-#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */
-#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */
-
/*
* This structure holds information about a type that
* was detected.
@@ -105,27 +76,18 @@ typedef struct detected_t {
unsigned int mpos, msize, imp; /* information about mantissa */
unsigned int epos, esize; /* information about exponent */
unsigned long bias; /* exponent bias for floating pt */
- unsigned int align; /* required byte alignment */
unsigned int comp_align; /* alignment for structure */
} detected_t;
-/* This structure holds structure alignment for pointers, vlen and reference
- * types. */
-typedef struct malign_t {
- const char * name;
- unsigned int comp_align; /* alignment for structure */
-} malign_t;
-
FILE *rawoutstream = NULL;
/* global variables types detection code */
H5_GCC_DIAG_OFF("larger-than=")
static detected_t d_g[MAXDETECT];
H5_GCC_DIAG_ON("larger-than=")
-static malign_t m_g[MAXDETECT];
-static volatile int nd_g = 0, na_g = 0;
+static volatile int nd_g = 0;
-static void print_results(int nd, detected_t *d, int na, malign_t *m);
+static void print_results(int nd, detected_t *d);
static void iprint(detected_t *);
static int byte_cmp(int, const void *, const void *, const unsigned char *);
static unsigned int bit_cmp(unsigned int, int *, void *, void *, const unsigned char *);
@@ -134,23 +96,8 @@ static unsigned int imp_bit(unsigned int, int *, void *, void *, const unsigned
static unsigned int find_bias(unsigned int, unsigned int, int *, void *);
static void precision(detected_t *);
static void print_header(void);
-static void detect_C89_integers(void);
static void detect_C89_floats(void);
-static void detect_C99_integers(void);
static void detect_C99_floats(void);
-static void detect_C99_integers8(void);
-static void detect_C99_integers16(void);
-static void detect_C99_integers32(void);
-static void detect_C99_integers64(void);
-static void detect_alignments(void);
-static unsigned int align_g[] = {1, 2, 4, 8, 16};
-static int align_status_g = 0; /* ALIGNMENT Signal Status */
-static int sigbus_handler_called_g = 0; /* how many times called */
-static int sigsegv_handler_called_g = 0; /* how many times called */
-static int sigill_handler_called_g = 0; /* how many times called */
-static int signal_handler_tested_g = 0; /* how many times tested */
-static int verify_signal_handlers(int signum, void (*handler)(int));
-static H5JMP_BUF jbuf_g;
/*-------------------------------------------------------------------------
* Function: precision
@@ -163,105 +110,12 @@ static H5JMP_BUF jbuf_g;
static void
precision(detected_t *d)
{
- unsigned int n;
-
- if (0 == d->msize) {
- /*
- * An integer. The permutation can have negative values at the
- * beginning or end which represent padding of bytes. We must adjust
- * the precision and offset accordingly.
- */
- if (d->perm[0] < 0) {
- /*
- * Lower addresses are padded.
- */
- for (n = 0; n < d->size && d->perm[n] < 0; n++)
- /*void*/;
- d->precision = 8 * (d->size - n);
- d->offset = 0;
- }
- else if (d->perm[d->size - 1] < 0) {
- /*
- * Higher addresses are padded.
- */
- for (n = 0; n < d->size && d->perm[d->size - (n + 1)]; n++)
- /*void*/;
- d->precision = 8 * (d->size - n);
- d->offset = 8 * n;
- }
- else {
- /*
- * No padding.
- */
- d->precision = 8 * d->size;
- d->offset = 0;
- }
- }
- else {
- /* A floating point */
- d->offset = MIN3(d->mpos, d->epos, d->sign);
- d->precision = d->msize + d->esize + 1;
- }
+ /* A floating point */
+ d->offset = MIN3(d->mpos, d->epos, d->sign);
+ d->precision = d->msize + d->esize + 1;
}
/*-------------------------------------------------------------------------
- * Function: DETECT_I/DETECT_BYTE
- *
- * Purpose: These macro takes a type like `int' and a base name like
- * `nati' and detects the byte order. The VAR is used to
- * construct the names of the C variables defined.
- *
- * DETECT_I is used for types that are larger than one byte,
- * DETECT_BYTE is used for types that are exactly one byte.
- *
- * Return: void
- *
- *-------------------------------------------------------------------------
- */
-#define DETECT_I_BYTE_CORE(TYPE, VAR, INFO, DETECT_TYPE) \
- { \
- DETECT_TYPE _v; \
- int _i, _j; \
- unsigned char *_x; \
- \
- HDmemset(&INFO, 0, sizeof(INFO)); \
- INFO.varname = #VAR; \
- INFO.size = sizeof(TYPE); \
- \
- for (_i = sizeof(DETECT_TYPE), _v = 0; _i > 0; --_i) \
- _v = (DETECT_TYPE)((DETECT_TYPE)(_v << 8) + (DETECT_TYPE)_i); \
- \
- for (_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(DETECT_TYPE); _i++) { \
- _j = (*_x++) - 1; \
- HDassert(_j < (signed)sizeof(DETECT_TYPE)); \
- INFO.perm[_i] = _j; \
- } /* end for */ \
- \
- INFO.sign = ('U' != *(#VAR)); \
- precision(&(INFO)); \
- ALIGNMENT(TYPE, INFO); \
- if (!HDstrcmp(INFO.varname, "SCHAR") || !HDstrcmp(INFO.varname, "SHORT") || \
- !HDstrcmp(INFO.varname, "INT") || !HDstrcmp(INFO.varname, "LONG") || \
- !HDstrcmp(INFO.varname, "LLONG")) { \
- COMP_ALIGNMENT(TYPE, INFO.comp_align); \
- } \
- }
-
-#define DETECT_BYTE(TYPE, VAR, INFO) \
- { \
- HDcompile_assert(sizeof(TYPE) == 1); \
- \
- DETECT_I_BYTE_CORE(TYPE, VAR, INFO, int) \
- }
-
-#define DETECT_I(TYPE, VAR, INFO) \
- { \
- HDcompile_assert(sizeof(TYPE) > 1); \
- \
- DETECT_I_BYTE_CORE(TYPE, VAR, INFO, TYPE) \
- }
-
-/*-------------------------------------------------------------------------
* Function: DETECT_F
*
* Purpose: This macro takes a floating point type like `double' and
@@ -351,28 +205,12 @@ precision(detected_t *d)
_v1 = (TYPE)1.0L; \
INFO.bias = find_bias(INFO.epos, INFO.esize, INFO.perm, &_v1); \
precision(&(INFO)); \
- ALIGNMENT(TYPE, INFO); \
if (!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \
!HDstrcmp(INFO.varname, "LDOUBLE")) { \
COMP_ALIGNMENT(TYPE, INFO.comp_align); \
} \
}
-/*-------------------------------------------------------------------------
- * Function: DETECT_M
- *
- * Purpose: This macro takes only miscellaneous structures or pointer.
- * It constructs the names and decides the alignment in structure.
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-#define DETECT_M(TYPE, VAR, INFO) \
- { \
- INFO.name = #VAR; \
- COMP_ALIGNMENT(TYPE, INFO.comp_align); \
- }
-
/* Detect alignment for C structure */
#define COMP_ALIGNMENT(TYPE, COMP_ALIGN) \
{ \
@@ -384,140 +222,6 @@ precision(detected_t *d)
COMP_ALIGN = (unsigned int)((char *)(&(s.x)) - (char *)(&s)); \
}
-#define ALIGNMENT(TYPE, INFO) \
- { \
- char *volatile _buf = NULL; \
- TYPE _val = 1, _val2; \
- volatile size_t _ano = 0; \
- void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \
- void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler); \
- void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \
- \
- _buf = (char *)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \
- if (H5SETJMP(jbuf_g)) \
- _ano++; \
- if (_ano < NELMTS(align_g)) { \
- *((TYPE *)(_buf + align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \
- _val2 = *((TYPE *)(_buf + align_g[_ano])); /*possible SIGBUS or SEGSEGV*/ \
- /* Cray Check: This section helps detect alignment on Cray's */ \
- /* vector machines (like the SV1) which mask off */ \
- /* pointer values when pointing to non-word aligned */ \
- /* locations with pointers that are supposed to be */ \
- /* word aligned. -QAK */ \
- HDmemset(_buf, 0xff, sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \
- /*How to handle VAX types?*/ \
- if (INFO.perm[0]) /* Big-Endian */ \
- HDmemcpy(_buf + align_g[_ano] + (INFO.size - ((INFO.offset + INFO.precision) / 8)), \
- ((char *)&_val) + (INFO.size - ((INFO.offset + INFO.precision) / 8)), \
- (size_t)(INFO.precision / 8)); \
- else /* Little-Endian */ \
- HDmemcpy(_buf + align_g[_ano] + (INFO.offset / 8), ((char *)&_val) + (INFO.offset / 8), \
- (size_t)(INFO.precision / 8)); \
- _val2 = *((TYPE *)(_buf + align_g[_ano])); \
- H5_GCC_CLANG_DIAG_OFF("float-equal") \
- if (_val != _val2) \
- H5LONGJMP(jbuf_g, 1); \
- H5_GCC_CLANG_DIAG_ON("float-equal") \
- /* End Cray Check */ \
- (INFO.align) = align_g[_ano]; \
- } \
- else { \
- (INFO.align) = 0; \
- fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \
- } \
- HDfree(_buf); \
- HDsignal(SIGBUS, _handler); /*restore original handler*/ \
- HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \
- HDsignal(SIGILL, _handler3); /*restore original handler*/ \
- }
-
-/*-------------------------------------------------------------------------
- * Function: sigsegv_handler
- *
- * Purpose: Handler for SIGSEGV. We use signal() instead of sigaction()
- * because it's more portable to non-Posix systems. Although
- * it's not nearly as nice to work with, it does the job for
- * this simple stuff.
- *
- * Return: Returns via H5LONGJMP to jbuf_g.
- *-------------------------------------------------------------------------
- */
-static void
-sigsegv_handler(int H5_ATTR_UNUSED signo)
-{
-#if !defined(H5HAVE_SIGJMP) && defined(H5_HAVE_SIGPROCMASK)
- /* Use sigprocmask to unblock the signal if sigsetjmp/siglongjmp are not */
- /* supported. */
- sigset_t set;
-
- HDsigemptyset(&set);
- HDsigaddset(&set, SIGSEGV);
- HDsigprocmask(SIG_UNBLOCK, &set, NULL);
-#endif
-
- sigsegv_handler_called_g++;
- HDsignal(SIGSEGV, sigsegv_handler);
- H5LONGJMP(jbuf_g, SIGSEGV);
-}
-
-/*-------------------------------------------------------------------------
- * Function: sigbus_handler
- *
- * Purpose: Handler for SIGBUS. We use signal() instead of sigaction()
- * because it's more portable to non-Posix systems. Although
- * it's not nearly as nice to work with, it does the job for
- * this simple stuff.
- *
- * Return: Returns via H5LONGJMP to jbuf_g.
- *-------------------------------------------------------------------------
- */
-static void
-sigbus_handler(int H5_ATTR_UNUSED signo)
-{
-#if !defined(H5HAVE_SIGJMP) && defined(H5_HAVE_SIGPROCMASK)
- /* Use sigprocmask to unblock the signal if sigsetjmp/siglongjmp are not */
- /* supported. */
- sigset_t set;
-
- HDsigemptyset(&set);
- HDsigaddset(&set, SIGBUS);
- HDsigprocmask(SIG_UNBLOCK, &set, NULL);
-#endif
-
- sigbus_handler_called_g++;
- HDsignal(SIGBUS, sigbus_handler);
- H5LONGJMP(jbuf_g, SIGBUS);
-}
-
-/*-------------------------------------------------------------------------
- * Function: sigill_handler
- *
- * Purpose: Handler for SIGILL. We use signal() instead of sigaction()
- * because it's more portable to non-Posix systems. Although
- * it's not nearly as nice to work with, it does the job for
- * this simple stuff.
- *
- * Return: Returns via H5LONGJMP to jbuf_g.
- *-------------------------------------------------------------------------
- */
-static void
-sigill_handler(int H5_ATTR_UNUSED signo)
-{
-#if !defined(H5HAVE_SIGJMP) && defined(H5_HAVE_SIGPROCMASK)
- /* Use sigprocmask to unblock the signal if sigsetjmp/siglongjmp are not */
- /* supported. */
- sigset_t set;
-
- HDsigemptyset(&set);
- HDsigaddset(&set, SIGILL);
- HDsigprocmask(SIG_UNBLOCK, &set, NULL);
-#endif
-
- sigill_handler_called_g++;
- HDsignal(SIGILL, sigill_handler);
- H5LONGJMP(jbuf_g, SIGILL);
-}
-
/*-------------------------------------------------------------------------
* Function: print_results
*
@@ -527,7 +231,7 @@ sigill_handler(int H5_ATTR_UNUSED signo)
*-------------------------------------------------------------------------
*/
static void
-print_results(int nd, detected_t *d, int na, malign_t *misc_align)
+print_results(int nd, detected_t *d)
{
int byte_order = 0; /*byte order of data types*/
int i, j;
@@ -645,10 +349,9 @@ H5T__init_native(void)\n\
if(NULL == (dt = H5T__alloc()))\n\
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\
dt->shared->state = H5T_STATE_IMMUTABLE;\n\
- dt->shared->type = H5T_%s;\n\
+ dt->shared->type = H5T_FLOAT;\n\
dt->shared->size = %d;\n",
- d[i].msize ? "FLOAT" : "INTEGER", /*class */
- d[i].size); /*size */
+ d[i].size); /*size */
if (byte_order == -1)
fprintf(rawoutstream, "\
@@ -669,46 +372,36 @@ H5T__init_native(void)\n\
d[i].precision); /*precision */
/*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */
- if (0 == d[i].msize) {
- /* The part unique to fixed point types */
- fprintf(rawoutstream, "\
- dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n",
- d[i].sign ? "2" : "NONE");
- }
- else {
- /* The part unique to floating point types */
- fprintf(rawoutstream, "\
- dt->shared->u.atomic.u.f.sign = %d;\n\
- dt->shared->u.atomic.u.f.epos = %d;\n\
- dt->shared->u.atomic.u.f.esize = %d;\n\
- dt->shared->u.atomic.u.f.ebias = 0x%08lx;\n\
- dt->shared->u.atomic.u.f.mpos = %d;\n\
- dt->shared->u.atomic.u.f.msize = %d;\n\
- dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\
- dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
- d[i].sign, /*sign location */
- d[i].epos, /*exponent loc */
- d[i].esize, /*exponent size */
- (unsigned long)(d[i].bias), /*exponent bias */
- d[i].mpos, /*mantissa loc */
- d[i].msize, /*mantissa size */
- d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
- }
+ /* The part unique to floating point types */
+ fprintf(rawoutstream, "\
+dt->shared->u.atomic.u.f.sign = %d;\n\
+dt->shared->u.atomic.u.f.epos = %d;\n\
+dt->shared->u.atomic.u.f.esize = %d;\n\
+dt->shared->u.atomic.u.f.ebias = 0x%08lx;\n\
+dt->shared->u.atomic.u.f.mpos = %d;\n\
+dt->shared->u.atomic.u.f.msize = %d;\n\
+dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\
+dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
+ d[i].sign, /*sign location */
+ d[i].epos, /*exponent loc */
+ d[i].esize, /*exponent size */
+ (unsigned long)(d[i].bias), /*exponent bias */
+ d[i].mpos, /*mantissa loc */
+ d[i].msize, /*mantissa size */
+ d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
/* Register the type */
fprintf(rawoutstream, "\
if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\")\n",
d[i].varname);
- fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname,
- (unsigned long)(d[i].align));
/* Variables for alignment of compound datatype */
if (!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") ||
!HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") ||
!HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") ||
!HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) {
- fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", d[i].varname,
+ fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname,
(unsigned long)(d[i].comp_align));
}
}
@@ -727,12 +420,6 @@ H5T__init_native(void)\n\
"BE");
}
- /* Structure alignment for pointers, vlen and reference types */
- fprintf(rawoutstream, "\n /* Structure alignment for pointers, vlen and reference types */\n");
- for (j = 0; j < na; j++)
- fprintf(rawoutstream, " H5T_%s_COMP_ALIGN_g = %lu;\n", misc_align[j].name,
- (unsigned long)(misc_align[j].comp_align));
-
fprintf(rawoutstream, "\
\n\
done:\n\
@@ -745,42 +432,6 @@ done:\n\
\n\
FUNC_LEAVE_NOAPI(ret_value);\n} /* end H5T__init_native() */\n");
- /* Print the ALIGNMENT and signal-handling status as comments */
- fprintf(rawoutstream, "\n"
- "/****************************************/\n"
- "/* ALIGNMENT and signal-handling status */\n"
- "/****************************************/\n");
- if (align_status_g & STA_NoALIGNMENT)
- fprintf(rawoutstream, "/* ALIGNAMENT test is not available */\n");
- if (align_status_g & STA_NoHandlerVerify)
- fprintf(rawoutstream, "/* Signal handlers verify test is not available */\n");
- /* The following is available in H5pubconf.h. Printing them here for */
- /* convenience. */
-#ifdef H5_HAVE_SIGSETJMP
- fprintf(rawoutstream, "/* sigsetjmp() support: yes */\n");
-#else
- fprintf(rawoutstream, "/* sigsetjmp() support: no */\n");
-#endif
-#ifdef H5_HAVE_SIGLONGJMP
- fprintf(rawoutstream, "/* siglongjmp() support: yes */\n");
-#else
- fprintf(rawoutstream, "/* siglongjmp() support: no */\n");
-#endif
-#ifdef H5_HAVE_SIGPROCMASK
- fprintf(rawoutstream, "/* sigprocmask() support: yes */\n");
-#else
- fprintf(rawoutstream, "/* sigprocmask() support: no */\n");
-#endif
-
- /* Print the statistics of signal handlers called for debugging */
- fprintf(rawoutstream, "\n"
- "/******************************/\n"
- "/* signal handlers statistics */\n"
- "/******************************/\n");
- fprintf(rawoutstream, "/* signal_handlers tested: %d times */\n", signal_handler_tested_g);
- fprintf(rawoutstream, "/* sigbus_handler called: %d times */\n", sigbus_handler_called_g);
- fprintf(rawoutstream, "/* sigsegv_handler called: %d times */\n", sigsegv_handler_called_g);
- fprintf(rawoutstream, "/* sigill_handler called: %d times */\n", sigill_handler_called_g);
} /* end print_results() */
/*-------------------------------------------------------------------------
@@ -820,7 +471,7 @@ iprint(detected_t *d)
unsigned int j;
for (j = 8; j > 0; --j) {
- if (k == d->sign && d->msize) {
+ if (k == d->sign) {
HDfputc('S', rawoutstream);
}
else if (k >= d->epos && k < d->epos + d->esize) {
@@ -829,14 +480,8 @@ iprint(detected_t *d)
else if (k >= d->mpos && k < d->mpos + d->msize) {
HDfputc('M', rawoutstream);
}
- else if (d->msize) {
- HDfputc('?', rawoutstream); /*unknown floating point bit */
- }
- else if (d->sign) {
- HDfputc('I', rawoutstream);
- }
else {
- HDfputc('U', rawoutstream);
+ HDfputc('?', rawoutstream); /*unknown floating point bit */
}
--k;
}
@@ -853,22 +498,7 @@ iprint(detected_t *d)
/*
* Is there an implicit bit in the mantissa.
*/
- if (d->msize) {
- fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no");
- }
-
- /*
- * Alignment
- */
- if (0 == d->align) {
- fprintf(rawoutstream, " * Alignment: NOT CALCULATED\n");
- }
- else if (1 == d->align) {
- fprintf(rawoutstream, " * Alignment: none\n");
- }
- else {
- fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long)(d->align));
- }
+ fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no");
}
/*-------------------------------------------------------------------------
@@ -1222,35 +852,6 @@ bit.\n";
}
/*-------------------------------------------------------------------------
- * Function: detect_C89_integers
- *
- * Purpose: Detect C89 integer types
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_C89_integers(void)
-{
- DETECT_BYTE(signed char, SCHAR, d_g[nd_g]);
- nd_g++;
- DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]);
- nd_g++;
- DETECT_I(short, SHORT, d_g[nd_g]);
- nd_g++;
- DETECT_I(unsigned short, USHORT, d_g[nd_g]);
- nd_g++;
- DETECT_I(int, INT, d_g[nd_g]);
- nd_g++;
- DETECT_I(unsigned int, UINT, d_g[nd_g]);
- nd_g++;
- DETECT_I(long, LONG, d_g[nd_g]);
- nd_g++;
- DETECT_I(unsigned long, ULONG, d_g[nd_g]);
- nd_g++;
-}
-
-/*-------------------------------------------------------------------------
* Function: detect_C89_floats
*
* Purpose: Detect C89 floating point types
@@ -1268,131 +869,6 @@ detect_C89_floats(void)
}
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers8
- *
- * Purpose: Detect C99 8 bit integer types
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_C99_integers8(void)
-{
- DETECT_BYTE(int8_t, INT8, d_g[nd_g]);
- nd_g++;
- DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]);
- nd_g++;
- DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]);
- nd_g++;
- DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]);
- nd_g++;
- DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]);
- nd_g++;
- DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]);
- nd_g++;
-}
-
-/*-------------------------------------------------------------------------
- * Function: detect_C99_integers16
- *
- * Purpose: Detect C99 16 bit integer types
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_C99_integers16(void)
-{
- DETECT_I(int16_t, INT16, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint16_t, UINT16, d_g[nd_g]);
- nd_g++;
- DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]);
- nd_g++;
- DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]);
- nd_g++;
-}
-
-/*-------------------------------------------------------------------------
- * Function: detect_C99_integers32
- *
- * Purpose: Detect C99 32 bit integer types
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_C99_integers32(void)
-{
- DETECT_I(int32_t, INT32, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint32_t, UINT32, d_g[nd_g]);
- nd_g++;
- DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]);
- nd_g++;
- DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]);
- nd_g++;
-}
-
-/*-------------------------------------------------------------------------
- * Function: detect_C99_integers64
- *
- * Purpose: Detect C99 64 bit integer types
- *
- * Return: void
- *
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_C99_integers64(void)
-{
- DETECT_I(int64_t, INT64, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint64_t, UINT64, d_g[nd_g]);
- nd_g++;
- DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]);
- nd_g++;
- DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]);
- nd_g++;
- DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]);
- nd_g++;
-
- DETECT_I(long long, LLONG, d_g[nd_g]);
- nd_g++;
- DETECT_I(unsigned long long, ULLONG, d_g[nd_g]);
- nd_g++;
-}
-
-/*-------------------------------------------------------------------------
- * Function: detect_C99_integers
- *
- * Purpose: Detect C99 integer types
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_C99_integers(void)
-{
- /* break it down to more subroutines so that each module subroutine */
- /* is smaller and takes less time to compile with optimization on. */
- detect_C99_integers8();
- detect_C99_integers16();
- detect_C99_integers32();
- detect_C99_integers64();
-}
-
-/*-------------------------------------------------------------------------
* Function: detect_C99_floats
*
* Purpose: Detect C99 floating point types
@@ -1419,87 +895,6 @@ detect_C99_floats(void)
}
/*-------------------------------------------------------------------------
- * Function: detect_alignments
- *
- * Purpose: Detect structure alignments
- *
- * Return: void
- *-------------------------------------------------------------------------
- */
-static void HDF_NO_UBSAN
-detect_alignments(void)
-{
- /* Detect structure alignment for pointers, vlen and reference types */
- DETECT_M(void *, POINTER, m_g[na_g]);
- na_g++;
- DETECT_M(hvl_t, HVL, m_g[na_g]);
- na_g++;
- DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]);
- na_g++;
- DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]);
- na_g++;
- DETECT_M(H5R_ref_t, REF, m_g[na_g]);
- na_g++;
-}
-
-/* Verify the signal handler for signal signum works correctly multiple times.
- * One possible cause of failure is that the signal handling is blocked or
- * changed to SIG_DFL after H5LONGJMP.
- * Return 0 for success, -1 for failure.
- */
-static int
-verify_signal_handlers(int signum, void (*handler)(int))
-{
-#if defined(__has_feature) /* Clang */
-#if __has_feature(address_sanitizer) || __has_feature(thread_sanitizer)
- /* Under the address and thread sanitizers, don't raise any signals. */
- return 0;
-#endif
-#elif defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__) /* GCC */
- return 0;
-#endif
- void (*save_handler)(int) = HDsignal(signum, handler);
- volatile int i, val;
- int ntries = 5;
- volatile int nfailures = 0;
- volatile int nsuccesses = 0;
-
- for (i = 0; i < ntries; i++) {
- val = H5SETJMP(jbuf_g);
- if (val == 0) {
- /* send self the signal to trigger the handler */
- signal_handler_tested_g++;
- HDraise(signum);
- /* Should not reach here. Record error. */
- nfailures++;
- }
- else {
- if (val == signum) {
- /* return from signum handler. Record a success. */
- nsuccesses++;
- }
- else {
- fprintf(stderr, "Unknown return value (%d) from H5SETJMP", val);
- nfailures++;
- }
- }
- }
- /* restore save handler, check results and report failures */
- HDsignal(signum, save_handler);
- if (nfailures > 0 || nsuccesses != ntries) {
- fprintf(stderr,
- "verify_signal_handlers for signal %d did %d tries. "
- "Found %d failures and %d successes\n",
- signum, ntries, nfailures, nsuccesses);
- return -1;
- }
- else {
- /* all succeeded */
- return 0;
- }
-}
-
-/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Main entry point.
@@ -1527,35 +922,15 @@ main(int argc, char *argv[])
if (!rawoutstream)
rawoutstream = stdout;
- /* verify the SIGBUS and SIGSEGV handlers work properly */
- if (verify_signal_handlers(SIGBUS, sigbus_handler) != 0) {
- fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigbus_handler", SIGBUS);
- }
- if (verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) {
- fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigsegv_handler", SIGSEGV);
- }
- if (verify_signal_handlers(SIGILL, sigill_handler) != 0) {
- fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigill_handler", SIGILL);
- }
-
print_header();
- /* C89 integer types */
- detect_C89_integers();
-
- /* C99 integer types */
- detect_C99_integers();
-
/* C89 floating point types */
detect_C89_floats();
/* C99 floating point types */
detect_C99_floats();
- /* Detect structure alignment */
- detect_alignments();
-
- print_results(nd_g, d_g, na_g, m_g);
+ print_results(nd_g, d_g);
if (rawoutstream && rawoutstream != stdout) {
if (HDfclose(rawoutstream))
@@ -1566,5 +941,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
-H5_GCC_CLANG_DIAG_ON("cast-align")