diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/H5C.c | 6 | ||||
-rw-r--r-- | src/H5FD.c | 40 | ||||
-rw-r--r-- | src/H5FDpublic.h | 16 | ||||
-rw-r--r-- | src/H5FDvfd_swmr.c | 82 | ||||
-rw-r--r-- | src/H5FDvfd_swmr.h | 7 | ||||
-rw-r--r-- | src/H5FDvfd_swmr_private.h | 18 | ||||
-rw-r--r-- | src/H5Fpkg.h | 3 | ||||
-rw-r--r-- | src/H5Fvfd_swmr.c | 201 | ||||
-rw-r--r-- | src/H5MF.c | 152 | ||||
-rw-r--r-- | src/H5MFsection.c | 4 | ||||
-rw-r--r-- | src/H5MV.c | 25 | ||||
-rw-r--r-- | src/H5PB.c | 100 | ||||
-rw-r--r-- | src/H5VLnative_object.c | 2 | ||||
-rw-r--r-- | src/H5private.h | 20 | ||||
-rw-r--r-- | src/H5queue.h | 369 | ||||
-rw-r--r-- | src/H5retry_private.h | 6 | ||||
-rw-r--r-- | src/H5system.c | 40 | ||||
-rw-r--r-- | src/H5time_private.h | 6 | ||||
-rw-r--r-- | src/H5win32defs.h | 3 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/hlog.c | 366 | ||||
-rw-r--r-- | src/hlog.h | 138 |
23 files changed, 310 insertions, 1301 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af4920b..a189f1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ set (H5_SOURCES ${HDF5_SRC_DIR}/H5system.c ${HDF5_SRC_DIR}/H5timer.c ${HDF5_SRC_DIR}/H5trace.c - ${HDF5_SRC_DIR}/hlog.c ) set (H5_HDRS @@ -816,7 +815,8 @@ set (H5_PUBLIC_HEADERS set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5private.h - ${HDF5_SRC_DIR}/hlog.h + ${HDF5_SRC_DIR}/H5queue.h + ${HDF5_SRC_DIR}/H5retry_private.h ${HDF5_SRC_DIR}/H5Apkg.h ${HDF5_SRC_DIR}/H5Aprivate.h @@ -1325,13 +1325,7 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, entry_ptr = entry_ptr->pi_next; } - if (!found) { - hlog_fast(mdc_invalidation, "no MDC match for page %" PRIu64 - " length %" PRIu32 " tick %" PRIu64, page, length, tick); - } - done: - FUNC_LEAVE_NOAPI(ret_value) } /* H5C_evict_or_refresh_all_entries_in_page() */ @@ -54,6 +54,11 @@ /* Package Typedefs */ /********************/ +/* H5FD wrapper for VFD SWMR. Allows use as a BSD TAILQ element. */ +typedef struct H5FD_wrap_t { + TAILQ_ENTRY(H5FD_wrap_t) link; /* Linkage for list of all VFDs. */ + H5FD_t *file; /* Pointer to wrapped VFD struct */ +} H5FD_wrap_t; /********************/ /* Local Prototypes */ @@ -92,7 +97,7 @@ hbool_t H5_PKG_INIT_VAR = FALSE; */ static unsigned long H5FD_file_serial_no_g; -static TAILQ_HEAD(_all_vfds, H5FD_t) all_vfds = TAILQ_HEAD_INITIALIZER(all_vfds); +static TAILQ_HEAD(_all_vfds, H5FD_wrap_t) all_vfds = TAILQ_HEAD_INITIALIZER(all_vfds); /* File driver ID class */ static const H5I_class_t H5I_VFL_CLS[1] = {{ @@ -726,18 +731,19 @@ H5FD_dedup(H5FD_t *self, H5FD_t *other, hid_t fapl) H5FD_t * H5FD_deduplicate(H5FD_t *file, hid_t fapl) { - H5FD_t *deduped = file, *item; + H5FD_t *deduped = file; + H5FD_wrap_t *item; TAILQ_FOREACH(item, &all_vfds, link) { /* skip "self" */ - if (item == file) + if (item->file == file) continue; /* skip files with exclusive owners, for now */ - if (item->exc_owner != NULL) + if (item->file->exc_owner != NULL) continue; - if ((deduped = H5FD_dedup(item, file, fapl)) != file) + if ((deduped = H5FD_dedup(item->file, file, fapl)) != file) goto finish; } @@ -746,10 +752,10 @@ H5FD_deduplicate(H5FD_t *file, hid_t fapl) * return NULL to indicate the conflict. */ TAILQ_FOREACH(item, &all_vfds, link) { - if (item == file || item->exc_owner == NULL) + if (item->file == file || item->file->exc_owner == NULL) continue; - if (H5FDcmp(file, item) == 0) { + if (H5FDcmp(file, item->file) == 0) { deduped = NULL; break; } @@ -784,6 +790,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5P_genplist_t *plist; /* Property list pointer */ unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ H5FD_file_image_info_t file_image_info; /* Initial file image */ + H5FD_wrap_t *swmr_wrapper = NULL; /* H5FD wrapper for SWMR queue */ H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -862,7 +869,11 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* (This will be changed later, when the superblock is located) */ file->base_addr = 0; - TAILQ_INSERT_TAIL(&all_vfds, file, link); + /* Create and insert a SWMR wrapper for the file */ + if(NULL == (swmr_wrapper = H5MM_calloc(sizeof(H5FD_wrap_t)))) + HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, NULL, "unable to allocate file wrap struct") + swmr_wrapper->file = file; + TAILQ_INSERT_TAIL(&all_vfds, swmr_wrapper, link); /* Set return value */ ret_value = file; @@ -923,7 +934,8 @@ herr_t H5FD_close(H5FD_t *file) { const H5FD_class_t *driver; - H5FD_t *item; + H5FD_wrap_t *item; + H5FD_wrap_t *delete_me = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -938,10 +950,14 @@ H5FD_close(H5FD_t *file) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") TAILQ_FOREACH(item, &all_vfds, link) { - if (item->exc_owner == file) - item->exc_owner = NULL; + if (item->file->exc_owner == file) + item->file->exc_owner = NULL; + if (item->file == file) + delete_me = item; } - TAILQ_REMOVE(&all_vfds, file, link); + HDassert(delete_me); + TAILQ_REMOVE(&all_vfds, delete_me, link); + H5MM_xfree(delete_me); /* Dispatch to the driver for actual close. If the driver fails to * close the file then the file will be in an unusable state. diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index a921c29..520668b 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -18,7 +18,6 @@ #ifndef _H5FDpublic_H #define _H5FDpublic_H -#include "H5queue.h" #include "H5public.h" #include "H5Fpublic.h" /*for H5F_close_degree_t */ @@ -319,19 +318,18 @@ typedef struct H5FD_free_t { * are declared here and the driver appends private fields in memory. */ struct H5FD_t { - hid_t driver_id; /*driver ID for this file */ - const H5FD_class_t *cls; /*constant class info */ - - TAILQ_ENTRY(H5FD_t) link; /* Linkage for list of all VFs. */ - H5FD_t *exc_owner; /* Pointer to an exclusive owner - * or NULL if none. - */ - unsigned long fileno; /* File 'serial' number */ + hid_t driver_id; /* Driver ID for this file */ + const H5FD_class_t *cls; /* Constant class info */ + unsigned long fileno; /* File 'serial' number */ unsigned access_flags; /* File access flags (from create or open) */ unsigned long feature_flags; /* VFL Driver feature Flags */ haddr_t maxaddr; /* For this file, overrides class */ haddr_t base_addr; /* Base address for HDF5 data w/in file */ + H5FD_t *exc_owner; /* Pointer to an exclusive owner + * or NULL if none. + */ + /* Space allocation management fields */ hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Allocation alignment */ diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index 898adaf..405bcd7 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -64,7 +64,7 @@ typedef struct H5FD_vfd_swmr_t { /* and to FALSE otherwise. */ /* Used for sanity checking. */ H5F_vfd_swmr_config_t config; - bool writer; /* True iff configured to write. + hbool_t writer; /* True iff configured to write. * All methods on a write-mode * SWMR VFD instance are passed * to the lower VFD instance. @@ -103,12 +103,6 @@ static htri_t H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_index *md_index, const H5FD_vfd_swmr_md_header *md_header); static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *, hbool_t); -HLOG_OUTLET_SHORT_DEFN(index_motion, swmr); -HLOG_OUTLET_SHORT_DEFN(swmr_stats, swmr); -HLOG_OUTLET_SHORT_DEFN(swmr_read, swmr); -HLOG_OUTLET_SHORT_DEFN(swmr_read_exception, swmr_read); -HLOG_OUTLET_MEDIUM_DEFN(swmr_read_err, swmr_read_exception, HLOG_OUTLET_S_ON); - static const H5FD_class_t H5FD_vfd_swmr_g = { "vfd_swmr", /* name */ MAXADDR, /* maxaddr */ @@ -269,14 +263,14 @@ static herr_t H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file) { h5_retry_t retry; - bool do_try; /* more tries remain */ + hbool_t do_try; /* more tries remain */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC file->api_elapsed_nbuckets = file->config.max_lag + 1; file->api_elapsed_ticks = - calloc(file->api_elapsed_nbuckets, sizeof(*file->api_elapsed_ticks)); + H5MM_calloc(file->api_elapsed_nbuckets * sizeof(*file->api_elapsed_ticks)); if (file->api_elapsed_ticks == NULL) { HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, @@ -430,15 +424,8 @@ swmr_reader_close(H5FD_vfd_swmr_t *file) { vfd_swmr_reader_did_increase_tick_to(0); - if (file->api_elapsed_ticks != NULL) { - uint32_t i; - for (i = 0; i < file->api_elapsed_nbuckets; i++) { - hlog_fast(swmr_stats, - "%s: %" PRIu32 " ticks elapsed in API %" PRIu64 " times", - __func__, i, file->api_elapsed_ticks[i]); - } - free(file->api_elapsed_ticks); - } + if (file->api_elapsed_ticks != NULL) + H5MM_xfree(file->api_elapsed_ticks); /* Close the metadata file */ if(file->md_fd >= 0 && HDclose(file->md_fd) < 0) { @@ -477,7 +464,7 @@ H5FD_vfd_swmr_close(H5FD_t *_file) if (file->hdf5_file_lf != NULL) { if (file->hdf5_file_lf->exc_owner != NULL) { - assert(file->hdf5_file_lf->exc_owner == &file->pub); + HDassert(file->hdf5_file_lf->exc_owner == &file->pub); file->hdf5_file_lf->exc_owner = NULL; } @@ -562,13 +549,13 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) { H5FD_vfd_swmr_t *self = (H5FD_vfd_swmr_t *)_self; - assert(_self->driver_id == H5FD_VFD_SWMR_g); + HDassert(_self->driver_id == H5FD_VFD_SWMR_g); if (_self->cls == _other->cls) { H5FD_vfd_swmr_t *other = (H5FD_vfd_swmr_t *)_other; H5P_genplist_t *plist; H5F_vfd_swmr_config_t *config; - bool equal_configs; + hbool_t equal_configs; if (H5FD_cmp(self->hdf5_file_lf, other->hdf5_file_lf) != 0) return _other; @@ -589,7 +576,7 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) return NULL; } - if ((config = malloc(sizeof(*config))) == NULL) { + if ((config = H5MM_malloc(sizeof(*config))) == NULL) { HERROR(H5E_ARGS, H5E_BADTYPE, "could not allocate config"); return NULL; } @@ -598,9 +585,9 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) return NULL; } - equal_configs = memcmp(&self->config, config, sizeof(*config)) == 0; + equal_configs = HDmemcmp(&self->config, config, sizeof(*config)) == 0; - free(config); + H5MM_xfree(config); if (equal_configs) return _self; @@ -856,11 +843,7 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, target_page = addr / fs_page_size; entry = vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, - false); - - hlog_fast(swmr_read, "%s: enter type %d addr %" PRIuHADDR " size %zu " - "file %s", __func__, type, addr, size, - (entry == NULL) ? "lower" : "shadow"); + FALSE); if (entry == NULL) { /* Cannot find addr in index, read from the underlying hdf5 file */ @@ -926,31 +909,15 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, * is John's hack to allow the library to find the superblock * signature. */ - if (!file->pb_configured) { - hlog_fast(swmr_read_exception, - "%s: skipping checksum, page buffer not configured", __func__); - } else if (entry->length != init_size) { - hlog_fast(swmr_read_exception, - "%s: skipping checksum, buffer size != entry size", __func__); - } else if (H5_checksum_metadata(buf, entry->length, 0) != entry->chksum) { + if (file->pb_configured && entry->length == init_size + && H5_checksum_metadata(buf, entry->length, 0) != entry->chksum) { H5FD_vfd_swmr_md_header tmp_header; - hlog_fast(swmr_read_err, "%s: bad checksum", __func__); - hlog_fast(swmr_read_err, "addr %" PRIuHADDR " page %" PRIuHADDR - " len %zu type %d ...", addr, addr / fs_page_size, init_size, type); - hlog_fast(swmr_read_err, "... index[%" PRId64 "] lower pgno %" PRIu64 - " shadow pgno %" PRIu64 " len %" PRIu32 " sum %" PRIx32, - (int64_t)(entry - index), entry->hdf5_page_offset, - entry->md_file_page_offset, entry->length, entry->chksum); - if (H5FD__vfd_swmr_header_deserialize(file, &tmp_header) != TRUE) { HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "checksum error in shadow file entry; could not load header"); } - hlog_fast(swmr_read_err, "... header tick last read %" PRIu64 - " latest %" PRIu64, file->md_header.tick_num, tmp_header.tick_num); - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "checksum error in shadow file entry"); } @@ -1117,7 +1084,7 @@ done: static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) { - bool do_try; + hbool_t do_try; h5_retry_t retry; H5FD_vfd_swmr_md_header md_header; /* Metadata file header, take 1 */ H5FD_vfd_swmr_md_header md_header_two; /* Metadata file header, take 2 */ @@ -1145,11 +1112,8 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) if (rc != TRUE) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not read header"); - if (md_header.index_offset != last_index_offset) { - hlog_fast(index_motion, "index offset changed %" PRIu64 "\n", - md_header.index_offset); + if (md_header.index_offset != last_index_offset) last_index_offset = md_header.index_offset; - } if (open) ; // ignore tick number on open @@ -1263,13 +1227,13 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, FUNC_ENTER_STATIC /* Set file pointer to the beginning the file */ - if (lseek(file->md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) { + if (HDlseek(file->md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) { HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, \ "unable to seek in metadata file"); } /* Read the header */ - nread = read(file->md_fd, image, H5FD_MD_HEADER_SIZE); + nread = HDread(file->md_fd, image, H5FD_MD_HEADER_SIZE); /* Try again if a signal interrupted the read. */ if (nread == -1 && errno == EINTR) @@ -1287,7 +1251,7 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, HGOTO_DONE(FALSE); /* Verify magic number */ - if (memcmp(image, H5FD_MD_HEADER_MAGIC, H5_SIZEOF_MAGIC) != 0) + if (HDmemcmp(image, H5FD_MD_HEADER_MAGIC, H5_SIZEOF_MAGIC) != 0) HGOTO_DONE(FALSE); /* Verify stored and computed checksums are equal */ @@ -1371,12 +1335,12 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, } /* We may seek past EOF. That's ok, the read(2) will catch that. */ - if (lseek(file->md_fd, (HDoff_t)md_header->index_offset, SEEK_SET) < 0){ + if (HDlseek(file->md_fd, (HDoff_t)md_header->index_offset, SEEK_SET) < 0){ HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file"); } - nread = read(file->md_fd, image, md_header->index_length); + nread = HDread(file->md_fd, image, md_header->index_length); /* Try again if a signal interrupted the read. */ if (nread == -1 && errno == EINTR) @@ -1423,7 +1387,7 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, * read bad magic. It's possible to recover by * re-reading the header. */ - if (memcmp(image, H5FD_MD_INDEX_MAGIC, H5_SIZEOF_MAGIC) != 0) + if (HDmemcmp(image, H5FD_MD_INDEX_MAGIC, H5_SIZEOF_MAGIC) != 0) HGOTO_DONE(FALSE); /* Verify stored and computed checksums are equal */ @@ -1521,7 +1485,7 @@ H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t reload_hdr_and_index, H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ herr_t ret_value = SUCCEED; /* Return value */ - assert(index == NULL || num_entries_ptr != NULL); + HDassert(index == NULL || num_entries_ptr != NULL); FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5FDvfd_swmr.h b/src/H5FDvfd_swmr.h index 86e9d0f..7d3b966 100644 --- a/src/H5FDvfd_swmr.h +++ b/src/H5FDvfd_swmr.h @@ -14,8 +14,8 @@ /* * The public header file for the VFD SWMR driver. */ -#ifndef H5FDswmr_H -#define H5FDswmr_H +#ifndef H5FDvfd_swmr_H +#define H5FDvfd_swmr_H #include "H5api_adpt.h" /* H5_DLL */ #include "H5public.h" /* uint64_t *ahem* */ @@ -34,5 +34,4 @@ H5_DLL herr_t H5Pset_fapl_vfd_swmr(hid_t fapl_id); } #endif -#endif - +#endif /* H5FDvfd_swmr_H */ diff --git a/src/H5FDvfd_swmr_private.h b/src/H5FDvfd_swmr_private.h index 74a937f..e2270b9 100644 --- a/src/H5FDvfd_swmr_private.h +++ b/src/H5FDvfd_swmr_private.h @@ -9,11 +9,10 @@ * help@hdfgroup.org. */ -#ifndef _H5FDvfd_swmr_private_H -#define _H5FDvfd_swmr_private_H +#ifndef H5FDvfd_swmr_private_H +#define H5FDvfd_swmr_private_H #include "H5queue.h" /* for TAILQ_* */ -#include "hlog.h" /* for TAILQ_* */ /* Forward declaration */ struct H5F_t; @@ -64,11 +63,6 @@ typedef TAILQ_HEAD(eot_queue, eot_queue_entry) eot_queue_t; extern eot_queue_t eot_queue_g; -HLOG_OUTLET_DECL(swmr); -HLOG_OUTLET_DECL(pbwr); -HLOG_OUTLET_DECL(shadow_index_reclaim); -HLOG_OUTLET_DECL(mdc_invalidation); - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -80,14 +74,14 @@ H5_DLL herr_t H5F_update_vfd_swmr_metadata_file(struct H5F_t *f, H5_DLL herr_t H5F_vfd_swmr_writer__delay_write(struct H5F_shared_t *, uint64_t, uint64_t *); H5_DLL herr_t H5F_vfd_swmr_writer__prep_for_flush_or_close(struct H5F_t *f); -herr_t H5F_vfd_swmr_process_eot_queue(bool); -H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f, bool); +herr_t H5F_vfd_swmr_process_eot_queue(hbool_t); +H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f, hbool_t); H5_DLL herr_t H5F_vfd_swmr_writer__dump_index(struct H5F_shared_t *); -H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(struct H5F_t *f, bool); +H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(struct H5F_t *f, hbool_t); H5_DLL herr_t H5F_vfd_swmr_remove_entry_eot(struct H5F_t *f); H5_DLL herr_t H5F_vfd_swmr_insert_entry_eot(struct H5F_t *f); H5_DLL void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *); H5_DLL herr_t H5F_dump_eot_queue(void); -#endif /* _H5FDvfd_swmr_private_H */ +#endif /* H5FDvfd_swmr_private_H */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 71d0ce4..260a25c 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -26,9 +26,6 @@ #ifndef _H5Fpkg_H #define _H5Fpkg_H -/* BSD queue macros */ -#include "H5queue.h" - /* Get package's private header */ #include "H5Fprivate.h" diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 555619d..0b0befd 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -48,7 +48,6 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ -#include "hlog.h" /****************/ /* Local Macros */ @@ -85,18 +84,6 @@ unsigned int vfd_swmr_api_entries_g = 0;/* Times the library was entered * on the 0->1 and 1->0 * transitions. */ -HLOG_OUTLET_SHORT_DEFN(swmr, all); -HLOG_OUTLET_SHORT_DEFN(eot, swmr); -HLOG_OUTLET_SHORT_DEFN(eotq, eot); -HLOG_OUTLET_SHORT_DEFN(shadow_defrees, swmr); -HLOG_OUTLET_MEDIUM_DEFN(noisy_shadow_defrees, shadow_defrees, - HLOG_OUTLET_S_OFF); -HLOG_OUTLET_SHORT_DEFN(shadow_index_enlarge, swmr); -HLOG_OUTLET_SHORT_DEFN(shadow_index_reclaim, swmr); -HLOG_OUTLET_SHORT_DEFN(shadow_index_update, swmr); -HLOG_OUTLET_SHORT_DEFN(tick, swmr); -HLOG_OUTLET_SHORT_DEFN(mdc_invalidation, swmr); - /* * The head of the end of tick queue (EOT queue) for files opened in either * VFD SWMR write or VFD SWMR read mode @@ -183,7 +170,7 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) md_size = (hsize_t)shared->vfd_swmr_config.md_pages_reserved * shared->fs_page_size; - assert(shared->fs_page_size >= H5FD_MD_HEADER_SIZE); + HDassert(shared->fs_page_size >= H5FD_MD_HEADER_SIZE); /* Allocate an entire page from the shadow file for the header. */ if ((hdr_addr = H5MV_alloc(f, shared->fs_page_size)) == HADDR_UNDEF){ @@ -246,12 +233,9 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "unable to load/decode metadata file"); - assert(shared->tick_num != 0); + HDassert(shared->tick_num != 0); vfd_swmr_reader_did_increase_tick_to(shared->tick_num); - hlog_fast(tick, "%s first tick %" PRIu64, - __func__, shared->tick_num); - #if 0 /* JRM */ HDfprintf(stderr, "##### initialized index: tick/used/len = %lld/%d/%d #####\n", @@ -347,9 +331,8 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) TAILQ_REMOVE(&shared->shadow_defrees, curr, link); H5FL_FREE(shadow_defree_t, curr); } - hlog_fast(shadow_defrees, "Emptied deferred shadow frees."); - assert(TAILQ_EMPTY(&shared->shadow_defrees)); + HDassert(TAILQ_EMPTY(&shared->shadow_defrees)); } else { /* For file flush */ /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, TRUE) < 0) @@ -372,9 +355,6 @@ shadow_range_defer_free(H5F_shared_t *shared, uint64_t offset, uint32_t length) shadow_defree->length = length; shadow_defree->tick_num = shared->tick_num; - if (TAILQ_EMPTY(&shared->shadow_defrees)) - hlog_fast(shadow_defrees, "Adding first deferred shadow free."); - TAILQ_INSERT_HEAD(&shared->shadow_defrees, shadow_defree, link); return 0; } @@ -432,7 +412,7 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, haddr_t md_addr; /* Address in the metadata file */ uint32_t i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - bool queue_was_nonempty; + hbool_t queue_was_nonempty; FUNC_ENTER_NOAPI(FAIL) @@ -441,7 +421,7 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, HDqsort(index, num_entries, sizeof(*index), H5F__idx_entry_cmp); /* Assert that no HDF5 page offsets are duplicated. */ for (i = 1; i < num_entries; i++) - assert(index[i - 1].hdf5_page_offset < index[i].hdf5_page_offset); + HDassert(index[i - 1].hdf5_page_offset < index[i].hdf5_page_offset); } /* For each non-null entry_ptr in the index: @@ -474,10 +454,6 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, \ "error in allocating space from the metadata file") - hlog_fast(noisy_shadow_defrees, - "shadow index %" PRIu32 " page offset %" PRIu64 " -> %" PRIuHADDR, - i, index[i].md_file_page_offset * shared->fs_page_size, md_addr); - HDassert(md_addr % shared->fs_page_size == 0); /* Compute checksum and update the index entry */ @@ -558,20 +534,12 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, "unable to flush clean entry"); } - hlog_fast(noisy_shadow_defrees, - "released %" PRIu32 " bytes at %" PRIu64, - shadow_defree->length, shadow_defree->offset); - TAILQ_REMOVE(&shared->shadow_defrees, shadow_defree, link); H5FL_FREE(shadow_defree_t, shadow_defree); } - if (queue_was_nonempty && TAILQ_EMPTY(&shared->shadow_defrees)) - hlog_fast(shadow_defrees, "Removed last deferred shadow free."); - done: - FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_update_vfd_swmr_metadata_file() */ @@ -644,7 +612,7 @@ H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, ie_ptr = NULL; } else { ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, - shared->mdf_idx_entries_used, page, false); + shared->mdf_idx_entries_used, page, FALSE); } if (ie_ptr == NULL) @@ -710,7 +678,7 @@ H5F_vfd_swmr_writer__prep_for_flush_or_close(H5F_t *f) * tick so as to avoid attempts to flush entries on the page buffer * tick list that were modified during the current tick. */ - if ( H5F_vfd_swmr_writer_end_of_tick(f, true) < 0 ) + if ( H5F_vfd_swmr_writer_end_of_tick(f, TRUE) < 0 ) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ "H5F_vfd_swmr_writer_end_of_tick() failed.") @@ -740,21 +708,10 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, for (i = j = ndeleted = 0; i < nentries; i++) { ie = &idx[i]; - if (ie->clean) { - hlog_fast(shadow_index_reclaim, - "Visiting clean shadow index slot %" PRIu32 - " lower page %" PRIu64 " last flush %" PRIu64 " ticks ago", - i, ie->hdf5_page_offset, tick_num - ie->tick_of_last_flush); - } - if (ie->clean && ie->tick_of_last_flush + max_lag < tick_num) { - assert(!ie->garbage); - assert(ie->entry_ptr == NULL); - - hlog_fast(shadow_index_reclaim, - "Reclaiming shadow index slot %" PRIu32 - " lower page %" PRIu64, i, ie->hdf5_page_offset); + HDassert(!ie->garbage); + HDassert(ie->entry_ptr == NULL); if (ie->md_file_page_offset != 0) { if (shadow_image_defer_free(shared, ie) == -1) @@ -832,7 +789,7 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, bool wait_for_reader) +H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) { H5F_shared_t *shared = f->shared; uint32_t idx_entries_added = 0; @@ -841,7 +798,7 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, bool wait_for_reader) uint32_t idx_ent_not_in_tl = 0; uint32_t idx_ent_not_in_tl_flushed = 0; herr_t ret_value = SUCCEED; /* Return value */ - bool incr_tick = false; + hbool_t incr_tick = FALSE; FUNC_ENTER_NOAPI(FAIL) @@ -853,7 +810,7 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, bool wait_for_reader) wait_for_reader)) goto update_eot; - incr_tick = true; + incr_tick = TRUE; /* 1) If requested, flush all raw data to the HDF5 file. * @@ -992,9 +949,6 @@ update_eot: if(H5F_vfd_swmr_insert_entry_eot(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") - hlog_fast(eot, "%s leave tick %" PRIu64 " idx len %" PRIu32, - __func__, shared->tick_num, shared->mdf_idx_entries_used); - done: FUNC_LEAVE_NOAPI(ret_value) } @@ -1093,7 +1047,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) +H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) { uint64_t tmp_tick_num = 0; H5FD_vfd_swmr_idx_entry_t * tmp_mdf_idx; @@ -1119,10 +1073,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) HDassert(!shared->vfd_swmr_writer); HDassert(file); - hlog_fast(eot, "%s enter file %p index len %" PRIu32 " used %" PRIu32, - __func__, (void *)file, - shared->mdf_idx_len, shared->mdf_idx_entries_used); - /* 1) Direct the VFD SWMR reader VFD to load the current header * from the metadata file, and report the current tick. * @@ -1135,14 +1085,10 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, \ "error in retrieving tick_num from driver") - hlog_fast(tick, - "%s last tick %" PRIu64 " new tick %" PRIu64, - __func__, shared->tick_num, tmp_tick_num); - /* This is ok if we're entering the API, but it should * not happen if we're exiting the API. */ - assert(entering_api || tmp_tick_num < + HDassert(entering_api || tmp_tick_num < shared->tick_num + shared->vfd_swmr_config.max_lag); if (!entering_api) { @@ -1244,14 +1190,7 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) * case where the new entry is *longer*, because the * extension could overlap with a second entry. */ - assert(oent->length == nent->length); - - hlog_fast(shadow_index_update, - "shadow page for slot %" PRIu32 " lower page %" PRIu64 - " moved, %" PRIu64 " -> %" PRIu64, i, - oent->hdf5_page_offset, - oent->md_file_page_offset, - nent->md_file_page_offset); + HDassert(oent->length == nent->length); /* the page has been altered -- evict it and * any contained metadata cache entries. @@ -1274,10 +1213,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) * for several ticks, we can probably omit this. However, * lets not worry about this for the first cut. */ - hlog_fast(shadow_index_update, - "writer removed shadow index slot %" PRIu32 - " for page %" PRIu64, i, oent->hdf5_page_offset); - change[nchanges].pgno = oent->hdf5_page_offset; change[nchanges].length = oent->length; nchanges++; @@ -1288,10 +1223,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) * nent->hdf5_page_offset */ - hlog_fast(shadow_index_update, - "writer added shadow index slot %" PRIu32 - " for page %" PRIu64, j, nent->hdf5_page_offset); - /* The page has been added to the index. */ change[nchanges].pgno = nent->hdf5_page_offset; change[nchanges].length = nent->length; @@ -1303,9 +1234,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) for (; j < new_mdf_idx_entries_used; j++) { const H5FD_vfd_swmr_idx_entry_t *nent = &new_mdf_idx[j]; - hlog_fast(shadow_index_update, - "writer added shadow index slot %" PRIu32 - " for page %" PRIu64, j, nent->hdf5_page_offset); change[nchanges].pgno = nent->hdf5_page_offset; change[nchanges].length = nent->length; nchanges++; @@ -1320,11 +1248,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) * index. Evict it from the page buffer and also evict any * contained metadata cache entries */ - - hlog_fast(shadow_index_update, - "writer removed shadow index slot %" PRIu32 - " for page %" PRIu64, i, oent->hdf5_page_offset); - change[nchanges].pgno = oent->hdf5_page_offset; change[nchanges].length = oent->length; nchanges++; @@ -1339,10 +1262,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) } } for (i = 0; i < nchanges; i++) { - hlog_fast(mdc_invalidation, - "invalidating MDC entries at page %" PRIu64 - " length %" PRIu32 " tick %" PRIu64, - change[i].pgno, change[i].length, tmp_tick_num); if (H5C_evict_or_refresh_all_entries_in_page(f, change[i].pgno, change[i].length, tmp_tick_num) < 0) { @@ -1387,16 +1306,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api) done: - hlog_fast(eot, "%s exit tick %" PRIu64 - " len %" PRIu32 " -> %" PRIu32 - " used %" PRIu32 " -> %" PRIu32 - " added %" PRIu32 " removed %" PRIu32 " moved %" PRIu32 " %s", - __func__, shared->tick_num, - shared->old_mdf_idx_len, shared->mdf_idx_len, - shared->old_mdf_idx_entries_used, shared->mdf_idx_entries_used, - entries_added, entries_removed, entries_moved, - (ret_value == SUCCEED) ? "success" : "failure"); - if (change != NULL) free(change); @@ -1415,12 +1324,6 @@ insert_eot_entry(eot_queue_entry_t *entry_ptr) break; } - hlog_fast(eotq, "%s: entry %p after %p file %p " - "tick %" PRIu64 " ending %jd.%09ld", __func__, - (void *)entry_ptr, (void *)prec_ptr, (void *)entry_ptr->vfd_swmr_file, - entry_ptr->tick_num, (intmax_t)entry_ptr->end_of_tick.tv_sec, - entry_ptr->end_of_tick.tv_nsec); - /* Insert the entry onto the EOT queue */ if (prec_ptr != NULL) TAILQ_INSERT_AFTER(&eot_queue_g, prec_ptr, entry_ptr, link); @@ -1441,20 +1344,10 @@ H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry) TAILQ_REMOVE(&eot_queue_g, entry, link); - hlog_fast(eotq, "%s: updating entry %p file %p " - "tick %" PRIu64 " ending %jd.%09ld", __func__, - (void *)entry, (void *)entry->vfd_swmr_file, - entry->tick_num, (intmax_t)entry->end_of_tick.tv_sec, - entry->end_of_tick.tv_nsec); - - assert(entry->vfd_swmr_writer == shared->vfd_swmr_writer); + HDassert(entry->vfd_swmr_writer == shared->vfd_swmr_writer); entry->tick_num = shared->tick_num; entry->end_of_tick = shared->end_of_tick; - hlog_fast(eotq, "%s: ... to tick %" PRIu64 " ending %jd.%09ld", __func__, - entry->tick_num, (intmax_t)entry->end_of_tick.tv_sec, - entry->end_of_tick.tv_nsec); - insert_eot_entry(entry); } @@ -1487,11 +1380,6 @@ H5F_vfd_swmr_remove_entry_eot(H5F_t *f) } if (curr != NULL) { - hlog_fast(eotq, "%s: entry %p file %p " - "tick %" PRIu64 " ending %jd.%09ld", __func__, - (void *)curr, (void *)curr->vfd_swmr_file, curr->tick_num, - (intmax_t)curr->end_of_tick.tv_sec, - curr->end_of_tick.tv_nsec); TAILQ_REMOVE(&eot_queue_g, curr, link); curr = H5FL_FREE(eot_queue_entry_t, curr); } @@ -1614,10 +1502,14 @@ H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, FUNC_ENTER_STATIC /* Get current time in struct timespec */ - if ( HDclock_gettime(CLOCK_MONOTONIC, &curr) < 0 ) - - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, \ - "can't get time via clock_gettime") +#ifdef H5_HAVE_WIN32_API + if (timespec_get(&curr, TIME_UTC) != TIME_UTC) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); +#else + if (HDclock_gettime(CLOCK_MONOTONIC, &curr) < 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); + } +#endif /* Convert curr to nsecs */ curr_nsecs = curr.tv_sec * nanosecs_per_second + curr.tv_nsec; @@ -1632,9 +1524,6 @@ H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, shared->tick_num++; - hlog_fast(tick, "%s tick %" PRIu64 " -> %" PRIu64, - __func__, shared->tick_num - 1, shared->tick_num); - if ( H5PB_vfd_swmr__set_tick(shared) < 0 ) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ @@ -1951,8 +1840,6 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) FUNC_ENTER_NOAPI(NULL) - hlog_fast(shadow_index_enlarge, "Enlarging shadow index."); - old_mdf_idx = shared->mdf_idx; old_mdf_idx_len = shared->mdf_idx_len; @@ -1984,7 +1871,7 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) * process of adding entries, and some callers may not update * _entries_used immediately. */ - memcpy(new_mdf_idx, old_mdf_idx, sizeof(new_mdf_idx[0]) * old_mdf_idx_len); + H5MM_memcpy(new_mdf_idx, old_mdf_idx, sizeof(new_mdf_idx[0]) * old_mdf_idx_len); shared->writer_index_offset = idx_addr; ret_value = shared->mdf_idx = new_mdf_idx; @@ -2033,43 +1920,29 @@ H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f) struct timespec req; struct timespec rem; uint64_t tick_in_nsec; - H5F_shared_t *shared = f->shared; + H5F_shared_t *shared; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC + HDassert(f); + shared = f->shared; HDassert(shared->vfd_swmr); HDassert(shared->vfd_swmr_writer); tick_in_nsec = shared->vfd_swmr_config.tick_len * nanosecs_per_tenth_sec; - req.tv_nsec = (long)(tick_in_nsec % nanosecs_per_second); - req.tv_sec = (time_t)(tick_in_nsec / nanosecs_per_second); - - result = HDnanosleep(&req, &rem); - while ( result == -1 ) { + H5_nanosleep(tick_in_nsec); - req = rem; - result = HDnanosleep(&req, &rem); - } - - if ( result != 0 ) - - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "HDnanosleep() failed.") - - if ( H5F_vfd_swmr_writer_end_of_tick(f, false) < 0 ) - - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ - "H5F_vfd_swmr_writer_end_of_tick() failed.") + if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "H5F_vfd_swmr_writer_end_of_tick() failed") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5F__vfd_swmr_writer__wait_a_tick() */ herr_t -H5F_vfd_swmr_process_eot_queue(bool entering_api) +H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) { struct timespec now; eot_queue_entry_t *first_head, *head; @@ -2083,10 +1956,14 @@ H5F_vfd_swmr_process_eot_queue(bool entering_api) H5F_t *f = head->vfd_swmr_file; H5F_shared_t *shared = f->shared; +#ifdef H5_HAVE_WIN32_API + if(timespec_get(&now, TIME_UTC) != TIME_UTC) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); +#else if(HDclock_gettime(CLOCK_MONOTONIC, &now) < 0) { - HGOTO_ERROR(H5E_FUNC, H5E_CANTGET, FAIL, - "can't get time via clock_gettime"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); } +#endif if(timespeccmp(&now, &head->end_of_tick, <)) break; /* If the H5F_shared_t is labeled with a later EOT time than @@ -2098,7 +1975,7 @@ H5F_vfd_swmr_process_eot_queue(bool entering_api) if (timespeccmp(&head->end_of_tick, &shared->end_of_tick, <)) { H5F_vfd_swmr_update_entry_eot(head); } else if (shared->vfd_swmr_writer) { - if (H5F_vfd_swmr_writer_end_of_tick(f, false) < 0) + if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer"); } else if (H5F_vfd_swmr_reader_end_of_tick(f, entering_api) < 0) { @@ -22,9 +22,6 @@ *------------------------------------------------------------------------- */ -#include "H5queue.h" -#include "hlog.h" - /****************/ /* Module Setup */ /****************/ @@ -46,8 +43,6 @@ #include "H5VMprivate.h" /* Vectors and arrays */ -#include "hlog.h" - /****************/ /* Local Macros */ /****************/ @@ -118,6 +113,9 @@ static herr_t H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type); /* Callbacks */ static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); +/* VFD SWMR */ +static herr_t H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, + haddr_t addr, hsize_t size); /*********************/ /* Package Variables */ @@ -135,58 +133,38 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -HLOG_OUTLET_DECL(h5mf); -HLOG_OUTLET_SHORT_DEFN(h5mf, all); -HLOG_OUTLET_SHORT_DEFN(h5mf_defer, h5mf); -HLOG_OUTLET_SHORT_DEFN(h5mf_free, h5mf); -HLOG_OUTLET_SHORT_DEFN(h5mf_alloc, h5mf); -HLOG_OUTLET_MEDIUM_DEFN(noisy_h5mf_alloc, h5mf_alloc, HLOG_OUTLET_S_OFF); -HLOG_OUTLET_SHORT_DEFN(h5mf_extend, h5mf); -HLOG_OUTLET_SHORT_DEFN(h5mf_shrink, h5mf); - static herr_t -defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, haddr_t addr, +H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - lower_defree_t *df; + lower_defree_t *df = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC - if ((df = malloc(sizeof(*df))) == NULL) - return FAIL; + if ((df = H5MM_malloc(sizeof(*df))) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate buffer") df->alloc_type = alloc_type; df->addr = addr; df->size = size; df->free_after_tick = shared->tick_num + shared->vfd_swmr_config.max_lag; - hlog_fast(h5mf_defer, - "%s.%d: deferred free at %" PRIuHADDR ", %" PRIuHSIZE - " bytes until tick %" PRIu64, __FILE__, __LINE__, addr, size, - df->free_after_tick); - SIMPLEQ_INSERT_TAIL(&shared->lower_defrees, df, link); - return SUCCEED; -} - -static uint64_t -H5MF_total_deferred_frees(H5F_shared_t *shared) -{ - lower_defree_t *df; - uint64_t total = 0; - - SIMPLEQ_FOREACH(df, &shared->lower_defrees, link) - total += df->size; - - return total; -} +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5MF__defer_free() */ herr_t H5MF_process_deferred_frees(H5F_t *f, const uint64_t tick_num) { lower_defree_t *df; - herr_t err = SUCCEED; H5F_shared_t *shared = f->shared; lower_defree_queue_t defrees = SIMPLEQ_HEAD_INITIALIZER(defrees); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOERR /* Have to empty the queue before processing it because we * could re-enter this routine through H5MF__xfree_impl. If @@ -198,25 +176,19 @@ H5MF_process_deferred_frees(H5F_t *f, const uint64_t tick_num) while ((df = SIMPLEQ_FIRST(&defrees)) != NULL) { if (tick_num <= df->free_after_tick) break; - hlog_fast(h5mf_defer, - "%s.%d: processing free at %" PRIuHADDR ", %" PRIuHSIZE " bytes", - __FILE__, __LINE__, df->addr, df->size); SIMPLEQ_REMOVE_HEAD(&defrees, link); - if (H5MF__xfree_impl(f, df->alloc_type, df->addr, df->size) < 0) - err = FAIL; - free(df); - } - if (err != SUCCEED) { - hlog_fast(h5mf_defer, "%s.%d: error: dropped entries on the floor", - __FILE__, __LINE__); + /* Record errors here, but keep trying to free */ + if (H5MF__xfree_impl(f, df->alloc_type, df->addr, df->size) < 0) + ret_value = FAIL; + H5MM_xfree(df); } - /* Save remaining entries for processing, later. */ + /* Save remaining entries for processing, later */ SIMPLEQ_CONCAT(&shared->lower_defrees, &defrees); - return err; -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5MF_process_deferred_frees() */ /*------------------------------------------------------------------------- @@ -883,11 +855,6 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, HADDR_UNDEF) - hlog_fast(h5mf_alloc, - "%s: enter %p type %u size %" PRIuHSIZE " tick %" PRIu64, - __func__, (void *)f->shared, (unsigned)alloc_type, size, - f->shared->vfd_swmr_writer ? f->shared->tick_num : 0); - /* check arguments */ HDassert(f); HDassert(f->shared); @@ -902,8 +869,6 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) } H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); - hlog_fast(noisy_h5mf_alloc, "%s: Check 1.0", __func__); - /* Set the ring type in the API context */ if(H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; @@ -937,8 +902,6 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) /* If no space is found from the free-space manager, continue further action */ if(!H5F_addr_defined(ret_value)) { - hlog_fast(noisy_h5mf_alloc, "%s: Check 2.0", __func__); - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); if(HADDR_UNDEF == (ret_value = H5MF__alloc_pagefs(f, alloc_type, size))) @@ -951,16 +914,11 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) } /* end if */ HDassert(H5F_addr_defined(ret_value)); - hlog_fast(noisy_h5mf_alloc, "%s: Check 3.0", FUNC); - done: /* Reset the ring in the API context */ if(orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - hlog_fast(h5mf_alloc, - "%s: leave %p type %u addr %" PRIuHADDR " size %" PRIuHSIZE, - __func__, (void *)f->shared, (unsigned)alloc_type, ret_value, size); #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ @@ -1190,12 +1148,7 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) - hlog_fast(h5mf_free, "%s: Entering - alloc_type %u addr %" PRIuHADDR - " size %" PRIuHSIZE " tick %" PRIu64, - __func__, (unsigned)alloc_type, addr, size, - f->shared->vfd_swmr_writer ? f->shared->tick_num : 0); - - /* check arguments */ + /* Check arguments */ HDassert(f); if(!H5F_addr_defined(addr) || 0 == size) HGOTO_DONE(SUCCEED) @@ -1207,7 +1160,7 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) * file starts to close. */ ret_value = H5MF__xfree_impl(f, alloc_type, addr, size); - } else if (defer_free(f->shared, alloc_type, addr, size) < 0) + } else if (H5MF__defer_free(f->shared, alloc_type, addr, size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "could not defer") else if (H5MF_process_deferred_frees(f, f->shared->tick_num) < 0) { HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, @@ -1228,10 +1181,6 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si H5AC_ring_t fsm_ring; /* Ring of FSM */ herr_t ret_value = SUCCEED; /* Return value */ - hlog_fast(h5mf_free, - "%s: enter %p type %u addr %" PRIuHADDR " size %" PRIuHSIZE, - __func__, (void *)f->shared, (unsigned)alloc_type, addr, size); - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); @@ -1272,25 +1221,16 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si * space is at the end of the file */ - hlog_fast(h5mf_free, "%s: fs_addr %" PRIuHADDR, __func__, - f->shared->fs_addr[fs_type]); - if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) { htri_t status; /* "can absorb" status for section into */ - hlog_fast(h5mf_free, "%s: Trying to avoid starting up free space manager", __func__); - /* Try to shrink the file or absorb the block into a block aggregator */ if((status = H5MF_try_shrink(f, alloc_type, addr, size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check for absorbing block") else if(status > 0) HGOTO_DONE(SUCCEED) - else if(size < f->shared->fs_threshold) { - hlog_fast(h5mf_free, "%s: dropping addr %" PRIuHADDR - " size %" PRIuHSIZE " on the floor!", - __func__, addr, size); - HGOTO_DONE(SUCCEED) - } + else if(size < f->shared->fs_threshold) + HGOTO_DONE(SUCCEED) } /* If we are deleting the free space manager, leave now, to avoid @@ -1304,8 +1244,6 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si */ if(f->shared->fs_state[fs_type] == H5F_FS_STATE_DELETING || !H5F_HAVE_FREE_SPACE_MANAGER(f)) { - hlog_fast(h5mf_free, "%s: dropping addr %" PRIuHADDR - " size %" PRIuHSIZE " on the floor!", __func__, addr, size); HGOTO_DONE(SUCCEED) } @@ -1326,14 +1264,11 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si if(size >= f->shared->fs_threshold) { HDassert(f->shared->fs_man[fs_type]); - hlog_fast(h5mf_free, "%s: Before H5FS_sect_add()", __func__); - /* Add to the free space for the file */ if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't add section to file free space") node = NULL; - hlog_fast(h5mf_free, "%s: After H5FS_sect_add()", __func__); } else { htri_t merged; /* Whether node was merged */ H5MF_sect_ud_t udata; /* User data for callback */ @@ -1362,9 +1297,6 @@ done: if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") - hlog_fast(h5mf_free, - "%s: %p leave %d", __func__, (void *)f->shared, ret_value); - #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ @@ -1460,10 +1392,6 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) - hlog_fast(h5mf_extend, "%s: Entering: alloc_type %u addr %" PRIuHADDR - " size %" PRIuHSIZE " extra_requested %" PRIuHSIZE, __func__, - (unsigned)alloc_type, addr, size, extra_requested); - /* Sanity check */ HDassert(f); HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); @@ -1511,9 +1439,6 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, if((ret_value = H5F__try_extend(f, map_type, end, extra_requested + frag_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") - hlog_fast(h5mf_extend, "%s: extended %s", __func__, - htri_to_string(ret_value)); - /* If extending at EOA succeeds: */ /* for paged aggregation, put the fragment into the large-sized free-space manager */ if(ret_value == TRUE && H5F_PAGED_AGGR(f) && frag_size) { @@ -1547,9 +1472,6 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); if((ret_value = H5MF__aggr_try_extend(f, aggr, map_type, end, extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending aggregation block") - - hlog_fast(h5mf_extend, "%s: H5MF__aggr_try_extend %s", __func__, - htri_to_string(ret_value)); } /* If no extension so far, try to extend into a free-space section */ @@ -1572,8 +1494,6 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, if((ret_value = H5FS_sect_try_extend(f, f->shared->fs_man[fs_type], addr, size, extra_requested, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") - hlog_fast(h5mf_extend, "%s: Try to H5FS_sect_try_extend %s", - __func__, htri_to_string(ret_value)); } /* For paged aggregation and a metadata block: try to extend into page end threshold */ @@ -1582,8 +1502,6 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, if(frag_size <= H5F_PGEND_META_THRES(f) && extra_requested <= frag_size) ret_value = TRUE; - - hlog_fast(h5mf_extend, "%s: Try to extend into the page end threshold %s", __func__, htri_to_string(ret_value)); } } } @@ -1593,9 +1511,6 @@ done: if(orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - - hlog_fast(h5mf_extend, "%s: Leaving: ret_value %s", __func__, htri_to_string(ret_value)); - #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ @@ -1631,9 +1546,6 @@ H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) - hlog_fast(h5mf_shrink, "%s: Entering - alloc_type %u addr %" PRIuHADDR - " size %" PRIuHSIZE, __func__, (unsigned)alloc_type, addr, size); - /* check arguments */ HDassert(f); HDassert(f->shared); @@ -1686,9 +1598,6 @@ done: if(node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") - hlog_fast(h5mf_shrink, "%s: Leaving, ret_value %d", __func__, - ret_value); - FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_try_shrink() */ @@ -1712,15 +1621,10 @@ H5MF_close(H5F_t *f) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) - hlog_fast(h5mf, "%s: entering", __func__); - /* check args */ HDassert(f); HDassert(f->shared); - hlog_fast(h5mf, "%s: total deferred frees %" PRIu64, __func__, - H5MF_total_deferred_frees(f->shared)); - if(H5F_PAGED_AGGR(f)) { if((ret_value = H5MF__close_pagefs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'page' file space") @@ -1730,8 +1634,6 @@ H5MF_close(H5F_t *f) } /* end else */ done: - hlog_fast(h5mf, "%s: leaving", __func__); - FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_close() */ diff --git a/src/H5MFsection.c b/src/H5MFsection.c index 1b9e756..6d23748 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -829,10 +829,10 @@ H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, HDassert(sect2); HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ if (!H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)) { - fprintf(stderr, "%s.%d: sect1->sect_info.addr %" PRIuHADDR + HDfprintf(stderr, "%s.%d: sect1->sect_info.addr %" PRIuHADDR ", sect2->sect_info.addr %" PRIuHADDR "\n", __func__, __LINE__, sect1->sect_info.addr, sect2->sect_info.addr); - fprintf(stderr, "%s.%d: sect1->sect_info.size %" PRIuHSIZE + HDfprintf(stderr, "%s.%d: sect1->sect_info.size %" PRIuHSIZE ", sect2->sect_info.size %" PRIuHSIZE "\n", __func__, __LINE__, sect1->sect_info.size, sect2->sect_info.size); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't merge") @@ -40,7 +40,6 @@ #include "H5MVpkg.h" /* File memory management */ #include "H5VMprivate.h" /* Vectors and arrays */ -#include "hlog.h" /****************/ /* Local Macros */ @@ -96,8 +95,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -HLOG_OUTLET_SHORT_DEFN(h5mv, all); - /*------------------------------------------------------------------------- * Function: H5MV__create() @@ -283,7 +280,6 @@ H5MV_alloc(H5F_t *f, hsize_t size) haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) - hlog_fast(h5mv, "%s: enter size %" PRIuHSIZE, __func__, size); /* check arguments */ HDassert(shared->vfd_swmr_md_fd >= 0); @@ -336,9 +332,6 @@ H5MV_alloc(H5F_t *f, hsize_t size) HDassert(H5F_addr_defined(ret_value)); done: - hlog_fast(h5mv, "%s: leave addr %" PRIuHADDR " size %" PRIuHSIZE, - __func__, ret_value, size); - FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_alloc() */ @@ -363,9 +356,6 @@ H5MV_free(H5F_t *f, haddr_t addr, hsize_t size) FUNC_ENTER_NOAPI(FAIL) - hlog_fast(h5mv, "%s: enter addr %" PRIuHADDR " size %" PRIuHSIZE, - __func__, addr, size); - /* check arguments */ HDassert(f); if(!H5F_addr_defined(addr) || 0 == size) @@ -381,9 +371,6 @@ H5MV_free(H5F_t *f, haddr_t addr, hsize_t size) */ htri_t status; /* "can absorb" status for section into */ - hlog_fast(h5mv, "%s: trying to avoid starting up free space manager", - __func__); - /* Try to shrink the file */ if((status = H5MV_try_shrink(f, addr, size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check for absorbing block") @@ -393,11 +380,8 @@ H5MV_free(H5F_t *f, haddr_t addr, hsize_t size) /* If we are deleting the free space manager, leave now, to avoid * [re-]starting it: dropping free space section on the floor. */ - if(shared->fs_state_md == H5F_FS_STATE_DELETING) { - hlog_fast(h5mv, "%s: dropping addr %" PRIuHADDR - " size %" PRIuHSIZE " on the floor!", __func__, addr, size); + if(shared->fs_state_md == H5F_FS_STATE_DELETING) HGOTO_DONE(SUCCEED) - } /* There's either already a free space manager, or the freed * space isn't at the end of the file, so start up (or create) @@ -413,25 +397,18 @@ H5MV_free(H5F_t *f, haddr_t addr, hsize_t size) HDassert(shared->fs_man_md); - hlog_fast(h5mv, "%s: before H5FS_sect_add, addr %" PRIuHADDR - " size %" PRIuHSIZE, __func__, addr, size); - /* Add the section */ if(H5FS_sect_add(f, shared->fs_man_md, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") node = NULL; - hlog_fast(h5mv, "%s: after H5FS_sect_add", __func__); - done: /* Release section node, if allocated and not added to section list or merged */ if(node) if(H5MV__sect_free(&node->sect_info) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") - hlog_fast(h5mv, "%s: leave %d", __func__, ret_value); - FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_free() */ @@ -45,8 +45,6 @@ #include "H5PBpkg.h" /* File access */ -#include "hlog.h" - /****************/ /* Local Macros */ /****************/ @@ -91,7 +89,7 @@ static herr_t H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, static void H5PB__deallocate_page(H5PB_entry_t *entry_ptr); -static herr_t H5PB__evict_entry(H5F_shared_t *, H5PB_entry_t *, bool, bool); +static herr_t H5PB__evict_entry(H5F_shared_t *, H5PB_entry_t *, hbool_t, hbool_t); static herr_t H5PB__flush_entry(H5F_shared_t *, H5PB_t *, H5PB_entry_t *); @@ -143,17 +141,6 @@ H5FL_DEFINE_STATIC(H5PB_t); /* Declare a free list to manage the H5PB_entry_t struct */ H5FL_DEFINE_STATIC(H5PB_entry_t); -HLOG_OUTLET_DECL(pagebuffer); -HLOG_OUTLET_SHORT_DEFN(pagebuffer, all); -HLOG_OUTLET_SHORT_DEFN(pb_access_sizes, pagebuffer); -HLOG_OUTLET_SHORT_DEFN(pbflush, pagebuffer); -HLOG_OUTLET_SHORT_DEFN(pbflush_entry, pbflush); -HLOG_OUTLET_SHORT_DEFN(pbio, pagebuffer); -HLOG_OUTLET_SHORT_DEFN(pbrd, pbio); -HLOG_OUTLET_SHORT_DEFN(pbwr, pbio); -HLOG_OUTLET_SHORT_DEFN(lengthen_pbentry, pagebuffer); -HLOG_OUTLET_SHORT_DEFN(pbrm, pagebuffer); - /*------------------------------------------------------------------------- * @@ -773,7 +760,7 @@ H5PB_dest(H5F_shared_t *shared) "Can't flush entry") } - if ( H5PB__evict_entry(shared, evict_ptr, TRUE, true) < 0 ) + if ( H5PB__evict_entry(shared, evict_ptr, TRUE, TRUE) < 0 ) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "forced eviction failed") @@ -862,19 +849,11 @@ H5PB_flush(H5F_shared_t *shared) flush_ptr = entry_ptr; entry_ptr = entry_ptr->ht_next; - hlog_fast(pbflush, "%s: visiting %zu-byte page %" PRIu64, - __func__, flush_ptr->size, flush_ptr->page); if ( flush_ptr->is_dirty ) { - if (flush_ptr->delay_write_until != 0) { - hlog_fast(pbflush, "%s: delaying %zu-byte page %" PRIu64 - " until %" PRIu64 " (now %" PRIu64 ")", - __func__, flush_ptr->size, flush_ptr->page, - flush_ptr->delay_write_until, - shared->tick_num); + if (flush_ptr->delay_write_until != 0) continue; - } if ( H5PB__flush_entry(shared, pb_ptr, flush_ptr) < 0 ) @@ -967,20 +946,10 @@ H5PB_log_access_by_size_counts(const H5PB_t *pb) const size_t nslots = NELMTS(pb->access_size_count); size_t i, lo, hi; - hlog_fast(pb_access_sizes, "page buffer %p metadata accesses by size:", - (const void *)pb); - for (lo = 0, hi = pb->page_size, i = 0; i < nslots - 1; i++, lo = hi + 1, hi *= 2) { - hlog_fast(pb_access_sizes, - "%16" PRIu64 " accesses %8zu - %8zu bytes long", - pb->access_size_count[i], lo, hi); } - - hlog_fast(pb_access_sizes, - "%16" PRIu64 " accesses %8zu - greater bytes long", - pb->access_size_count[i], lo); } @@ -1179,10 +1148,6 @@ H5PB_read(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, /* Sanity checks */ HDassert(shared); - hlog_fast(pbrd, "%s %p type %d %" PRIuHADDR " size %zu", - __func__, (void *)shared, type, addr, size); - - pb_ptr = shared->pb_ptr; if (pb_ptr != NULL && type != H5FD_MEM_DRAW) @@ -1488,13 +1453,13 @@ done: * this routine performs an O(n) copy of index entries. */ static int -shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, bool only_mark) +shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) { ptrdiff_t i; H5FD_vfd_swmr_idx_entry_t *entry; entry = vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, - shared->mdf_idx_entries_used, page, false); + shared->mdf_idx_entries_used, page, FALSE); if (entry == NULL) return 0; @@ -1506,7 +1471,7 @@ shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, bool only_mark) } if (only_mark) { - entry->garbage = true; + entry->garbage = TRUE; return 0; } @@ -1515,7 +1480,7 @@ shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, bool only_mark) if (shared->mdf_idx_entries_used > i + 1) { const size_t ntocopy = (size_t)(shared->mdf_idx_entries_used - (i + 1)); - memmove(&shared->mdf_idx[i], + HDmemmove(&shared->mdf_idx[i], &shared->mdf_idx[i + 1], ntocopy * sizeof(shared->mdf_idx[i + 1])); } @@ -1625,11 +1590,11 @@ H5PB_remove_entry(H5F_shared_t *shared, haddr_t addr) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "mark entry clean failed") - if ( H5PB__evict_entry(shared, entry_ptr, TRUE, false) < 0 ) + if ( H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0 ) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "forced eviction failed") - assert(!shared->vfd_swmr_writer || vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, false) == NULL); + HDassert(!shared->vfd_swmr_writer || vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, FALSE) == NULL); } done: @@ -1959,7 +1924,7 @@ H5PB_vfd_swmr__release_delayed_writes(H5F_shared_t *shared) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ "flush of mpmde failed") - if ( H5PB__evict_entry(shared, entry_ptr, TRUE, false) < 0 ) + if ( H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0 ) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "eviction of mpmde failed") @@ -2038,7 +2003,7 @@ H5PB_vfd_swmr__release_tick_list(H5F_shared_t *shared) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ "flush of mpmde failed") - if ( H5PB__evict_entry(shared, entry_ptr, TRUE, false) < 0 ) + if ( H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0 ) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "eviction of mpmde failed") @@ -2252,7 +2217,7 @@ H5PB_vfd_swmr__update_index(H5F_t *f, /* see if the shadow index already contains an entry for *entry. */ ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, - shared->mdf_idx_entries_used, target_page, false); + shared->mdf_idx_entries_used, target_page, FALSE); if ( ie_ptr == NULL ) { /* alloc new entry in the metadata file index*/ uint32_t new_index_entry_index; @@ -2266,7 +2231,7 @@ H5PB_vfd_swmr__update_index(H5F_t *f, "\n\nmax mdf index len (%" PRIu32 ") exceeded.\n\n", shared->mdf_idx_len); HDfprintf(stderr, "tick = %" PRIu64 ".\n", tick_num); - exit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } ie_ptr = idx + new_index_entry_index; @@ -2280,8 +2245,8 @@ H5PB_vfd_swmr__update_index(H5F_t *f, /* ie_ptr->clean initialized below */ /* ie_ptr->tick_of_last_flush initialized below */ ie_ptr->delayed_flush = entry->delay_write_until; - ie_ptr->moved_to_lower_file = false; - ie_ptr->garbage = false; + ie_ptr->moved_to_lower_file = FALSE; + ie_ptr->garbage = FALSE; ie_ptr->length = (uint32_t)entry->size; } else { @@ -2305,8 +2270,8 @@ H5PB_vfd_swmr__update_index(H5F_t *f, ie_ptr->entry_ptr = entry->image_ptr; ie_ptr->tick_of_last_change = tick_num; - assert(entry->is_dirty); - ie_ptr->clean = false; + HDassert(entry->is_dirty); + ie_ptr->clean = FALSE; ie_ptr->tick_of_last_flush = 0; } @@ -2333,9 +2298,6 @@ H5PB_vfd_swmr__update_index(H5F_t *f, H5PB__SEARCH_INDEX(pb_ptr, ie_ptr->hdf5_page_offset, entry, FAIL); if (entry == NULL || !entry->is_dirty) { - hlog_fast(shadow_index_reclaim, - "Marking shadow index slot %" PRIu32 " clean at tick %" PRIu64, - i, tick_num); idx_ent_not_in_tl_flushed++; ie_ptr->clean = TRUE; ie_ptr->tick_of_last_flush = tick_num; @@ -2522,9 +2484,6 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, FUNC_ENTER_NOAPI(FAIL) - hlog_fast(pbwr, "%s %p type %d addr %" PRIuHADDR " size %zu", - __func__, (void *)shared, type, addr, size); - pb_ptr = shared->pb_ptr; if (pb_ptr != NULL && type != H5FD_MEM_DRAW) @@ -3188,8 +3147,8 @@ H5PB__deallocate_page(H5PB_entry_t *entry_ptr) *------------------------------------------------------------------------- */ static herr_t -H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, bool force, - bool only_mark) +H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, + hbool_t only_mark) { H5PB_t *pb_ptr = shared->pb_ptr; herr_t ret_value = SUCCEED; /* Return value */ @@ -3338,10 +3297,6 @@ H5PB__flush_entry(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *const entr HDassert((pb_ptr->vfd_swmr_writer) || (!(entry_ptr->is_mpmde))); HDassert(0 == entry_ptr->delay_write_until); - hlog_fast(pbflush_entry, - "%s: flushing %zu-byte page %" PRIu64 " @ %" PRIuHADDR, - __func__, entry_ptr->size, entry_ptr->page, entry_ptr->addr); - /* Retrieve the 'eoa' for the file */ if ( HADDR_UNDEF == (eoa = H5FD_get_eoa(shared->lf, entry_ptr->mem_type)) ) @@ -3688,7 +3643,7 @@ H5PB__make_space(H5F_shared_t *shared, H5PB_t *pb_ptr, H5FD_mem_t inserted_type) evict_ptr = search_ptr; search_ptr = search_ptr->prev; - if ( H5PB__evict_entry(shared, evict_ptr, FALSE, false) < 0 ) + if ( H5PB__evict_entry(shared, evict_ptr, FALSE, FALSE) < 0 ) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ "Can't evict entry") @@ -4153,7 +4108,7 @@ H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert( ! ( entry_ptr->is_dirty ) ); if ( H5PB__evict_entry(shared, entry_ptr, - TRUE, false) < 0 ) + TRUE, FALSE) < 0 ) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "forced eviction failed (1)") @@ -4718,14 +4673,9 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, uint64_t last_page = page + roundup(size, pb_ptr->page_size) / pb_ptr->page_size; - hlog_fast(lengthen_pbentry, - "lengthening page %" PRIu64 " from %zu bytes to %zu, " - "last page %" PRIu64 "\n", page, entry_ptr->size, size, - last_page); - for (iter_page = page + 1; iter_page < last_page; iter_page++) { H5PB__SEARCH_INDEX(pb_ptr, iter_page, overlap, FAIL) - assert(overlap == NULL); + HDassert(overlap == NULL); } if (new_image == NULL) { HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, @@ -4742,7 +4692,7 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); entry_ptr->image_ptr = new_image; - entry_ptr->is_mpmde = true; + entry_ptr->is_mpmde = TRUE; entry_ptr->size = size; if (entry_ptr->modified_this_tick) @@ -4819,7 +4769,7 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, * already present. */ if (pb_ptr->vfd_swmr_writer && !entry_ptr->modified_this_tick) { - entry_ptr->modified_this_tick = true; + entry_ptr->modified_this_tick = TRUE; H5PB__INSERT_IN_TL(pb_ptr, entry_ptr, FAIL) } @@ -4974,7 +4924,7 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "mark entry clean failed") - if (H5PB__evict_entry(shared, entry_ptr, TRUE, false) < 0) + if (H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "forced eviction failed (1)") diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index 8f60ac4..4fdc0b0 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -342,7 +342,7 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V /* Lookup object */ case H5VL_OBJECT_LOOKUP: { - H5O_token_t *token = va_arg(arguments, H5O_token_t *); + H5O_token_t *token = HDva_arg(arguments, H5O_token_t *); HDassert(token); diff --git a/src/H5private.h b/src/H5private.h index 3e11b4f..66763b2 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -154,6 +154,13 @@ #endif /* + * Needed for dirname and basename on POSIX systems + */ +#ifdef H5_HAVE_LIBGEN_H +#include <libgen.h> +#endif + +/* * Dynamic library handling. These are needed for dynamically loading I/O * filters and VFDs. */ @@ -164,6 +171,13 @@ #include <dirent.h> #endif +/* BSD-style queues + * + * We use a private copy of netBSD's queues instead of including sys/queue.h + * due to irreconcilable differences between different queue implementations. + */ +#include "H5queue.h" + /* Define the default VFD for this platform. * Since the removal of the Windows VFD, this is sec2 for all platforms. */ @@ -727,6 +741,9 @@ typedef struct { #ifndef HDatoll #define HDatoll(S) atoll(S) #endif /* HDatol */ +#ifndef HDbasename + #define HDbasename(P) basename(P) +#endif /* HDbasename */ #ifndef HDbind #define HDbind(A,B,C) bind((A),(B),(C)) /* mirror VFD */ #endif /* HDbind */ @@ -803,6 +820,9 @@ typedef struct { #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) #endif /* H5_HAVE_DIFFTIME */ #endif /* HDdifftime */ +#ifndef HDdirname + #define HDdirname(P) dirname(P) +#endif /* HDdirname */ #ifndef HDdiv #define HDdiv(X,Y) div(X,Y) #endif /* HDdiv */ diff --git a/src/H5queue.h b/src/H5queue.h index 816acca..bef7ef7 100644 --- a/src/H5queue.h +++ b/src/H5queue.h @@ -31,8 +31,29 @@ * @(#)queue.h 8.5 (Berkeley) 8/20/94 */ -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ +#ifndef H5queue_H_ +#define H5queue_H_ + +/* This is a copy of netBSD's sys/queue.h header for use in HDF5. We've copied + * it here instead of using the system's version to avoid incompatibilities. + * The exception is MacOS, where other system headers make use of sys/queue.h + * (this may also be an issue on FreeBSD, et al.). + * + * The deprecated and unwise circular queue macros have been removed from + * this file to discourage their use. + */ + + +/* On MacOS, sys/file.h (needed for flock(3)) includes sys.queue.h, so we + * can't just use an alternative BSD queue implementation without running + * into symbol redefinition errors. + * + * Unfortunately, MacOS is missing SIMPLEQ, so we have to handle that + * separately later in the file. + */ +#if defined(__APPLE__) +#include <sys/queue.h> +#else /* * This file defines five types of data structures: singly-linked lists, @@ -296,106 +317,6 @@ struct { \ } while (/*CONSTCOND*/0) /* - * Simple queue definitions. - */ -#define SIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define SIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define SIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue access methods. - */ -#define SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define SIMPLEQ_END(head) NULL -#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) -#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - -#define SIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var) != SIMPLEQ_END(head); \ - (var) = ((var)->field.sqe_next)) - -#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->sqh_first); \ - (var) != SIMPLEQ_END(head) && \ - ((next = ((var)->field.sqe_next)), 1); \ - (var) = (next)) - -/* - * Simple queue functions. - */ -#define SIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ - if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ - == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - SIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_CONCAT(head1, head2) do { \ - if (!SIMPLEQ_EMPTY((head2))) { \ - *(head1)->sqh_last = (head2)->sqh_first; \ - (head1)->sqh_last = (head2)->sqh_last; \ - SIMPLEQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_LAST(head, type, field) \ - (SIMPLEQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->sqh_last) - offsetof(struct type, field)))) - -/* * Tail queue definitions. */ #define _TAILQ_HEAD(name, type, qual) \ @@ -656,192 +577,106 @@ struct { \ ((struct type *)(void *) \ ((char *)((head)->stqh_last) - offsetof(struct type, field)))) - -#ifndef _KERNEL -/* - * Circular queue definitions. Do not use. We still keep the macros - * for compatibility but because of pointer aliasing issues their use - * is discouraged! - */ +#endif /* defined(__APPLE__) */ /* - * __launder_type(): We use this ugly hack to work around the the compiler - * noticing that two types may not alias each other and elide tests in code. - * We hit this in the CIRCLEQ macros when comparing 'struct name *' and - * 'struct type *' (see CIRCLEQ_HEAD()). Modern compilers (such as GCC - * 4.8) declare these comparisons as always false, causing the code to - * not run as designed. - * - * This hack is only to be used for comparisons and thus can be fully const. - * Do not use for assignment. - * - * If we ever choose to change the ABI of the CIRCLEQ macros, we could fix - * this by changing the head/tail sentinal values, but see the note above - * this one. + * Simple queue definitions. */ -static __inline const void * __launder_type(const void *); -static __inline const void * -__launder_type(const void *__x) -{ - __asm __volatile("" : "+r" (__x)); - return __x; -} - -#if defined(QUEUEDEBUG) -#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \ - if ((head)->cqh_first != CIRCLEQ_ENDC(head) && \ - (head)->cqh_first->field.cqe_prev != CIRCLEQ_ENDC(head)) \ - QUEUEDEBUG_ABORT("CIRCLEQ head forw %p %s:%d", (head), \ - __FILE__, __LINE__); \ - if ((head)->cqh_last != CIRCLEQ_ENDC(head) && \ - (head)->cqh_last->field.cqe_next != CIRCLEQ_ENDC(head)) \ - QUEUEDEBUG_ABORT("CIRCLEQ head back %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \ - if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) { \ - if ((head)->cqh_last != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm last %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } else { \ - if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm forw %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } \ - if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) { \ - if ((head)->cqh_first != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm first %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } else { \ - if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm prev %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } -#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \ - (elm)->field.cqe_next = (void *)1L; \ - (elm)->field.cqe_prev = (void *)1L; -#else -#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) -#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) -#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) -#endif - -#define CIRCLEQ_HEAD(name, type) \ +#define SIMPLEQ_HEAD(name, type) \ struct name { \ - struct type *cqh_first; /* first element */ \ - struct type *cqh_last; /* last element */ \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ } -#define CIRCLEQ_HEAD_INITIALIZER(head) \ - { CIRCLEQ_END(&head), CIRCLEQ_END(&head) } +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } -#define CIRCLEQ_ENTRY(type) \ +#define SIMPLEQ_ENTRY(type) \ struct { \ - struct type *cqe_next; /* next element */ \ - struct type *cqe_prev; /* previous element */ \ + struct type *sqe_next; /* next element */ \ } /* - * Circular queue functions. + * Simple queue access methods. */ -#define CIRCLEQ_INIT(head) do { \ - (head)->cqh_first = CIRCLEQ_END(head); \ - (head)->cqh_last = CIRCLEQ_END(head); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ - (elm)->field.cqe_next = (listelm)->field.cqe_next; \ - (elm)->field.cqe_prev = (listelm); \ - if ((listelm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ - (head)->cqh_last = (elm); \ - else \ - (listelm)->field.cqe_next->field.cqe_prev = (elm); \ - (listelm)->field.cqe_next = (elm); \ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var) != SIMPLEQ_END(head); \ + (var) = ((var)->field.sqe_next)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) != SIMPLEQ_END(head) && \ + ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ - (elm)->field.cqe_next = (listelm); \ - (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ - if ((listelm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ - (head)->cqh_first = (elm); \ - else \ - (listelm)->field.cqe_prev->field.cqe_next = (elm); \ - (listelm)->field.cqe_prev = (elm); \ +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - (elm)->field.cqe_next = (head)->cqh_first; \ - (elm)->field.cqe_prev = CIRCLEQ_END(head); \ - if ((head)->cqh_last == CIRCLEQ_ENDC(head)) \ - (head)->cqh_last = (elm); \ - else \ - (head)->cqh_first->field.cqe_prev = (elm); \ - (head)->cqh_first = (elm); \ +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - (elm)->field.cqe_next = CIRCLEQ_END(head); \ - (elm)->field.cqe_prev = (head)->cqh_last; \ - if ((head)->cqh_first == CIRCLEQ_ENDC(head)) \ - (head)->cqh_first = (elm); \ - else \ - (head)->cqh_last->field.cqe_next = (elm); \ - (head)->cqh_last = (elm); \ +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_REMOVE(head, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \ - if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ - (head)->cqh_last = (elm)->field.cqe_prev; \ - else \ - (elm)->field.cqe_next->field.cqe_prev = \ - (elm)->field.cqe_prev; \ - if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ - (head)->cqh_first = (elm)->field.cqe_next; \ - else \ - (elm)->field.cqe_prev->field.cqe_next = \ - (elm)->field.cqe_next; \ - QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \ +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->cqh_first); \ - (var) != CIRCLEQ_ENDC(head); \ - (var) = ((var)->field.cqe_next)) +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ + if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ + == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) -#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ - for ((var) = ((head)->cqh_last); \ - (var) != CIRCLEQ_ENDC(head); \ - (var) = ((var)->field.cqe_prev)) +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) -/* - * Circular queue access methods. - */ -#define CIRCLEQ_FIRST(head) ((head)->cqh_first) -#define CIRCLEQ_LAST(head) ((head)->cqh_last) -/* For comparisons */ -#define CIRCLEQ_ENDC(head) (__launder_type(head)) -/* For assignments */ -#define CIRCLEQ_END(head) ((void *)(head)) -#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) -#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) -#define CIRCLEQ_EMPTY(head) \ - (CIRCLEQ_FIRST(head) == CIRCLEQ_ENDC(head)) - -#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ - (((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ - ? ((head)->cqh_first) \ - : (elm->field.cqe_next)) -#define CIRCLEQ_LOOP_PREV(head, elm, field) \ - (((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ - ? ((head)->cqh_last) \ - : (elm->field.cqe_prev)) -#endif /* !_KERNEL */ - -#endif /* !_SYS_QUEUE_H_ */ +#define SIMPLEQ_CONCAT(head1, head2) do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_LAST(head, type, field) \ + (SIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +#endif /* H5queue_H_ */ diff --git a/src/H5retry_private.h b/src/H5retry_private.h index 6621957..45ba8d2 100644 --- a/src/H5retry_private.h +++ b/src/H5retry_private.h @@ -9,8 +9,8 @@ * help@hdfgroup.org. */ -#ifndef _H5retry_private_H -#define _H5retry_private_H +#ifndef H5retry_private_H +#define H5retry_private_H /* * Data types and functions for retry loops. @@ -111,4 +111,4 @@ h5_retry_tries(struct h5_retry_t *r) return r->maxtries - r->tries; } -#endif /* _H5retry_private_H */ +#endif /* H5retry_private_H */ diff --git a/src/H5system.c b/src/H5system.c index fff4c8c..c645105 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -1040,26 +1040,6 @@ Wflock(int fd, int operation) { return 0; } /* end Wflock() */ - - /*-------------------------------------------------------------------------- - * Function: Wnanosleep - * - * Purpose: Sleep for a given # of nanoseconds (Windows version) - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * Fall 2016 - *-------------------------------------------------------------------------- - */ -int -Wnanosleep(const struct timespec *req, struct timespec *rem) -{ - /* XXX: Currently just a placeholder */ - return 0; - -} /* end Wnanosleep() */ - /*------------------------------------------------------------------------- * Function: Wllround, Wllroundf, Wlround, Wlroundf, Wround, Wroundf @@ -1439,15 +1419,13 @@ done: * * Purpose: Sleep for a given # of nanoseconds * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * October 01, 2016 + * Return: void *-------------------------------------------------------------------------- */ void H5_nanosleep(uint64_t nanosec) { +#ifndef H5_HAVE_WIN32_API const uint64_t nanosec_per_sec = 1000 * 1000 * 1000; struct timespec sleeptime; /* Struct to hold time to sleep */ @@ -1476,6 +1454,20 @@ H5_nanosleep(uint64_t nanosec) } FUNC_LEAVE_NOAPI_VOID +#else + DWORD dwMilliseconds = (DWORD)HDceil(nanosec / 1000.0); + DWORD ignore; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Windows can't sleep at a ns resolution. Best we can do is ~1 ms. We + * don't care about the return value since the second parameter + * (bAlertable) is FALSE, so it will always be zero. + */ + ignore = SleepEx(dwMilliseconds, FALSE); + + FUNC_LEAVE_NOAPI_VOID +#endif /* H5_HAVE_WIN32_API */ } /* end H5_nanosleep() */ #ifdef H5_HAVE_WIN32_API diff --git a/src/H5time_private.h b/src/H5time_private.h index 30cbaf1..603c273 100644 --- a/src/H5time_private.h +++ b/src/H5time_private.h @@ -73,8 +73,8 @@ * @(#)time.h 8.5 (Berkeley) 5/4/95 */ -#ifndef _H5time_private_H -#define _H5time_private_H +#ifndef H5time_private_H +#define H5time_private_H #ifdef __NetBSD__ #include <sys/time.h> @@ -106,4 +106,4 @@ #define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000UL + (uint64_t)(x)->tv_nsec) #endif -#endif /* _H5time_private_H */ +#endif /* H5time_private_H */ diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 71162eb..ab3acb9 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -86,7 +86,6 @@ typedef __int64 h5_stat_size_t; #define HDlseek(F,O,W) _lseeki64(F,O,W) #define HDlstat(S,B) _lstati64(S,B) #define HDmkdir(S,M) _mkdir(S) -#define HDnanosleep(N, O) Wnanosleep(N, O) #define HDoff_t __int64 /* Note that the variadic HDopen macro is using a VC++ extension @@ -169,11 +168,11 @@ extern "C" { H5_DLL char* Wgetlogin(void); H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); - H5_DLL int Wnanosleep(const struct timespec *req, struct timespec *rem); H5_DLL herr_t H5_expand_windows_env_vars(char **env_var); H5_DLL const wchar_t *H5_get_utf16_str(const char *s); H5_DLL int Wopen_utf8(const char *path, int oflag, ...); H5_DLL int Wremove_utf8(const char *path); + H5_DLL int H5_get_win32_times(H5_timevals_t* tvs); /* Round functions only needed for VS2012 and earlier. * They are always built to ensure they don't go stale and diff --git a/src/Makefile.am b/src/Makefile.am index cb3fa3c..bf565d8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -115,8 +115,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5VLpassthru.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ - H5Zscaleoffset.c H5Zszip.c H5Ztrans.c \ - hlog.c + H5Zscaleoffset.c H5Zszip.c H5Ztrans.c # Only compile parallel sources if necessary if BUILD_PARALLEL_CONDITIONAL diff --git a/src/hlog.c b/src/hlog.c deleted file mode 100644 index d2d0e51..0000000 --- a/src/hlog.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright (c) 2004, 2005, 2006, 2007 David Young. All rights reserved. - * - * See COPYING at the top of the HDF5 distribution for license terms. - */ -/* - * Copyright (c) 2004 Urbana-Champaign Independent Media Center. - * All rights reserved. - * - * See COPYING at the top of the HDF5 distribution for license terms. - */ -#include <err.h> -#include <errno.h> -#include <stdarg.h> -#include <stdbool.h> -#include <stdint.h> /* for uintmax_t */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#include <sys/param.h> -#include <sys/cdefs.h> - -#include "hlog.h" -#include "H5time_private.h" - -TAILQ_HEAD(, hlog_outlet) hlog_outlets = TAILQ_HEAD_INITIALIZER(hlog_outlets); - -HLOG_OUTLET_TOP_DEFN(all); - -static struct timespec timestamp_zero; - -void hlog_init(void) _constructor; -static void hlog_init_timestamps(void); - -void -hlog_init(void) -{ - const char *settings0; - char *item, *settings; - - if ((settings0 = getenv("HLOG")) == NULL) - return; - - if ((settings = strdup(settings0)) == NULL) { - warn("%s: cannot duplicate settings string", __func__); - return; - } - - while ((item = strsep(&settings, " ,")) != NULL) { - hlog_outlet_state_t state; - char key[64 + 1], val[4 + 1]; // + 1 for the terminating NUL - int nconverted; - - nconverted = sscanf(item, " %64[0-9a-z_] = %4s ", key, val); - if (nconverted != 2) { - warnx("%s: malformed HLOG item \"%s\"", __func__, item); - continue; - } - - if (strcmp(val, "on") == 0 || strcmp(val, "yes") == 0) - state = HLOG_OUTLET_S_ON; - else if (strcmp(val, "off") == 0 || strcmp(val, "no") == 0) - state = HLOG_OUTLET_S_OFF; - else if (strcmp(val, "pass") == 0) - state = HLOG_OUTLET_S_PASS; - else { - warnx("%s: bad HLOG value \"%s\" in item \"%s\"", __func__, - val, item); - continue; - } - - if (hlog_set_state(key, state, true) == -1) { - warn("%s: could not set state for HLOG item \"%s\"", __func__, - item); - } - } - - free(settings); -} - - -static void -hlog_init_timestamps(void) -{ - static bool initialized = false; - - if (initialized) - return; - - if (clock_gettime(CLOCK_MONOTONIC, ×tamp_zero) == -1) - err(EXIT_FAILURE, "%s: clock_gettime", __func__); - - initialized = true; -} - -static void -hlog_print_time(void) -{ - struct timespec elapsed, now; - - hlog_init_timestamps(); - - if (clock_gettime(CLOCK_MONOTONIC, &now) == -1) - err(EXIT_FAILURE, "%s: clock_gettime", __func__); - - timespecsub(&now, ×tamp_zero, &elapsed); - - fprintf(stderr, "%ju.%.9ld ", (uintmax_t)elapsed.tv_sec, elapsed.tv_nsec); -} - -void -vhlog(const char *fmt, va_list ap) -{ - hlog_print_time(); - (void)vfprintf(stderr, fmt, ap); - (void)fputc('\n', stderr); -} - -static char * -message_extend_stderr(const char *fmt0) -{ - static const char sep[] = ": "; - const char *m; - char *fmt; - size_t fmtlen; - - m = strerror(errno); - - fmtlen = strlen(fmt0) + strlen(m) + sizeof(sep); - - if ((fmt = malloc(fmtlen)) == NULL) { - err(EXIT_FAILURE, "%s: malloc failed", __func__); - return NULL; - } - - /* Note well the safe strcpy, strcat usage. Thank you. */ - strcpy(fmt, fmt0); - strcat(fmt, sep); - strcat(fmt, m); - - return fmt; -} - -static char * -message_extend(const char *fmt0) -{ - return message_extend_stderr(fmt0); -} - -void -vhlog_err(int status, const char *fmt0, va_list ap) -{ - char *fmt; - - if ((fmt = message_extend(fmt0)) == NULL) - exit(status); - vhlog(fmt, ap); - free(fmt); - - exit(status); -} - -void -vhlog_errx(int status, const char *fmt, va_list ap) -{ - vhlog(fmt, ap); - exit(status); -} - -void -vhlog_warn(const char *fmt0, va_list ap) -{ - char *fmt; - - if ((fmt = message_extend(fmt0)) == NULL) - return; - vhlog(fmt, ap); - free(fmt); -} - -void -vhlog_warnx(const char *fmt, va_list ap) -{ - vhlog(fmt, ap); -} - -void -hlog_err(int status, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vhlog_err(status, fmt, ap); - va_end(ap); -} - -void -hlog_errx(int status, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vhlog_errx(status, fmt, ap); - va_end(ap); -} - -void -hlog_warn(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vhlog_warn(fmt, ap); - va_end(ap); -} - -void -hlog_warnx(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vhlog_warnx(fmt, ap); - va_end(ap); -} - -struct hlog_outlet * -hlog_outlet_find_active(struct hlog_outlet *ls0) -{ - struct hlog_outlet *ls; - - HLOG_OUTLET_FOREACH(ls, ls0) { - switch (ls->ls_state) { - case HLOG_OUTLET_S_PASS: - continue; - case HLOG_OUTLET_S_OFF: - return NULL; - case HLOG_OUTLET_S_ON: - default: - return ls; - } - } - return NULL; -} - -void -hlog_always(struct hlog_outlet *ls _unused, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vhlog(fmt, ap); - va_end(ap); -} - -void -hlog_impl(struct hlog_outlet *ls0, const char *fmt, ...) -{ - struct hlog_outlet *ls; - va_list ap; - - if ((ls = hlog_outlet_find_active(ls0)) == NULL) { - ls0->ls_resolved = HLOG_OUTLET_S_OFF; - return; - } - - ls0->ls_resolved = HLOG_OUTLET_S_ON; - - va_start(ap, fmt); - vhlog(fmt, ap); - va_end(ap); -} - -static void -hlog_outlet_reset_all(void) -{ - struct hlog_outlet *ls; - - TAILQ_FOREACH(ls, &hlog_outlets, ls_next) - ls->ls_resolved = HLOG_OUTLET_S_PASS; -} - -struct hlog_outlet * -hlog_outlet_lookup(const char *name) -{ - struct hlog_outlet *ls; - - TAILQ_FOREACH(ls, &hlog_outlets, ls_next) { - if (strcmp(ls->ls_name, name) == 0) - return ls; - } - return NULL; -} - -static struct hlog_outlet * -hlog_outlet_create(const char *name) -{ - struct hlog_outlet *ls; - - if ((ls = calloc(1, sizeof(*ls))) == NULL) - return NULL; - else if ((ls->ls_name0 = strdup(name)) == NULL) { - free(ls); - return NULL; - } - ls->ls_name = ls->ls_name0; - ls->ls_rendezvous = true; - return ls; -} - -static void -hlog_outlet_destroy(struct hlog_outlet *ls) -{ - /*LINTED*/ - if (ls->ls_name0 != NULL) - free(ls->ls_name0); - free(ls); -} - -int -hlog_set_state(const char *name, hlog_outlet_state_t state, bool rendezvous) -{ - struct hlog_outlet *ls; - errno = 0; - - switch (state) { - case HLOG_OUTLET_S_PASS: - case HLOG_OUTLET_S_OFF: - case HLOG_OUTLET_S_ON: - break; - default: - errno = EINVAL; - return -1; - } - if ((ls = hlog_outlet_lookup(name)) == NULL && !rendezvous) { - errno = ESRCH; - return -1; - } else if (ls == NULL) { - if ((ls = hlog_outlet_create(name)) == NULL) - return -1; - TAILQ_INSERT_TAIL(&hlog_outlets, ls, ls_next); - } - ls->ls_state = state; - hlog_outlet_reset_all(); - return 0; -} - -void -hlog_outlet_register(struct hlog_outlet *ls_arg) -{ - struct hlog_outlet *ls; - if ((ls = hlog_outlet_lookup(ls_arg->ls_name)) == NULL || - ls->ls_rendezvous) { - TAILQ_INSERT_TAIL(&hlog_outlets, ls_arg, ls_next); - if (ls == NULL) - return; - warnx("%s: rendezvous with log-outlet '%s'", __func__, - ls->ls_name); - ls_arg->ls_state = ls->ls_state; - TAILQ_REMOVE(&hlog_outlets, ls, ls_next); - hlog_outlet_destroy(ls); - } else - warnx("%s: duplicate log-outlet, '%s'", __func__, ls->ls_name); -} diff --git a/src/hlog.h b/src/hlog.h deleted file mode 100644 index 2489a47..0000000 --- a/src/hlog.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2004, 2005, 2006, 2007 David Young. All rights reserved. - * - * See COPYING at the top of the HDF5 distribution for license terms. - */ -/* - * Copyright (c) 2004 Urbana-Champaign Independent Media Center. - * All rights reserved. - * - * See COPYING at the top of the HDF5 distribution for license terms. - */ -#ifndef _HLOG_H -#define _HLOG_H - -#include <stdarg.h> -#include <stdbool.h> -#include <syslog.h> -#include <sys/cdefs.h> - -#include "H5queue.h" - -#ifndef _unused -#define _unused __attribute__((unused)) -#endif - -#ifndef _constructor -#define _constructor __attribute__((constructor)) -#endif - -#ifndef _noreturn -#define _noreturn __attribute__((__noreturn__)) -#endif - -#ifndef _printflike -#define _printflike(_fmt, _args) \ - __attribute__((__format__(__printf__,_fmt,_args))) -#endif - -enum hlog_outlet_state { - HLOG_OUTLET_S_PASS = 0 - , HLOG_OUTLET_S_OFF = 1 - , HLOG_OUTLET_S_ON = 2 -}; - -typedef enum hlog_outlet_state hlog_outlet_state_t; - -struct hlog_outlet { - hlog_outlet_state_t ls_resolved; - struct hlog_outlet *ls_parent; - hlog_outlet_state_t ls_state; - const char *ls_name; - char *ls_name0; - bool ls_rendezvous; - TAILQ_ENTRY(hlog_outlet) ls_next; -}; - -typedef struct hlog_outlet hlog_outlet_t; - -#define HLOG_CONSTRUCTOR(__sym) \ -void hlog_constructor_##__sym(void) _constructor; \ -void \ -hlog_constructor_##__sym(void) \ -{ \ - hlog_outlet_register(&__sym); \ -} \ -void hlog_undefined_##__sym(void) _constructor - -#define HLOG_OUTLET_FOREACH(__le, __le0) \ - for ((__le) = (__le0); (__le) != NULL; (__le) = (__le)->ls_parent) - -#define HLOG_OUTLET_DECL1(__sym) extern struct hlog_outlet __sym - -#define HLOG_JOIN_SYMS(x, y) x ## y - -#define HLOG_PREFIX(_sfx) HLOG_JOIN_SYMS(hlog_gbl_, _sfx) - -#define HLOG_OUTLET_DECL(__name) HLOG_OUTLET_DECL1(HLOG_PREFIX(__name)) - -#define HLOG_OUTLET_DEFN(__sym, __name, __parent, __state) \ - struct hlog_outlet __sym = { \ - .ls_name = __name \ - , .ls_parent = (__parent) \ - , .ls_state = (__state) \ - }; \ - HLOG_CONSTRUCTOR(__sym) - -#define HLOG_OUTLET_MEDIUM_DEFN(__name, __parent, __state) \ - HLOG_OUTLET_DEFN(HLOG_PREFIX(__name), #__name, &HLOG_PREFIX(__parent), \ - __state) - -#define HLOG_OUTLET_SHORT_DEFN(__name, __parent) \ - HLOG_OUTLET_MEDIUM_DEFN(__name, __parent, HLOG_OUTLET_S_PASS) - -#define HLOG_OUTLET_TOP_DEFN(__name) \ - HLOG_OUTLET_DEFN(HLOG_PREFIX(__name), #__name, NULL, HLOG_OUTLET_S_PASS) - -HLOG_OUTLET_DECL(all); - -#define hlog(_name, _fmt, ...) \ - hlog_impl(&HLOG_PREFIX(_name), _fmt, __VA_ARGS__) - -#define hlog_fast(_name, ...) \ - do { \ - hlog_outlet_t *_ls0 = &HLOG_PREFIX(_name); \ - \ - if (_ls0->ls_resolved == HLOG_OUTLET_S_OFF) \ - break; \ - else if (_ls0->ls_resolved == HLOG_OUTLET_S_ON) \ - hlog_always(_ls0, __VA_ARGS__); \ - else \ - hlog_impl(_ls0, __VA_ARGS__); \ - } while (/*CONSTCOND*/0) - -struct hlog_outlet *hlog_outlet_find_active(struct hlog_outlet *); -void hlog_outlet_register(struct hlog_outlet *); -struct hlog_outlet *hlog_outlet_lookup(const char *); -int hlog_set_state(const char *, hlog_outlet_state_t, bool); - -void vhlog(const char *, va_list) _printflike(1,0); - -void vhlog_warn(const char *, va_list) _printflike(1,0); -void vhlog_warnx(const char *, va_list) _printflike(1,0); -void vhlog_err(int, const char *, va_list) _printflike(2,0) _noreturn; -void vhlog_errx(int, const char *, va_list) _printflike(2,0) _noreturn; - -void hlog_warnx(const char *, ...) _printflike(1,2); -void hlog_warn(const char *, ...) _printflike(1,2); - -void hlog_err(int, const char *, ...) _printflike(2,3) _noreturn; -void hlog_errx(int, const char *, ...) _printflike(2,3) _noreturn; - -void hlog_always(struct hlog_outlet *, const char *, ...) - _printflike(2,3); - -void hlog_impl(struct hlog_outlet *, const char *, ...) - _printflike(2,3); - -#endif /* _HLOG_H */ |