summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-07-05 23:55:18 (GMT)
committerGitHub <noreply@github.com>2022-07-05 23:55:18 (GMT)
commit5ceaf920eccbf5176065b0deeb27b124b821db76 (patch)
tree2bca04a4fd6fd27065c3e33335092970ef30b940 /src
parentac7bddf2af317d4bc34854f5565396da51ff12aa (diff)
downloadhdf5-feature/vfd_swmr.zip
hdf5-feature/vfd_swmr.tar.gz
hdf5-feature/vfd_swmr.tar.bz2
VFD SWMR: Warning fixes and minor cleanup (#1847)feature/vfd_swmr
* Normalization with develop * Moves remaining datatype code changes over from develop * Cleanup in examples files * Warning cleanup in VFD SWMR code * Committing clang-format changes * Warning cleanup * Warning reduction * More warning fixes * Committing clang-format changes * Even more warning reduction in the VFD SWMR tests * More warning fixes in the VFD SWMR tests * Even more VFD SWMR test warning fixes * Last warning fixes in VFD SWMR * Committing clang-format changes * Minor things missed from develop * Warning fixes from GitHub build failures * Committing clang-format changes * Fix for warning due to weird bit shift type promotion * Yet another attempt at fixing the integral promotion warning Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/H5Dint.c4
-rw-r--r--src/H5FD.c40
-rw-r--r--src/H5FDint.c18
-rw-r--r--src/H5FDvfd_swmr.c4
-rw-r--r--src/H5Fint.c7
-rw-r--r--src/H5Gname.c5
-rw-r--r--src/H5Gnode.c2
-rw-r--r--src/H5Gobj.c8
-rw-r--r--src/H5Gtraverse.c5
-rw-r--r--src/H5HFcache.c5
-rw-r--r--src/H5Idbg.c2
-rw-r--r--src/H5Iint.c13
-rw-r--r--src/H5Lint.c10
-rw-r--r--src/H5Ocache.c18
-rw-r--r--src/H5Opline.c16
-rw-r--r--src/H5Pdcpl.c144
-rw-r--r--src/H5Pfapl.c7
-rw-r--r--src/H5Ppublic.h3
-rw-r--r--src/H5SM.c2
-rw-r--r--src/H5Shyper.c2
-rw-r--r--src/H5T.c43
-rw-r--r--src/H5Tconv.c32
-rw-r--r--src/H5Tnative.c362
-rw-r--r--src/H5Tpkg.h37
-rw-r--r--src/H5Tref.c13
-rw-r--r--src/H5Tvlen.c16
-rw-r--r--src/H5detect.c687
27 files changed, 574 insertions, 931 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 3b6b884..ee49464 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1564,7 +1564,7 @@ done:
vds_prefix = (char *)H5MM_xfree(vds_prefix);
if (ret_value == NULL) {
- /* Free the location--casting away const*/
+ /* Free the location */
if (dataset) {
if (shared_fo == NULL && dataset->shared) { /* Need to free shared fo */
dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix);
@@ -3502,7 +3502,7 @@ H5D_flush_all(H5F_t *f)
HDassert(f);
/* Iterate over all the open datasets */
- if (H5I_iterate(H5I_DATASET, H5D__flush_all_cb, f, FALSE) < 0) /* Casting away const OK -QAK */
+ if (H5I_iterate(H5I_DATASET, H5D__flush_all_cb, f, FALSE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to flush cached dataset info")
done:
diff --git a/src/H5FD.c b/src/H5FD.c
index a3be3db..162c228 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -919,21 +919,19 @@ done:
*
* Purpose: Private version of H5FDcmp()
*
- * Return: Success: A value like strcmp()
- *
- * Failure: Must never fail.
- *
- * Changes: Re-worked function to use H5FD_ctl() to obtain the terminal
- * VFDs for f1 and f2. Typically, these are the same thing,
- * however, if there is an intervening pass through VFD
- * (i.e. splitter of vfd swrmr reader vfd), using the terminal
- * VFD for the comparison will avoid some false negatives.
+ * Uses H5FD_ctl() to obtain the terminal VFDs for f1 and f2.
+ * Typically, these are the same thing, however, if there is an
+ * intervening pass through VFD (i.e. splitter or VFD SWMR
+ * reader), using the terminal VFD for the comparison will avoid
+ * some false negatives.
*
* Note, however, that we will still fail to detect the
- * case in which a give file is opened twice with different
+ * case in which a given file is opened twice with different
* terminal VFDs.
*
- * JRM -- 5/5/22
+ * Return: Success: A value like strcmp()
+ *
+ * Failure: Must never fail.
*
*-------------------------------------------------------------------------
*/
@@ -956,9 +954,16 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2)
H5E_BEGIN_TRY
{
+ /* Using the generic ctl callback, which takes non-const parameters,
+ * to work with const data is going to cause the compiler to complain.
+ */
+ H5_GCC_CLANG_DIAG_OFF("discarded-qualifiers")
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
ctl_result = H5FD_ctl(f1, H5FD_CTL_GET_TERMINAL_VFD,
H5FD_CTL_FAIL_IF_UNKNOWN_FLAG | H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG, NULL,
(void **)(&term_f1));
+ H5_GCC_CLANG_DIAG_ON("discarded-qualifiers")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
}
H5E_END_TRY;
@@ -977,9 +982,16 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2)
H5E_BEGIN_TRY
{
+ /* Using the generic ctl callback, which takes non-const parameters,
+ * to work with const data is going to cause the compiler to complain.
+ */
+ H5_GCC_CLANG_DIAG_OFF("discarded-qualifiers")
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
ctl_result = H5FD_ctl(f2, H5FD_CTL_GET_TERMINAL_VFD,
H5FD_CTL_FAIL_IF_UNKNOWN_FLAG | H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG, NULL,
(void **)(&term_f2));
+ H5_GCC_CLANG_DIAG_ON("discarded-qualifiers")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
}
H5E_END_TRY;
@@ -2323,8 +2335,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/H5FDint.c b/src/H5FDint.c
index 602559d..28dc3a1 100644
--- a/src/H5FDint.c
+++ b/src/H5FDint.c
@@ -233,6 +233,24 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*
HGOTO_DONE(SUCCEED)
#endif /* H5_HAVE_PARALLEL */
+ /* If the file is open for SWMR read access, allow access to data past
+ * the end of the allocated space (the 'eoa'). This is done because the
+ * eoa stored in the file's superblock might be out of sync with the
+ * objects being written within the file by the application performing
+ * SWMR write operations.
+ */
+ if (!(file->access_flags & H5F_ACC_SWMR_READ)) {
+ haddr_t eoa;
+
+ if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed")
+
+ if ((addr + file->base_addr + size) > eoa)
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu",
+ (unsigned long long)(addr + file->base_addr), (unsigned long long)size,
+ (unsigned long long)eoa)
+ }
+
/* Dispatch to driver */
if ((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0)
HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed")
diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c
index 548bc89..3f742d8 100644
--- a/src/H5FDvfd_swmr.c
+++ b/src/H5FDvfd_swmr.c
@@ -600,7 +600,7 @@ H5FD__vfd_swmr_create_make_believe_data(H5FD_vfd_swmr_t *_file)
*-------------------------------------------------------------------------
*/
static H5FD_t *
-H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
+H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR_UNUSED maxaddr)
{
H5FD_vfd_swmr_t * file = NULL;
size_t page_buf_size;
@@ -1802,7 +1802,7 @@ H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed)
H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file;
- uint32_t elapsed_idx = MIN(elapsed, file->api_elapsed_nbuckets);
+ uint64_t elapsed_idx = MIN(elapsed, file->api_elapsed_nbuckets);
file->api_elapsed_ticks[elapsed_idx]++;
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 2f384fc..d9f923c 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -2938,10 +2938,13 @@ H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *n
if (NULL == (new_fapl = (H5P_genplist_t *)H5I_object(new_fapl_id)))
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "can't get property list")
- /* Set the character encoding on the new property list */
+ /*
+ * Set the private property for retrieving the backing store
+ * POSIX file descriptor from the Core VFD
+ */
want_posix_fd = TRUE;
if (H5P_set(new_fapl, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set property for retrieving file descriptor")
/* Retrieve the file handle */
if (H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0)
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 7002daa..2ea1912 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -446,9 +446,10 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
dst->user_path_r = H5RS_dup(src->user_path_r);
}
else {
- /* Discarding 'const' qualifier OK - QAK */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
H5G_name_reset((H5G_name_t *)src);
- } /* end if */
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
+ }
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_name_copy() */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index aabb6a7..9f6d7e0 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1228,7 +1228,9 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const
/* Set up group location for soft link to start in */
H5G_name_reset(&grp_path);
grp_loc.path = &grp_path;
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
grp_loc.oloc = (H5O_loc_t *)src_oloc;
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Get pointer to link value in local heap */
if ((link_name = (char *)H5HL_offset_into(heap, tmp_src_ent.cache.slink.lval_offset)) == NULL)
diff --git a/src/H5Gobj.c b/src/H5Gobj.c
index 5412b52..cc92f2c 100644
--- a/src/H5Gobj.c
+++ b/src/H5Gobj.c
@@ -242,21 +242,20 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linf
/* Check for format of group to create */
if (use_at_least_v18) {
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
/* Insert link info message */
- /* (Casting away const OK - QAK) */
if (H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message")
/* Insert group info message */
- /* (Casting away const OK - QAK) */
if (H5O_msg_create(oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)ginfo) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message")
/* Insert pipeline message */
if (pline && pline->nused)
- /* (Casting away const OK - QAK) */
if (H5O_msg_create(oloc, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)pline) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
} /* end if */
else {
H5O_stab_t stab; /* Symbol table message */
@@ -398,9 +397,10 @@ H5G__obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata)
HDassert(udata);
/* Insert link into group */
- /* (Casting away const OK - QAK) */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, H5O_TYPE_UNKNOWN, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert link into group")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 15fb9a4..f03794e 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -713,18 +713,17 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open")
/* Reset any non-default object header messages */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (ginfo != &def_ginfo)
- /* (Casting away const OK - QAK) */
if (H5O_msg_reset(H5O_GINFO_ID, (void *)ginfo) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset group info message")
if (linfo != &def_linfo)
- /* (Casting away const OK - QAK) */
if (H5O_msg_reset(H5O_LINFO_ID, (void *)linfo) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link info message")
if (pline != &def_pline)
- /* (Casting away const OK - QAK) */
if (H5O_msg_reset(H5O_PLINE_ID, (void *)pline) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset I/O pipeline message")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
} /* end if */
else
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found")
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index f7e2e53..9006c21 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -745,7 +745,9 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN
HDassert(len == hdr->heap_size);
/* Set the shared heap header's file context for this operation */
+ H5_GCC_CLANG_DIAG_OFF("discarded-qualifiers")
hdr->f = f;
+ H5_GCC_CLANG_DIAG_ON("discarded-qualifiers")
/* Magic number */
H5MM_memcpy(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
@@ -1331,7 +1333,9 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG
hdr = iblock->hdr;
/* Set the shared heap header's file context for this operation */
+ H5_GCC_CLANG_DIAG_OFF("discarded-qualifiers")
hdr->f = f;
+ H5_GCC_CLANG_DIAG_ON("discarded-qualifiers")
/* Magic number */
H5MM_memcpy(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC);
@@ -1678,7 +1682,6 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
chk_p -= H5HF_SIZEOF_CHKSUM;
/* Reset checksum field, for computing the checksum */
- /* (Casting away const OK - QAK) */
HDmemset(chk_p, 0, (size_t)H5HF_SIZEOF_CHKSUM);
/* Compute checksum on entire direct block */
diff --git a/src/H5Idbg.c b/src/H5Idbg.c
index 6b4a979..3eb6518 100644
--- a/src/H5Idbg.c
+++ b/src/H5Idbg.c
@@ -111,7 +111,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
const H5T_t *dt = (const H5T_t *)info->object;
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- object = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */
+ object = (void *)H5T_get_actual_type((H5T_t *)dt);
H5_GCC_CLANG_DIAG_ON("cast-qual")
path = H5T_nameof(object);
diff --git a/src/H5Iint.c b/src/H5Iint.c
index ca6d208..e382efc 100644
--- a/src/H5Iint.c
+++ b/src/H5Iint.c
@@ -697,7 +697,7 @@ H5I_subst(hid_t id, const void *new_object)
/* Get the old object pointer to return */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- ret_value = (void *)info->object; /* (Casting away const OK -QAK) */
+ ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Set the new object pointer for the ID */
@@ -731,7 +731,7 @@ H5I_object(hid_t id)
if (NULL != (info = H5I__find_id(id))) {
/* Get the object pointer to return */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- ret_value = (void *)info->object; /* (Casting away const OK -QAK) */
+ ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
}
@@ -767,7 +767,7 @@ H5I_object_verify(hid_t id, H5I_type_t type)
if (type == H5I_TYPE(id) && NULL != (info = H5I__find_id(id))) {
/* Get the object pointer to return */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- ret_value = (void *)info->object; /* (Casting away const OK -QAK) */
+ ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
}
@@ -930,7 +930,7 @@ H5I__remove_common(H5I_type_info_t *type_info, hid_t id)
type_info->last_id_info = NULL;
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- ret_value = (void *)info->object; /* (Casting away const OK -QAK) */
+ ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
if (!H5I_marking_g)
@@ -1032,7 +1032,6 @@ H5I__dec_ref(hid_t id, void **request)
type_info = H5I_type_info_array_g[H5I_TYPE(id)];
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- /* (Casting away const OK -QAK) */
if (!type_info->cls->free_func || (type_info->cls->free_func)((void *)info->object, request) >= 0) {
/* Remove the node from the type */
if (NULL == H5I__remove_common(type_info, id))
@@ -1521,7 +1520,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
* case we'll need to get the wrapped object struct (H5F_t *, etc.).
*/
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- object = H5I__unwrap((void *)info->object, type); /* Casting away const OK */
+ object = H5I__unwrap((void *)info->object, type);
H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Invoke callback function */
@@ -1713,7 +1712,7 @@ H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
/* Get a pointer to the VOL connector's data */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
- object = H5I__unwrap((void *)info->object, type); /* Casting away const OK */
+ object = H5I__unwrap((void *)info->object, type);
H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Check for a match */
diff --git a/src/H5Lint.c b/src/H5Lint.c
index 9dc8d0b..12de22f 100644
--- a/src/H5Lint.c
+++ b/src/H5Lint.c
@@ -595,8 +595,9 @@ H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_AT
udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */
/* Set the link's name correctly */
- /* Casting away const OK -QAK */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
udata->lnk->name = (char *)name;
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Insert link into group */
if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE,
@@ -1374,9 +1375,10 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "moving a link across files is not allowed")
/* Give the object its new name */
- /* Casting away const okay -JML */
HDassert(udata->lnk->name == NULL);
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
udata->lnk->name = (char *)name;
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Insert the link into the group */
if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0)
@@ -2123,7 +2125,9 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t
/* Set up group location for link */
H5G_name_reset(&lnk_grp_path);
lnk_grp_loc.path = &lnk_grp_path;
- lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
+ lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc;
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
/* Check if the target object exists */
if (H5G_loc_exists(&lnk_grp_loc, src_lnk->name, &tar_exists) < 0)
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 51c44f9..9f194c8 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -1432,11 +1432,13 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t chunk_size, const uint8_t
oh->nmesgs++;
/* Initialize information about message */
- mesg->dirty = FALSE;
- mesg->flags = flags;
- mesg->crt_idx = crt_idx;
- mesg->native = NULL;
- mesg->raw = (uint8_t *)chunk_image; /* Casting away const OK - QAK */
+ mesg->dirty = FALSE;
+ mesg->flags = flags;
+ mesg->crt_idx = crt_idx;
+ mesg->native = NULL;
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
+ mesg->raw = (uint8_t *)chunk_image;
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
mesg->raw_size = mesg_size;
mesg->chunkno = chunkno;
@@ -1639,10 +1641,12 @@ H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno)
/* Encode any dirty messages in this chunk */
for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++)
- if (curr_msg->dirty && curr_msg->chunkno == chunkno)
- /* Casting away const OK -QAK */
+ if (curr_msg->dirty && curr_msg->chunkno == chunkno) {
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (H5O_msg_flush((H5F_t *)f, oh, curr_msg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message")
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
+ }
/* Sanity checks */
if (oh->version > H5O_VERSION_1)
diff --git a/src/H5Opline.c b/src/H5Opline.c
index 7f73801..5618dce 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -639,7 +639,6 @@ static herr_t
H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth)
{
const H5O_pline_t *pline = (const H5O_pline_t *)mesg;
- size_t i, j;
FUNC_ENTER_PACKAGE_NOERR
@@ -654,10 +653,15 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int in
pline->nalloc);
/* Loop over all the filters */
- for (i = 0; i < pline->nused; i++) {
- char name[32];
+ for (size_t i = 0; i < pline->nused; i++) {
+ /* 19 characters for text + 20 characters for largest 64-bit size_t +
+ * terminal NUL = 40 characters.
+ */
+ char name[64];
+ HDmemset(name, 0, 64);
HDsnprintf(name, sizeof(name), "Filter at position %zu", i);
+
HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name);
HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3),
"Filter identification:", (unsigned)(pline->filter[i].id));
@@ -672,14 +676,14 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int in
"Num CD values:", pline->filter[i].cd_nelmts);
/* Filter parameters */
- for (j = 0; j < pline->filter[i].cd_nelmts; j++) {
+ for (size_t j = 0; j < pline->filter[i].cd_nelmts; j++) {
char field_name[32];
HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j);
HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), field_name,
pline->filter[i].cd_values[j]);
- } /* end for */
- } /* end for */
+ }
+ }
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O__pline_debug() */
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 3c7bc09..3561c65 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -93,7 +93,6 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE \
}
-#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER
#define H5D_DEF_STORAGE_COMPACT \
{ \
H5D_COMPACT, \
@@ -142,41 +141,6 @@
H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \
H5D_DEF_STORAGE_VIRTUAL \
}
-#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-/* Note that the compact & chunked layout initialization values are using the
- * contiguous layout initialization in the union, because the contiguous
- * layout is first in the union. These values are overridden in the
- * H5P__init_def_layout() routine. -QAK
- */
-#define H5D_DEF_LAYOUT_COMPACT \
- { \
- H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \
- { \
- H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \
- } \
- }
-#define H5D_DEF_LAYOUT_CONTIG \
- { \
- H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \
- { \
- H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \
- } \
- }
-#define H5D_DEF_LAYOUT_CHUNK \
- { \
- H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \
- { \
- H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \
- } \
- }
-#define H5D_DEF_LAYOUT_VIRTUAL \
- { \
- H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \
- { \
- H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \
- } \
- }
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
/* ======== Dataset creation properties ======== */
/* Definitions for storage layout property */
@@ -245,9 +209,6 @@
/* General routines */
static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout);
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
-static herr_t H5P__init_def_layout(void);
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
/* Property class callbacks */
static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass);
@@ -320,18 +281,10 @@ static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default
static const unsigned H5O_ohdr_min_g = H5D_CRT_MIN_DSET_HDR_SIZE_DEF; /* Default object header minimization */
/* Defaults for each type of layout */
-#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER
static const H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT;
static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG;
static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK;
static const H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL;
-#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT;
-static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG;
-static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK;
-static H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL;
-static hbool_t H5P_dcrt_def_layout_init_g = FALSE;
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
/*-------------------------------------------------------------------------
* Function: H5P__dcrt_reg_prop
@@ -1926,47 +1879,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__set_layout() */
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
-
-/*-------------------------------------------------------------------------
- * Function: H5P__init_def_layout
- *
- * Purpose: Set the default layout information for the various types of
- * dataset layouts
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, January 13, 2009
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5P__init_def_layout(void)
-{
- const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT;
- const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT;
- const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT;
- const H5O_storage_virtual_t def_store_virtual = H5D_DEF_STORAGE_VIRTUAL_INIT;
-
- FUNC_ENTER_PACKAGE_NOERR
-
- /* Initialize the default layout info for non-contigous layouts */
- H5D_def_layout_compact_g.storage.type = H5D_COMPACT;
- H5D_def_layout_compact_g.storage.u.compact = def_store_compact;
- H5D_def_layout_chunk_g.u.chunk = def_layout_chunk;
- H5D_def_layout_chunk_g.storage.type = H5D_CHUNKED;
- H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk;
- H5D_def_layout_virtual_g.storage.type = H5D_VIRTUAL;
- H5D_def_layout_virtual_g.storage.u.virt = def_store_virtual;
-
- /* Note that we've initialized the default values */
- H5P_dcrt_def_layout_init_g = TRUE;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5P__init_def_layout() */
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-
/*-------------------------------------------------------------------------
* Function: H5Pset_layout
*
@@ -1997,15 +1909,6 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type)
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
- /* If the compiler doesn't support C99 designated initializers, check if
- * the default layout structs have been initialized yet or not. *ick* -QAK
- */
- if (!H5P_dcrt_def_layout_init_g)
- if (H5P__init_def_layout() < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info")
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-
/* Get pointer to correct default layout */
switch (layout_type) {
case H5D_COMPACT:
@@ -2114,15 +2017,6 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/])
if (!dim)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified")
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
- /* If the compiler doesn't support C99 designated initializers, check if
- * the default layout structs have been initialized yet or not. *ick* -QAK
- */
- if (!H5P_dcrt_def_layout_init_g)
- if (H5P__init_def_layout() < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info")
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-
/* Verify & initialize property's chunk dims */
H5MM_memcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g));
HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim));
@@ -2254,15 +2148,6 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, const
if (H5D_virtual_check_mapping_pre(vspace, src_space, H5O_VIRTUAL_STATUS_USER) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "invalid mapping selections")
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
- /* If the compiler doesn't support C99 designated initializers, check if
- * the default layout structs have been initialized yet or not. *ick* -QAK
- */
- if (!H5P_dcrt_def_layout_init_g)
- if (H5P__init_def_layout() < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info")
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
@@ -2734,15 +2619,6 @@ H5Pset_chunk_opts(hid_t plist_id, unsigned options)
if (options & ~(H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS))
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unknown chunk options")
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
- /* If the compiler doesn't support C99 designated initializers, check if
- * the default layout structs have been initialized yet or not. *ick* -QAK
- */
- if (!H5P_dcrt_def_layout_init_g)
- if (H5P__init_def_layout() < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info")
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
@@ -2794,15 +2670,6 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options /*out*/)
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", plist_id, options);
-#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER
- /* If the compiler doesn't support C99 designated initializers, check if
- * the default layout structs have been initialized yet or not. *ick* -QAK
- */
- if (!H5P_dcrt_def_layout_init_g)
- if (H5P__init_def_layout() < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info")
-#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */
-
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
@@ -2995,8 +2862,17 @@ H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out
/* Return values */
if (name_size > 0 && name)
HDstrncpy(name, efl.slot[idx].name, name_size);
+ /* XXX: Badness!
+ *
+ * The offset parameter is of type off_t and the offset field of H5O_efl_entry_t
+ * is HDoff_t which is a different type on Windows (off_t is a 32-bit long,
+ * HDoff_t is __int64, a 64-bit type).
+ *
+ * In a future API reboot, we'll either want to make this parameter a haddr_t
+ * or define a 64-bit HDF5-specific offset type that is platform-independent.
+ */
if (offset)
- *offset = efl.slot[idx].offset;
+ *offset = (off_t)efl.slot[idx].offset;
if (size)
*size = efl.slot[idx].size;
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index d6beece..ce8fde8 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -546,8 +546,13 @@ static const hbool_t H5F_def_use_file_locking_g =
H5F_ACS_USE_FILE_LOCKING_DEF; /* Default use file locking flag */
static const hbool_t H5F_def_ignore_disabled_file_locks_g =
H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF; /* Default ignore disabled file locks flag */
+/* The VFD SWMR struct contains multiple large strings and triggers size
+ * warnings. We'll disable this for now and revisit later.
+ */
+H5_GCC_CLANG_DIAG_OFF("larger-than=")
static const H5F_vfd_swmr_config_t H5F_def_vfd_swmr_config_g =
H5F_ACS_VFD_SWMR_CONFIG_DEF; /* Default vfd swmr configuration */
+H5_GCC_CLANG_DIAG_ON("larger-than=")
/* For VFD SWMR testing only: Default to generate checksum for metadata file */
static const H5F_generate_md_ck_t H5F_def_generate_md_ck_cb_g = H5F_ACS_GENERATE_MD_CK_CB_DEF;
@@ -1221,7 +1226,7 @@ done:
*
* Purpose: Set the file driver (DRIVER_ID) for a file access
* property list (PLIST_ID) and supply an optional
- * struct containing the driver-specific properites
+ * struct containing the driver-specific properties
* (DRIVER_INFO). The driver properties will be copied into the
* property list and the reference count on the driver will be
* incremented, allowing the caller to close the driver ID but
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 4262026..62eb484 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -5789,6 +5789,9 @@ H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize);
* are null pointers then the corresponding information is not
* returned.
*
+ * \note On Windows, off_t is typically a 32-bit signed long value, which
+ * limits the valid offset that can be returned to 2 GiB.
+ *
* \version 1.6.4 \p idx parameter type changed to unsigned.
* \since 1.0.0
*
diff --git a/src/H5SM.c b/src/H5SM.c
index bd061dc8a..7ec5b8f 100644
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -1076,7 +1076,7 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id,
ssize_t index_num;
htri_t tri_ret;
#ifndef NDEBUG
- unsigned deferred_type = -1U;
+ unsigned deferred_type = UINT_MAX;
#endif
htri_t ret_value = TRUE;
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 86aaef2..f27b57a 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -11544,7 +11544,7 @@ H5S__hyper_proj_int_iterate(H5S_hyper_span_info_t *ss_span_info, const H5S_hyper
H5S_HYPER_PROJ_INT_ADD_SKIP(
udata,
H5S__hyper_spans_nelem_helper((H5S_hyper_span_info_t *)ss_span_info, 0, udata->op_gen) * count,
- FAIL); /* Casting away const OK -NAF */
+ FAIL);
/* Clean up if we are done */
if (depth == 0) {
diff --git a/src/H5T.c b/src/H5T.c
index 135e069..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")
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..9625290 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,335 @@ 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 */
+
+ /* Version 19.10 of the PGI C compiler croaks on the following
+ * tables if they are `static`, so make them `static` only if
+ * some other compiler is used.
+ */
+#if defined(__PGIC__) && __PGIC__ == 19 && __PGIC_MINOR__ == 10
+# define static_unless_buggy_pgic
+#else
+# define static_unless_buggy_pgic static
+#endif
+
+ /* The library compiles with a limit on `static` object size, so
+ * I broke this table into three.
+ */
+ static_unless_buggy_pgic 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_unless_buggy_pgic 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_unless_buggy_pgic 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_unless_buggy_pgic const native_int_table_t table_table[] = {
+ {table1, NELMTS(table1)}
+ , {table2, NELMTS(table2)}
+ , {table3, NELMTS(table3)}
+ };
+#undef static_unless_buggy_pgic
+ /* 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/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/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")