summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2010-08-03 23:33:43 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2010-08-03 23:33:43 (GMT)
commite440364f8e53fd52ef97d56b84f93fe580c9e2b6 (patch)
treefa3d905c09e70466816d3203bfa887e8ed1f92ad /src
parent28ffed9ebf80f0fd0247ffdd117aafeab42efb19 (diff)
downloadhdf5-e440364f8e53fd52ef97d56b84f93fe580c9e2b6.zip
hdf5-e440364f8e53fd52ef97d56b84f93fe580c9e2b6.tar.gz
hdf5-e440364f8e53fd52ef97d56b84f93fe580c9e2b6.tar.bz2
[svn-r19166] Bug fix: 1917.
Description: test/big incorrectly determined not able to write files larger than 2GB and skipped the SEC2 and STDIO driver tests. The reason was because it was using off_t while the SEC2 driver is using lseek64 which expects off64_t type. Solution: Created a new HDoff_t which is set to off_t or off64_t or other appropriate type depending on which of lseek or lseek64 is available. Changed SEC2 file driver and the big test to use this common definition. Tested: In BP (AIX), using --enable and --disable-largefile, for both 32 and 64 bits modes. Did not do h5committest because: 1. the error was exposed in the remote BP machine; 2. the change is trivial.
Diffstat (limited to 'src')
-rw-r--r--src/H5FDsec2.c34
-rw-r--r--src/H5private.h11
2 files changed, 21 insertions, 24 deletions
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 4b5c305..7e54063 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -107,24 +107,14 @@ typedef struct H5FD_sec2_t {
* some macros here so we don't have to have conditional compilations later
* throughout the code.
*
- * file_offset_t: The datatype for file offsets, the second argument of
- * the lseek() or lseek64() call.
+ * HDoff_t: The datatype for file offsets, the second argument of
+ * the lseek() or lseek64() call.
*
*/
-/* adding for windows NT file system support. */
-
-#ifdef H5_HAVE_LSEEK64
-# define file_offset_t off64_t
-#elif defined (_WIN32) && !defined(__MWERKS__)
-# /*MSVC*/
-# define file_offset_t __int64
-#else
-# define file_offset_t off_t
-#endif
/*
* These macros check for overflow of various quantities. These macros
- * assume that file_offset_t is signed and haddr_t and size_t are unsigned.
+ * assume that HDoff_t is signed and haddr_t and size_t are unsigned.
*
* ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
* is too large to be represented by the second argument
@@ -137,13 +127,13 @@ typedef struct H5FD_sec2_t {
* which can be addressed entirely by the second
* argument of the file seek function.
*/
-#define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1)
+#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1)
#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \
((A) & ~(haddr_t)MAXADDR))
#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR)
#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \
HADDR_UNDEF==(A)+(Z) || \
- (file_offset_t)((A)+(Z))<(file_offset_t)(A))
+ (HDoff_t)((A)+(Z))<(HDoff_t)(A))
/* Prototypes */
static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id,
@@ -344,7 +334,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
FUNC_ENTER_NOAPI(H5FD_sec2_open, NULL)
/* Sanity check on file offsets */
- HDassert(sizeof(file_offset_t) >= sizeof(size_t));
+ HDassert(sizeof(HDoff_t) >= sizeof(size_t));
/* Check arguments */
if(!name || !*name)
@@ -752,7 +742,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
/* Seek to the correct location */
if((addr != file->pos || OP_READ != file->op) &&
- HDlseek(file->fd, (file_offset_t)addr, SEEK_SET) < 0)
+ HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0)
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
/*
@@ -766,7 +756,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
if(-1 == nbytes) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
- file_offset_t myoffset = HDlseek(file->fd, (file_offset_t)0, SEEK_CUR);
+ HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR);
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset);
} /* end if */
@@ -838,7 +828,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
/* Seek to the correct location */
if((addr != file->pos || OP_WRITE != file->op) &&
- HDlseek(file->fd, (file_offset_t)addr, SEEK_SET) < 0)
+ HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0)
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
/*
@@ -852,7 +842,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
if(-1 == nbytes) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
- file_offset_t myoffset = HDlseek(file->fd, (file_offset_t)0, SEEK_CUR);
+ HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR);
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset);
} /* end if */
@@ -927,11 +917,11 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
#ifdef H5_VMS
/* Reset seek offset to the beginning of the file, so that the file isn't
* re-extended later. This may happen on Open VMS. */
- if(-1 == HDlseek(file->fd, (file_offset_t)0, SEEK_SET))
+ if(-1 == HDlseek(file->fd, (HDoff_t)0, SEEK_SET))
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
#endif
- if(-1 == HDftruncate(file->fd, (file_offset_t)file->eoa))
+ if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa))
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly")
#endif /* _WIN32 */
diff --git a/src/H5private.h b/src/H5private.h
index f772dae..29f1bf0 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -908,9 +908,16 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
#endif /* HDlongjmp */
#ifndef HDlseek
#ifdef H5_HAVE_LSEEK64
- #define HDlseek(F,O,W) lseek64(F,O,W)
+ #define HDlseek(F,O,W) lseek64(F,O,W)
+ #define HDoff_t off64_t
#else
- #define HDlseek(F,O,W) lseek(F,O,W)
+ #define HDlseek(F,O,W) lseek(F,O,W)
+ #if defined (_WIN32) && !defined(__MWERKS__)
+ # /*MSVC*/
+ # define HDoff_t __int64
+ #else
+ # define HDoff_t off_t
+ #endif
#endif
#endif /* HDlseek */
#ifndef HDmalloc