summaryrefslogtreecommitdiffstats
path: root/src/H5FDwindows.c
diff options
context:
space:
mode:
authorScott Wegner <swegner@hdfgroup.org>2007-06-18 18:19:56 (GMT)
committerScott Wegner <swegner@hdfgroup.org>2007-06-18 18:19:56 (GMT)
commit5e7acfed72dab3bb0a653067b99b18368bdba3f3 (patch)
tree17e32ef2d3351720f7a8c4e3f2ae859fac812311 /src/H5FDwindows.c
parent4d9397a1019cfd08dd36564a34d89bda294996ff (diff)
downloadhdf5-5e7acfed72dab3bb0a653067b99b18368bdba3f3.zip
hdf5-5e7acfed72dab3bb0a653067b99b18368bdba3f3.tar.gz
hdf5-5e7acfed72dab3bb0a653067b99b18368bdba3f3.tar.bz2
[svn-r13873] Purpose: Code cleanup
Description: Changed a macro in H5FDwindows.c from IO_BUF_SIZE to a more specific WINDOWS_MAX_BUF, and moved it to our H5pubconf.h, where users can customize it to their own preference. This value is needed because of a bug in the Windows _write function, it is unsafe to write buffers larger than 2GB-1 bytes in one write. Tested: VS2005 on WinXP.
Diffstat (limited to 'src/H5FDwindows.c')
-rw-r--r--src/H5FDwindows.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c
index e0ef11e..9d2b3f9 100644
--- a/src/H5FDwindows.c
+++ b/src/H5FDwindows.c
@@ -53,11 +53,6 @@ static hid_t H5FD_WINDOWS_g = 0;
#define OP_WRITE 2
/*
- * This is the max number of bytes that will be read or written by the file driver.
- * Values above 2^31-1 may cause trouble with Windows. Default is 2^30.
- */
-#define IO_BUF_SIZE 1073741824
-/*
* The description of a file belonging to this driver. The `eoa' and `eof'
* determine the amount of hdf5 address space in use and the high-water mark
* of the file (the current size of the underlying file). The `pos'
@@ -800,7 +795,7 @@ H5FD_windows_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
while (size>0) {
#ifndef WINDOWS_USE_STDIO
do {
- nbytes = _read(file->fd, buf, (unsigned)(size <= IO_BUF_SIZE ? size: IO_BUF_SIZE));
+ nbytes = _read(file->fd, buf, (unsigned)(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF));
} while (-1==nbytes && EINTR==errno);
if (-1==nbytes) /* error */
HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
@@ -811,7 +806,7 @@ H5FD_windows_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
}
#else
do {
- nbytes = fread(buf,(size_t)1,(size <= IO_BUF_SIZE ? size: IO_BUF_SIZE),file->fp);
+ nbytes = fread(buf,(size_t)1,(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF),file->fp);
} while (!nbytes && EINTR==errno);
if(!nbytes) {
if (ferror(file->fp)) /* error */
@@ -909,14 +904,14 @@ H5FD_windows_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
while (size>0) {
do {
#ifndef WINDOWS_USE_STDIO
- nbytes = _write(file->fd, buf, (unsigned)(size <= IO_BUF_SIZE ? size: IO_BUF_SIZE));
+ nbytes = _write(file->fd, buf, (unsigned)(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF));
} while (-1==nbytes && EINTR==errno);
if (-1==nbytes) /* error */
#else
/* Write 1GB or less at a time */
- nbytes = fwrite(buf, 1, (size <= IO_BUF_SIZE ? size: IO_BUF_SIZE),file->fp);
+ nbytes = fwrite(buf, 1, (size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF),file->fp);
} while (!nbytes && EINTR==errno);
if (!nbytes) /* error */
#endif /* WINDOWS_USE_STDIO */