summaryrefslogtreecommitdiffstats
path: root/src/H5Cimage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Cimage.c')
-rw-r--r--src/H5Cimage.c120
1 files changed, 59 insertions, 61 deletions
diff --git a/src/H5Cimage.c b/src/H5Cimage.c
index 4fa3a1c..b969054 100644
--- a/src/H5Cimage.c
+++ b/src/H5Cimage.c
@@ -133,7 +133,7 @@ static herr_t H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_p
static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr);
static herr_t H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr);
static H5C_cache_entry_t *H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf);
-static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create);
+static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, bool create);
static herr_t H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr);
static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr);
static herr_t H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr);
@@ -161,17 +161,17 @@ H5FL_DEFINE(H5C_cache_entry_t);
* load is pending (i.e. will be executed on the next
* protect or insert)
*
- * Returns TRUE if a cache image load is pending, and FALSE
+ * Returns true if a cache image load is pending, and false
* if not. Throws an assertion failure on error.
*
- * Return: TRUE if a cache image load is pending, and FALSE otherwise.
+ * Return: true if a cache image load is pending, and false otherwise.
*
*-------------------------------------------------------------------------
*/
-hbool_t
+bool
H5C_cache_image_pending(const H5C_t *cache_ptr)
{
- hbool_t ret_value = TRUE; /* Return value */
+ bool ret_value = true; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -191,19 +191,19 @@ H5C_cache_image_pending(const H5C_t *cache_ptr)
* cache image has either been queued or executed, and if
* construction of a cache image has been requested.
*
- * This done, it set *load_ci_ptr to TRUE if a cache image
+ * This done, it set *load_ci_ptr to true if a cache image
* has either been loaded or a load has been requested, and
- * to FALSE otherwise.
+ * to false otherwise.
*
- * Similarly, set *write_ci_ptr to TRUE if construction of
- * a cache image has been requested, and to FALSE otherwise.
+ * Similarly, set *write_ci_ptr to true if construction of
+ * a cache image has been requested, and to false otherwise.
*
* Return: SUCCEED on success, and FAIL on failure.
*
*-------------------------------------------------------------------------
*/
herr_t
-H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr)
+H5C_cache_image_status(H5F_t *f, bool *load_ci_ptr, bool *write_ci_ptr)
{
H5C_t *cache_ptr;
@@ -638,7 +638,7 @@ H5C__load_cache_image(H5F_t *f)
*/
H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr);
- cache_ptr->image_loaded = TRUE;
+ cache_ptr->image_loaded = true;
} /* end if */
/* If directed, free the on disk metadata cache image */
@@ -688,7 +688,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw)
+H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, bool rw)
{
H5C_t *cache_ptr;
@@ -703,7 +703,7 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_
/* Set information needed to load cache image */
cache_ptr->image_addr = addr;
cache_ptr->image_len = len;
- cache_ptr->load_image = TRUE;
+ cache_ptr->load_image = true;
cache_ptr->delete_image = rw;
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -806,7 +806,7 @@ H5C__image_entry_cmp(const void *_entry1, const void *_entry2)
*-------------------------------------------------------------------------
*/
herr_t
-H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
+H5C__prep_image_for_file_close(H5F_t *f, bool *image_generated)
{
H5C_t *cache_ptr = NULL;
haddr_t eoa_frag_addr = HADDR_UNDEF;
@@ -828,7 +828,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
* it exists) has not been read yet. Do this now if required.
*/
if (cache_ptr->load_image) {
- cache_ptr->load_image = FALSE;
+ cache_ptr->load_image = false;
if (H5C__load_cache_image(f) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image");
} /* end if */
@@ -872,7 +872,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
* cache_ptr->image_ctl.flags.
*/
if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDCI_SBE_MESG)
- if (H5C__write_cache_image_superblock_msg(f, TRUE) < 0)
+ if (H5C__write_cache_image_superblock_msg(f, true) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "creation of cache image SB mesg failed.");
/* Serialize the cache */
@@ -993,7 +993,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
* cache_ptr->image_ctl.flags.
*/
if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK)
- if (H5C__write_cache_image_superblock_msg(f, FALSE) < 0)
+ if (H5C__write_cache_image_superblock_msg(f, false) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "update of cache image SB mesg failed");
/* At this point:
@@ -1026,7 +1026,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
*
* If the metadata cache image will be empty, delete the
* metadata cache image superblock extension message, set
- * cache_ptr->image_ctl.generate_image to FALSE. This will
+ * cache_ptr->image_ctl.generate_image to false. This will
* allow the file close to continue normally without the
* unnecessary generation of the metadata cache image.
*/
@@ -1051,11 +1051,11 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL,
"can't remove MDC image msg from superblock ext");
- cache_ptr->image_ctl.generate_image = FALSE;
+ cache_ptr->image_ctl.generate_image = false;
} /* end else */
/* Indicate that a cache image was generated */
- *image_generated = TRUE;
+ *image_generated = true;
} /* end if */
done:
@@ -1096,8 +1096,6 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl
/* Sanity checks */
assert(f);
- assert(f->shared);
- assert(f->shared->cache == f->shared->cache);
/* Check arguments */
if (cache_ptr == NULL)
@@ -1117,7 +1115,7 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl
cache_ptr->image_ctl = default_image_ctl;
assert(!(cache_ptr->image_ctl.generate_image));
- } /* end if */
+ }
else {
#endif /* H5_HAVE_PARALLEL */
/* A cache image can only be generated if the file is opened read / write
@@ -1139,9 +1137,9 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl
cache_ptr->image_ctl = default_image_ctl;
assert(!(cache_ptr->image_ctl.generate_image));
- } /* end else */
+ }
#ifdef H5_HAVE_PARALLEL
- } /* end else */
+ }
#endif /* H5_HAVE_PARALLEL */
done:
@@ -1175,9 +1173,9 @@ H5C_validate_cache_image_config(H5C_cache_image_ctl_t *ctl_ptr)
/* At present, we do not support inclusion of the adaptive resize
* configuration in the cache image. Thus the save_resize_status
- * field must be FALSE.
+ * field must be false.
*/
- if (ctl_ptr->save_resize_status != FALSE)
+ if (ctl_ptr->save_resize_status != false)
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unexpected value in save_resize_status field");
/* At present, we do not support prefetched entry ageouts. Thus
@@ -1276,7 +1274,7 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t *
{
uint8_t version;
uint8_t flags;
- hbool_t have_resize_status = FALSE;
+ bool have_resize_status = false;
size_t actual_header_len;
size_t expected_header_len;
const uint8_t *p;
@@ -1305,7 +1303,7 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t *
/* Decode flags */
flags = *p++;
if (flags & H5C__MDCI_HEADER_HAVE_RESIZE_STATUS)
- have_resize_status = TRUE;
+ have_resize_status = true;
if (have_resize_status)
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "MDC resize status not yet supported");
@@ -1355,10 +1353,10 @@ done:
static herr_t
H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf, unsigned entry_num)
{
- hbool_t is_dirty = FALSE;
- hbool_t in_lru = FALSE; /* Only used in assertions */
- hbool_t is_fd_parent = FALSE; /* Only used in assertions */
- hbool_t is_fd_child = FALSE; /* Only used in assertions */
+ bool is_dirty = false;
+ bool in_lru = false; /* Only used in assertions */
+ bool is_fd_parent = false; /* Only used in assertions */
+ bool is_fd_child = false; /* Only used in assertions */
haddr_t addr;
hsize_t size = 0;
void *image_ptr;
@@ -1397,13 +1395,13 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint
/* Decode flags */
flags = *p++;
if (flags & H5C__MDCI_ENTRY_DIRTY_FLAG)
- is_dirty = TRUE;
+ is_dirty = true;
if (flags & H5C__MDCI_ENTRY_IN_LRU_FLAG)
- in_lru = TRUE;
+ in_lru = true;
if (flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG)
- is_fd_parent = TRUE;
+ is_fd_parent = true;
if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG)
- is_fd_child = TRUE;
+ is_fd_child = true;
/* Decode ring */
ring = *p++;
@@ -1725,7 +1723,7 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
unsigned external_parent_fd_refs_removed = 0;
unsigned external_child_fd_refs_removed = 0;
#endif
- hbool_t done = FALSE;
+ bool done = false;
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED;
@@ -1741,9 +1739,9 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
* that the child will have dirty children of its own, this may take
* multiple passes through the index list.
*/
- done = FALSE;
+ done = false;
while (!done) {
- done = TRUE;
+ done = true;
entry_ptr = cache_ptr->il_head;
while (entry_ptr != NULL) {
/* Should this entry be in the image */
@@ -1762,7 +1760,7 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
#ifndef NDEBUG
entries_removed_from_image++;
#endif
- entry_ptr->include_in_image = FALSE;
+ entry_ptr->include_in_image = false;
} /* end if */
} /* for */
} /* end if */
@@ -2010,7 +2008,7 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr)
sizeof(H5C_image_entry_t) * (size_t)(cache_ptr->num_entries_in_image + 1))))
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for image_entries");
- /* Initialize (non-zero/NULL/FALSE) fields */
+ /* Initialize (non-zero/NULL/false) fields */
for (u = 0; u <= cache_ptr->num_entries_in_image; u++) {
image_entries[u].addr = HADDR_UNDEF;
image_entries[u].ring = H5C_RING_UNDEFINED;
@@ -2124,7 +2122,7 @@ static herr_t
H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
{
H5C_cache_entry_t *entry_ptr;
- hbool_t include_in_image;
+ bool include_in_image;
int lru_rank = 1;
#ifndef NDEBUG
unsigned entries_visited = 0;
@@ -2167,9 +2165,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
* of these entries later.
*/
if (entry_ptr->ring > H5C_MAX_RING_IN_IMAGE)
- include_in_image = FALSE;
+ include_in_image = false;
else
- include_in_image = TRUE;
+ include_in_image = true;
entry_ptr->include_in_image = include_in_image;
if (include_in_image) {
@@ -2450,7 +2448,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
* Do this now, and then uprotect when done.
*/
H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL);
- parent_ptr->is_protected = TRUE;
+ parent_ptr->is_protected = true;
/* Setup the flush dependency */
if (H5C_create_flush_dependency(parent_ptr, pf_entry_ptr) < 0)
@@ -2458,7 +2456,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
/* And now unprotect */
H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL);
- parent_ptr->is_protected = FALSE;
+ parent_ptr->is_protected = false;
} /* end for */
} /* end for */
@@ -2531,7 +2529,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
/* cache is oversized -- call H5C__make_space_in_cache() with zero
* space needed to repair the situation if possible.
*/
- hbool_t write_permitted = FALSE;
+ bool write_permitted = false;
if (cache_ptr->check_write_permitted && (cache_ptr->check_write_permitted)(f, &write_permitted) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted");
@@ -2565,14 +2563,14 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
{
H5C_cache_entry_t *pf_entry_ptr = NULL; /* Reconstructed cache entry */
uint8_t flags = 0;
- hbool_t is_dirty = FALSE;
+ bool is_dirty = false;
#ifndef NDEBUG /* only used in assertions */
- hbool_t in_lru = FALSE;
- hbool_t is_fd_parent = FALSE;
- hbool_t is_fd_child = FALSE;
+ bool in_lru = false;
+ bool is_fd_parent = false;
+ bool is_fd_child = false;
#endif
const uint8_t *p;
- hbool_t file_is_rw;
+ bool file_is_rw;
H5C_cache_entry_t *ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -2598,14 +2596,14 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
/* Decode flags */
flags = *p++;
if (flags & H5C__MDCI_ENTRY_DIRTY_FLAG)
- is_dirty = TRUE;
+ is_dirty = true;
#ifndef NDEBUG /* only used in assertions */
if (flags & H5C__MDCI_ENTRY_IN_LRU_FLAG)
- in_lru = TRUE;
+ in_lru = true;
if (flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG)
- is_fd_parent = TRUE;
+ is_fd_parent = true;
if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG)
- is_fd_child = TRUE;
+ is_fd_child = true;
#endif
/* Force dirty entries to clean if the file read only -- must do
@@ -2696,11 +2694,11 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
p += pf_entry_ptr->size;
/* Initialize the rest of the fields in the prefetched entry */
- /* (Only need to set non-zero/NULL/FALSE fields, due to calloc() above) */
+ /* (Only need to set non-zero/NULL/false fields, due to calloc() above) */
pf_entry_ptr->cache_ptr = cache_ptr;
- pf_entry_ptr->image_up_to_date = TRUE;
+ pf_entry_ptr->image_up_to_date = true;
pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY;
- pf_entry_ptr->prefetched = TRUE;
+ pf_entry_ptr->prefetched = true;
pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw);
/* Sanity checks */
@@ -2734,7 +2732,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create)
+H5C__write_cache_image_superblock_msg(H5F_t *f, bool create)
{
H5C_t *cache_ptr;
H5O_mdci_t mdci_msg; /* metadata cache image message */