summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2013-01-08 01:19:17 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2013-01-08 01:19:17 (GMT)
commit724a0a93b4c6d00a47431d4c33fbedc4e402c2c4 (patch)
tree2a5e8962d028f9c3269bde09652da38110a99fa5 /src
parent38517de982be2c3abc2abc53e5096f5ef57c5ab5 (diff)
downloadhdf5-724a0a93b4c6d00a47431d4c33fbedc4e402c2c4.zip
hdf5-724a0a93b4c6d00a47431d4c33fbedc4e402c2c4.tar.gz
hdf5-724a0a93b4c6d00a47431d4c33fbedc4e402c2c4.tar.bz2
[svn-r23142] Purpose:
Merged 23111 from the trunk. (Core VFD and Mac OS X I/O changes) Tested on: 64-bit Windows 7, Visual Studio 2010, CMake 64-bit Mac OS X Snow Leopard (Fred), Fortran, C++ 64-bit BE Linux (Ostrich), Fortran, C++ 32-bit LE LInux (jam), Fortran, C++ (also parallel w/ Fortran)
Diffstat (limited to 'src')
-rw-r--r--src/H5FDcore.c514
-rw-r--r--src/H5FDlog.c410
-rw-r--r--src/H5FDmpiposix.c62
-rw-r--r--src/H5FDsec2.c377
-rw-r--r--src/H5config.h.in3
-rw-r--r--src/H5private.h18
6 files changed, 642 insertions, 742 deletions
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 6ef7bb0..d5c77d5 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -17,57 +17,40 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Tuesday, August 10, 1999
*
- * Purpose: A driver which stores the HDF5 data in main memory using
- * only the HDF5 public API. This driver is useful for fast
- * access to small, temporary hdf5 files.
+ * Purpose: A driver which stores the HDF5 data in main memory using
+ * only the HDF5 public API. This driver is useful for fast
+ * access to small, temporary hdf5 files.
*/
/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5FDcore.h" /* Core file driver */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5FDcore.h" /* Core file driver */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
/* The driver identification number, initialized at runtime */
static hid_t H5FD_CORE_g = 0;
-/* Since Windows doesn't follow the rest of the world when it comes
- * to POSIX I/O types, some typedefs and constants are needed to avoid
- * making the code messy with #ifdefs.
- * NOTE: These are only used when writing data to the backing store on
- * file close.
- */
-#ifdef H5_HAVE_WIN32_API
-typedef unsigned int h5_core_io_t;
-typedef int h5_core_io_ret_t;
-static int H5_CORE_MAX_IO_BYTES_g = INT_MAX;
-#else
-/* Unix, everyone else */
-typedef size_t h5_core_io_t;
-typedef ssize_t h5_core_io_ret_t;
-static size_t H5_CORE_MAX_IO_BYTES_g = SSIZET_MAX;
-#endif /* H5_HAVE_WIN32_API */
-
-/* The description of a file belonging to this driver. The `eoa' and `eof'
+/* 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 memory).
*/
typedef struct H5FD_core_t {
- H5FD_t pub; /*public stuff, must be first */
- char *name; /*for equivalence testing */
- unsigned char *mem; /*the underlying memory */
- haddr_t eoa; /*end of allocated region */
- haddr_t eof; /*current allocated size */
- size_t increment; /*multiples for mem allocation */
- hbool_t backing_store; /*write to file name on flush */
- int fd; /*backing store file descriptor */
+ H5FD_t pub; /* public stuff, must be first */
+ char *name; /* for equivalence testing */
+ unsigned char *mem; /* the underlying memory */
+ haddr_t eoa; /* end of allocated region */
+ haddr_t eof; /* current allocated size */
+ size_t increment; /* multiples for mem allocation */
+ hbool_t backing_store; /* write to file name on flush */
+ int fd; /* backing store file descriptor */
/* Information for determining uniqueness of a file with a backing store */
#ifndef H5_HAVE_WIN32_API
/* On most systems the combination of device and i-node number uniquely
@@ -100,38 +83,38 @@ typedef struct H5FD_core_t {
HANDLE hFile; /* Native windows file handle */
#endif /* H5_HAVE_WIN32_API */
- hbool_t dirty; /*changes not saved? */
- H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */
+ hbool_t dirty; /* changes not saved? */
+ H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */
} H5FD_core_t;
/* Driver-specific file access properties */
typedef struct H5FD_core_fapl_t {
- size_t increment; /*how much to grow memory */
- hbool_t backing_store; /*write to file name on flush */
+ size_t increment; /* how much to grow memory */
+ hbool_t backing_store; /* write to file name on flush */
} H5FD_core_fapl_t;
/* Allocate memory in multiples of this size by default */
-#define H5FD_CORE_INCREMENT 8192
+#define H5FD_CORE_INCREMENT 8192
/* 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.
*
- * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
- * is too large to be represented by the second argument
- * of the file seek function.
+ * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
+ * is too large to be represented by the second argument
+ * of the file seek function.
*
- * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
- * large to be represented by the `size_t' type.
+ * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
+ * large to be represented by the `size_t' type.
*
- * REGION_OVERFLOW: Checks whether an address and size pair describe data
- * which can be addressed entirely in memory.
+ * REGION_OVERFLOW: Checks whether an address and size pair describe data
+ * which can be addressed entirely in memory.
*/
-#define MAXADDR ((haddr_t)((~(size_t)0)-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) || \
- (size_t)((A)+(Z))<(size_t)(A))
+#define MAXADDR ((haddr_t)((~(size_t)0)-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) || \
+ (size_t)((A)+(Z))<(size_t)(A))
/* Prototypes */
static void *H5FD_core_fapl_get(H5FD_t *_file);
@@ -145,60 +128,57 @@ static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
static haddr_t H5FD_core_get_eof(const H5FD_t *_file);
static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, void *buf);
+ size_t size, void *buf);
static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
size_t size, const void *buf);
static herr_t H5FD_core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
static herr_t H5FD_core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static const H5FD_class_t H5FD_core_g = {
- "core", /*name */
- MAXADDR, /*maxaddr */
- H5F_CLOSE_WEAK, /*fc_degree */
- NULL, /*sb_size */
- NULL, /*sb_encode */
- NULL, /*sb_decode */
- sizeof(H5FD_core_fapl_t), /*fapl_size */
- H5FD_core_fapl_get, /*fapl_get */
- NULL, /*fapl_copy */
- NULL, /*fapl_free */
- 0, /*dxpl_size */
- NULL, /*dxpl_copy */
- NULL, /*dxpl_free */
- H5FD_core_open, /*open */
- H5FD_core_close, /*close */
- H5FD_core_cmp, /*cmp */
- H5FD_core_query, /*query */
- NULL, /*get_type_map */
- NULL, /*alloc */
- NULL, /*free */
- H5FD_core_get_eoa, /*get_eoa */
- H5FD_core_set_eoa, /*set_eoa */
- H5FD_core_get_eof, /*get_eof */
- H5FD_core_get_handle, /*get_handle */
- H5FD_core_read, /*read */
- H5FD_core_write, /*write */
- H5FD_core_flush, /*flush */
- H5FD_core_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
- H5FD_FLMAP_DICHOTOMY /*fl_map */
+ "core", /* name */
+ MAXADDR, /* maxaddr */
+ H5F_CLOSE_WEAK, /* fc_degree */
+ NULL, /* sb_size */
+ NULL, /* sb_encode */
+ NULL, /* sb_decode */
+ sizeof(H5FD_core_fapl_t), /* fapl_size */
+ H5FD_core_fapl_get, /* fapl_get */
+ NULL, /* fapl_copy */
+ NULL, /* fapl_free */
+ 0, /* dxpl_size */
+ NULL, /* dxpl_copy */
+ NULL, /* dxpl_free */
+ H5FD_core_open, /* open */
+ H5FD_core_close, /* close */
+ H5FD_core_cmp, /* cmp */
+ H5FD_core_query, /* query */
+ NULL, /* get_type_map */
+ NULL, /* alloc */
+ NULL, /* free */
+ H5FD_core_get_eoa, /* get_eoa */
+ H5FD_core_set_eoa, /* set_eoa */
+ H5FD_core_get_eof, /* get_eof */
+ H5FD_core_get_handle, /* get_handle */
+ H5FD_core_read, /* read */
+ H5FD_core_write, /* write */
+ H5FD_core_flush, /* flush */
+ H5FD_core_truncate, /* truncate */
+ NULL, /* lock */
+ NULL, /* unlock */
+ H5FD_FLMAP_DICHOTOMY /* fl_map */
};
-/*--------------------------------------------------------------------------
-NAME
- H5FD_core_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5FD_core_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines. (Just calls
- H5FD_core_init currently).
-
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5FD_core_init_interface
+ *
+ * Purpose: Initializes any interface-specific data or routines.
+ *
+ * Return: Success: The driver ID for the core driver.
+ * Failure: Negative.
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5FD_core_init_interface(void)
{
@@ -209,14 +189,13 @@ H5FD_core_init_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5FD_core_init
+ * Function: H5FD_core_init
*
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Return: Success: The driver ID for the core driver.
- *
- * Failure: Negative.
+ * Return: Success: The driver ID for the core driver.
+ * Failure: Negative.
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -226,15 +205,15 @@ H5FD_core_init_interface(void)
hid_t
H5FD_core_init(void)
{
- hid_t ret_value=H5FD_CORE_g; /* Return value */
+ hid_t ret_value = H5FD_CORE_g; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- if (H5I_VFL!=H5Iget_type(H5FD_CORE_g))
+ if(H5I_VFL != H5Iget_type(H5FD_CORE_g))
H5FD_CORE_g = H5FD_register(&H5FD_core_g,sizeof(H5FD_class_t),FALSE);
/* Set return value */
- ret_value=H5FD_CORE_g;
+ ret_value = H5FD_CORE_g;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -242,11 +221,11 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_core_term
+ * Function: H5FD_core_term
*
- * Purpose: Shut down the VFD
+ * Purpose: Shut down the VFD
*
- * Return: <none>
+ * Returns: <none>
*
* Programmer: Quincey Koziol
* Friday, Jan 30, 2004
@@ -259,32 +238,32 @@ H5FD_core_term(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Reset VFL ID */
- H5FD_CORE_g=0;
+ H5FD_CORE_g = 0;
FUNC_LEAVE_NOAPI_VOID
} /* end H5FD_core_term() */
/*-------------------------------------------------------------------------
- * Function: H5Pset_fapl_core
+ * Function: H5Pset_fapl_core
*
- * Purpose: Modify the file access property list to use the H5FD_CORE
- * driver defined in this source file. The INCREMENT specifies
- * how much to grow the memory each time we need more.
+ * Purpose: Modify the file access property list to use the H5FD_CORE
+ * driver defined in this source file. The INCREMENT specifies
+ * how much to grow the memory each time we need more.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
* Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Thursday, February 19, 1998
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store)
{
- H5FD_core_fapl_t fa;
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value;
+ H5FD_core_fapl_t fa;
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "izb", fapl_id, increment, backing_store);
@@ -304,13 +283,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_fapl_core
- *
- * Purpose: Queries properties set by the H5Pset_fapl_core() function.
+ * Function: H5Pget_fapl_core
*
- * Return: Success: Non-negative
+ * Purpose: Queries properties set by the H5Pset_fapl_core() function.
*
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
* Programmer: Robb Matzke
* Tuesday, August 10, 1999
@@ -318,12 +295,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/,
- hbool_t *backing_store/*out*/)
+H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/)
{
- H5FD_core_fapl_t *fa;
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5FD_core_fapl_t *fa;
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "ixx", fapl_id, increment, backing_store);
@@ -346,13 +322,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_fapl_get
+ * Function: H5FD_core_fapl_get
*
- * Purpose: Returns a copy of the file access properties.
+ * Purpose: Returns a copy of the file access properties.
*
- * Return: Success: Ptr to new file access properties.
+ * Return: Success: Ptr to new file access properties.
*
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Friday, August 13, 1999
@@ -362,9 +338,9 @@ done:
static void *
H5FD_core_fapl_get(H5FD_t *_file)
{
- H5FD_core_t *file = (H5FD_core_t*)_file;
- H5FD_core_fapl_t *fa;
- void *ret_value; /* Return value */
+ H5FD_core_t *file = (H5FD_core_t*)_file;
+ H5FD_core_fapl_t *fa;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -375,7 +351,7 @@ H5FD_core_fapl_get(H5FD_t *_file)
fa->backing_store = (hbool_t)(file->fd >= 0);
/* Set return value */
- ret_value=fa;
+ ret_value = fa;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -383,15 +359,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_open
+ * Function: H5FD_core_open
*
- * Purpose: Create memory as an HDF5 file.
+ * Purpose: Create memory as an HDF5 file.
*
- * Return: Success: A pointer to a new file data structure. The
- * public fields will be initialized by the
- * caller, which is always H5FD_open().
+ * Return: Success: A pointer to a new file data structure. The
+ * public fields will be initialized by the
+ * caller, which is always H5FD_open().
*
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -399,20 +375,19 @@ done:
*-------------------------------------------------------------------------
*/
static H5FD_t *
-H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr)
+H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
- int o_flags;
- H5FD_core_t *file=NULL;
- H5FD_core_fapl_t *fa=NULL;
- H5P_genplist_t *plist; /* Property list pointer */
+ int o_flags;
+ H5FD_core_t *file = NULL;
+ H5FD_core_fapl_t *fa = NULL;
+ H5P_genplist_t *plist; /* Property list pointer */
#ifdef H5_HAVE_WIN32_API
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
#endif
- h5_stat_t sb;
- int fd=-1;
- H5FD_file_image_info_t file_image_info;
- H5FD_t *ret_value;
+ h5_stat_t sb;
+ int fd = -1;
+ H5FD_file_image_info_t file_image_info;
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI_NOINIT
@@ -552,20 +527,23 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
/* Read in existing data, being careful of interrupted system calls,
* partial results, and the end of the file.
*/
+
+ uint8_t *mem = file->mem; /* memory pointer for writes */
+
while(size > 0) {
- h5_core_io_t bytes_in = 0; /* # of bytes to read */
- h5_core_io_ret_t bytes_read = -1; /* # of bytes actually read */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to read */
+ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
/* Trying to read more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_CORE_MAX_IO_BYTES_g)
- bytes_in = H5_CORE_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_core_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
- bytes_read = HDread(file->fd, file->mem, bytes_in);
+ bytes_read = HDread(file->fd, mem, bytes_in);
} while(-1 == bytes_read && EINTR == errno);
if(-1 == bytes_read) { /* error */
@@ -573,12 +551,13 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
time_t mytime = HDtime(NULL);
HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR);
- HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', file->mem = %p, size = %lu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, (unsigned long)size, (unsigned long long)myoffset);
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', file->mem = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset);
} /* end if */
HDassert(bytes_read >= 0);
HDassert((size_t)bytes_read <= size);
+ mem += bytes_read;
size -= (size_t)bytes_read;
} /* end while */
} /* end else */
@@ -594,13 +573,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_close
+ * Function: H5FD_core_close
*
- * Purpose: Closes the file.
+ * Purpose: Closes the file.
*
- * Return: Success: 0
- *
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -610,8 +587,8 @@ done:
static herr_t
H5FD_core_close(H5FD_t *_file)
{
- H5FD_core_t *file = (H5FD_core_t*)_file;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -642,17 +619,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_cmp
+ * Function: H5FD_core_cmp
*
- * Purpose: Compares two files belonging to this driver by name. If one
- * file doesn't have a name then it is less than the other file.
- * If neither file has a name then the comparison is by file
- * address.
+ * Purpose: Compares two files belonging to this driver by name. If one
+ * file doesn't have a name then it is less than the other file.
+ * If neither file has a name then the comparison is by file
+ * address.
*
- * Return: Success: A value like strcmp()
+ * Return: Success: A value like strcmp()
*
- * Failure: never fails (arguments were checked by the
- * caller).
+ * Failure: never fails (arguments were checked by the
+ * caller).
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -662,9 +639,9 @@ done:
static int
H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
{
- const H5FD_core_t *f1 = (const H5FD_core_t*)_f1;
- const H5FD_core_t *f2 = (const H5FD_core_t*)_f2;
- int ret_value = 0;
+ const H5FD_core_t *f1 = (const H5FD_core_t*)_f1;
+ const H5FD_core_t *f2 = (const H5FD_core_t*)_f2;
+ int ret_value = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -726,13 +703,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_query
+ * Function: H5FD_core_query
*
- * Purpose: Set the flags that this VFL driver is capable of supporting.
+ * Purpose: Set the flags that this VFL driver is capable of supporting.
* (listed in H5FDpublic.h)
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
* Programmer: Quincey Koziol
* Tuesday, October 7, 2008
@@ -742,7 +718,7 @@ done:
static herr_t
H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */)
{
- const H5FD_core_t *file = (const H5FD_core_t*)_file;
+ const H5FD_core_t *file = (const H5FD_core_t*)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -766,15 +742,13 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */)
/*-------------------------------------------------------------------------
- * Function: H5FD_core_get_eoa
+ * Function: H5FD_core_get_eoa
*
- * Purpose: Gets the end-of-address marker for the file. The EOA marker
- * is the first address past the last byte allocated in the
- * format address space.
+ * Purpose: Gets the end-of-address marker for the file. The EOA marker
+ * is the first address past the last byte allocated in the
+ * format address space.
*
- * Return: Success: The end-of-address marker.
- *
- * Failure: HADDR_UNDEF
+ * Return: The end-of-address marker. (Can't fail)
*
* Programmer: Robb Matzke
* Monday, August 2, 1999
@@ -784,7 +758,7 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */)
static haddr_t
H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
{
- const H5FD_core_t *file = (const H5FD_core_t*)_file;
+ const H5FD_core_t *file = (const H5FD_core_t*)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -793,15 +767,13 @@ H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
/*-------------------------------------------------------------------------
- * Function: H5FD_core_set_eoa
- *
- * Purpose: Set the end-of-address marker for the file. This function is
- * called shortly after an existing HDF5 file is opened in order
- * to tell the driver where the end of the HDF5 data is located.
+ * Function: H5FD_core_set_eoa
*
- * Return: Success: 0
+ * Purpose: Set the end-of-address marker for the file. This function is
+ * called shortly after an existing HDF5 file is opened in order
+ * to tell the driver where the end of the HDF5 data is located.
*
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -811,8 +783,8 @@ H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
static herr_t
H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
{
- H5FD_core_t *file = (H5FD_core_t*)_file;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -827,17 +799,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_get_eof
- *
- * Purpose: Returns the end-of-file marker, which is the greater of
- * either the size of the underlying memory or the HDF5
- * end-of-address markers.
+ * Function: H5FD_core_get_eof
*
- * Return: Success: End of file address, the first address past
- * the end of the "file", either the memory
- * or the HDF5 file.
+ * Purpose: Returns the end-of-file marker, which is the greater of
+ * either the size of the underlying memory or the HDF5
+ * end-of-address markers.
*
- * Failure: HADDR_UNDEF
+ * Return: End of file address, the first address past
+ * the end of the "file", either the memory
+ * or the HDF5 file. (Can't fail)
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -847,7 +817,7 @@ done:
static haddr_t
H5FD_core_get_eof(const H5FD_t *_file)
{
- const H5FD_core_t *file = (const H5FD_core_t*)_file;
+ const H5FD_core_t *file = (const H5FD_core_t*)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -858,9 +828,9 @@ H5FD_core_get_eof(const H5FD_t *_file)
/*-------------------------------------------------------------------------
* Function: H5FD_core_get_handle
*
- * Purpose: Returns the file handle of CORE file driver.
+ * Purpose: Gets the file handle of CORE file driver.
*
- * Returns: Non-negative if succeed or negative if fails.
+ * Returns: SUCCEED/FAIL
*
* Programmer: Raymond Lu
* Sept. 16, 2002
@@ -871,7 +841,7 @@ static herr_t
H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle)
{
H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -916,26 +886,25 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_read
+ * Function: H5FD_core_read
*
- * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
- * into buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
+ * into buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero. Result is stored in caller-supplied
- * buffer BUF.
+ * Return: Success: SUCCEED. Result is stored in caller-supplied
+ * buffer BUF.
*
- * Failure: -1, Contents of buffer BUF are undefined.
+ * Failure: FAIL, Contents of buffer BUF are undefined.
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr,
- size_t size, void *buf/*out*/)
+ size_t size, void *buf/*out*/)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
herr_t ret_value=SUCCEED; /* Return value */
@@ -982,28 +951,25 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_write
- *
- * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
- * from buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Function: H5FD_core_write
*
- * Return: Success: Zero
+ * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
+ * from buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr,
- size_t size, const void *buf)
+ size_t size, const void *buf)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1042,7 +1008,7 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
} /* end else */
#ifdef H5_CLEAR_MEMORY
-HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof));
+ HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof));
#endif /* H5_CLEAR_MEMORY */
file->mem = x;
@@ -1061,49 +1027,46 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_flush
+ * Function: H5FD_core_flush
*
- * Purpose: Flushes the file to backing store if there is any and if the
- * dirty flag is set.
+ * Purpose: Flushes the file to backing store if there is any and if the
+ * dirty flag is set.
*
- * Return: Success: 0
- *
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
* Programmer: Robb Matzke
* Friday, October 15, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing)
{
- H5FD_core_t *file = (H5FD_core_t*)_file;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Write to backing store */
- if (file->dirty && file->fd>=0 && file->backing_store) {
+ if (file->dirty && file->fd >= 0 && file->backing_store) {
haddr_t size = file->eof;
unsigned char *ptr = file->mem;
- if (0!=HDlseek(file->fd, (off_t)0, SEEK_SET))
+ if(0 != HDlseek(file->fd, (off_t)0, SEEK_SET))
HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store")
while (size > 0) {
- h5_core_io_t bytes_in = 0; /* # of bytes to write */
- h5_core_io_ret_t bytes_wrote = -1; /* # of bytes written */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to write */
+ h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
/* Trying to write more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_CORE_MAX_IO_BYTES_g)
- bytes_in = H5_CORE_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_core_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_wrote = HDwrite(file->fd, ptr, bytes_in);
@@ -1114,7 +1077,7 @@ H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing)
time_t mytime = HDtime(NULL);
HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR);
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, size = %lu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long)size, (unsigned long long)myoffset);
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset);
} /* end if */
HDassert(bytes_wrote > 0);
@@ -1134,42 +1097,40 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_truncate
+ * Function: H5FD_core_truncate
*
- * Purpose: Makes sure that the true file size is the same (or larger)
- * than the end-of-address.
+ * Purpose: Makes sure that the true file size is the same (or larger)
+ * than the end-of-address.
*
- * Addendum -- 12/2/11
- * For file images opened with the core file driver, it is
- * necessary that we avoid reallocating the core file driver's
- * buffer uneccessarily.
+ * Addendum -- 12/2/11
+ * For file images opened with the core file driver, it is
+ * necessary that we avoid reallocating the core file driver's
+ * buffer uneccessarily.
*
- * To this end, I have made the following functional changes
- * to this function.
+ * To this end, I have made the following functional changes
+ * to this function.
*
- * If we are closing, and there is no backing store, this
- * function becomes a no-op.
+ * If we are closing, and there is no backing store, this
+ * function becomes a no-op.
*
- * If we are closing, and there is backing store, we set the
- * eof to equal the eoa, and truncate the backing store to
- * the new eof
+ * If we are closing, and there is backing store, we set the
+ * eof to equal the eoa, and truncate the backing store to
+ * the new eof
*
- * If we are not closing, we realloc the buffer to size equal
- * to the smallest multiple of the allocation increment that
- * equals or exceeds the eoa and set the eof accordingly.
- * Note that we no longer truncate the backing store to the
- * new eof if applicable.
- * -- JRM
+ * If we are not closing, we realloc the buffer to size equal
+ * to the smallest multiple of the allocation increment that
+ * equals or exceeds the eoa and set the eof accordingly.
+ * Note that we no longer truncate the backing store to the
+ * new eof if applicable.
+ * -- JRM
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* Tuesday, October 7, 2008
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_core_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t closing)
{
@@ -1260,4 +1221,3 @@ H5FD_core_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t closing)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_core_truncate() */
-
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 3690d0b..e0619c3 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -14,50 +14,35 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Monday, April 17, 2000
*
- * Purpose: The POSIX unbuffered file driver using only the HDF5 public
- * API and with a few optimizations: the lseek() call is made
- * only when the current file position is unknown or needs to be
- * changed based on previous I/O through this driver (don't mix
- * I/O from this driver with I/O from other parts of the
- * application to the same file).
- * With custom modifications...
+ * Purpose: The POSIX unbuffered file driver using only the HDF5 public
+ * API and with a few optimizations: the lseek() call is made
+ * only when the current file position is unknown or needs to be
+ * changed based on previous I/O through this driver (don't mix
+ * I/O from this driver with I/O from other parts of the
+ * application to the same file).
+ * With custom modifications...
*/
/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC H5FD_log_init_interface
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5FDlog.h" /* Logging file driver */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5FDlog.h" /* Logging file driver */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
/* The driver identification number, initialized at runtime */
static hid_t H5FD_LOG_g = 0;
-/* Since Windows doesn't follow the rest of the world when it comes
- * to POSIX I/O types, some typedefs and constants are needed to avoid
- * making the code messy with #ifdefs.
- */
-#ifdef H5_HAVE_WIN32_API
-typedef unsigned int h5_log_io_t;
-typedef int h5_log_io_ret_t;
-static int H5_LOG_MAX_IO_BYTES_g = INT_MAX;
-#else
-/* Unix, everyone else */
-typedef size_t h5_log_io_t;
-typedef ssize_t h5_log_io_ret_t;
-static size_t H5_LOG_MAX_IO_BYTES_g = SSIZET_MAX;
-#endif /* H5_HAVE_WIN32_API */
-
/* Driver-specific file access properties */
typedef struct H5FD_log_fapl_t {
char *logfile; /* Allocated log file name */
@@ -161,31 +146,30 @@ typedef struct H5FD_log_t {
* These macros check for overflow of various quantities. These macros
* 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
- * of the file seek function.
+ * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
+ * is too large to be represented by the second argument
+ * of the file seek function.
*
- * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
- * large to be represented by the `size_t' type.
+ * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
+ * large to be represented by the `size_t' type.
*
- * REGION_OVERFLOW: Checks whether an address and size pair describe data
- * which can be addressed entirely by the second
- * argument of the file seek function.
+ * REGION_OVERFLOW: Checks whether an address and size pair describe data
+ * which can be addressed entirely by the second
+ * argument of the file seek function.
*/
-#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) || \
- (HDoff_t)((A)+(Z))<(HDoff_t)(A))
+#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) || \
+ (HDoff_t)((A)+(Z))<(HDoff_t)(A))
/* Prototypes */
static void *H5FD_log_fapl_get(H5FD_t *file);
static void *H5FD_log_fapl_copy(const void *_old_fa);
static herr_t H5FD_log_fapl_free(void *_fa);
static H5FD_t *H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr);
+ haddr_t maxaddr);
static herr_t H5FD_log_close(H5FD_t *_file);
static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags);
@@ -195,9 +179,9 @@ static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
static haddr_t H5FD_log_get_eof(const H5FD_t *_file);
static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, void *buf);
+ size_t size, void *buf);
static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, const void *buf);
+ size_t size, const void *buf);
static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static const H5FD_class_t H5FD_log_g = {
@@ -238,19 +222,16 @@ static const H5FD_class_t H5FD_log_g = {
H5FL_DEFINE_STATIC(H5FD_log_t);
-/*--------------------------------------------------------------------------
-NAME
- H5FD_log_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5FD_log_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines. (Just calls
- H5FD_log_init currently).
-
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5FD_log_init_interface
+ *
+ * Purpose: Initializes any interface-specific data or routines.
+ *
+ * Return: Success: The driver ID for the log driver.
+ * Failure: Negative.
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5FD_log_init_interface(void)
{
@@ -261,15 +242,15 @@ H5FD_log_init_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5FD_log_init
+ * Function: H5FD_log_init
*
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Return: Success: The driver ID for the log driver.
- * Failure: Negative.
+ * Return: Success: The driver ID for the log driver.
+ * Failure: Negative.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -293,9 +274,9 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_log_term
+ * Function: H5FD_log_term
*
- * Purpose: Shut down the VFD
+ * Purpose: Shut down the VFD
*
* Returns: <none>
*
@@ -317,15 +298,15 @@ H5FD_log_term(void)
/*-------------------------------------------------------------------------
- * Function: H5Pset_fapl_log
+ * Function: H5Pset_fapl_log
*
- * Purpose: Modify the file access property list to use the H5FD_LOG
- * driver defined in this source file.
+ * Purpose: Modify the file access property list to use the H5FD_LOG
+ * driver defined in this source file.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Programmer: Robb Matzke
+ * Thursday, February 19, 1998
*
*-------------------------------------------------------------------------
*/
@@ -358,17 +339,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_fapl_get
+ * Function: H5FD_log_fapl_get
*
- * Purpose: Returns a file access property list which indicates how the
- * specified file is being accessed. The return list could be
- * used to access another file the same way.
+ * Purpose: Returns a file access property list which indicates how the
+ * specified file is being accessed. The return list could be
+ * used to access another file the same way.
*
- * Return: Success: Ptr to new file access property list with all
- * members copied from the file struct.
- * Failure: NULL
+ * Return: Success: Ptr to new file access property list with all
+ * members copied from the file struct.
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, April 20, 2000
*
*-------------------------------------------------------------------------
@@ -376,8 +357,8 @@ done:
static void *
H5FD_log_fapl_get(H5FD_t *_file)
{
- H5FD_log_t *file = (H5FD_log_t *)_file;
- void *ret_value; /* Return value */
+ H5FD_log_t *file = (H5FD_log_t *)_file;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -389,14 +370,14 @@ H5FD_log_fapl_get(H5FD_t *_file)
/*-------------------------------------------------------------------------
- * Function: H5FD_log_fapl_copy
+ * Function: H5FD_log_fapl_copy
*
- * Purpose: Copies the log-specific file access properties.
+ * Purpose: Copies the log-specific file access properties.
*
- * Return: Success: Ptr to a new property list
- * Failure: NULL
+ * Return: Success: Ptr to a new property list
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, April 20, 2000
*
*-------------------------------------------------------------------------
@@ -404,9 +385,9 @@ H5FD_log_fapl_get(H5FD_t *_file)
static void *
H5FD_log_fapl_copy(const void *_old_fa)
{
- const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa;
- H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */
- void *ret_value; /* Return value */
+ const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa;
+ H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -440,14 +421,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_fapl_free
+ * Function: H5FD_log_fapl_free
*
- * Purpose: Frees the log-specific file access properties.
+ * Purpose: Frees the log-specific file access properties.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, April 20, 2000
*
*-------------------------------------------------------------------------
@@ -469,16 +449,16 @@ H5FD_log_fapl_free(void *_fa)
/*-------------------------------------------------------------------------
- * Function: H5FD_log_open
+ * Function: H5FD_log_open
*
- * Purpose: Create and/or opens a file as an HDF5 file.
+ * Purpose: Create and/or opens a file as an HDF5 file.
*
- * Return: Success: A pointer to a new file data structure. The
- * public fields will be initialized by the
- * caller, which is always H5FD_open().
- * Failure: NULL
+ * Return: Success: A pointer to a new file data structure. The
+ * public fields will be initialized by the
+ * caller, which is always H5FD_open().
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -486,11 +466,11 @@ H5FD_log_fapl_free(void *_fa)
static H5FD_t *
H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
- H5FD_log_t *file = NULL;
- H5P_genplist_t *plist; /* Property list */
- H5FD_log_fapl_t *fa; /* File access property list information */
- int fd = (-1); /* File descriptor */
- int o_flags; /* Flags for open() call */
+ H5FD_log_t *file = NULL;
+ H5P_genplist_t *plist; /* Property list */
+ H5FD_log_fapl_t *fa; /* File access property list information */
+ int fd = -1; /* File descriptor */
+ int o_flags; /* Flags for open() call */
#ifdef H5_HAVE_WIN32_API
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
#endif
@@ -499,8 +479,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
struct timeval open_timeval_diff;
struct timeval stat_timeval_diff;
#endif /* H5_HAVE_GETTIMEOFDAY */
- h5_stat_t sb;
- H5FD_t *ret_value; /* Return value */
+ h5_stat_t sb;
+ H5FD_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -677,14 +657,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_close
+ * Function: H5FD_log_close
*
- * Purpose: Closes an HDF5 file.
+ * Purpose: Closes an HDF5 file.
*
- * Return: Success: 0
- * Failure: -1, file not closed.
+ * Return: Success: SUCCEED
+ * Failure: FAIL, file not closed.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -825,16 +805,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_cmp
+ * Function: H5FD_log_cmp
*
- * Purpose: Compares two files belonging to this driver using an
- * arbitrary (but consistent) ordering.
+ * Purpose: Compares two files belonging to this driver using an
+ * arbitrary (but consistent) ordering.
*
- * Return: Success: A value like strcmp()
- * Failure: never fails (arguments were checked by the
- * caller).
+ * Return: Success: A value like strcmp()
+ * Failure: never fails (arguments were checked by the
+ * caller).
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -842,8 +822,8 @@ done:
static int
H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
{
- const H5FD_log_t *f1 = (const H5FD_log_t *)_f1;
- const H5FD_log_t *f2 = (const H5FD_log_t *)_f2;
+ const H5FD_log_t *f1 = (const H5FD_log_t *)_f1;
+ const H5FD_log_t *f2 = (const H5FD_log_t *)_f2;
int ret_value = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -886,15 +866,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_query
+ * Function: H5FD_log_query
*
- * Purpose: Set the flags that this VFL driver is capable of supporting.
+ * Purpose: Set the flags that this VFL driver is capable of supporting.
* (listed in H5FDpublic.h)
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Friday, August 25, 2000
*
*-------------------------------------------------------------------------
@@ -902,7 +881,7 @@ done:
static herr_t
H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */)
{
- const H5FD_log_t *file = (const H5FD_log_t *)_file;
+ const H5FD_log_t *file = (const H5FD_log_t *)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -925,19 +904,18 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */)
/*-------------------------------------------------------------------------
- * Function: H5FD_log_alloc
+ * Function: H5FD_log_alloc
*
- * Purpose: Allocate file memory.
+ * Purpose: Allocate file memory.
*
- * Return: Success: Address of new memory
- * Failure: HADDR_UNDEF
+ * Return: Success: Address of new memory
+ * Failure: HADDR_UNDEF
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, April 17, 2000
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static haddr_t
H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t size)
{
@@ -979,16 +957,16 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t siz
/*-------------------------------------------------------------------------
- * Function: H5FD_log_get_eoa
+ * Function: H5FD_log_get_eoa
*
- * Purpose: Gets the end-of-address marker for the file. The EOA marker
- * is the first address past the last byte allocated in the
- * format address space.
+ * Purpose: Gets the end-of-address marker for the file. The EOA marker
+ * is the first address past the last byte allocated in the
+ * format address space.
*
- * Return: Success: The end-of-address marker.
- * Failure: HADDR_UNDEF
+ * Return: Success: The end-of-address marker.
+ * Failure: HADDR_UNDEF
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, August 2, 1999
*
*-------------------------------------------------------------------------
@@ -996,7 +974,7 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t siz
static haddr_t
H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
{
- const H5FD_log_t *file = (const H5FD_log_t *)_file;
+ const H5FD_log_t *file = (const H5FD_log_t *)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1005,16 +983,15 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
/*-------------------------------------------------------------------------
- * Function: H5FD_log_set_eoa
+ * Function: H5FD_log_set_eoa
*
- * Purpose: Set the end-of-address marker for the file. This function is
- * called shortly after an existing HDF5 file is opened in order
- * to tell the driver where the end of the HDF5 data is located.
+ * Purpose: Set the end-of-address marker for the file. This function is
+ * called shortly after an existing HDF5 file is opened in order
+ * to tell the driver where the end of the HDF5 data is located.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -1022,25 +999,25 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
static herr_t
H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr)
{
- H5FD_log_t *file = (H5FD_log_t *)_file;
+ H5FD_log_t *file = (H5FD_log_t *)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(file->fa.flags != 0) {
- if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) {
- hsize_t size = addr - file->eoa;
+ if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) {
+ hsize_t size = addr - file->eoa;
/* Retain the flavor of the space allocated by the extension */
- if(file->fa.flags & H5FD_LOG_FLAVOR) {
- HDassert(addr < file->iosize);
- H5_CHECK_OVERFLOW(size, hsize_t, size_t);
- HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size);
- } /* end if */
+ if(file->fa.flags & H5FD_LOG_FLAVOR) {
+ HDassert(addr < file->iosize);
+ H5_CHECK_OVERFLOW(size, hsize_t, size_t);
+ HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size);
+ } /* end if */
/* Log the extension like an allocation */
- if(file->fa.flags & H5FD_LOG_ALLOC)
- HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]);
- } /* end if */
+ if(file->fa.flags & H5FD_LOG_ALLOC)
+ HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]);
+ } /* end if */
} /* end if */
file->eoa = addr;
@@ -1050,18 +1027,18 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr)
/*-------------------------------------------------------------------------
- * Function: H5FD_log_get_eof
+ * Function: H5FD_log_get_eof
*
- * Purpose: Returns the end-of-file marker, which is the greater of
- * either the filesystem end-of-file or the HDF5 end-of-address
- * markers.
+ * Purpose: Returns the end-of-file marker, which is the greater of
+ * either the filesystem end-of-file or the HDF5 end-of-address
+ * markers.
*
- * Return: Success: End of file address, the first address past
- * the end of the "file", either the filesystem file
- * or the HDF5 file.
- * Failure: HADDR_UNDEF
+ * Return: Success: End of file address, the first address past
+ * the end of the "file", either the filesystem file
+ * or the HDF5 file.
+ * Failure: HADDR_UNDEF
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -1082,14 +1059,13 @@ H5FD_log_get_eof(const H5FD_t *_file)
*
* Purpose: Returns the file handle of LOG file driver.
*
- * Returns: Non-negative if succeed or negative if fails.
+ * Returns: SUCCEED/FAIL
*
* Programmer: Raymond Lu
* Sept. 16, 2002
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_log_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle)
{
@@ -1109,27 +1085,26 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_read
+ * Function: H5FD_log_read
*
- * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
- * into buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
+ * into buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero. Result is stored in caller-supplied
- * buffer BUF.
- * Failure: -1, Contents of buffer BUF are undefined.
+ * Return: Success: SUCCEED. Result is stored in caller-supplied
+ * buffer BUF.
+ * Failure: FAIL, Contents of buffer BUF are undefined.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr,
- size_t size, void *buf/*out*/)
+ size_t size, void *buf/*out*/)
{
- H5FD_log_t *file = (H5FD_log_t *)_file;
+ H5FD_log_t *file = (H5FD_log_t *)_file;
size_t orig_size = size; /* Save the original size for later */
haddr_t orig_addr = addr;
#ifdef H5_HAVE_GETTIMEOFDAY
@@ -1217,16 +1192,16 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr
#endif /* H5_HAVE_GETTIMEOFDAY */
while(size > 0) {
- h5_log_io_t bytes_in = 0; /* # of bytes to read */
- h5_log_io_ret_t bytes_read = -1; /* # of bytes actually read */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to read */
+ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
/* Trying to read more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_LOG_MAX_IO_BYTES_g)
- bytes_in = H5_LOG_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_log_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_read = HDread(file->fd, buf, bytes_in);
@@ -1240,7 +1215,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr
if(file->fa.flags & H5FD_LOG_LOC_READ)
HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size);
- 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);
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset);
} /* end if */
if(0 == bytes_read) {
@@ -1311,26 +1286,24 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_write
+ * Function: H5FD_log_write
*
- * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
- * from buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
+ * from buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr,
- size_t size, const void *buf)
+ size_t size, const void *buf)
{
- H5FD_log_t *file = (H5FD_log_t *)_file;
+ H5FD_log_t *file = (H5FD_log_t *)_file;
size_t orig_size = size; /* Save the original size for later */
haddr_t orig_addr = addr;
#ifdef H5_HAVE_GETTIMEOFDAY
@@ -1423,16 +1396,16 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
#endif /* H5_HAVE_GETTIMEOFDAY */
while(size > 0) {
- h5_log_io_t bytes_in = 0; /* # of bytes to write */
- h5_log_io_ret_t bytes_wrote = -1; /* # of bytes written */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to write */
+ h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
/* Trying to write more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_LOG_MAX_IO_BYTES_g)
- bytes_in = H5_LOG_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_log_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
@@ -1446,7 +1419,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
if(file->fa.flags & H5FD_LOG_LOC_WRITE)
HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size);
- 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);
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset);
} /* end if */
HDassert(bytes_wrote > 0);
@@ -1516,25 +1489,23 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_log_truncate
+ * Function: H5FD_log_truncate
*
- * Purpose: Makes sure that the true file size is the same (or larger)
- * than the end-of-address.
+ * Purpose: Makes sure that the true file size is the same (or larger)
+ * than the end-of-address.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, August 4, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
{
- H5FD_log_t *file = (H5FD_log_t *)_file;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_log_t *file = (H5FD_log_t *)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1595,4 +1566,3 @@ H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_log_truncate() */
-
diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c
index 9cf8b45..725913c 100644
--- a/src/H5FDmpiposix.c
+++ b/src/H5FDmpiposix.c
@@ -71,21 +71,6 @@
*/
static hid_t H5FD_MPIPOSIX_g = 0;
-/* Since Windows doesn't follow the rest of the world when it comes
- * to POSIX I/O types, some typedefs and constants are needed to avoid
- * making the code messy with #ifdefs.
- */
-#ifdef H5_HAVE_WIN32_API
-typedef unsigned int h5_mpiposix_io_t;
-typedef int h5_mpiposix_io_ret_t;
-static int H5_MPIPOSIX_MAX_IO_BYTES_g = INT_MAX;
-#else
-/* Unix, everyone else */
-typedef size_t h5_mpiposix_io_t;
-typedef ssize_t h5_mpiposix_io_ret_t;
-static size_t H5_MPIPOSIX_MAX_IO_BYTES_g = SSIZET_MAX;
-#endif /* H5_HAVE_WIN32_API */
-
/*
* The description of a file belonging to this driver.
* The EOF value is only used just after the file is opened in order for the
@@ -236,19 +221,16 @@ static const H5FD_class_mpi_t H5FD_mpiposix_g = {
};
-/*--------------------------------------------------------------------------
-NAME
- H5FD_mpiposix_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5FD_mpiposix_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines. (Just calls
- H5FD_mpiposix_init currently).
-
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5FD_mpiposix_init_interface
+ *
+ * Purpose: Initializes any interface-specific data or routines.
+ *
+ * Return: Success: The driver ID for the mpiposix driver.
+ * Failure: Negative.
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5FD_mpiposix_init_interface(void)
{
@@ -1079,16 +1061,16 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
*/
while(size > 0) {
- h5_mpiposix_io_t bytes_in = 0; /* # of bytes to read */
- h5_mpiposix_io_ret_t bytes_read = -1; /* # of bytes actually read */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to read */
+ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
/* Trying to read more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_MPIPOSIX_MAX_IO_BYTES_g)
- bytes_in = H5_MPIPOSIX_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_mpiposix_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_read = HDread(file->fd, buf, bytes_in);
@@ -1099,7 +1081,7 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
time_t mytime = HDtime(NULL);
HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR);
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset);
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset);
} /* end if */
if(0 == bytes_read) {
@@ -1263,16 +1245,16 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
*/
while(size > 0) {
- h5_mpiposix_io_t bytes_in = 0; /* # of bytes to write */
- h5_mpiposix_io_ret_t bytes_wrote = -1; /* # of bytes actually written */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to write */
+ h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes actually written */
/* Trying to write more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_MPIPOSIX_MAX_IO_BYTES_g)
- bytes_in = H5_MPIPOSIX_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_mpiposix_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
@@ -1283,7 +1265,7 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
time_t mytime = HDtime(NULL);
HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR);
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file write failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset);
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file write failed: time = %s, file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset);
} /* end if */
if(0 == bytes_wrote) {
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 877fae6..952389e 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -17,56 +17,41 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Thursday, July 29, 1999
*
- * Purpose: The POSIX unbuffered file driver using only the HDF5 public
- * API and with a few optimizations: the lseek() call is made
- * only when the current file position is unknown or needs to be
- * changed based on previous I/O through this driver (don't mix
- * I/O from this driver with I/O from other parts of the
- * application to the same file).
+ * Purpose: The POSIX unbuffered file driver using only the HDF5 public
+ * API and with a few optimizations: the lseek() call is made
+ * only when the current file position is unknown or needs to be
+ * changed based on previous I/O through this driver (don't mix
+ * I/O from this driver with I/O from other parts of the
+ * application to the same file).
*/
/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface
+#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5FDsec2.h" /* Sec2 file driver */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5FDsec2.h" /* Sec2 file driver */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
/* The driver identification number, initialized at runtime */
static hid_t H5FD_SEC2_g = 0;
-/* Since Windows doesn't follow the rest of the world when it comes
- * to POSIX I/O types, some typedefs and constants are needed to avoid
- * making the code messy with #ifdefs.
- */
-#ifdef H5_HAVE_WIN32_API
-typedef unsigned int h5_sec2_io_t;
-typedef int h5_sec2_io_ret_t;
-static int H5_SEC2_MAX_IO_BYTES_g = INT_MAX;
-#else
-/* Unix, everyone else */
-typedef size_t h5_sec2_io_t;
-typedef ssize_t h5_sec2_io_ret_t;
-static size_t H5_SEC2_MAX_IO_BYTES_g = SSIZET_MAX;
-#endif /* H5_HAVE_WIN32_API */
-
-/* The description of a file belonging to this driver. The `eoa' and `eof'
+/* 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 filesystem file). The
- * `pos' value is used to eliminate file position updates when they would be a
+ * 'pos' value is used to eliminate file position updates when they would be a
* no-op. Unfortunately we've found systems that use separate file position
* indicators for reading and writing so the lseek can only be eliminated if
* the current operation is the same as the previous operation. When opening
- * a file the `eof' will be set to the current file size, `eoa' will be set
- * to zero, `pos' will be set to H5F_ADDR_UNDEF (as it is when an error
- * occurs), and `op' will be set to H5F_OP_UNKNOWN.
+ * a file the 'eof' will be set to the current file size, `eoa' will be set
+ * to zero, 'pos' will be set to H5F_ADDR_UNDEF (as it is when an error
+ * occurs), and 'op' will be set to H5F_OP_UNKNOWN.
*/
typedef struct H5FD_sec2_t {
H5FD_t pub; /* public stuff, must be first */
@@ -123,28 +108,27 @@ typedef struct H5FD_sec2_t {
* These macros check for overflow of various quantities. These macros
* 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
- * of the file seek function.
+ * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
+ * is too large to be represented by the second argument
+ * of the file seek function.
*
- * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
- * large to be represented by the `size_t' type.
+ * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
+ * large to be represented by the `size_t' type.
*
- * REGION_OVERFLOW: Checks whether an address and size pair describe data
- * which can be addressed entirely by the second
- * argument of the file seek function.
+ * REGION_OVERFLOW: Checks whether an address and size pair describe data
+ * which can be addressed entirely by the second
+ * argument of the file seek function.
*/
#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) || \
- (HDoff_t)((A)+(Z))<(HDoff_t)(A))
+#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) || \
+ (HDoff_t)((A)+(Z))<(HDoff_t)(A))
/* Prototypes */
static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr);
+ haddr_t maxaddr);
static herr_t H5FD_sec2_close(H5FD_t *_file);
static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags);
@@ -153,62 +137,59 @@ static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file);
static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, void *buf);
+ size_t size, void *buf);
static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
- size_t size, const void *buf);
+ size_t size, const void *buf);
static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static const H5FD_class_t H5FD_sec2_g = {
- "sec2", /*name */
- MAXADDR, /*maxaddr */
- H5F_CLOSE_WEAK, /* fc_degree */
- NULL, /*sb_size */
- NULL, /*sb_encode */
- NULL, /*sb_decode */
- 0, /*fapl_size */
- NULL, /*fapl_get */
- NULL, /*fapl_copy */
- NULL, /*fapl_free */
- 0, /*dxpl_size */
- NULL, /*dxpl_copy */
- NULL, /*dxpl_free */
- H5FD_sec2_open, /*open */
- H5FD_sec2_close, /*close */
- H5FD_sec2_cmp, /*cmp */
- H5FD_sec2_query, /*query */
- NULL, /*get_type_map */
- NULL, /*alloc */
- NULL, /*free */
- H5FD_sec2_get_eoa, /*get_eoa */
- H5FD_sec2_set_eoa, /*set_eoa */
- H5FD_sec2_get_eof, /*get_eof */
- H5FD_sec2_get_handle, /*get_handle */
- H5FD_sec2_read, /*read */
- H5FD_sec2_write, /*write */
- NULL, /*flush */
- H5FD_sec2_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
- H5FD_FLMAP_DICHOTOMY /*fl_map */
+ "sec2", /* name */
+ MAXADDR, /* maxaddr */
+ H5F_CLOSE_WEAK, /* fc_degree */
+ NULL, /* sb_size */
+ NULL, /* sb_encode */
+ NULL, /* sb_decode */
+ 0, /* fapl_size */
+ NULL, /* fapl_get */
+ NULL, /* fapl_copy */
+ NULL, /* fapl_free */
+ 0, /* dxpl_size */
+ NULL, /* dxpl_copy */
+ NULL, /* dxpl_free */
+ H5FD_sec2_open, /* open */
+ H5FD_sec2_close, /* close */
+ H5FD_sec2_cmp, /* cmp */
+ H5FD_sec2_query, /* query */
+ NULL, /* get_type_map */
+ NULL, /* alloc */
+ NULL, /* free */
+ H5FD_sec2_get_eoa, /* get_eoa */
+ H5FD_sec2_set_eoa, /* set_eoa */
+ H5FD_sec2_get_eof, /* get_eof */
+ H5FD_sec2_get_handle, /* get_handle */
+ H5FD_sec2_read, /* read */
+ H5FD_sec2_write, /* write */
+ NULL, /* flush */
+ H5FD_sec2_truncate, /* truncate */
+ NULL, /* lock */
+ NULL, /* unlock */
+ H5FD_FLMAP_DICHOTOMY /* fl_map */
};
/* Declare a free list to manage the H5FD_sec2_t struct */
H5FL_DEFINE_STATIC(H5FD_sec2_t);
-/*--------------------------------------------------------------------------
-NAME
- H5FD_sec2_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5FD_sec2_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines. (Just calls
- H5FD_sec2_init currently).
-
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5FD_sec2_init_interface
+ *
+ * Purpose: Initializes any interface-specific data or routines.
+ *
+ * Return: Success: The driver ID for the sec2 driver.
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5FD_sec2_init_interface(void)
{
@@ -219,15 +200,15 @@ H5FD_sec2_init_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_init
+ * Function: H5FD_sec2_init
*
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Return: Success: The driver ID for the sec2 driver.
- * Failure: Negative.
+ * Return: Success: The driver ID for the sec2 driver.
+ * Failure: Negative
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -251,9 +232,9 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_sec2_term
+ * Function: H5FD_sec2_term
*
- * Purpose: Shut down the VFD
+ * Purpose: Shut down the VFD
*
* Returns: <none>
*
@@ -275,16 +256,16 @@ H5FD_sec2_term(void)
/*-------------------------------------------------------------------------
- * Function: H5Pset_fapl_sec2
+ * Function: H5Pset_fapl_sec2
*
- * Purpose: Modify the file access property list to use the H5FD_SEC2
- * driver defined in this source file. There are no driver
- * specific properties.
+ * Purpose: Modify the file access property list to use the H5FD_SEC2
+ * driver defined in this source file. There are no driver
+ * specific properties.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
- * Thursday, February 19, 1998
+ * Programmer: Robb Matzke
+ * Thursday, February 19, 1998
*
*-------------------------------------------------------------------------
*/
@@ -308,16 +289,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_open
+ * Function: H5FD_sec2_open
*
- * Purpose: Create and/or opens a file as an HDF5 file.
+ * Purpose: Create and/or opens a file as an HDF5 file.
*
- * Return: Success: A pointer to a new file data structure. The
- * public fields will be initialized by the
- * caller, which is always H5FD_open().
- * Failure: NULL
+ * Return: Success: A pointer to a new file data structure. The
+ * public fields will be initialized by the
+ * caller, which is always H5FD_open().
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -433,14 +414,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_close
+ * Function: H5FD_sec2_close
*
- * Purpose: Closes an HDF5 file.
+ * Purpose: Closes an HDF5 file.
*
- * Return: Success: 0
- * Failure: -1, file not closed.
+ * Return: Success: SUCCEED
+ * Failure: FAIL, file not closed.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -448,8 +429,8 @@ done:
static herr_t
H5FD_sec2_close(H5FD_t *_file)
{
- H5FD_sec2_t *file = (H5FD_sec2_t *)_file;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_sec2_t *file = (H5FD_sec2_t *)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -469,16 +450,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_cmp
+ * Function: H5FD_sec2_cmp
*
- * Purpose: Compares two files belonging to this driver using an
- * arbitrary (but consistent) ordering.
+ * Purpose: Compares two files belonging to this driver using an
+ * arbitrary (but consistent) ordering.
*
- * Return: Success: A value like strcmp()
- * Failure: never fails (arguments were checked by the
- * caller).
+ * Return: Success: A value like strcmp()
+ * Failure: never fails (arguments were checked by the
+ * caller).
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -486,8 +467,8 @@ done:
static int
H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
{
- const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1;
- const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2;
+ const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1;
+ const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2;
int ret_value = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -528,15 +509,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_query
+ * Function: H5FD_sec2_query
*
- * Purpose: Set the flags that this VFL driver is capable of supporting.
+ * Purpose: Set the flags that this VFL driver is capable of supporting.
* (listed in H5FDpublic.h)
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Friday, August 25, 2000
*
*-------------------------------------------------------------------------
@@ -567,21 +547,19 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */)
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_get_eoa
+ * Function: H5FD_sec2_get_eoa
*
- * Purpose: Gets the end-of-address marker for the file. The EOA marker
- * is the first address past the last byte allocated in the
- * format address space.
+ * Purpose: Gets the end-of-address marker for the file. The EOA marker
+ * is the first address past the last byte allocated in the
+ * format address space.
*
- * Return: Success: The end-of-address marker.
- * Failure: HADDR_UNDEF
+ * Return: The end-of-address marker.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, August 2, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static haddr_t
H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
{
@@ -594,21 +572,19 @@ H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_set_eoa
+ * Function: H5FD_sec2_set_eoa
*
- * Purpose: Set the end-of-address marker for the file. This function is
- * called shortly after an existing HDF5 file is opened in order
- * to tell the driver where the end of the HDF5 data is located.
+ * Purpose: Set the end-of-address marker for the file. This function is
+ * called shortly after an existing HDF5 file is opened in order
+ * to tell the driver where the end of the HDF5 data is located.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
{
@@ -623,18 +599,16 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_get_eof
+ * Function: H5FD_sec2_get_eof
*
- * Purpose: Returns the end-of-file marker, which is the greater of
- * either the filesystem end-of-file or the HDF5 end-of-address
- * markers.
+ * Purpose: Returns the end-of-file marker, which is the greater of
+ * either the filesystem end-of-file or the HDF5 end-of-address
+ * markers.
*
- * Return: Success: End of file address, the first address past
- * the end of the "file", either the filesystem file
- * or the HDF5 file.
- * Failure: HADDR_UNDEF
+ * Return: End of file address, the first address past the end of the
+ * "file", either the filesystem file or the HDF5 file.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -642,7 +616,7 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
static haddr_t
H5FD_sec2_get_eof(const H5FD_t *_file)
{
- const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file;
+ const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -655,14 +629,13 @@ H5FD_sec2_get_eof(const H5FD_t *_file)
*
* Purpose: Returns the file handle of sec2 file driver.
*
- * Returns: Non-negative if succeed or negative if fails.
+ * Returns: SUCCEED/FAIL
*
* Programmer: Raymond Lu
* Sept. 16, 2002
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle)
{
@@ -682,22 +655,21 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_read
+ * Function: H5FD_sec2_read
*
- * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
- * into buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR
+ * into buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero. Result is stored in caller-supplied
- * buffer BUF.
- * Failure: -1, Contents of buffer BUF are undefined.
+ * Return: Success: SUCCEED. Result is stored in caller-supplied
+ * buffer BUF.
+ * Failure: FAIL, Contents of buffer BUF are undefined.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
haddr_t addr, size_t size, void *buf /*out*/)
@@ -730,16 +702,16 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
*/
while(size > 0) {
- h5_sec2_io_t bytes_in = 0; /* # of bytes to read */
- h5_sec2_io_ret_t bytes_read = -1; /* # of bytes actually read */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to read */
+ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
/* Trying to read more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_SEC2_MAX_IO_BYTES_g)
- bytes_in = H5_SEC2_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_sec2_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_read = HDread(file->fd, buf, bytes_in);
@@ -750,7 +722,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
time_t mytime = HDtime(NULL);
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);
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)myoffset);
} /* end if */
if(0 == bytes_read) {
@@ -783,21 +755,19 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_write
+ * Function: H5FD_sec2_write
*
- * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
- * from buffer BUF according to data transfer properties in
- * DXPL_ID.
+ * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR
+ * from buffer BUF according to data transfer properties in
+ * DXPL_ID.
*
- * Return: Success: Zero
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
haddr_t addr, size_t size, const void *buf)
@@ -829,16 +799,16 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
*/
while(size > 0) {
- h5_sec2_io_t bytes_in = 0; /* # of bytes to write */
- h5_sec2_io_ret_t bytes_wrote = -1; /* # of bytes written */
+ h5_posix_io_t bytes_in = 0; /* # of bytes to write */
+ h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
/* Trying to write more bytes than the return type can handle is
* undefined behavior in POSIX.
*/
- if(size > H5_SEC2_MAX_IO_BYTES_g)
- bytes_in = H5_SEC2_MAX_IO_BYTES_g;
+ if(size > H5_POSIX_MAX_IO_BYTES)
+ bytes_in = H5_POSIX_MAX_IO_BYTES;
else
- bytes_in = (h5_sec2_io_t)size;
+ bytes_in = (h5_posix_io_t)size;
do {
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
@@ -849,7 +819,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
time_t mytime = HDtime(NULL);
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);
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)myoffset);
} /* end if */
HDassert(bytes_wrote > 0);
@@ -878,20 +848,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sec2_truncate
+ * Function: H5FD_sec2_truncate
*
- * Purpose: Makes sure that the true file size is the same (or larger)
- * than the end-of-address.
+ * Purpose: Makes sure that the true file size is the same (or larger)
+ * than the end-of-address.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, August 4, 1999
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
{
@@ -952,4 +920,3 @@ 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/H5config.h.in b/src/H5config.h.in
index 6de4d37..2e9aa6c 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -78,6 +78,9 @@
/* Define if the function stack tracing code is to be compiled in */
#undef HAVE_CODESTACK
+/* Define if Darwin or Mac OS X */
+#undef HAVE_DARWIN
+
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
*/
#undef HAVE_DECL_TZNAME
diff --git a/src/H5private.h b/src/H5private.h
index ffabac8..4501dd8 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -427,6 +427,24 @@
#define HSSIZET_MIN (~(HSSIZET_MAX))
/*
+ * Types and max sizes for POSIX I/O.
+ * OS X (Darwin) is odd since the max I/O size does not match the types.
+ */
+#if defined(H5_HAVE_WIN32_API)
+# define h5_posix_io_t unsigned int
+# define h5_posix_io_ret_t int
+# define H5_POSIX_MAX_IO_BYTES INT_MAX
+#elif defined(H5_HAVE_DARWIN)
+# define h5_posix_io_t size_t
+# define h5_posix_io_ret_t ssize_t
+# define H5_POSIX_MAX_IO_BYTES INT_MAX
+#else
+# define h5_posix_io_t size_t
+# define h5_posix_io_ret_t ssize_t
+# define H5_POSIX_MAX_IO_BYTES SSIZET_MAX
+#endif
+
+/*
* A macro to portably increment enumerated types.
*/
#ifndef H5_INC_ENUM