From 11486e26a23a9fe45199515e02c8062270cd8894 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Mar 2021 11:07:21 -0600 Subject: Changing the signal handling to named pipe for better portablity. --- test/testvfdswmr.sh.in | 5 +- test/vfd_swmr_group_writer.c | 159 ++++++++++++++++++++++++++++++++----------- 2 files changed, 122 insertions(+), 42 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index a2e47b1..58c852e 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -616,11 +616,11 @@ fi if [ ${do_groups:-no} = yes ]; then echo launch vfd_swmr_group_writer catch_out_err_and_rc vfd_swmr_group_writer \ - ../vfd_swmr_group_writer -q -u 10 -n 10000 & + ../vfd_swmr_group_writer -q -c 1000 -n 10000 & pid_writer=$! catch_out_err_and_rc vfd_swmr_group_reader \ - ../vfd_swmr_group_reader -q -u 10 -n 10000 -W & + ../vfd_swmr_group_reader -q -c 1000 -n 10000 & pid_reader=$! # Wait for the reader to finish before signalling the @@ -628,7 +628,6 @@ if [ ${do_groups:-no} = yes ]; then # reader will find the shadow file when it opens # the .h5 file. wait $pid_reader - kill -USR1 $(cat vfd_swmr_group_writer.pid) wait $pid_writer # Collect exit code of the reader diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 2f355c2..112bcb4 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -12,13 +12,13 @@ */ #include +#include /* getopt(3) */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" #include "H5Fpkg.h" -// #include "H5Iprivate.h" #include "H5HGprivate.h" #include "H5VLprivate.h" @@ -29,8 +29,8 @@ typedef struct { hid_t file, filetype, one_by_one_sid; char filename[PATH_MAX]; char progname[PATH_MAX]; - struct timespec update_interval; unsigned int asteps; + unsigned int csteps; unsigned int nsteps; bool wait_for_signal; bool use_vfd_swmr; @@ -42,12 +42,10 @@ typedef struct { , .filename = "" \ , .filetype = H5T_NATIVE_UINT32 \ , .asteps = 10 \ + , .csteps = 10 \ , .nsteps = 100 \ , .wait_for_signal = true \ - , .use_vfd_swmr = true \ - , .update_interval = (struct timespec){ \ - .tv_sec = 0 \ - , .tv_nsec = 1000000000UL / 30 /* 1/30 second */}} + , .use_vfd_swmr = true} static void state_init(state_t *, int, char **); @@ -56,7 +54,7 @@ static const hid_t badhid = H5I_INVALID_HID; static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-S] [-W] [-a steps] [-b]\n" + fprintf(stderr, "usage: %s [-S] [-W] [-a steps] [-b] [-c]\n" " [-n iterations] [-u milliseconds]\n" "\n" "-S: do not use VFD SWMR\n" @@ -64,6 +62,7 @@ usage(const char *progname) " exiting\n" "-a steps: `steps` between adding attributes\n" "-b: write data in big-endian byte order\n" + "-c steps: `steps` between communication between the writer and reader\n" "-n iterations: how many times to expand each dataset\n" "-u ms: milliseconds interval between updates\n" " to %s.h5\n" @@ -80,13 +79,12 @@ state_init(state_t *s, int argc, char **argv) const hsize_t dims = 1; char tfile[PATH_MAX]; char *end; - unsigned long millis; *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); - while ((ch = getopt(argc, argv, "SWa:bn:qu:")) != -1) { + while ((ch = getopt(argc, argv, "SWa:bc:n:qu:")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; @@ -95,6 +93,7 @@ state_init(state_t *s, int argc, char **argv) s->wait_for_signal = false; break; case 'a': + case 'c': case 'n': errno = 0; tmp = strtoul(optarg, &end, 0); @@ -109,7 +108,9 @@ state_init(state_t *s, int argc, char **argv) if (ch == 'a') s->asteps = (unsigned)tmp; - else + else if (ch == 'c') + s->csteps = (unsigned)tmp; + else if (ch == 'n') s->nsteps = (unsigned)tmp; break; case 'b': @@ -118,21 +119,6 @@ state_init(state_t *s, int argc, char **argv) case 'q': verbosity = 0; break; - case 'u': - errno = 0; - millis = strtoul(optarg, &end, 0); - if (millis == ULONG_MAX && errno == ERANGE) { - err(EXIT_FAILURE, - "option -p argument \"%s\"", optarg); - } else if (*end != '\0') { - errx(EXIT_FAILURE, - "garbage after -p argument \"%s\"", optarg); - } - s->update_interval.tv_sec = (time_t)(millis / 1000UL); - s->update_interval.tv_nsec = - (long)((millis * 1000000UL) % 1000000000UL); - dbgf(1, "%lu milliseconds between updates\n", millis); - break; case '?': default: usage(s->progname); @@ -146,6 +132,12 @@ state_init(state_t *s, int argc, char **argv) if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) errx(EXIT_FAILURE, "H5Screate_simple failed"); + if( s->csteps < 1 || s->csteps > s->nsteps) + errx(EXIT_FAILURE, "communication interval is out of bounds"); + + if( s->asteps < 1 || s->asteps > s->nsteps) + errx(EXIT_FAILURE, "attribute interval is out of bounds"); + if (argc > 0) errx(EXIT_FAILURE, "unexpected command-line arguments"); @@ -259,17 +251,30 @@ verify_group(state_t *s, unsigned int which) return result; } +/* Sleep for `tenths` tenths of a second */ +static void +decisleep(uint32_t tenths) +{ + uint64_t nsec = tenths * 100 * 1000 * 1000; + + H5_nanosleep(nsec); +} + int main(int argc, char **argv) { hid_t fapl, fcpl; - sigset_t oldsigs; herr_t ret; unsigned step; bool writer; state_t s; const char *personality; H5F_vfd_swmr_config_t config; + const char *fifo_writer_to_reader = "./fifo_group_writer_to_reader"; + const char *fifo_reader_to_writer = "./fifo_group_reader_to_writer"; + int fd_writer_to_reader, fd_reader_to_writer; + int notify = 0, verify = 0; + unsigned int i; state_init(&s, argc, argv); @@ -310,27 +315,87 @@ main(int argc, char **argv) if (s.file == badhid) errx(EXIT_FAILURE, writer ? "H5Fcreate" : "H5Fopen"); - block_signals(&oldsigs); + /* Writer creates two named pipes(FIFO) to coordinate two-way communication */ + if (writer) { + if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) + errx(EXIT_FAILURE, "HDmkfifo"); + + if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) + errx(EXIT_FAILURE, "HDmkfifo"); + } + + /* Both the writer and reader open the pipes */ + if ((fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) + errx(EXIT_FAILURE, "fifo_writer_to_reader open failed"); + + if ((fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) + errx(EXIT_FAILURE, "fifo_reader_to_writer open failed"); if (writer) { + /* Writer tells reader to start */ + if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) + err(EXIT_FAILURE, "write failed"); + for (step = 0; step < s.nsteps; step++) { - dbgf(2, "step %d\n", step); + dbgf(2, "writer: step %d\n", step); + write_group(&s, step); - nanosleep(&s.update_interval, NULL); + + /* At communication interval, notifies the reader and waits for its response */ + if (step % s.csteps == 0) { + /* Bump up the value and notify the reader */ + notify++; + if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) + err(EXIT_FAILURE, "write failed"); + + /* During the wait, writer makes repeated HDF5 API calls + * to trigger EOT at approximately the correct time */ + for(i = 0; i < config.max_lag + 1; i++) { + decisleep(config.tick_len); + H5Aexists(s.file, "nonexistent"); + } + + /* Receive the same value from the reader and verify it */ + verify++; + if (HDread(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) + err(EXIT_FAILURE, "read failed"); + + if (notify != verify) + errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); + } } } else { - for (step = 0; step < s.nsteps;) { - dbgf(2, "step %d\n", step); - if (verify_group(&s, step)) - step++; - nanosleep(&s.update_interval, NULL); - } - } + /* Start to verify group creation after receiving the writer's notice */ + if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) + err(EXIT_FAILURE, "read failed"); - if (s.use_vfd_swmr && s.wait_for_signal) - await_signal(s.file); + /* Both notify and verify are 0 now */ + if (notify != verify) + errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); + + for (step = 0; step < s.nsteps; step++) { + dbgf(2, "reader: step %d\n", step); - restore_signals(&oldsigs); + while (!verify_group(&s, step)) + ; + + /* At communication interval, waits for the writer's notice and responds back */ + if (step % s.csteps == 0) { + verify++; + + /* Receive the notify that the writer bumped up the value */ + if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) + err(EXIT_FAILURE, "read failed"); + + if (notify != verify) + errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); + + /* Send back the same nofity value for acknowledgement */ + if (HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) + err(EXIT_FAILURE, "write failed"); + } + } + } if (H5Pclose(fapl) < 0) errx(EXIT_FAILURE, "H5Pclose(fapl)"); @@ -341,5 +406,21 @@ main(int argc, char **argv) if (H5Fclose(s.file) < 0) errx(EXIT_FAILURE, "H5Fclose"); + /* Close the named pipes */ + if (HDclose(fd_writer_to_reader) < 0) + errx(EXIT_FAILURE, "HDclose"); + + if (HDclose(fd_reader_to_writer) < 0) + errx(EXIT_FAILURE, "HDclose"); + + /* Reader finishes last and deletes the named pipes */ + if(!writer) { + if(HDremove(fifo_writer_to_reader) != 0) + errx(EXIT_FAILURE, "fifo_writer_to_reader deletion failed"); + + if(HDremove(fifo_reader_to_writer) != 0) + errx(EXIT_FAILURE, "fifo_reader_to_writer deletion failed"); + } + return EXIT_SUCCESS; } -- cgit v0.12 From 923e15b749a8a587cae3d0b738efd5f85bae30d3 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Mon, 15 Mar 2021 10:49:43 -0500 Subject: Some minor changes. --- test/vfd_swmr_group_writer.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 112bcb4..a3b1833 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -12,7 +12,6 @@ */ #include -#include /* getopt(3) */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -55,7 +54,7 @@ static void usage(const char *progname) { fprintf(stderr, "usage: %s [-S] [-W] [-a steps] [-b] [-c]\n" - " [-n iterations] [-u milliseconds]\n" + " [-n iterations]\n" "\n" "-S: do not use VFD SWMR\n" "-W: do not wait for a signal before\n" @@ -64,7 +63,6 @@ usage(const char *progname) "-b: write data in big-endian byte order\n" "-c steps: `steps` between communication between the writer and reader\n" "-n iterations: how many times to expand each dataset\n" - "-u ms: milliseconds interval between updates\n" " to %s.h5\n" "\n", progname, progname); @@ -84,7 +82,7 @@ state_init(state_t *s, int argc, char **argv) esnprintf(tfile, sizeof(tfile), "%s", argv[0]); esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); - while ((ch = getopt(argc, argv, "SWa:bc:n:qu:")) != -1) { + while ((ch = getopt(argc, argv, "SWa:bc:n:q")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; @@ -315,8 +313,12 @@ main(int argc, char **argv) if (s.file == badhid) errx(EXIT_FAILURE, writer ? "H5Fcreate" : "H5Fopen"); - /* Writer creates two named pipes(FIFO) to coordinate two-way communication */ + /* Use two named pipes(FIFO) to coordinate the writer and reader for + * two-way communication so that the two sides can move forward together. + * One is for the writer to write to the reader. + * The other one is for the reader to signal the writer. */ if (writer) { + /* Writer creates two named pipes(FIFO) */ if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) errx(EXIT_FAILURE, "HDmkfifo"); @@ -343,7 +345,7 @@ main(int argc, char **argv) /* At communication interval, notifies the reader and waits for its response */ if (step % s.csteps == 0) { - /* Bump up the value and notify the reader */ + /* Bump up the value of notify to notice the reader to start to read */ notify++; if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "write failed"); @@ -381,9 +383,10 @@ main(int argc, char **argv) /* At communication interval, waits for the writer's notice and responds back */ if (step % s.csteps == 0) { + /* The writer should have bumped up the value of notify. + * Do the same with verify and confirm it */ verify++; - /* Receive the notify that the writer bumped up the value */ if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "read failed"); @@ -406,7 +409,7 @@ main(int argc, char **argv) if (H5Fclose(s.file) < 0) errx(EXIT_FAILURE, "H5Fclose"); - /* Close the named pipes */ + /* Both the writer and reader close the named pipes */ if (HDclose(fd_writer_to_reader) < 0) errx(EXIT_FAILURE, "HDclose"); -- cgit v0.12 From 20cbe6895872b162ca04ed371d211c8c5124e0db Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Mon, 15 Mar 2021 11:01:25 -0500 Subject: Adding more comments. --- test/vfd_swmr_group_writer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index a3b1833..5e01c4e 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -334,7 +334,7 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "fifo_reader_to_writer open failed"); if (writer) { - /* Writer tells reader to start */ + /* Writer tells reader to start verification */ if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "write failed"); @@ -357,7 +357,8 @@ main(int argc, char **argv) H5Aexists(s.file, "nonexistent"); } - /* Receive the same value from the reader and verify it */ + /* Receive the same value from the reader and verify it before + * going to the next step */ verify++; if (HDread(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "read failed"); @@ -393,7 +394,8 @@ main(int argc, char **argv) if (notify != verify) errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); - /* Send back the same nofity value for acknowledgement */ + /* Send back the same nofity value for acknowledgement to tell the writer + * move to the next step */ if (HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "write failed"); } -- cgit v0.12 From 796018e5582d9c3d0d009cb58e4d4898723b0d32 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Tue, 16 Mar 2021 20:39:01 -0500 Subject: Re-arranged the communication between the writer and reader through named pipes to facilitate possible test improvements in the future. --- test/vfd_swmr_group_writer.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 5e01c4e..3dd84ab 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -62,10 +62,9 @@ usage(const char *progname) "-a steps: `steps` between adding attributes\n" "-b: write data in big-endian byte order\n" "-c steps: `steps` between communication between the writer and reader\n" - "-n iterations: how many times to expand each dataset\n" - " to %s.h5\n" + "-n ngroups: the number of groups\n" "\n", - progname, progname); + progname); exit(EXIT_FAILURE); } @@ -334,10 +333,6 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "fifo_reader_to_writer open failed"); if (writer) { - /* Writer tells reader to start verification */ - if (HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) - err(EXIT_FAILURE, "write failed"); - for (step = 0; step < s.nsteps; step++) { dbgf(2, "writer: step %d\n", step); @@ -368,34 +363,29 @@ main(int argc, char **argv) } } } else { - /* Start to verify group creation after receiving the writer's notice */ - if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) - err(EXIT_FAILURE, "read failed"); - - /* Both notify and verify are 0 now */ - if (notify != verify) - errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); - for (step = 0; step < s.nsteps; step++) { dbgf(2, "reader: step %d\n", step); - while (!verify_group(&s, step)) - ; - - /* At communication interval, waits for the writer's notice and responds back */ + /* At communication interval, waits for the writer to finish creation before starting verification */ if (step % s.csteps == 0) { /* The writer should have bumped up the value of notify. * Do the same with verify and confirm it */ verify++; + /* Receive the notify that the writer bumped up the value */ if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "read failed"); if (notify != verify) errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); + } + while (!verify_group(&s, step)) + ; + + if (step % s.csteps == 0) { /* Send back the same nofity value for acknowledgement to tell the writer - * move to the next step */ + * move to the next step. */ if (HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) err(EXIT_FAILURE, "write failed"); } -- cgit v0.12 From 5a5a2dbca85355aa027367a986d6615b3e620e38 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 22 Mar 2021 17:03:40 -0700 Subject: Adds missing dedup callback entries to other VFDs NOTE: The mirror VFD and parallel are currently broken --- src/H5FDdirect.c | 1 + src/H5FDmirror.c | 1 + src/H5FDmpio.c | 1 + src/H5FDros3.c | 1 + 4 files changed, 4 insertions(+) diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 34c4346..498d5f8 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -171,6 +171,7 @@ static const H5FD_class_t H5FD_direct_g = { H5FD_direct_truncate, /*truncate */ H5FD_direct_lock, /*lock */ H5FD_direct_unlock, /*unlock */ + NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /*fl_map */ }; diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index ef035c1..9f47806 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -197,6 +197,7 @@ static const H5FD_class_t H5FD_mirror_g = { H5FD_mirror_truncate, /* truncate */ H5FD_mirror_lock, /* lock */ H5FD_mirror_unlock, /* unlock */ + NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 3d2e0cf..4fce560 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -127,6 +127,7 @@ static const H5FD_class_mpi_t H5FD_mpio_g = { H5FD__mpio_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ + NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /*fl_map */ }, /* End of superclass information */ H5FD__mpio_mpi_rank, /*get_rank */ diff --git a/src/H5FDros3.c b/src/H5FDros3.c index d99272c..a936f55 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -272,6 +272,7 @@ static const H5FD_class_t H5FD_ros3_g = { H5FD_ros3_truncate, /* truncate */ H5FD_ros3_lock, /* lock */ H5FD_ros3_unlock, /* unlock */ + NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; -- cgit v0.12 From d2e5e45e10055e137a95e7e8c29c334dc5bb1f59 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 22 Mar 2021 18:21:16 -0700 Subject: Fixed MANIFEST --- MANIFEST | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MANIFEST b/MANIFEST index 0ee904a..a29c987 100644 --- a/MANIFEST +++ b/MANIFEST @@ -196,6 +196,8 @@ ./examples/Attributes.txt ./examples/Makefile.am +./examples/credel.c +./examples/gaussians.c ./examples/h5_chunk_read.c ./examples/h5_compound.c ./examples/h5_crtgrpd.c @@ -234,6 +236,8 @@ ./examples/h5_vds-percival.c ./examples/h5_vds-percival-unlim.c ./examples/h5_vds-percival-unlim-maxmin.c +./examples/nbcompat.c +./examples/nbcompat.h ./examples/testh5cc.sh.in ./examples/README -- cgit v0.12 From 915e36f1d2217cd8f5f614ae975c8b4d97f7c5b5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 23 Mar 2021 14:32:25 -0700 Subject: Protects timespeccmp --- MANIFEST | 1 - config/cmake/H5pubconf.h.in | 3 + config/cmake_ext_mod/ConfigureChecks.cmake | 1 + configure.ac | 2 +- src/H5Fvfd_swmr.c | 6 +- src/H5private.h | 11 ++- src/H5time_private.h | 109 ----------------------------- 7 files changed, 18 insertions(+), 115 deletions(-) delete mode 100644 src/H5time_private.h diff --git a/MANIFEST b/MANIFEST index a29c987..9ff9698 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1035,7 +1035,6 @@ ./src/H5Ztrans.c ./src/H5queue.h ./src/H5retry_private.h -./src/H5time_private.h ./src/H5win32defs.h ./src/Makefile.am ./src/hdf5.h diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 24adb1a..5f6b67f 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -444,6 +444,9 @@ # cmakedefine H5_HAVE_THREADSAFE @H5_HAVE_THREADSAFE@ #endif +/* Define to 1 if you have the `timespeccmp' function. */ +#cmakedefine H5_HAVE_TIMESPECCMP @H5_HAVE_TIMESPECCMP@ + /* Define if timezone is a global variable */ #cmakedefine H5_HAVE_TIMEZONE @H5_HAVE_TIMEZONE@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 18aed24..1fce173 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -530,6 +530,7 @@ CHECK_FUNCTION_EXISTS (symlink ${HDF_PREFIX}_HAVE_SYMLINK) CHECK_FUNCTION_EXISTS (system ${HDF_PREFIX}_HAVE_SYSTEM) CHECK_FUNCTION_EXISTS (tmpfile ${HDF_PREFIX}_HAVE_TMPFILE) +CHECK_FUNCTION_EXISTS (timespeccmp ${HDF_PREFIX}_HAVE_TIMESPECCMP) CHECK_FUNCTION_EXISTS (asprintf ${HDF_PREFIX}_HAVE_ASPRINTF) CHECK_FUNCTION_EXISTS (vasprintf ${HDF_PREFIX}_HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS (waitpid ${HDF_PREFIX}_HAVE_WAITPID) diff --git a/configure.ac b/configure.ac index 9e241a8..2efe9d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1959,7 +1959,7 @@ AC_CHECK_FUNCS([frexpl gethostname getrusage gettimeofday]) AC_CHECK_FUNCS([lstat rand_r random setsysinfo]) AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask]) AC_CHECK_FUNCS([sigtimedwait snprintf srandom strdup symlink system]) -AC_CHECK_FUNCS([strtoll strtoull]) +AC_CHECK_FUNCS([strtoll strtoull timespeccmp]) AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid]) AC_CHECK_FUNCS([roundf lroundf llroundf round lround llround]) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 0b0befd..b55f157 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1320,7 +1320,7 @@ insert_eot_entry(eot_queue_entry_t *entry_ptr) /* Find the insertion point for the entry on the EOT queue */ TAILQ_FOREACH_REVERSE(prec_ptr, &eot_queue_g, eot_queue, link) { - if (timespeccmp(&prec_ptr->end_of_tick, &entry_ptr->end_of_tick, <=)) + if (HDtimespeccmp(&prec_ptr->end_of_tick, &entry_ptr->end_of_tick, <=)) break; } @@ -1964,7 +1964,7 @@ H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); } #endif - if(timespeccmp(&now, &head->end_of_tick, <)) + if(HDtimespeccmp(&now, &head->end_of_tick, <)) break; /* If the H5F_shared_t is labeled with a later EOT time than * the queue entry is, then we have already performed the @@ -1972,7 +1972,7 @@ H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) * multiple H5F_t share the H5F_shared_t. Just update the * EOT queue entry and move to the next. */ - if (timespeccmp(&head->end_of_tick, &shared->end_of_tick, <)) { + if (HDtimespeccmp(&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) diff --git a/src/H5private.h b/src/H5private.h index 66763b2..b57918d 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1588,6 +1588,16 @@ typedef off_t h5_stat_size_t; #ifndef HDtimes #define HDtimes(T) times(T) #endif /* HDtimes*/ +#ifndef HDtimespeccmp +#ifdef H5_HAVE_TIMESPECCMP + #define HDtimespeccmp(tsp, usp, cmp) timespeccmp(tsp, usp, cmp) +#else +#define HDtimespeccmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? \ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ + ((tsp)->tv_sec cmp (usp)->tv_sec)) +#endif +#endif /* HDtimespeccmp */ #ifndef HDtmpfile #define HDtmpfile() tmpfile() #endif /* HDtmpfile */ @@ -2200,7 +2210,6 @@ H5_DLL herr_t H5CX_pop(void); BEGIN_MPE_LOG #include "H5FDvfd_swmr_private.h" -#include "H5time_private.h" /* for timespeccmp */ #define VFD_SWMR_ENTER(err) \ do { \ diff --git a/src/H5time_private.h b/src/H5time_private.h deleted file mode 100644 index 603c273..0000000 --- a/src/H5time_private.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019 The HDF Group. All rights reserved. - * - * This file is part of HDF5. The full HDF5 copyright notice, including - * terms governing use, modification, and redistribution, is contained in - * the COPYING file, which can be found at the root of the source code - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. - * If you do not have access to either file, you may request a copy from - * help@hdfgroup.org. - */ - -/* - * Portions of this file derive from in NetBSD. Applicable - * copyright notices and licenses are reproduced here: - */ - -/*- - * Copyright (c) 2017 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)time.h 8.5 (Berkeley) 5/4/95 - */ - -#ifndef H5time_private_H -#define H5time_private_H - -#ifdef __NetBSD__ -#include -#else -#define timespecclear(tsp) (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L) -#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) -#define timespeccmp(tsp, usp, cmp) \ - (((tsp)->tv_sec == (usp)->tv_sec) ? \ - ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ - ((tsp)->tv_sec cmp (usp)->tv_sec)) -#define timespecadd(tsp, usp, vsp) \ - do { \ - (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ - (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ - if ((vsp)->tv_nsec >= 1000000000L) { \ - (vsp)->tv_sec++; \ - (vsp)->tv_nsec -= 1000000000L; \ - } \ - } while (/* CONSTCOND */ 0) -#define timespecsub(tsp, usp, vsp) \ - do { \ - (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ - (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ - if ((vsp)->tv_nsec < 0) { \ - (vsp)->tv_sec--; \ - (vsp)->tv_nsec += 1000000000L; \ - } \ - } while (/* CONSTCOND */ 0) -#define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000UL + (uint64_t)(x)->tv_nsec) -#endif - -#endif /* H5time_private_H */ -- cgit v0.12