summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2021-03-23 21:32:25 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2021-03-23 21:32:25 (GMT)
commit915e36f1d2217cd8f5f614ae975c8b4d97f7c5b5 (patch)
treeff15801afc4852cbd23ec515e17e1478a45eb152 /src
parent1598238b2f2364957d6390f99edb9a49a8e18d3d (diff)
downloadhdf5-915e36f1d2217cd8f5f614ae975c8b4d97f7c5b5.zip
hdf5-915e36f1d2217cd8f5f614ae975c8b4d97f7c5b5.tar.gz
hdf5-915e36f1d2217cd8f5f614ae975c8b4d97f7c5b5.tar.bz2
Protects timespeccmp
Diffstat (limited to 'src')
-rw-r--r--src/H5Fvfd_swmr.c6
-rw-r--r--src/H5private.h11
-rw-r--r--src/H5time_private.h109
3 files changed, 13 insertions, 113 deletions
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 <sys/time.h> 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 <sys/time.h>
-#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 */