diff options
Diffstat (limited to 'perform')
-rw-r--r-- | perform/pio_engine.c | 56 | ||||
-rw-r--r-- | perform/pio_perf.c | 20 | ||||
-rw-r--r-- | perform/sio_engine.c | 30 | ||||
-rw-r--r-- | perform/sio_perf.c | 12 | ||||
-rw-r--r-- | perform/sio_standalone.h | 23 | ||||
-rw-r--r-- | perform/zip_perf.c | 148 |
6 files changed, 154 insertions, 135 deletions
diff --git a/perform/pio_engine.c b/perform/pio_engine.c index 0e3190c..87fa82c 100644 --- a/perform/pio_engine.c +++ b/perform/pio_engine.c @@ -245,52 +245,52 @@ do_pio(parameters param) /* Validate transfer buffer size & block size*/ if(blk_size<=0) { HDfprintf(stderr, - "Transfer block size (%Hd) must be > 0\n", (long long)blk_size); + "Transfer block size (%zu) must be > 0\n", blk_size); GOTOERROR(FAIL); } if(buf_size<=0) { HDfprintf(stderr, - "Transfer buffer size (%Hd) must be > 0\n", (long long)buf_size); + "Transfer buffer size (%zu) must be > 0\n", buf_size); GOTOERROR(FAIL); } if ((buf_size % blk_size) != 0){ HDfprintf(stderr, - "Transfer buffer size (%Hd) must be a multiple of the " - "interleaved I/O block size (%Hd)\n", - (long long)buf_size, (long long)blk_size); + "Transfer buffer size (%zu) must be a multiple of the " + "interleaved I/O block size (%zu)\n", + buf_size, blk_size); GOTOERROR(FAIL); } if((snbytes%pio_mpi_nprocs_g)!=0) { HDfprintf(stderr, - "Dataset size (%Hd) must be a multiple of the " - "number of processes (%d)\n", - (long long)snbytes, pio_mpi_nprocs_g); + "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "number of processes (%d)\n", + (long long)snbytes, pio_mpi_nprocs_g); GOTOERROR(FAIL); } if (!param.dim2d){ if(((snbytes/pio_mpi_nprocs_g)%buf_size)!=0) { HDfprintf(stderr, - "Dataset size/process (%Hd) must be a multiple of the " - "trasfer buffer size (%Hd)\n", - (long long)(snbytes/pio_mpi_nprocs_g), (long long)buf_size); + "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "trasfer buffer size (%zu)\n", + (long long)(snbytes/pio_mpi_nprocs_g), buf_size); GOTOERROR(FAIL); } } else { if((snbytes%buf_size)!=0) { HDfprintf(stderr, - "Dataset side size (%Hd) must be a multiple of the " - "trasfer buffer size (%Hd)\n", - (long long)snbytes, (long long)buf_size); + "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "trasfer buffer size (%zu)\n", + (long long)snbytes, buf_size); GOTOERROR(FAIL); } } /* Allocate transfer buffer */ if ((buffer = malloc(bsize)) == NULL){ - HDfprintf(stderr, "malloc for transfer buffer size (%Hd) failed\n", - (long long)(bsize)); + HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", + bsize); GOTOERROR(FAIL); } @@ -651,13 +651,13 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, HDprint_rank(output); if (!parms->dim2d) { HDfprintf(output, "Debug(do_write): " - "buf_size=%Hd, bytes_begin=%Hd, bytes_count=%Hd\n", - (long long)buf_size, (long long)bytes_begin[0], + "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + buf_size, (long long)bytes_begin[0], (long long)bytes_count); } else { HDfprintf(output, "Debug(do_write): " - "linear buf_size=%Hd, bytes_begin=(%Hd,%Hd), bytes_count=%Hd\n", - (long long)buf_size*blk_size, (long long)bytes_begin[0], + "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + buf_size*blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1], (long long)bytes_count); } } @@ -1625,13 +1625,13 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, HDprint_rank(output); if (!parms->dim2d) { HDfprintf(output, "Debug(do_write): " - "buf_size=%Hd, bytes_begin=%Hd, bytes_count=%Hd\n", - (long long)buf_size, (long long)bytes_begin[0], + "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + buf_size, (long long)bytes_begin[0], (long long)bytes_count); } else { HDfprintf(output, "Debug(do_write): " - "linear buf_size=%Hd, bytes_begin=(%Hd,%Hd), bytes_count=%Hd\n", - (long long)buf_size*blk_size, (long long)bytes_begin[0], + "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + buf_size*blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1], (long long)bytes_count); } } @@ -2336,10 +2336,10 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, if (++nerror < 20){ /* report at most 20 errors */ HDprint_rank(output); - HDfprintf(output, "read data error, expected (%Hd), " - "got (%Hd)\n", - (long long)pio_mpi_rank_g+1, - (long long)*(ucharptr-1)); + HDfprintf(output, "read data error, expected (%d), " + "got (%d)\n", + pio_mpi_rank_g+1, + (int)*(ucharptr-1)); } /* end if */ } /* end if */ } /* end for */ diff --git a/perform/pio_perf.c b/perform/pio_perf.c index 337e982..a47754b 100644 --- a/perform/pio_perf.c +++ b/perform/pio_perf.c @@ -1116,14 +1116,14 @@ recover_size_and_print(long long val, const char *end) if (val >= ONE_KB && (val % ONE_KB) == 0) { if (val >= ONE_MB && (val % ONE_MB) == 0) { if (val >= ONE_GB && (val % ONE_GB) == 0) - HDfprintf(output, "%HdGB%s", val / ONE_GB, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end); else - HDfprintf(output, "%HdMB%s", val / ONE_MB, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end); } else { - HDfprintf(output, "%HdKB%s", val / ONE_KB, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end); } } else { - HDfprintf(output, "%Hd%s", val, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end); } } @@ -1150,12 +1150,12 @@ report_parameters(struct options *opts) HDfprintf(output, "rank %d: IO API=", rank); print_io_api(opts->io_types); - HDfprintf(output, "rank %d: Number of files=%Hd\n", rank, - (long long)opts->num_files); - HDfprintf(output, "rank %d: Number of datasets=%Hd\n", rank, - (long long)opts->num_dsets); - HDfprintf(output, "rank %d: Number of iterations=%Hd\n", rank, - (long long)opts->num_iters); + HDfprintf(output, "rank %d: Number of files=%ld\n", rank, + opts->num_files); + HDfprintf(output, "rank %d: Number of datasets=%ld\n", rank, + opts->num_dsets); + HDfprintf(output, "rank %d: Number of iterations=%d\n", rank, + opts->num_iters); HDfprintf(output, "rank %d: Number of processes=%d:%d\n", rank, opts->min_num_procs, opts->max_num_procs); diff --git a/perform/sio_engine.c b/perform/sio_engine.c index 4d6afd8..8539f75 100644 --- a/perform/sio_engine.c +++ b/perform/sio_engine.c @@ -196,15 +196,15 @@ do_sio(parameters param) /* Validate transfer buffer size */ if (param.buf_size[i]<=0) { HDfprintf(stderr, - "Transfer buffer size[%d] (%Hd) must be > 0\n", i,(long long)buf_size[i]); + "Transfer buffer size[%d] (%zu) must be > 0\n", i,buf_size[i]); GOTOERROR(FAIL); } if ((param.dset_size[i]%param.buf_size[i])!=0) { HDfprintf(stderr, - "Dataset size[%d] (%Hd) must be a multiple of the " - "trasfer buffer size[%d] (%Hd)\n",param.rank, - (long long)param.dset_size[i], param.rank, (long long)param.buf_size[i]); + "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "trasfer buffer size[%d] (%zu)\n",param.rank, + (long long)param.dset_size[i], param.rank, param.buf_size[i]); GOTOERROR(FAIL); } @@ -212,7 +212,7 @@ do_sio(parameters param) /* Allocate transfer buffer */ if ((buffer = malloc(linear_buf_size)) == NULL){ - HDfprintf(stderr, "malloc for transfer buffer size (%Hd) failed\n", (long long)(linear_buf_size)); + HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", linear_buf_size); GOTOERROR(FAIL); } @@ -1149,25 +1149,25 @@ done: hid_t set_vfd(parameters *param) { - hid_t fapl = -1; + hid_t my_fapl = -1; vfdtype vfd; vfd = param->vfd; - if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; + if ((my_fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; if (vfd == sec2) { /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; + if (H5Pset_fapl_sec2(my_fapl)<0) return -1; } else if (vfd == stdio) { /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; + if (H5Pset_fapl_stdio(my_fapl)<0) return -1; } else if (vfd == core) { /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, (size_t)1024*1024, TRUE)<0) return -1; + if (H5Pset_fapl_core(my_fapl, (size_t)1024*1024, TRUE)<0) return -1; } else if (vfd == split) { /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, + if (H5Pset_fapl_split(my_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) return -1; @@ -1193,7 +1193,7 @@ set_vfd(parameters *param) memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); } - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, + if (H5Pset_fapl_multi(my_fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE)<0) { return -1; } @@ -1203,20 +1203,20 @@ set_vfd(parameters *param) /* Family of files, each 1MB and using the default driver */ /* if ((val=HDstrtok(NULL, " \t\n\r"))) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); */ - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + if (H5Pset_fapl_family(my_fapl, fam_size, H5P_DEFAULT)<0) return -1; } else if (vfd == direct) { #ifdef H5_HAVE_DIRECT /* Linux direct read() and write() system calls. Set memory boundary, file block size, * and copy buffer size to the default values. */ - if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1; + if (H5Pset_fapl_direct(my_fapl, 1024, 4096, 8*4096)<0) return -1; #endif } else { /* Unknown driver */ return -1; } - return fapl; + return my_fapl; } /* diff --git a/perform/sio_perf.c b/perform/sio_perf.c index 985f3c4..7df9337 100644 --- a/perform/sio_perf.c +++ b/perform/sio_perf.c @@ -832,14 +832,14 @@ recover_size_and_print(long long val, const char *end) if (val >= ONE_KB && (val % ONE_KB) == 0) { if (val >= ONE_MB && (val % ONE_MB) == 0) { if (val >= ONE_GB && (val % ONE_GB) == 0) - HDfprintf(output, "%HdGB%s", val / ONE_GB, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end); else - HDfprintf(output, "%HdMB%s", val / ONE_MB, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end); } else { - HDfprintf(output, "%HdKB%s", val / ONE_KB, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end); } } else { - HDfprintf(output, "%Hd%s", val, end); + HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end); } } @@ -865,8 +865,8 @@ report_parameters(struct options *opts) HDfprintf(output, "IO API="); print_io_api(opts->io_types); - HDfprintf(output, "Number of iterations=%Hd\n", - (long long)opts->num_iters); + HDfprintf(output, "Number of iterations=%d\n", + opts->num_iters); HDfprintf(output, "Dataset size="); diff --git a/perform/sio_standalone.h b/perform/sio_standalone.h index 677a8ae..b407ecb 100644 --- a/perform/sio_standalone.h +++ b/perform/sio_standalone.h @@ -62,7 +62,15 @@ */ #define HDabort() abort() #define HDabs(X) abs(X) +#ifdef H5_HAVE_WIN32_API +#define HDaccess(F,M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#else /* H5_HAVE_WIN32_API */ #define HDaccess(F,M) access(F, M) +#endif /* H5_HAVE_WIN32_API */ #define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM #define HDalarm(N) alarm(N) @@ -214,7 +222,12 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetpwuid(U) getpwuid(U) #define HDgetrusage(X,S) getrusage(X,S) #define HDgets(S) gets(S) +#ifdef H5_HAVE_VISUAL_STUDIO + H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +#else /* H5_HAVE_VISUAL_STUDIO */ #define HDgettimeofday(S,P) gettimeofday(S,P) +#endif /* H5_HAVE_VISUAL_STUDIO */ #define HDgetuid() getuid() #define HDgmtime(T) gmtime(T) #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ @@ -355,7 +368,8 @@ int HDremove_all(const char * fname); #define HDsinh(X) sinh(X) #define HDsleep(N) sleep(N) #ifdef H5_HAVE_WIN32_API -#define HDsnprintf _snprintf /*varargs*/ +H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); +#define HDsnprintf c99_snprintf /*varargs*/ #else #define HDsnprintf snprintf /*varargs*/ #endif @@ -373,7 +387,11 @@ H5_DLL void HDsrand(unsigned int seed); #endif /* sscanf() variable arguments */ +#ifdef H5_HAVE_WIN32_API +#define HDstrcasecmp(A,B) _stricmp(A,B) +#else #define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#endif #define HDstrcat(X,Y) strcat(X,Y) #define HDstrchr(S,C) strchr(S,C) #define HDstrcmp(X,Y) strcmp(X,Y) @@ -433,7 +451,8 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #define HDvprintf(FMT,A) vprintf(FMT,A) #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) #ifdef H5_HAVE_WIN32_API -# define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A) +H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); +#define HDvsnprintf c99_vsnprintf #else # define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) #endif diff --git a/perform/zip_perf.c b/perform/zip_perf.c index 585dc13..f76e10b 100644 --- a/perform/zip_perf.c +++ b/perform/zip_perf.c @@ -157,11 +157,11 @@ error(const char *fmt, ...) va_list ap; va_start(ap, fmt); - fprintf(stderr, "%s: error: ", prog); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); + HDfprintf(stderr, "%s: error: ", prog); + HDvfprintf(stderr, fmt, ap); + HDfprintf(stderr, "\n"); va_end(ap); - exit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } /* @@ -174,9 +174,9 @@ error(const char *fmt, ...) static void cleanup(void) { - if (!getenv("HDF5_NOCLEANUP")) - unlink(filename); - free(filename); + if (!HDgetenv("HDF5_NOCLEANUP")) + HDunlink(filename); + HDfree(filename); } static void @@ -189,7 +189,7 @@ write_file(Bytef *source, uLongf sourceLen) /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ destLen = (uLongf)((double)sourceLen + ((double)sourceLen * 0.1)) + 12; - dest = (Bytef *)malloc(destLen); + dest = (Bytef *)HDmalloc(destLen); if (!dest) error("out of memory"); @@ -204,7 +204,7 @@ write_file(Bytef *source, uLongf sourceLen) ((double)timer_start.tv_usec) / MICROSECOND); if (report_once_flag) { - printf("\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); + HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); report_once_flag = 0; } @@ -213,10 +213,10 @@ write_file(Bytef *source, uLongf sourceLen) /* loop to make sure we write everything out that we want to write */ for (;;) { - int rc = (int)write(output, d_ptr, (size_t)d_len); + int rc = (int)HDwrite(output, d_ptr, (size_t)d_len); if (rc == -1) - error(strerror(errno)); + error(HDstrerror(errno)); if (rc == (int)d_len) break; @@ -225,7 +225,7 @@ write_file(Bytef *source, uLongf sourceLen) d_ptr += rc; } - free(dest); + HDfree(dest); } /* @@ -299,7 +299,7 @@ static void get_unique_name(void) { const char *prefix = NULL; - const char *env = getenv("HDF5_PREFIX"); + const char *env = HDgetenv("HDF5_PREFIX"); if (env) prefix = env; @@ -309,19 +309,19 @@ get_unique_name(void) if (prefix) /* 2 = 1 for '/' + 1 for null terminator */ - filename = (char *) HDmalloc(strlen(prefix) + strlen(ZIP_PERF_FILE) + 2); + filename = (char *) HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2); else - filename = (char *) HDmalloc(strlen(ZIP_PERF_FILE) + 1); + filename = (char *) HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1); if (!filename) error("out of memory"); filename[0] = 0; if (prefix){ - strcpy(filename, prefix); - strcat(filename, "/"); + HDstrcpy(filename, prefix); + HDstrcat(filename, "/"); } - strcat(filename, ZIP_PERF_FILE); + HDstrcat(filename, ZIP_PERF_FILE); } /* @@ -334,30 +334,30 @@ get_unique_name(void) static void usage(void) { - printf("usage: %s [OPTIONS]\n", prog); - printf(" OPTIONS\n"); - printf(" -h, --help Print this usage message and exit\n"); - printf(" -1...-9 Level of compression, from 1 to 9\n"); - printf(" -c P, --compressability=P Percentage of compressability of the random\n"); - printf(" data you want [default: 0]"); - printf(" -s S, --file-size=S Maximum size of uncompressed file [default: 64M]\n"); - printf(" -B S, --max-buffer_size=S Maximum size of buffer [default: 1M]\n"); - printf(" -b S, --min-buffer_size=S Minumum size of buffer [default: 128K]\n"); - printf(" -p D, --prefix=D The directory prefix to place the file\n"); - printf(" -r, --random-test Use random data to write to the file\n"); - printf(" [default: no]\n"); - printf("\n"); - printf(" D - a directory which exists\n"); - printf(" P - a number between 0 and 100\n"); - printf(" S - is a size specifier, an integer >=0 followed by a size indicator:\n"); - printf("\n"); - printf(" K - Kilobyte (%d)\n", ONE_KB); - printf(" M - Megabyte (%d)\n", ONE_MB); - printf(" G - Gigabyte (%d)\n", ONE_GB); - printf("\n"); - printf(" Example: 37M = 37 Megabytes = %d bytes\n", 37 * ONE_MB); - printf("\n"); - fflush(stdout); + HDfprintf(stdout, "usage: %s [OPTIONS]\n", prog); + HDfprintf(stdout, " OPTIONS\n"); + HDfprintf(stdout, " -h, --help Print this usage message and exit\n"); + HDfprintf(stdout, " -1...-9 Level of compression, from 1 to 9\n"); + HDfprintf(stdout, " -c P, --compressability=P Percentage of compressability of the random\n"); + HDfprintf(stdout, " data you want [default: 0]"); + HDfprintf(stdout, " -s S, --file-size=S Maximum size of uncompressed file [default: 64M]\n"); + HDfprintf(stdout, " -B S, --max-buffer_size=S Maximum size of buffer [default: 1M]\n"); + HDfprintf(stdout, " -b S, --min-buffer_size=S Minumum size of buffer [default: 128K]\n"); + HDfprintf(stdout, " -p D, --prefix=D The directory prefix to place the file\n"); + HDfprintf(stdout, " -r, --random-test Use random data to write to the file\n"); + HDfprintf(stdout, " [default: no]\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " D - a directory which exists\n"); + HDfprintf(stdout, " P - a number between 0 and 100\n"); + HDfprintf(stdout, " S - is a size specifier, an integer >=0 followed by a size indicator:\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " K - Kilobyte (%d)\n", ONE_KB); + HDfprintf(stdout, " M - Megabyte (%d)\n", ONE_MB); + HDfprintf(stdout, " G - Gigabyte (%d)\n", ONE_GB); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " Example: 37M = 37 Megabytes = %d bytes\n", 37 * ONE_MB); + HDfprintf(stdout, "\n"); + HDfflush(stdout); } /* @@ -380,7 +380,7 @@ parse_size_directive(const char *size) unsigned long s; char *endptr; - s = strtoul(size, &endptr, 10); + s = HDstrtoul(size, &endptr, 10); if (endptr && *endptr) { while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) @@ -419,16 +419,16 @@ fill_with_random_data(Bytef *src, uLongf src_len) Bytef *buf = src; int fd = HDopen("/dev/urandom", O_RDONLY, 0); - printf("Using /dev/urandom for random data\n"); + HDfprintf(stdout, "Using /dev/urandom for random data\n"); if (fd < 0) - error(strerror(errno)); + error(HDstrerror(errno)); for (;;) { - ssize_t rc = read(fd, buf, src_len); + ssize_t rc = HDread(fd, buf, src_len); if (rc == -1) - error(strerror(errno)); + error(HDstrerror(errno)); if (rc == (ssize_t)len) break; @@ -437,7 +437,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) len -= rc; } } else { - printf("Using random() for random data\n"); + HDfprintf(stdout, "Using random() for random data\n"); for (u = 0; u < src_len; ++u) src[u] = (Bytef)(0xff & HDrandom()); @@ -446,7 +446,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) if (compress_percent) { unsigned long s = src_len * compress_percent / 100; - memset(src, '\0', s); + HDmemset(src, '\0', s); } } @@ -463,7 +463,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, register unsigned long i, iters; iters = file_size / src_len; - src = (Bytef *)calloc(1, sizeof(Bytef) * src_len); + src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); if (!src) { cleanup(); @@ -475,26 +475,26 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, if (random_test) fill_with_random_data(src, src_len); - printf("Buffer size == "); + HDfprintf(stdout, "Buffer size == "); if (src_len >= ONE_KB && (src_len % ONE_KB) == 0) { if (src_len >= ONE_MB && (src_len % ONE_MB) == 0) { - printf("%ldMB", src_len / ONE_MB); + HDfprintf(stdout, "%ldMB", src_len / ONE_MB); } else { - printf("%ldKB", src_len / ONE_KB); + HDfprintf(stdout, "%ldKB", src_len / ONE_KB); } } else { - printf("%ld", src_len); + HDfprintf(stdout, "%ld", src_len); } - printf("\n"); + HDfprintf(stdout, "\n"); /* do uncompressed data write */ HDgettimeofday(&timer_start, NULL); output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) - error(strerror(errno)); + error(HDstrerror(errno)); for (i = 0; i <= iters; ++i) { Bytef *s_ptr = src; @@ -502,10 +502,10 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, /* loop to make sure we write everything out that we want to write */ for (;;) { - ssize_t rc = write(output, s_ptr, s_len); + ssize_t rc = HDwrite(output, s_ptr, s_len); if (rc == -1) - error(strerror(errno)); + error(HDstrerror(errno)); if (rc == (ssize_t)s_len) break; @@ -515,7 +515,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, } } - close(output); + HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + @@ -523,17 +523,17 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); - printf("\tUncompressed Write Time: %.2fs\n", total_time); - printf("\tUncompressed Write Throughput: %.2fMB/s\n", + HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); + HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); - unlink(filename); + HDunlink(filename); /* do compressed data write */ output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) - error(strerror(errno)); + error(HDstrerror(errno)); report_once_flag = 1; HDgettimeofday(&timer_start, NULL); @@ -541,7 +541,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, for (total_len = 0; total_len < file_size; total_len += src_len) write_file(src, src_len); - close(output); + HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + @@ -549,13 +549,13 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); - printf("\tCompressed Write Time: %.2fs\n", total_time); - printf("\tCompressed Write Throughput: %.2fMB/s\n", + HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); + HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); - printf("\tCompression Time: %gs\n", compression_time); + HDfprintf(stdout, "\tCompression Time: %gs\n", compression_time); - unlink(filename); - free(src); + HDunlink(filename); + HDfree(src); } } @@ -593,7 +593,7 @@ main(int argc, char **argv) min_buf_size = parse_size_directive(opt_arg); break; case 'c': - compress_percent = (int)strtol(opt_arg, NULL, 10); + compress_percent = (int)HDstrtol(opt_arg, NULL, 10); if (compress_percent < 0) compress_percent = 0; @@ -626,12 +626,12 @@ main(int argc, char **argv) error("minmum buffer size (%d) exceeds maximum buffer size (%d)", min_buf_size, max_buf_size); - printf("Filesize: %ld\n", file_size); + HDfprintf(stdout, "Filesize: %ld\n", file_size); if (compress_level == Z_DEFAULT_COMPRESSION) - printf("Compression Level: 6\n"); + HDfprintf(stdout, "Compression Level: 6\n"); else - printf("Compression Level: %d\n", compress_level); + HDfprintf(stdout, "Compression Level: %d\n", compress_level); get_unique_name(); do_write_test(file_size, min_buf_size, max_buf_size); @@ -652,7 +652,7 @@ main(int argc, char **argv) int main(void) { - printf("No compression IO performance because zlib was not configured\n"); + HDfprintf(stdout, "No compression IO performance because zlib was not configured\n"); return EXIT_SUCCESS; } |