summaryrefslogtreecommitdiffstats
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
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)
-rw-r--r--config/cmake/ConfigureChecks.cmake7
-rw-r--r--config/cmake/H5pubconf.h.in3
-rwxr-xr-xconfigure8
-rw-r--r--configure.ac6
-rw-r--r--fortran/examples/Makefile.in2
-rw-r--r--src/H5FDcore.c550
-rw-r--r--src/H5FDlog.c412
-rw-r--r--src/H5FDmpiposix.c62
-rw-r--r--src/H5FDsec2.c381
-rw-r--r--src/H5config.h.in3
-rw-r--r--src/H5private.h18
11 files changed, 687 insertions, 765 deletions
diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake
index 4f4f759..6db6d78 100644
--- a/config/cmake/ConfigureChecks.cmake
+++ b/config/cmake/ConfigureChecks.cmake
@@ -14,7 +14,7 @@ INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
#-----------------------------------------------------------------------------
-# Always SET this for now IF we are on an OS X box
+# APPLE/Darwin setup
#-----------------------------------------------------------------------------
IF (APPLE)
LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_LENGTH)
@@ -28,6 +28,11 @@ IF (APPLE)
SET (H5_AC_APPLE_UNIVERSAL_BUILD 0)
ENDIF (APPLE)
+# Check for Darwin (not just Apple - we also want to catch OpenDarwin)
+IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ SET (H5_HAVE_DARWIN 1)
+ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+
#-----------------------------------------------------------------------------
# Option to Clear File Buffers before write --enable-clear-file-buffers
#-----------------------------------------------------------------------------
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in
index 6fca1ae..d9f0997 100644
--- a/config/cmake/H5pubconf.h.in
+++ b/config/cmake/H5pubconf.h.in
@@ -111,6 +111,9 @@
/* Define if the function stack tracing code is to be compiled in */
#cmakedefine H5_HAVE_CODESTACK @H5_HAVE_CODESTACK@
+/* Define if Darwin or Mac OS X */
+#cmakedefine H5_HAVE_DARWIN @H5_HAVE_DARWIN@
+
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
*/
#cmakedefine H5_HAVE_DECL_TZNAME @H5_HAVE_DECL_TZNAME@
diff --git a/configure b/configure
index 4a43f4e..9affafe 100755
--- a/configure
+++ b/configure
@@ -22754,6 +22754,14 @@ fi
done
+## Also need to detect Darwin for pubconf
+case $host_os in
+ darwin*)
+
+$as_echo "#define HAVE_DARWIN 1" >>confdefs.h
+
+ ;;
+esac
## Windows
case "`uname`" in
diff --git a/configure.ac b/configure.ac
index c5c0118..758c497 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1278,6 +1278,12 @@ AC_CHECK_HEADERS([stdint.h], [C9x=yes])
## Darwin
AC_CHECK_HEADERS([mach/mach_time.h])
+## Also need to detect Darwin for pubconf
+case $host_os in
+ darwin*)
+ AC_DEFINE([HAVE_DARWIN], [1], [Define if Darwin or Mac OS X])
+ ;;
+esac
## Windows
case "`uname`" in
diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in
index a3b0b98..5f6124c 100644
--- a/fortran/examples/Makefile.in
+++ b/fortran/examples/Makefile.in
@@ -70,7 +70,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/run-fortran-ex.sh.in $(srcdir)/testh5fc.sh.in \
$(top_srcdir)/bin/mkinstalldirs \
$(top_srcdir)/config/commence.am \
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() */
-
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 9f4abd3..81d050d 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,24 +146,23 @@ 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 herr_t H5FD_log_term(void);
@@ -186,7 +170,7 @@ 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);
@@ -196,9 +180,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 = {
@@ -240,19 +224,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)
{
@@ -263,15 +244,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
*
*-------------------------------------------------------------------------
@@ -295,11 +276,11 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_log_term
+ * Function: H5FD_log_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
@@ -319,15 +300,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
*
*-------------------------------------------------------------------------
*/
@@ -360,17 +341,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
*
*-------------------------------------------------------------------------
@@ -378,8 +359,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
@@ -391,14 +372,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
*
*-------------------------------------------------------------------------
@@ -406,9 +387,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
@@ -442,14 +423,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
*
*-------------------------------------------------------------------------
@@ -471,16 +451,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
*
*-------------------------------------------------------------------------
@@ -488,11 +468,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
@@ -501,8 +481,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
@@ -679,14 +659,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
*
*-------------------------------------------------------------------------
@@ -827,16 +807,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
*
*-------------------------------------------------------------------------
@@ -844,8 +824,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
@@ -888,15 +868,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
*
*-------------------------------------------------------------------------
@@ -904,7 +883,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
@@ -927,19 +906,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)
{
@@ -981,16 +959,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
*
*-------------------------------------------------------------------------
@@ -998,7 +976,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
@@ -1007,16 +985,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
*
*-------------------------------------------------------------------------
@@ -1024,25 +1001,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;
@@ -1052,18 +1029,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
*
*-------------------------------------------------------------------------
@@ -1084,14 +1061,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)
{
@@ -1111,27 +1087,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
@@ -1219,16 +1194,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);
@@ -1242,7 +1217,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) {
@@ -1313,26 +1288,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
@@ -1425,16 +1398,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);
@@ -1448,7 +1421,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);
@@ -1518,25 +1491,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
@@ -1597,4 +1568,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 092cd24..978494e 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
@@ -238,19 +223,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)
{
@@ -1081,16 +1063,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);
@@ -1101,7 +1083,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) {
@@ -1265,16 +1247,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);
@@ -1285,7 +1267,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 241609d..ca5127e 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,29 +108,28 @@ 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 herr_t H5FD_sec2_term(void);
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);
@@ -154,63 +138,60 @@ 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 */
- H5FD_sec2_term, /*terminate */
- 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 */
+ H5FD_sec2_term, /* terminate */
+ 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)
{
@@ -221,15 +202,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
*
*-------------------------------------------------------------------------
@@ -253,11 +234,11 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5FD_sec2_term
+ * Function: H5FD_sec2_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
@@ -277,16 +258,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
*
*-------------------------------------------------------------------------
*/
@@ -310,16 +291,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
*
*-------------------------------------------------------------------------
@@ -435,14 +416,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
*
*-------------------------------------------------------------------------
@@ -450,8 +431,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
@@ -471,16 +452,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
*
*-------------------------------------------------------------------------
@@ -488,8 +469,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
@@ -530,15 +511,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
*
*-------------------------------------------------------------------------
@@ -569,21 +549,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)
{
@@ -596,21 +574,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)
{
@@ -625,18 +601,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
*
*-------------------------------------------------------------------------
@@ -644,7 +618,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
@@ -657,14 +631,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)
{
@@ -684,22 +657,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*/)
@@ -732,16 +704,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);
@@ -752,7 +724,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) {
@@ -785,21 +757,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)
@@ -831,16 +801,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);
@@ -851,7 +821,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);
@@ -880,20 +850,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)
{
@@ -954,4 +922,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 fdbcd49..0308b38 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -74,6 +74,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 7dfd349..bff4e59 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -430,6 +430,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