summaryrefslogtreecommitdiffstats
path: root/src/H5FDsec2.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2010-08-03 23:35:42 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2010-08-03 23:35:42 (GMT)
commit41f0057dbc1bb5333b6a41ed9d5a4d1942964808 (patch)
tree7e13e5933db3a0b58db06536f1a94d2801bd5949 /src/H5FDsec2.c
parent2d8a18a1fdac369b39f8160eb22b1562406e31de (diff)
downloadhdf5-41f0057dbc1bb5333b6a41ed9d5a4d1942964808.zip
hdf5-41f0057dbc1bb5333b6a41ed9d5a4d1942964808.tar.gz
hdf5-41f0057dbc1bb5333b6a41ed9d5a4d1942964808.tar.bz2
[svn-r19167] 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. Note that STDIO driver failed when --disable-largefile is used. That is an error in the STDIO driver code that is being fixed.
Diffstat (limited to 'src/H5FDsec2.c')
-rw-r--r--src/H5FDsec2.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index c715aae..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 */
@@ -946,3 +936,4 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_sec2_truncate() */
+