summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5MFaggr.c2
-rw-r--r--src/H5detect.c24
-rw-r--r--src/H5private.h42
-rw-r--r--src/H5timer.c89
-rw-r--r--src/H5trace.c14
5 files changed, 102 insertions, 69 deletions
diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c
index f015b19..29d21fd 100644
--- a/src/H5MFaggr.c
+++ b/src/H5MFaggr.c
@@ -46,7 +46,7 @@
/******************/
/* Local Typedefs */
/******************/
-#define EXTEND_THRESHOLD .10
+#define EXTEND_THRESHOLD 0.10F
/********************/
diff --git a/src/H5detect.c b/src/H5detect.c
index aed7514..b902af4 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -323,7 +323,7 @@ precision (detected_t *d)
* steps). This is necessary because padding bits can change arbitrarily \
* and interfere with detection of the various properties below unless we \
* know to ignore them. */ \
- _v1 = 4.0; \
+ _v1 = (TYPE)4.0L; \
HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
for(_i = 0; _i < (int)sizeof(TYPE); _i++) \
for(_byte_mask = (unsigned char)1; _byte_mask; _byte_mask <<= 1) { \
@@ -335,10 +335,10 @@ precision (detected_t *d)
} /* end for */ \
\
/* Byte Order */ \
- for(_i = 0, _v1 = 0.0, _v2 = 1.0; _i < (int)sizeof(TYPE); _i++) { \
+ for(_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \
_v3 = _v1; \
_v1 += _v2; \
- _v2 /= 256.0; \
+ _v2 /= (TYPE)256.0L; \
HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
HDmemcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \
_j = byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \
@@ -353,20 +353,20 @@ precision (detected_t *d)
INFO.is_vax = TRUE; \
\
/* Implicit mantissa bit */ \
- _v1 = 0.5; \
- _v2 = 1.0; \
+ _v1 = (TYPE)0.5L; \
+ _v2 = (TYPE)1.0L; \
INFO.imp = imp_bit (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \
\
/* Sign bit */ \
- _v1 = 1.0; \
- _v2 = -1.0; \
+ _v1 = (TYPE)1.0L; \
+ _v2 = (TYPE)-1.0L; \
INFO.sign = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \
\
/* Mantissa */ \
INFO.mpos = 0; \
\
- _v1 = 1.0; \
- _v2 = 1.5; \
+ _v1 = (TYPE)1.0L; \
+ _v2 = (TYPE)1.5L; \
INFO.msize = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \
INFO.msize += 1 + (INFO.imp?0:1) - INFO.mpos; \
\
@@ -375,7 +375,7 @@ precision (detected_t *d)
\
INFO.esize = INFO.sign - INFO.epos; \
\
- _v1 = 1.0; \
+ _v1 = (TYPE)1.0L; \
INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.perm, &_v1); \
precision (&(INFO)); \
ALIGNMENT(TYPE, INFO); \
@@ -1381,8 +1381,8 @@ detect_C89_integers(void)
static void
detect_C89_floats(void)
{
- DETECT_F(float, FLOAT, d_g[nd_g]); nd_g++;
- DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++;
+ DETECT_F(float, FLOAT, d_g[nd_g]); nd_g++;
+ DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++;
}
diff --git a/src/H5private.h b/src/H5private.h
index a532c79..1164a2d 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -480,6 +480,48 @@
# define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1))
#endif
+/* Double constant wrapper
+ *
+ * Quiets gcc warnings from -Wunsuffixed-float-constants.
+ *
+ * This is a really annoying warning since the standard specifies that
+ * constants of type double do NOT get a suffix so there's no way
+ * to specify a constant of type double. To quiet gcc, we specify floating
+ * point constants as type long double and cast to double.
+ *
+ * Note that this macro only needs to be used where using a double
+ * is important. For most code, suffixing constants with F will quiet the
+ * compiler and not produce erroneous code.
+ */
+#define H5_DOUBLE(S) ((double) S ## L)
+
+/*
+ * Methods to compare the equality of floating-point values:
+ *
+ * 1. H5_XXX_ABS_EQUAL - check if the difference is smaller than the
+ * Epsilon value. The Epsilon values, FLT_EPSILON, DBL_EPSILON,
+ * and LDBL_EPSILON, are defined by compiler in float.h.
+ *
+ * 2. H5_XXX_REL_EQUAL - check if the relative difference is smaller than a
+ * predefined value M. See if two values are relatively equal.
+ * It's the developer's responsibility not to pass in the value 0, which
+ * may cause the equation to fail.
+ */
+#define H5_FLT_ABS_EQUAL(X,Y) (HDfabsf(X-Y) < FLT_EPSILON)
+#define H5_DBL_ABS_EQUAL(X,Y) (HDfabs (X-Y) < DBL_EPSILON)
+#define H5_LDBL_ABS_EQUAL(X,Y) (HDfabsl(X-Y) < LDBL_EPSILON)
+
+#define H5_FLT_REL_EQUAL(X,Y,M) (HDfabsf((Y-X) / X) < M)
+#define H5_DBL_REL_EQUAL(X,Y,M) (HDfabs ((Y-X) / X) < M)
+#define H5_LDBL_REL_EQUAL(X,Y,M) (HDfabsl((Y-X) / X) < M)
+
+/* KiB, MiB, GiB, TiB, EiB - Used in profiling and timing code */
+#define H5_KB (1024.0F)
+#define H5_MB (1024.0F * 1024.0F)
+#define H5_GB (1024.0F * 1024.0F * 1024.0F)
+#define H5_TB (1024.0F * 1024.0F * 1024.0F * 1024.0F)
+#define H5_EB (1024.0F * 1024.0F * 1024.0F * 1024.0F * 1024.0F)
+
/*
* Data types and functions for timing certain parts of the library.
*/
diff --git a/src/H5timer.c b/src/H5timer.c
index 301d98b..94f2883 100644
--- a/src/H5timer.c
+++ b/src/H5timer.c
@@ -90,8 +90,6 @@
* Programmer: Robb Matzke
* Thursday, April 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -112,8 +110,6 @@ H5_timer_reset (H5_timer_t *timer)
* Programmer: Robb Matzke
* Thursday, April 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -131,18 +127,18 @@ H5_timer_begin (H5_timer_t *timer)
#ifdef H5_HAVE_GETRUSAGE
HDgetrusage (RUSAGE_SELF, &rusage);
timer->utime = (double)rusage.ru_utime.tv_sec +
- ((double)rusage.ru_utime.tv_usec / 1e6);
+ ((double)rusage.ru_utime.tv_usec / 1e6F);
timer->stime = (double)rusage.ru_stime.tv_sec +
- ((double)rusage.ru_stime.tv_usec / 1e6);
+ ((double)rusage.ru_stime.tv_usec / 1e6F);
#else
- timer->utime = 0.0;
- timer->stime = 0.0;
+ timer->utime = 0.0F;
+ timer->stime = 0.0F;
#endif
#ifdef H5_HAVE_GETTIMEOFDAY
HDgettimeofday (&etime, NULL);
- timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec / 1e6);
+ timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec / 1e6F);
#else
- timer->etime = 0.0;
+ timer->etime = 0.0F;
#endif
} /* end H5_timer_begin() */
@@ -160,8 +156,6 @@ H5_timer_begin (H5_timer_t *timer)
* Programmer: Robb Matzke
* Thursday, April 16, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -170,16 +164,16 @@ H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/)
H5_timer_t now;
HDassert(timer);
- H5_timer_begin (&now);
+ H5_timer_begin(&now);
- timer->utime = MAX(0.0, now.utime - timer->utime);
- timer->stime = MAX(0.0, now.stime - timer->stime);
- timer->etime = MAX(0.0, now.etime - timer->etime);
+ timer->utime = MAX(0.0F, now.utime - timer->utime);
+ timer->stime = MAX(0.0F, now.stime - timer->stime);
+ timer->etime = MAX(0.0F, now.etime - timer->etime);
if (sum) {
- sum->utime += timer->utime;
- sum->stime += timer->stime;
- sum->etime += timer->etime;
+ sum->utime += timer->utime;
+ sum->stime += timer->stime;
+ sum->etime += timer->etime;
}
} /* end H5_timer_end() */
@@ -207,8 +201,6 @@ H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/)
* Programmer: Robb Matzke
* Wednesday, August 5, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -216,35 +208,34 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds)
{
double bw;
- if(nseconds <= 0.0)
- HDstrcpy(buf, " NaN");
+ if(nseconds <= 0.0F)
+ HDstrcpy(buf, " NaN");
else {
- bw = nbytes/nseconds;
- if(HDfabs(bw) < 0.0000000001)
- /* That is == 0.0, but direct comparison between floats is bad */
- HDstrcpy(buf, "0.000 B/s");
- else if(bw < 1.0)
- sprintf(buf, "%10.4e", bw);
- else if(bw < 1024.0) {
- sprintf(buf, "%05.4f", bw);
- HDstrcpy(buf+5, " B/s");
- } else if(bw < (1024.0 * 1024.0)) {
- sprintf(buf, "%05.4f", bw / 1024.0);
- HDstrcpy(buf+5, " kB/s");
- } else if(bw < (1024.0 * 1024.0 * 1024.0)) {
- sprintf(buf, "%05.4f", bw / (1024.0 * 1024.0));
- HDstrcpy(buf+5, " MB/s");
- } else if(bw < (1024.0 * 1024.0 * 1024.0 * 1024.0)) {
- sprintf(buf, "%05.4f", bw / (1024.0 * 1024.0 * 1024.0));
- HDstrcpy(buf+5, " GB/s");
- } else if(bw < (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)) {
- sprintf(buf, "%05.4f", bw / (1024.0 * 1024.0 * 1024.0 * 1024.0));
- HDstrcpy(buf+5, " TB/s");
- } else {
- sprintf(buf, "%10.4e", bw);
- if(HDstrlen(buf) > 10)
- sprintf(buf, "%10.3e", bw);
- }
+ bw = nbytes/nseconds;
+ if(H5_DBL_ABS_EQUAL(bw, 0.0F))
+ HDstrcpy(buf, "0.000 B/s");
+ else if(bw < 1.0F)
+ sprintf(buf, "%10.4e", bw);
+ else if(bw < H5_KB) {
+ sprintf(buf, "%05.4f", bw);
+ HDstrcpy(buf+5, " B/s");
+ } else if(bw < H5_MB) {
+ sprintf(buf, "%05.4f", bw / H5_KB);
+ HDstrcpy(buf+5, " kB/s");
+ } else if(bw < H5_GB) {
+ sprintf(buf, "%05.4f", bw / H5_MB);
+ HDstrcpy(buf+5, " MB/s");
+ } else if(bw < H5_TB) {
+ sprintf(buf, "%05.4f", bw / H5_GB);
+ HDstrcpy(buf+5, " GB/s");
+ } else if(bw < H5_EB) {
+ sprintf(buf, "%05.4f", bw / H5_TB);
+ HDstrcpy(buf+5, " TB/s");
+ } else {
+ sprintf(buf, "%10.4e", bw);
+ if(HDstrlen(buf) > 10)
+ sprintf(buf, "%10.3e", bw);
+ }
}
} /* end H5_bandwidth() */
diff --git a/src/H5trace.c b/src/H5trace.c
index 3a84489..6634a2a 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -110,7 +110,7 @@
* SO MAY CAUSE H5_trace() TO BE INVOKED RECURSIVELY OR MAY
* CAUSE LIBRARY INITIALIZATIONS THAT ARE NOT DESIRED.
*
- * Return: void
+ * Return: Execution time for an API call
*
* Programmer: Robb Matzke
* Tuesday, June 16, 1998
@@ -129,34 +129,34 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
void *vp = NULL;
FILE *out = H5_debug_g.trace;
H5_timer_t event_time;
- static H5_timer_t first_time = {0.0, 0.0, 0.0};
+ static H5_timer_t first_time = {0.0F, 0.0F, 0.0F};
static int current_depth = 0;
static int last_call_depth = 0;
/* FUNC_ENTER() should not be called */
if(!out)
- return 0.0; /*tracing is off*/
+ return 0.0F; /*tracing is off*/
va_start(ap, type);
if(H5_debug_g.ttop) {
if(returning) {
if(current_depth > 1) {
--current_depth;
- return 0.0;
+ return 0.0F;
} /* end if */
} /* end if */
else {
if(current_depth > 0) {
/*do not update last_call_depth*/
current_depth++;
- return 0.0;
+ return 0.0F;
} /* end if */
} /* end else */
} /* end if */
- /* Get tim for event */
- if(HDfabs(first_time.etime) < 0.0000000001)
+ /* Get time for event */
+ if(HDfabs(first_time.etime) < 0.0000000001F)
/* That is == 0.0, but direct comparison between floats is bad */
H5_timer_begin(&first_time);
if(H5_debug_g.ttimes)