diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-03-08 22:19:41 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-03-08 22:19:41 (GMT) |
commit | d72405e43d44a3ac9ec27bb9d7a84e638a7aea10 (patch) | |
tree | 48ec01f76f61306e0965d13f25a16171abc8db78 | |
parent | ef5a1941f7638688c3d66cead33f03c329c2ed3e (diff) | |
download | hdf5-d72405e43d44a3ac9ec27bb9d7a84e638a7aea10.zip hdf5-d72405e43d44a3ac9ec27bb9d7a84e638a7aea10.tar.gz hdf5-d72405e43d44a3ac9ec27bb9d7a84e638a7aea10.tar.bz2 |
Changes to help vfd_swmr.c build on Windows
-rw-r--r-- | test/vfd_swmr.c | 24 | ||||
-rw-r--r-- | test/vfd_swmr_common.c | 87 | ||||
-rw-r--r-- | test/vfd_swmr_common.h | 10 |
3 files changed, 66 insertions, 55 deletions
diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index 09188f6..e2b0172 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -1082,8 +1082,7 @@ error: return 1; } /* test_writer__md() */ - -#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_FLOCK)) +#ifndef H5_HAVE_UNISTD_H static unsigned test_reader_md_concur(void) @@ -1091,7 +1090,7 @@ test_reader_md_concur(void) /* Output message about test being performed */ TESTING("Verify the metadata file for VFD SWMR reader"); SKIPPED(); - HDputs(" Test skipped due to fork, waitpid, or flock not defined."); + HDputs(" Test skipped (unistd.h not present)"); return 0; } /* test_reader_md_concur() */ @@ -1102,7 +1101,7 @@ test_multiple_file_opens_concur(void) /* Output message about test being performed */ TESTING("EOT queue entries when opening files concurrently with VFD SWMR"); SKIPPED(); - HDputs(" Test skipped due to fork, waitpid, or flock not defined."); + HDputs(" Test skipped (unistd.h not present)"); return 0; } /* test_multiple_file_opens_concur() */ @@ -1113,12 +1112,23 @@ test_disable_enable_eot_concur(void) /* Output message about test being performed */ TESTING("Verify concurrent H5Fvfd_swmr_enable/disable_end_of_tick()"); SKIPPED(); - HDputs(" Test skipped due to fork, waitpid, or flock not defined."); + HDputs(" Test skipped (unistd.h not present)"); + return 0; + +} /* test_disable_enble_eot_concur() */ + +static unsigned +test_file_end_tick_concur(void) + + /* Output message about test being performed */ + TESTING("Verify concurrent H5Fvfd_swmr_end_tick()"); + SKIPPED(); + HDputs(" Test skipped (unistd.h not present)"); return 0; } /* test_disable_enble_eot_concur() */ -#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_FLOCK) */ +#else /* H5_HAVE_UNISTD_H */ /*------------------------------------------------------------------------- * Function: test_reader_md_concur() @@ -2610,7 +2620,7 @@ error: return 1; } /* test_file_end_tick_concur() */ -#endif /* !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) && defined(H5_HAVE_FLOCK)) */ +#endif /* H5_HAVE_UNISTD_H */ /*------------------------------------------------------------------------- diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index 3f03ce7..1c8d7b3 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -19,18 +19,18 @@ /* Headers */ /***********/ -#include <err.h> /* for err(3) */ - -/* Only need the pthread solution if sigtimedwai(2) isn't available */ -#ifndef H5_HAVE_SIGTIMEDWAIT -#include <pthread.h> -#endif - #include "h5test.h" #include "vfd_swmr_common.h" #include "swmr_common.h" -static const hid_t badhid = H5I_INVALID_HID; +#ifndef H5_HAVE_WIN32_API + +#include <err.h> + +/* Only need the pthread solution if sigtimedwait(2) isn't available */ +#ifndef H5_HAVE_SIGTIMEDWAIT +#include <pthread.h> +#endif int verbosity = 2; @@ -43,17 +43,19 @@ int verbosity = 2; * greater than the duration `ival`, then record the current time at * `last` and return true. Otherwise, return false. */ -bool +hbool_t below_speed_limit(struct timespec *last, const struct timespec *ival) { struct timespec now; - bool result; + hbool_t result; - assert(0 <= last->tv_nsec && last->tv_nsec < 1000000000L); - assert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000L); + HDassert(0 <= last->tv_nsec && last->tv_nsec < 1000000000L); + HDassert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000L); - if (clock_gettime(CLOCK_MONOTONIC, &now) == -1) - err(EXIT_FAILURE, "%s: clock_gettime", __func__); + if (HDclock_gettime(CLOCK_MONOTONIC, &now) == -1) { + HDfprintf(stderr, "%s: clock_gettime", __func__); + HDexit(EXIT_FAILURE); + } if (now.tv_sec - last->tv_sec > ival->tv_sec) result = true; @@ -78,10 +80,12 @@ evsnprintf(char *buf, size_t bufsz, const char *fmt, va_list ap) rc = vsnprintf(buf, bufsz, fmt, ap); - if (rc < 0) + if (rc < 0) { err(EXIT_FAILURE, "%s: vsnprintf", __func__); - else if ((size_t)rc >= bufsz) + } + else if ((size_t)rc >= bufsz) { errx(EXIT_FAILURE, "%s: buffer too small", __func__); + } } /* Like snprintf(3), but abort the program with an error message on @@ -244,8 +248,8 @@ await_signal(hid_t fid) sigset_t sleepset; if (sigfillset(&sleepset) == -1) { - err(EXIT_FAILURE, "%s.%d: could not initialize signal mask", - __func__, __LINE__); + HDfprintf(stderr, "%s.%d: could not initialize signal mask", __func__, __LINE__); + HDexit(EXIT_FAILURE); } /* Avoid deadlock: flush the file before waiting for the reader's @@ -275,14 +279,14 @@ await_signal(hid_t fid) rc = sigwait(&sleepset, NULL); if (rc != -1) { - fprintf(stderr, "Received signal, wrapping things up.\n"); + HDfprintf(stderr, "Received signal, wrapping things up.\n"); pthread_mutex_lock(&timer_mutex); timer_stop = TRUE; pthread_mutex_unlock(&timer_mutex); pthread_join(timer, NULL); } else - err(EXIT_FAILURE, "%s: sigtimedwait", __func__); + err(EXIT_FAILURE, "%s: sigwait", __func__); } #else for (;;) { @@ -322,7 +326,7 @@ init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t { va_list ap; - memset(config, 0, sizeof(H5F_vfd_swmr_config_t)); + HDmemset(config, 0, sizeof(H5F_vfd_swmr_config_t)); config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; config->pb_expansion_threshold = 0; @@ -333,10 +337,10 @@ init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t config->flush_raw_data = flush_raw_data; config->md_pages_reserved = md_pages_reserved; - va_start(ap, md_file_fmtstr); + HDva_start(ap, md_file_fmtstr); evsnprintf(config->md_file_path, sizeof(config->md_file_path), md_file_fmtstr, ap); - va_end(ap); + HDva_end(ap); } /* init_vfd_swmr_config() */ @@ -351,40 +355,33 @@ init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t hid_t vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_pages, H5F_vfd_swmr_config_t *config) { - hid_t fapl; + hid_t fapl = H5I_INVALID_HID; /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) { - warnx("h5_fileaccess"); - return badhid; - } + if((fapl = h5_fileaccess()) < 0) + return H5I_INVALID_HID; if(use_latest_format) { - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { - warnx("H5Pset_libver_bounds"); - return badhid; - } + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + return H5I_INVALID_HID; } /* Enable page buffering */ - if(H5Pset_page_buffer_size(fapl, 4096, only_meta_pages ? 100 : 0, 0) < 0) { - warnx("H5Pset_page_buffer_size"); - return badhid; - } + if(H5Pset_page_buffer_size(fapl, 4096, only_meta_pages ? 100 : 0, 0) < 0) + return H5I_INVALID_HID; /* * Set up to open the file with VFD SWMR configured. */ /* Enable VFD SWMR configuration */ - if(use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, config) < 0) { - warnx("H5Pset_vfd_swmr_config"); - return badhid; - } + if(use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, config) < 0) + return H5I_INVALID_HID; return fapl; } /* vfd_swmr_create_fapl() */ +#endif /* H5_HAVE_WIN32_API */ /* Fetch a variable from the environment and parse it for unsigned long * content. Return 0 if the variable is not present, -1 if it is present @@ -398,21 +395,21 @@ fetch_env_ulong(const char *varname, unsigned long limit, unsigned long *valp) unsigned long ul; char *tmp; - if ((tmp = getenv(varname)) == NULL) + if ((tmp = HDgetenv(varname)) == NULL) return 0; errno = 0; - ul = strtoul(tmp, &end, 0); + ul = HDstrtoul(tmp, &end, 0); if (ul == ULONG_MAX && errno != 0) { - fprintf(stderr, "could not parse %s: %s\n", varname, strerror(errno)); + HDfprintf(stderr, "could not parse %s: %s\n", varname, HDstrerror(errno)); return -1; } if (end == tmp || *end != '\0') { - fprintf(stderr, "could not parse %s\n", varname); + HDfprintf(stderr, "could not parse %s\n", varname); return -1; } if (ul > limit) { - fprintf(stderr, "%s (%lu) out of range\n", varname, ul); + HDfprintf(stderr, "%s (%lu) out of range\n", varname, ul); return -1; } *valp = ul; diff --git a/test/vfd_swmr_common.h b/test/vfd_swmr_common.h index d96983a..e04020a 100644 --- a/test/vfd_swmr_common.h +++ b/test/vfd_swmr_common.h @@ -44,9 +44,9 @@ typedef struct _estack_state { } estack_state_t; typedef enum _testsel { - TEST_NONE = 0 -, TEST_NULL -, TEST_OOB + TEST_NONE = 0, + TEST_NULL, + TEST_OOB } testsel_t; /********************/ @@ -60,6 +60,8 @@ typedef enum _testsel { extern "C" { #endif +#ifndef H5_HAVE_WIN32_API + H5TEST_DLL bool below_speed_limit(struct timespec *, const struct timespec *); H5TEST_DLL estack_state_t estack_get_state(void); @@ -85,6 +87,8 @@ H5TEST_DLL void evsnprintf(char *, size_t, const char *, va_list); H5TEST_DLL void esnprintf(char *, size_t, const char *, ...) H5_ATTR_FORMAT(printf, 3, 4); +#endif /* H5_HAVE_WIN32_API */ + H5TEST_DLL int fetch_env_ulong(const char *, unsigned long, unsigned long *); #ifdef __cplusplus |