diff options
-rw-r--r-- | src/H5timer.c | 49 | ||||
-rw-r--r-- | src/H5trace.c | 191 |
2 files changed, 121 insertions, 119 deletions
diff --git a/src/H5timer.c b/src/H5timer.c index e417f8b..7e6981e 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -131,18 +131,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 / (double)1e6); timer->stime = (double)rusage.ru_stime.tv_sec + - ((double)rusage.ru_stime.tv_usec/1e6); + ((double)rusage.ru_stime.tv_usec / (double)1e6); #else - timer->utime = 0.0; - timer->stime = 0.0; + timer->utime = (double)0.0; + timer->stime = (double)0.0; #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 / (double)1e6); #else - timer->etime = 0.0; + timer->etime = (double)0.0; #endif } /* end H5_timer_begin() */ @@ -172,9 +172,9 @@ H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/) assert (timer); 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((double)0.0, now.utime - timer->utime); + timer->stime = MAX((double)0.0, now.stime - timer->stime); + timer->etime = MAX((double)0.0, now.etime - timer->etime); if (sum) { sum->utime += timer->utime; @@ -216,37 +216,34 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) { double bw; - if (nseconds<=0.0) { + if(nseconds <= (double)0.0) HDstrcpy(buf, " NaN"); - } else { + else { bw = nbytes/nseconds; - if (fabs(bw) < 0.0000000001) { + if(fabs(bw) < (double)0.0000000001) /* That is == 0.0, but direct comparison between floats is bad */ HDstrcpy(buf, "0.000 B/s"); - } else if (bw<1.0) { + else if(bw < (double)1.0) sprintf(buf, "%10.4e", bw); - } else if (bw<1024.0) { + else if(bw < (double)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); + } else if(bw < (double)(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)); + } else if(bw < (double)(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)); + } else if(bw < (double)(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)); + } else if(bw < (double)(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) { + if(HDstrlen(buf) > 10) sprintf(buf, "%10.3e", bw); - } } } } /* end H5_bandwidth() */ diff --git a/src/H5trace.c b/src/H5trace.c index 84f8436..3ee3c3c 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -135,43 +135,43 @@ H5_trace (const double *returning, const char *func, const char *type, ...) va_list ap; char buf[64], *rest; const char *argname; - int argno=0, ptr, asize_idx; + int argno = 0, ptr, asize_idx; hssize_t asize[16]; hssize_t i; 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 int current_depth=0; - static int last_call_depth=0; + static H5_timer_t first_time = {(double)0.0, (double)0.0, (double)0.0}; + 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*/ - va_start (ap, type); + if(!out) return (double)0.0; /*tracing is off*/ + va_start(ap, type); - if (H5_debug_g.ttop) { - if (returning) { - if (current_depth>1) { + if(H5_debug_g.ttop) { + if(returning) { + if(current_depth > 1) { --current_depth; - return 0.0; + return (double)0.0; } } else { - if (current_depth>0) { + if(current_depth > 0) { /*do not update last_call_depth*/ current_depth++; - return 0.0; + return (double)0.0; } } } /* Get tim for event */ - if (fabs(first_time.etime) < 0.0000000001) + if(fabs(first_time.etime) < (double)0.0000000001) /* That is == 0.0, but direct comparison between floats is bad */ H5_timer_begin(&first_time); - if (H5_debug_g.ttimes) { + if(H5_debug_g.ttimes) H5_timer_begin(&event_time); - } else { + else { HDmemset(&event_time, 0, sizeof event_time); } @@ -464,26 +464,26 @@ H5_trace (const double *returning, const char *func, const char *type, ...) fprintf(out, "NULL"); } } else { - H5D_layout_t layout = va_arg (ap, H5D_layout_t); /*lint !e64 Type mismatch not really occuring */ + H5D_layout_t layout = va_arg(ap, H5D_layout_t); /*lint !e64 Type mismatch not really occuring */ switch (layout) { - case H5D_LAYOUT_ERROR: - fprintf (out, "H5D_LAYOUT_ERROR"); - break; - case H5D_COMPACT: - fprintf (out, "H5D_COMPACT"); - break; - case H5D_CONTIGUOUS: - fprintf (out, "H5D_CONTIGUOUS"); - break; - case H5D_CHUNKED: - fprintf (out, "H5D_CHUNKED"); - break; - case H5D_NLAYOUTS: - fprintf (out, "H5D_NLAYOUTS"); - break; - default: - fprintf (out, "%ld", (long)layout); - break; + case H5D_LAYOUT_ERROR: + fprintf (out, "H5D_LAYOUT_ERROR"); + break; + case H5D_COMPACT: + fprintf (out, "H5D_COMPACT"); + break; + case H5D_CONTIGUOUS: + fprintf (out, "H5D_CONTIGUOUS"); + break; + case H5D_CHUNKED: + fprintf (out, "H5D_CHUNKED"); + break; + case H5D_NLAYOUTS: + fprintf (out, "H5D_NLAYOUTS"); + break; + default: + fprintf (out, "%ld", (long)layout); + break; } } break; @@ -497,22 +497,22 @@ H5_trace (const double *returning, const char *func, const char *type, ...) } } else { H5D_space_status_t space_status = va_arg(ap, H5D_space_status_t); /*lint !e64 Type mismatch not really occuring */ - switch (space_status) { - case H5D_SPACE_STATUS_NOT_ALLOCATED: - fprintf (out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); - break; - case H5D_SPACE_STATUS_PART_ALLOCATED: - fprintf (out, "H5D_SPACE_STATUS_PART_ALLOCATED"); - break; - case H5D_SPACE_STATUS_ALLOCATED: - fprintf (out, "H5D_SPACE_STATUS_ALLOCATED"); - break; - case H5D_SPACE_STATUS_ERROR: - fprintf (out, "H5D_SPACE_STATUS_ERROR"); - break; - default: - fprintf (out, "%ld", (long)space_status); - break; + switch(space_status) { + case H5D_SPACE_STATUS_NOT_ALLOCATED: + fprintf (out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); + break; + case H5D_SPACE_STATUS_PART_ALLOCATED: + fprintf (out, "H5D_SPACE_STATUS_PART_ALLOCATED"); + break; + case H5D_SPACE_STATUS_ALLOCATED: + fprintf (out, "H5D_SPACE_STATUS_ALLOCATED"); + break; + case H5D_SPACE_STATUS_ERROR: + fprintf (out, "H5D_SPACE_STATUS_ERROR"); + break; + default: + fprintf (out, "%ld", (long)space_status); + break; } } break; @@ -527,15 +527,15 @@ H5_trace (const double *returning, const char *func, const char *type, ...) } else { H5FD_mpio_xfer_t transfer = va_arg(ap, H5FD_mpio_xfer_t); /*lint !e64 Type mismatch not really occuring */ switch (transfer) { - case H5FD_MPIO_INDEPENDENT: - fprintf (out, "H5FD_MPIO_INDEPENDENT"); - break; - case H5FD_MPIO_COLLECTIVE: - fprintf (out, "H5FD_MPIO_COLLECTIVE"); - break; - default: - fprintf (out, "%ld", (long)transfer); - break; + case H5FD_MPIO_INDEPENDENT: + fprintf (out, "H5FD_MPIO_INDEPENDENT"); + break; + case H5FD_MPIO_COLLECTIVE: + fprintf (out, "H5FD_MPIO_COLLECTIVE"); + break; + default: + fprintf (out, "%ld", (long)transfer); + break; } } break; @@ -571,16 +571,16 @@ H5_trace (const double *returning, const char *func, const char *type, ...) } } else { H5E_direction_t direction = va_arg (ap, H5E_direction_t); /*lint !e64 Type mismatch not really occuring */ - switch (direction) { - case H5E_WALK_UPWARD: - fprintf (out, "H5E_WALK_UPWARD"); - break; - case H5E_WALK_DOWNWARD: - fprintf (out, "H5E_WALK_DOWNWARD"); - break; - default: - fprintf (out, "%ld", (long)direction); - break; + switch(direction) { + case H5E_WALK_UPWARD: + fprintf (out, "H5E_WALK_UPWARD"); + break; + case H5E_WALK_DOWNWARD: + fprintf (out, "H5E_WALK_DOWNWARD"); + break; + default: + fprintf (out, "%ld", (long)direction); + break; } } break; @@ -607,16 +607,16 @@ H5_trace (const double *returning, const char *func, const char *type, ...) } } else { H5E_type_t etype = va_arg (ap, H5E_type_t); /*lint !e64 Type mismatch not really occuring */ - switch (etype) { - case H5E_MAJOR: - fprintf (out, "H5E_MAJOR"); - break; - case H5E_MINOR: - fprintf (out, "H5E_MINOR"); - break; - default: - fprintf (out, "%ld", (long)etype); - break; + switch(etype) { + case H5E_MAJOR: + fprintf (out, "H5E_MAJOR"); + break; + case H5E_MINOR: + fprintf (out, "H5E_MINOR"); + break; + default: + fprintf (out, "%ld", (long)etype); + break; } } break; @@ -1822,34 +1822,39 @@ H5_trace (const double *returning, const char *func, const char *type, ...) break; case 'p': - if (ptr) { - if (vp) { - fprintf (out, "0x%lx", (unsigned long)vp); - } else { + if(ptr) { + if(vp) + fprintf(out, "0x%lx", (unsigned long)vp); + else fprintf(out, "NULL"); - } } else { - H5T_pad_t pad = va_arg (ap, H5T_pad_t); /*lint !e64 Type mismatch not really occuring */ - switch (pad) { + H5T_pad_t pad = (H5T_pad_t)va_arg(ap, H5T_pad_t); /*lint !e64 Type mismatch not really occuring */ + + switch(pad) { case H5T_PAD_ERROR: - fprintf (out, "H5T_PAD_ERROR"); + fprintf(out, "H5T_PAD_ERROR"); break; + case H5T_PAD_ZERO: - fprintf (out, "H5T_PAD_ZERO"); + fprintf(out, "H5T_PAD_ZERO"); break; + case H5T_PAD_ONE: - fprintf (out, "H5T_PAD_ONE"); + fprintf(out, "H5T_PAD_ONE"); break; + case H5T_PAD_BACKGROUND: - fprintf (out, "H5T_PAD_BACKGROUND"); + fprintf(out, "H5T_PAD_BACKGROUND"); break; + case H5T_NPAD: - fprintf (out, "H5T_NPAD"); + fprintf(out, "H5T_NPAD"); break; + default: - fprintf (out, "%ld", (long)pad); + fprintf(out, "%ld", (long)pad); break; - } + } /* end switch */ } break; |