From 7e5de2473bb2bf780a69995665e2df091c8df9cf Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 20 Apr 2006 01:09:51 -0500 Subject: [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 --- c++/test/tattr.cpp | 4 ++-- src/H5private.h | 16 +++++++++++++--- test/h5test.c | 4 ++-- test/h5test.h | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 7768952..5791797 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -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__); diff --git a/src/H5private.h b/src/H5private.h index 263b529..98793a8 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -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) diff --git a/test/h5test.c b/test/h5test.c index 555485b..e93be23 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -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() */ diff --git a/test/h5test.h b/test/h5test.h index a21ccdc..c065c34 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -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) */ -- cgit v0.12