From cfc376080860337f8f7a6716ed50e9d123eb7176 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 30 Aug 2011 10:35:30 -0500 Subject: [svn-r21334] HDFFV-7687: add HD macro prefrix to functions and use h5_stat_t where necessary reviewed --- perform/CMakeLists.txt | 14 ++++--- perform/pio_engine.c | 98 +++++++++++++++++++++++++------------------------ perform/zip_perf.c | 2 +- testpar/t_chunk_alloc.c | 4 +- testpar/t_mpi.c | 4 +- testpar/testphdf5.c | 2 +- 6 files changed, 65 insertions(+), 59 deletions(-) diff --git a/perform/CMakeLists.txt b/perform/CMakeLists.txt index 66a0794..95ffd30 100644 --- a/perform/CMakeLists.txt +++ b/perform/CMakeLists.txt @@ -110,12 +110,14 @@ IF (H5_HAVE_PARALLEL) TARGET_LINK_LIBRARIES (benchpar ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) #-- Adding test for mpi-perf - SET (mpi-perf_SRCS - ${HDF5_PERFORM_SOURCE_DIR}/mpi-perf.c - ) - ADD_EXECUTABLE (mpi-perf ${mpi-perf_SRCS}) - TARGET_NAMING (mpi-perf ${LIB_TYPE}) - TARGET_LINK_LIBRARIES (mpi-perf ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + IF (NOT WIN32) + SET (mpi-perf_SRCS + ${HDF5_PERFORM_SOURCE_DIR}/mpi-perf.c + ) + ADD_EXECUTABLE (mpi-perf ${mpi-perf_SRCS}) + TARGET_NAMING (mpi-perf ${LIB_TYPE}) + TARGET_LINK_LIBRARIES (mpi-perf ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + ENDIF (NOT WIN32) ENDIF (H5_HAVE_PARALLEL) diff --git a/perform/pio_engine.c b/perform/pio_engine.c index 129addf..abb72fa 100644 --- a/perform/pio_engine.c +++ b/perform/pio_engine.c @@ -418,9 +418,9 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si size_t i, j; if (!base_name || !fullname || size < 1) - return NULL; + return NULL; - memset(fullname, 0, size); + HDmemset(fullname, 0, size); switch (iot) { case POSIXIO: @@ -435,77 +435,81 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si } /* First use the environment variable and then try the constant */ - prefix = getenv("HDF5_PARAPREFIX"); + prefix = HDgetenv("HDF5_PARAPREFIX"); #ifdef HDF5_PARAPREFIX if (!prefix) - prefix = HDF5_PARAPREFIX; + prefix = HDF5_PARAPREFIX; #endif /* HDF5_PARAPREFIX */ /* Prepend the prefix value to the base name */ if (prefix && *prefix) { - /* If the prefix specifies the HDF5_PARAPREFIX directory, then - * default to using the "/tmp/$USER" or "/tmp/$LOGIN" - * directory instead. */ - register char *user, *login, *subdir; - - user = getenv("USER"); - login = getenv("LOGIN"); - subdir = (user ? user : login); + /* If the prefix specifies the HDF5_PARAPREFIX directory, then + * default to using the "/tmp/$USER" or "/tmp/$LOGIN" + * directory instead. */ + register char *user, *login, *subdir; - if (subdir) { - for (i = 0; i < size && prefix[i]; i++) - fullname[i] = prefix[i]; + user = HDgetenv("USER"); + login = HDgetenv("LOGIN"); + subdir = (user ? user : login); - fullname[i++] = '/'; + if (subdir) { + for (i = 0; i < size && prefix[i]; i++) + fullname[i] = prefix[i]; - for (j = 0; i < size && subdir[j]; i++, j++) - fullname[i] = subdir[j]; - } else { - /* We didn't append the prefix yet */ - strncpy(fullname, prefix, MIN(strlen(prefix), size)); - } + fullname[i++] = '/'; - if ((strlen(fullname) + strlen(base_name) + 1) < size) { - /* Append the base_name with a slash first. Multiple slashes are - * handled below. */ - h5_stat_t buf; - - if (HDstat(fullname, &buf) < 0) - /* The directory doesn't exist just yet */ - if (mkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) { - /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. - * Default to PREFIX's original prefix value. */ - strcpy(fullname, prefix); + for (j = 0; i < size && subdir[j]; i++, j++) + fullname[i] = subdir[j]; + } + else { + /* We didn't append the prefix yet */ + HDstrncpy(fullname, prefix, MIN(HDstrlen(prefix), size)); } - strcat(fullname, "/"); - strcat(fullname, base_name); - } else { + if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) { + /* Append the base_name with a slash first. Multiple slashes are + * handled below. */ + h5_stat_t buf; + + if (HDstat(fullname, &buf) < 0) + /* The directory doesn't exist just yet */ + if (HDmkdir(fullname, (mode_t) 0755) < 0 && errno != EEXIST) { + /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. + * Default to PREFIX's original prefix value. */ + HDstrcpy(fullname, prefix); + } + + HDstrcat(fullname, "/"); + HDstrcat(fullname, base_name); + } + else { + /* Buffer is too small */ + return NULL; + } + } + else if (HDstrlen(base_name) >= size) { /* Buffer is too small */ return NULL; } - } else if (strlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; - } else { - strcpy(fullname, base_name); + else { + HDstrcpy(fullname, base_name); } /* Append a suffix */ if (suffix) { - if (strlen(fullname) + strlen(suffix) >= size) - return NULL; + if (HDstrlen(fullname) + HDstrlen(suffix) >= size) + return NULL; - strcat(fullname, suffix); + HDstrcat(fullname, suffix); } /* Remove any double slashes in the filename */ for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) { - if (*ptr != '/' || last != '/') - fullname[j++] = *ptr; + if (*ptr != '/' || last != '/') + fullname[j++] = *ptr; - last = *ptr; + last = *ptr; } return fullname; diff --git a/perform/zip_perf.c b/perform/zip_perf.c index fdd824b..897fc7e 100644 --- a/perform/zip_perf.c +++ b/perform/zip_perf.c @@ -413,7 +413,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) register unsigned u; h5_stat_t stat_buf; - if (stat("/dev/urandom", &stat_buf) == 0) { + if (HDstat("/dev/urandom", &stat_buf) == 0) { uLongf len = src_len; Bytef *buf = src; int fd = HDopen("/dev/urandom", O_RDONLY, 0); diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c index bb13d4e..e8a6ca4 100644 --- a/testpar/t_chunk_alloc.c +++ b/testpar/t_chunk_alloc.c @@ -37,7 +37,7 @@ get_filesize(const char *filename) MPI_File fd; MPI_Offset filesize; #ifndef H5_HAVE_MPI_GET_SIZE - struct stat stat_buf; + h5_stat_t stat_buf; #endif #ifdef H5_HAVE_MPI_GET_SIZE @@ -54,7 +54,7 @@ get_filesize(const char *filename) /* Some systems (only SGI Altix Propack 4 so far) doesn't return correct * file size for MPI_File_get_size. Use stat instead. */ - if((mpierr=stat(filename, &stat_buf))<0) + if((mpierr=HDstat(filename, &stat_buf))<0) VRFY((mpierr == MPI_SUCCESS), ""); /* Hopefully this casting is safe */ diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c index cf2cb35..6cba5af 100644 --- a/testpar/t_mpi.c +++ b/testpar/t_mpi.c @@ -206,7 +206,7 @@ test_mpio_gb_file(char *filename) MPI_Offset mpi_off; MPI_Offset mpi_off_old; MPI_Status mpi_stat; - struct stat stat_buf; + h5_stat_t stat_buf; int is_signed, sizeof_mpi_offset; nerrs = 0; @@ -395,7 +395,7 @@ test_mpio_gb_file(char *filename) mrc = MPI_File_get_size(fh, &size); VRFY((mrc==MPI_SUCCESS), ""); - mrc=stat(filename, &stat_buf); + mrc=HDstat(filename, &stat_buf); VRFY((mrc==0), ""); /* Hopefully this casting is safe */ diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index 8b24f87..07568d4 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -81,7 +81,7 @@ void pause_proc(void) MPI_Get_processor_name(mpi_name, &mpi_namelen); if (MAINPROCESS) - while ((stat(greenlight, &statbuf) == -1) && loops < maxloop){ + while ((HDstat(greenlight, &statbuf) == -1) && loops < maxloop){ if (!loops++){ printf("Proc %d (%*s, %d): to debug, attach %d\n", mpi_rank, mpi_namelen, mpi_name, pid, pid); -- cgit v0.12