summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5FDsec2.c35
-rw-r--r--src/H5private.h11
-rw-r--r--test/big.c9
3 files changed, 26 insertions, 29 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() */
+
diff --git a/src/H5private.h b/src/H5private.h
index 5b8d123..e6da2cc 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -914,9 +914,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
diff --git a/test/big.c b/test/big.c
index dde9d7a..8d65559 100644
--- a/test/big.c
+++ b/test/big.c
@@ -32,8 +32,7 @@ const char *FILENAME[] = {
#define WRT_SIZE 4*1024
#define FAMILY_SIZE 1024*1024*1024
-/* Define big file as 2GB */
-#define BIG_FILE (off_t)0x80000000UL
+#define GB (HDoff_t)0x40000000L
#define MAX_TRIES 100
@@ -165,15 +164,15 @@ supports_big(void)
if ((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) return 0;
/* Write a few bytes at 2GB */
- if (HDlseek(fd, BIG_FILE, SEEK_SET)!=BIG_FILE) return 0;
+ if (HDlseek(fd, 2*GB, SEEK_SET)!=2*GB) return 0;
if (5!=HDwrite(fd, "hello", (size_t)5)) return 0;
/* Write a few bytes at 4GB */
- if (HDlseek(fd, 2*BIG_FILE, SEEK_SET) != 2*BIG_FILE) return 0;
+ if (HDlseek(fd, 4*GB, SEEK_SET) != 4*GB) return 0;
if (5!=HDwrite(fd, "hello", (size_t)5)) return 0;
if (HDclose(fd) < 0) return 0;
- if (HDunlink("y.h5") < 0) return 0;
+ if (HDremove("y.h5") < 0) return 0;
return (1);
}