[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})
#-- 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)

View File

@ -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;
/* 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);
user = HDgetenv("USER");
login = HDgetenv("LOGIN");
subdir = (user ? user : login);
if (subdir) {
for (i = 0; i < size && prefix[i]; i++)
fullname[i] = prefix[i];
if (subdir) {
for (i = 0; i < size && prefix[i]; i++)
fullname[i] = prefix[i];
fullname[i++] = '/';
fullname[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));
}
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;

View File

@ -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);

View File

@ -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 */

View File

@ -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 */

View File

@ -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);