[svn-r12286] Purpose: Fix bug

Description:
    The file size test in C++ library failed on Copper because the
    value returned by h5_get_file_size was intepreted incorrectly
    due to different interger sizes.

Solution:
    H5private.h: Added check to use stat64 and off64_t where appropriate.
    h5test.c and h5test.h: used h5_stat_size_t in place of off_t.
    tattr.cpp: used h5_stat_size_t in place of off_t.

Platforms tested:
    Linux 2.4 (heping)
    AIX 5.1 (copper)
    SunOS 5.8 64-bit (sol) - still on going
This commit is contained in:
Binh-Minh Ribler 2006-04-20 01:09:51 -05:00
parent 57a2e33c57
commit 7e5de2473b
4 changed files with 18 additions and 8 deletions

View File

@ -1022,7 +1022,7 @@ test_attr_dtype_shared(void)
int data=8; /* Data to write */
int rdata=0; /* Read read in */
H5G_stat_t statbuf; /* Object's information */
off_t filesize; /* Size of file after modifications */
h5_stat_size_t filesize; /* Size of file after modifications */
// Output message about test being performed */
MESSAGE(5, ("Testing Shared Datatypes with Attributes\n"));
@ -1035,7 +1035,7 @@ test_attr_dtype_shared(void)
fid1.close();
// Get size of file */
off_t empty_filesize; // Size of empty file */
h5_stat_size_t empty_filesize; // Size of empty file */
empty_filesize = h5_get_file_size(FILENAME.c_str());
if (empty_filesize == 0)
TestErrPrintf("Line %d: file size wrong!\n",__LINE__);

View File

@ -668,9 +668,15 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
typedef __int64 h5_stat_size_t;
#endif
#else
#define HDfstat(F,B) fstat(F,B)
typedef struct stat h5_stat_t;
typedef off_t h5_stat_size_t;
#if H5_SIZEOF___INT64==8
#define HDfstat(F,B) fstat64(F,B)
typedef struct stat64 h5_stat_t;
typedef off64_t h5_stat_size_t;
#else
#define HDfstat(F,B) fstat(F,B)
typedef struct stat h5_stat_t;
typedef off_t h5_stat_size_t;
#endif
#endif
#define HDftell(F) ftell(F)
@ -850,8 +856,12 @@ H5_DLL void HDsrand(unsigned int seed);
#define HDstat(S,B) _stati64(S,B)
#endif
#else
#if H5_SIZEOF___INT64==8
#define HDstat(S,B) stat64(S,B)
#else
#define HDstat(S,B) stat(S,B)
#endif
#endif
#define HDstrcat(X,Y) strcat(X,Y)
#define HDstrchr(S,C) strchr(S,C)

View File

@ -802,14 +802,14 @@ h5_dump_info_object(MPI_Info info)
*
*-------------------------------------------------------------------------
*/
off_t
h5_stat_size_t
h5_get_file_size(const char *filename)
{
h5_stat_t sb;
/* Get the file's statistics */
if (HDstat(filename, &sb)>=0)
return((off_t)sb.st_size);
return((h5_stat_size_t)sb.st_size);
return(0);
} /* end get_file_size() */

View File

@ -128,7 +128,7 @@ H5TEST_DLL hid_t h5_fileaccess(void);
H5TEST_DLL void h5_no_hwconv(void);
H5TEST_DLL void h5_reset(void);
H5TEST_DLL void h5_show_hostname(void);
H5TEST_DLL off_t h5_get_file_size(const char *filename);
H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename);
H5TEST_DLL int print_func(const char *format, ...);
/* Routines for operating on the list of tests (for the "all in one" tests) */