[svn-r21334] HDFFV-7687: add HD macro prefrix to functions and use h5_stat_t where necessary

reviewed
This commit is contained in:
Allen Byrne 2011-08-30 10:35:30 -05:00
parent 4f3950a882
commit cfc3760808
6 changed files with 65 additions and 59 deletions

View File

@ -110,12 +110,14 @@ IF (H5_HAVE_PARALLEL)
TARGET_LINK_LIBRARIES (benchpar ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) TARGET_LINK_LIBRARIES (benchpar ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
#-- Adding test for mpi-perf #-- Adding test for mpi-perf
SET (mpi-perf_SRCS IF (NOT WIN32)
${HDF5_PERFORM_SOURCE_DIR}/mpi-perf.c SET (mpi-perf_SRCS
) ${HDF5_PERFORM_SOURCE_DIR}/mpi-perf.c
ADD_EXECUTABLE (mpi-perf ${mpi-perf_SRCS}) )
TARGET_NAMING (mpi-perf ${LIB_TYPE}) ADD_EXECUTABLE (mpi-perf ${mpi-perf_SRCS})
TARGET_LINK_LIBRARIES (mpi-perf ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) 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) ENDIF (H5_HAVE_PARALLEL)

View File

@ -418,9 +418,9 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si
size_t i, j; size_t i, j;
if (!base_name || !fullname || size < 1) if (!base_name || !fullname || size < 1)
return NULL; return NULL;
memset(fullname, 0, size); HDmemset(fullname, 0, size);
switch (iot) { switch (iot) {
case POSIXIO: 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 */ /* First use the environment variable and then try the constant */
prefix = getenv("HDF5_PARAPREFIX"); prefix = HDgetenv("HDF5_PARAPREFIX");
#ifdef HDF5_PARAPREFIX #ifdef HDF5_PARAPREFIX
if (!prefix) if (!prefix)
prefix = HDF5_PARAPREFIX; prefix = HDF5_PARAPREFIX;
#endif /* HDF5_PARAPREFIX */ #endif /* HDF5_PARAPREFIX */
/* Prepend the prefix value to the base name */ /* Prepend the prefix value to the base name */
if (prefix && *prefix) { if (prefix && *prefix) {
/* If the prefix specifies the HDF5_PARAPREFIX directory, then /* If the prefix specifies the HDF5_PARAPREFIX directory, then
* default to using the "/tmp/$USER" or "/tmp/$LOGIN" * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
* directory instead. */ * directory instead. */
register char *user, *login, *subdir; register char *user, *login, *subdir;
user = getenv("USER"); user = HDgetenv("USER");
login = getenv("LOGIN"); login = HDgetenv("LOGIN");
subdir = (user ? user : login); subdir = (user ? user : login);
if (subdir) { if (subdir) {
for (i = 0; i < size && prefix[i]; i++) for (i = 0; i < size && prefix[i]; i++)
fullname[i] = prefix[i]; fullname[i] = prefix[i];
fullname[i++] = '/'; fullname[i++] = '/';
for (j = 0; i < size && subdir[j]; i++, j++) for (j = 0; i < size && subdir[j]; i++, j++)
fullname[i] = subdir[j]; fullname[i] = subdir[j];
} else { }
/* We didn't append the prefix yet */ else {
strncpy(fullname, prefix, MIN(strlen(prefix), size)); /* We didn't append the prefix yet */
} HDstrncpy(fullname, prefix, MIN(HDstrlen(prefix), size));
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);
} }
strcat(fullname, "/"); if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) {
strcat(fullname, base_name); /* Append the base_name with a slash first. Multiple slashes are
} else { * 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 */ /* Buffer is too small */
return NULL; return NULL;
} }
} else if (strlen(base_name) >= size) { else {
/* Buffer is too small */ HDstrcpy(fullname, base_name);
return NULL;
} else {
strcpy(fullname, base_name);
} }
/* Append a suffix */ /* Append a suffix */
if (suffix) { if (suffix) {
if (strlen(fullname) + strlen(suffix) >= size) if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
return NULL; return NULL;
strcat(fullname, suffix); HDstrcat(fullname, suffix);
} }
/* Remove any double slashes in the filename */ /* Remove any double slashes in the filename */
for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) { for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
if (*ptr != '/' || last != '/') if (*ptr != '/' || last != '/')
fullname[j++] = *ptr; fullname[j++] = *ptr;
last = *ptr; last = *ptr;
} }
return fullname; return fullname;

View File

@ -413,7 +413,7 @@ fill_with_random_data(Bytef *src, uLongf src_len)
register unsigned u; register unsigned u;
h5_stat_t stat_buf; h5_stat_t stat_buf;
if (stat("/dev/urandom", &stat_buf) == 0) { if (HDstat("/dev/urandom", &stat_buf) == 0) {
uLongf len = src_len; uLongf len = src_len;
Bytef *buf = src; Bytef *buf = src;
int fd = HDopen("/dev/urandom", O_RDONLY, 0); int fd = HDopen("/dev/urandom", O_RDONLY, 0);

View File

@ -37,7 +37,7 @@ get_filesize(const char *filename)
MPI_File fd; MPI_File fd;
MPI_Offset filesize; MPI_Offset filesize;
#ifndef H5_HAVE_MPI_GET_SIZE #ifndef H5_HAVE_MPI_GET_SIZE
struct stat stat_buf; h5_stat_t stat_buf;
#endif #endif
#ifdef H5_HAVE_MPI_GET_SIZE #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 /* Some systems (only SGI Altix Propack 4 so far) doesn't return correct
* file size for MPI_File_get_size. Use stat instead. * 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), ""); VRFY((mpierr == MPI_SUCCESS), "");
/* Hopefully this casting is safe */ /* Hopefully this casting is safe */

View File

@ -206,7 +206,7 @@ test_mpio_gb_file(char *filename)
MPI_Offset mpi_off; MPI_Offset mpi_off;
MPI_Offset mpi_off_old; MPI_Offset mpi_off_old;
MPI_Status mpi_stat; MPI_Status mpi_stat;
struct stat stat_buf; h5_stat_t stat_buf;
int is_signed, sizeof_mpi_offset; int is_signed, sizeof_mpi_offset;
nerrs = 0; nerrs = 0;
@ -395,7 +395,7 @@ test_mpio_gb_file(char *filename)
mrc = MPI_File_get_size(fh, &size); mrc = MPI_File_get_size(fh, &size);
VRFY((mrc==MPI_SUCCESS), ""); VRFY((mrc==MPI_SUCCESS), "");
mrc=stat(filename, &stat_buf); mrc=HDstat(filename, &stat_buf);
VRFY((mrc==0), ""); VRFY((mrc==0), "");
/* Hopefully this casting is safe */ /* Hopefully this casting is safe */

View File

@ -81,7 +81,7 @@ void pause_proc(void)
MPI_Get_processor_name(mpi_name, &mpi_namelen); MPI_Get_processor_name(mpi_name, &mpi_namelen);
if (MAINPROCESS) if (MAINPROCESS)
while ((stat(greenlight, &statbuf) == -1) && loops < maxloop){ while ((HDstat(greenlight, &statbuf) == -1) && loops < maxloop){
if (!loops++){ if (!loops++){
printf("Proc %d (%*s, %d): to debug, attach %d\n", printf("Proc %d (%*s, %d): to debug, attach %d\n",
mpi_rank, mpi_namelen, mpi_name, pid, pid); mpi_rank, mpi_namelen, mpi_name, pid, pid);