summaryrefslogtreecommitdiffstats
path: root/src/H5FDcore.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2012-12-19 21:51:55 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2012-12-19 21:51:55 (GMT)
commit7b5b6d239e5f7a9f5317bc1df521468823db53f8 (patch)
tree11a5030f6e12dff457e56e95d7ee07ac2625a37f /src/H5FDcore.c
parenta50b051538a76ccfcf427b5fbf9b95e1ba8e81e4 (diff)
downloadhdf5-7b5b6d239e5f7a9f5317bc1df521468823db53f8.zip
hdf5-7b5b6d239e5f7a9f5317bc1df521468823db53f8.tar.gz
hdf5-7b5b6d239e5f7a9f5317bc1df521468823db53f8.tar.bz2
[svn-r23111] Purpose:
Fixes for HDF5 1.8.10 p1 HDFFV-7975 Changed the max single I/O operation size on Darwin/Mac OS X. HDFFV-8124 and HDFFV-8158 Fixed a core VFD bug when large blocks of data are read. HDFFV-8246 Added more fields to the VFD read/write error messages. 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/H5FDcore.c')
-rw-r--r--src/H5FDcore.c550
1 files changed, 255 insertions, 295 deletions
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 07f4551..03cc15e 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,44 +83,44 @@ 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 herr_t H5FD_core_term(void);
static void *H5FD_core_fapl_get(H5FD_t *_file);
static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr);
+ haddr_t maxaddr);
static herr_t H5FD_core_close(H5FD_t *_file);
static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
static herr_t H5FD_core_query(const H5FD_t *_f1, unsigned long *flags);
@@ -146,61 +129,58 @@ 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);
+ 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 */
- H5FD_core_term, /*terminate */
- 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 */
+ H5FD_core_term, /* terminate */
+ 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)
{
@@ -211,16 +191,15 @@ H5FD_core_init_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5FD_core_init
- *
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Function: H5FD_core_init
*
- * Return: Success: The driver ID for the core driver.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Failure: Negative.
+ * Return: Success: The driver ID for the core driver.
+ * Failure: Negative.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -228,15 +207,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)
@@ -244,11 +223,11 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_core_term
+ * Function: H5FD_core_term
*
- * Purpose: Shut down the VFD
+ * Purpose: Shut down the VFD
*
- * Returns: Non-negative on success or negative on failure
+ * Returns: SUCCEED (Can't fail)
*
* Programmer: Quincey Koziol
* Friday, Jan 30, 2004
@@ -261,32 +240,32 @@ H5FD_core_term(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Reset VFL ID */
- H5FD_CORE_g=0;
+ H5FD_CORE_g = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* 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
+ * Programmer: Robb Matzke
+ * 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);
@@ -306,26 +285,23 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Pget_fapl_core
+ * Function: H5Pget_fapl_core
*
- * Purpose: Queries properties set by the H5Pset_fapl_core() function.
+ * Purpose: Queries properties set by the H5Pset_fapl_core() function.
*
- * Return: Success: Non-negative
+ * Return: SUCCEED/FAIL
*
- * Failure: Negative
- *
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, August 10, 1999
*
*-------------------------------------------------------------------------
*/
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);
@@ -348,15 +324,15 @@ 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
+ * Programmer: Robb Matzke
* Friday, August 13, 1999
*
*-------------------------------------------------------------------------
@@ -364,9 +340,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
@@ -377,7 +353,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)
@@ -385,36 +361,35 @@ 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
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
*/
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
@@ -554,20 +529,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 */
@@ -575,12 +553,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 */
@@ -596,15 +575,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_close
- *
- * Purpose: Closes the file.
+ * Function: H5FD_core_close
*
- * Return: Success: 0
+ * Purpose: Closes the file.
*
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -612,8 +589,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
@@ -644,19 +621,19 @@ 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
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -664,9 +641,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
@@ -728,15 +705,14 @@ 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
+ * Programmer: Quincey Koziol
* Tuesday, October 7, 2008
*
*-------------------------------------------------------------------------
@@ -744,7 +720,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
@@ -768,17 +744,15 @@ 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.
+ * Return: The end-of-address marker. (Can't fail)
*
- * Failure: HADDR_UNDEF
- *
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, August 2, 1999
*
*-------------------------------------------------------------------------
@@ -786,7 +760,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
@@ -795,17 +769,15 @@ 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
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -813,8 +785,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
@@ -829,19 +801,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_get_eof
+ * 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.
+ * 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.
*
- * Return: Success: End of file address, the first address past
- * the end of the "file", either the memory
- * or the HDF5 file.
+ * Return: End of file address, the first address past
+ * the end of the "file", either the memory
+ * or the HDF5 file. (Can't fail)
*
- * Failure: HADDR_UNDEF
- *
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, July 29, 1999
*
*-------------------------------------------------------------------------
@@ -849,7 +819,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
@@ -860,9 +830,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
@@ -873,7 +843,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
@@ -918,26 +888,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
+ * 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 */
@@ -984,28 +953,25 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_write
+ * 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.
+ * 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
+ * Return: SUCCEED/FAIL
*
- * Failure: -1
- *
- * Programmer: Robb Matzke
+ * 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
@@ -1044,7 +1010,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;
@@ -1063,49 +1029,46 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_core_flush
- *
- * Purpose: Flushes the file to backing store if there is any and if the
- * dirty flag is set.
+ * Function: H5FD_core_flush
*
- * Return: Success: 0
+ * Purpose: Flushes the file to backing store if there is any and if the
+ * dirty flag is set.
*
- * Failure: -1
+ * Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
+ * 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);
@@ -1116,7 +1079,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);
@@ -1136,42 +1099,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
+ * 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)
{
@@ -1262,4 +1223,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() */
-