summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5AC.c23
-rw-r--r--src/H5ACprivate.h140
-rw-r--r--src/H5B.c64
-rw-r--r--src/H5D.c845
-rw-r--r--src/H5Farray.c395
-rw-r--r--src/H5Fprivate.h550
-rw-r--r--src/H5V.c546
-rw-r--r--src/H5Vprivate.h51
-rw-r--r--test/istore.c15
9 files changed, 1396 insertions, 1233 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 42a7b9f..247ae62 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -36,7 +36,7 @@
*/
#define PABLO_MASK H5AC_mask
#define INTERFACE_INIT NULL
-static int interface_initialize_g = FALSE; /*initialized? */
+static int interface_initialize_g = FALSE;
#ifdef H5AC_SORT_BY_ADDR
static H5AC_t *current_cache_g = NULL; /*for sorting */
@@ -179,7 +179,8 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
unsigned idx;
herr_t status;
void *thing = NULL;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
+ void *) = NULL;
H5AC_slot_t *slot = NULL;
H5AC_t *cache = NULL;
@@ -340,7 +341,8 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
{
uintn i;
herr_t status;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
+ void *) = NULL;
H5AC_slot_t *slot;
intn *map = NULL;
intn nslots;
@@ -464,7 +466,8 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
{
herr_t status;
uintn idx;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
+ void *) = NULL;
H5AC_slot_t *slot = NULL;
H5AC_t *cache = NULL;
@@ -533,7 +536,8 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
const haddr_t *old_addr, const haddr_t *new_addr)
{
uintn old_idx, new_idx;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *);
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
+ void *);
herr_t status;
H5AC_t *cache = NULL;
@@ -553,10 +557,12 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
int i;
for (i = 0; i < cache->slot[old_idx].nprots; i++) {
- assert(H5F_addr_ne(old_addr, &(cache->slot[old_idx].prot[i].addr)));
+ assert(H5F_addr_ne(old_addr,
+ &(cache->slot[old_idx].prot[i].addr)));
}
for (i = 0; i < cache->slot[new_idx].nprots; i++) {
- assert(H5F_addr_ne(new_addr, &(cache->slot[new_idx].prot[i].addr)));
+ assert(H5F_addr_ne(new_addr,
+ &(cache->slot[new_idx].prot[i].addr)));
}
}
#endif
@@ -743,7 +749,8 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
{
herr_t status;
uintn idx;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
+ void *) = NULL;
H5AC_t *cache = NULL;
H5AC_slot_t *slot = NULL;
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 50df708..2b4abe5 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -1,23 +1,23 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
- * All rights reserved.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5ACprivate.h
- * Jul 9 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5ACprivate.h
+ * Jul 9 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Constants and typedefs available to the rest of the
- * library.
+ * Purpose: Constants and typedefs available to the rest of the
+ * library.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
#ifndef _H5ACprivate_H
#define _H5ACprivate_H
-#include <H5ACpublic.h> /*public prototypes */
+#include <H5ACpublic.h> /*public prototypes */
/* Pivate headers needed by this header */
#include <H5private.h>
@@ -25,43 +25,43 @@
/*
* Feature: Define H5AC_DEBUG on the compiler command line if you want to
- * debug H5AC_protect() and H5AC_unprotect() by insuring that
- * nothing accesses protected objects. NDEBUG must not be defined
- * in order for this to have any effect.
+ * debug H5AC_protect() and H5AC_unprotect() by insuring that
+ * nothing accesses protected objects. NDEBUG must not be defined
+ * in order for this to have any effect.
*/
#ifdef NDEBUG
# undef H5AC_DEBUG
#endif
/*
- * Class methods pertaining to caching. Each type of cached object will
+ * Class methods pertaining to caching. Each type of cached object will
* have a constant variable with permanent life-span that describes how
- * to cache the object. That variable will be of type H5AC_class_t and
+ * to cache the object. That variable will be of type H5AC_class_t and
* have the following required fields...
*
- * LOAD: Loads an object from disk to memory. The function
- * should allocate some data structure and return it.
+ * LOAD: Loads an object from disk to memory. The function
+ * should allocate some data structure and return it.
*
- * FLUSH: Writes some data structure back to disk. It would be
- * wise for the data structure to include dirty flags to
- * indicate whether it really needs to be written. This
- * function is also responsible for freeing memory allocated
- * by the LOAD method if the DEST argument is non-zero.
+ * FLUSH: Writes some data structure back to disk. It would be
+ * wise for the data structure to include dirty flags to
+ * indicate whether it really needs to be written. This
+ * function is also responsible for freeing memory allocated
+ * by the LOAD method if the DEST argument is non-zero.
*/
typedef enum H5AC_subid_t {
- H5AC_BT_ID = 0, /*B-tree nodes */
- H5AC_SNODE_ID = 1, /*symbol table nodes */
- H5AC_HEAP_ID = 2, /*object or name heap */
- H5AC_OHDR_ID = 3, /*object header */
- H5AC_NTYPES = 4 /*THIS MUST BE LAST! */
+ H5AC_BT_ID = 0, /*B-tree nodes */
+ H5AC_SNODE_ID = 1, /*symbol table nodes */
+ H5AC_HEAP_ID = 2, /*object or name heap */
+ H5AC_OHDR_ID = 3, /*object header */
+ H5AC_NTYPES = 4 /*THIS MUST BE LAST! */
} H5AC_subid_t;
typedef struct H5AC_class_t {
- H5AC_subid_t id;
- void *(*load) (H5F_t *, const haddr_t *addr, const void *udata1,
- void *udata2);
- herr_t (*flush) (H5F_t *, hbool_t dest, const haddr_t *addr,
- void *thing);
+ H5AC_subid_t id;
+ void *(*load) (H5F_t *, const haddr_t *addr,
+ const void *udata1, void *udata2);
+ herr_t (*flush) (H5F_t *, hbool_t dest,
+ const haddr_t *addr, void *thing);
} H5AC_class_t;
/*
@@ -69,63 +69,65 @@ typedef struct H5AC_class_t {
* cache entry by hashing the object's file address. Each file has its
* own cache, an array of slots.
*/
-#define H5AC_NSLOTS 10330 /*prime number tend to work best */
+#define H5AC_NSLOTS 10330 /*prime number tend to work best */
#define H5AC_HASH(F,ADDR_P) H5F_addr_hash(ADDR_P,(F)->shared->cache->nslots)
typedef struct H5AC_prot_t {
- const H5AC_class_t *type; /*type of protected thing */
- haddr_t addr; /*address of protected thing */
- void *thing; /*(possible) protected thing */
+ const H5AC_class_t *type; /*type of protected thing */
+ haddr_t addr; /*address of protected thing */
+ void *thing; /*(possible) protected thing */
} H5AC_prot_t;
typedef struct H5AC_slot_t {
- const H5AC_class_t *type; /*type of object stored here */
- haddr_t addr; /*file address for object */
- void *thing; /*the thing which is cached */
+ const H5AC_class_t *type; /*type of object stored here */
+ haddr_t addr; /*file address for object */
+ void *thing; /*the thing which is cached */
#ifdef H5AC_DEBUG
- intn nprots; /*number of things protected */
- intn aprots; /*nelmts of `prot' array */
- H5AC_prot_t *prot; /*array of protected things */
+ intn nprots; /*number of things protected */
+ intn aprots; /*nelmts of `prot' array */
+ H5AC_prot_t *prot; /*array of protected things */
#endif
} H5AC_slot_t;
typedef struct H5AC_t {
- intn nslots; /*number of cache slots */
- H5AC_slot_t *slot; /*the cache slots */
- intn nprots; /*number of protected objects */
+ intn nslots; /*number of cache slots */
+ H5AC_slot_t *slot; /*the cache slots */
+ intn nprots; /*number of protected objects */
struct {
- uintn nhits; /*number of cache hits */
- uintn nmisses; /*number of cache misses */
- uintn ninits; /*number of cache initializations */
- uintn nflushes; /*number of flushes to disk */
- } diagnostics[H5AC_NTYPES]; /*diagnostics for each type of object */
+ uintn nhits; /*number of cache hits */
+ uintn nmisses;/*number of cache misses */
+ uintn ninits; /*number of cache inits */
+ uintn nflushes;/*number of flushes to disk */
+ } diagnostics[H5AC_NTYPES]; /*diagnostics for each type of object */
} H5AC_t;
/*
* Library prototypes.
*/
-herr_t H5AC_dest(H5F_t *f);
-void *H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2);
-void *H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2);
-herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- void *thing);
-herr_t H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- hbool_t destroy);
-herr_t H5AC_create(H5F_t *f, intn size_hint);
-herr_t H5AC_rename(H5F_t *f, const H5AC_class_t *type,
- const haddr_t *old_addr, const haddr_t *new_addr);
-herr_t H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- void *thing);
-herr_t H5AC_debug(H5F_t *f);
+herr_t H5AC_dest(H5F_t *f);
+void *H5AC_find_f(H5F_t *f, const H5AC_class_t *type,
+ const haddr_t *addr, const void *udata1,
+ void *udata2);
+void *H5AC_protect(H5F_t *f, const H5AC_class_t *type,
+ const haddr_t *addr, const void *udata1,
+ void *udata2);
+herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type,
+ const haddr_t *addr, void *thing);
+herr_t H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ hbool_t destroy);
+herr_t H5AC_create(H5F_t *f, intn size_hint);
+herr_t H5AC_rename(H5F_t *f, const H5AC_class_t *type,
+ const haddr_t *old_addr, const haddr_t *new_addr);
+herr_t H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ void *thing);
+herr_t H5AC_debug(H5F_t *f);
-#define H5AC_find(F,TYPE,ADDR_P,UDATA1,UDATA2) \
- (((F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].type==(TYPE) && \
+#define H5AC_find(F,TYPE,ADDR_P,UDATA1,UDATA2) \
+ (((F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].type==(TYPE) && \
H5F_addr_eq (&((F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].addr), \
- ADDR_P)) ? \
- ((F)->shared->cache->diagnostics[(TYPE)->id].nhits++, \
- (F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].thing) : \
+ ADDR_P)) ? \
+ ((F)->shared->cache->diagnostics[(TYPE)->id].nhits++, \
+ (F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].thing) : \
H5AC_find_f (F, TYPE, ADDR_P, UDATA1, UDATA2))
#endif /* !_H5ACprivate_H */
diff --git a/src/H5B.c b/src/H5B.c
index e7436c6..b2eeecd 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -101,37 +101,40 @@
/* PRIVATE PROTOTYPES */
static H5B_ins_t H5B_insert_helper(H5F_t *f, const haddr_t *addr,
const H5B_class_t *type,
- uint8 *lt_key, hbool_t *lt_key_changed,
+ uint8 *lt_key,
+ hbool_t *lt_key_changed,
uint8 *md_key, void *udata,
- uint8 *rt_key, hbool_t *rt_key_changed,
+ uint8 *rt_key,
+ hbool_t *rt_key_changed,
haddr_t *retval);
static herr_t H5B_insert_child(H5F_t *f, const H5B_class_t *type,
- H5B_t *bt, intn idx, const haddr_t *child,
+ H5B_t *bt, intn idx,
+ const haddr_t *child,
H5B_ins_t anchor, void *md_key);
-static herr_t H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
- H5B_t *b);
-static H5B_t *H5B_load(H5F_t *f, const haddr_t *addr, const void *_type,
- void *udata);
+static herr_t H5B_flush(H5F_t *f, hbool_t destroy,
+ const haddr_t *addr, H5B_t *b);
+static H5B_t *H5B_load(H5F_t *f, const haddr_t *addr,
+ const void *_type, void *udata);
static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, intn idx);
static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx);
static size_t H5B_nodesize(H5F_t *f, const H5B_class_t *type,
size_t *total_nkey_size, size_t sizeof_rkey);
-static herr_t H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
- const haddr_t *old_addr, void *udata,
- haddr_t *new_addr /*out */ );
+static herr_t H5B_split(H5F_t *f, const H5B_class_t *type,
+ H5B_t *old_bt, const haddr_t *old_addr,
+ void *udata, haddr_t *new_addr /*out*/ );
#ifdef H5B_DEBUG
static herr_t H5B_assert(H5F_t *f, const haddr_t *addr,
const H5B_class_t *type, void *udata);
#endif
/* H5B inherits cache-like properties from H5AC */
-static const H5AC_class_t H5AC_BT[1] =
-{
+static const H5AC_class_t H5AC_BT[1] = {
{
H5AC_BT_ID,
(void *(*)(H5F_t *, const haddr_t *, const void *, void *)) H5B_load,
(herr_t (*)(H5F_t *, hbool_t, const haddr_t *, void *)) H5B_flush,
- }};
+ }
+};
/* Interface initialization? */
#define INTERFACE_INIT NULL
@@ -1101,8 +1104,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
} else if (cmp < 0 && idx <= 0 && bt->level > 0) {
/*
- * The value being inserted is less than any value in this tree. Follow
- * the minimum branch out of this node to a subtree.
+ * The value being inserted is less than any value in this tree.
+ * Follow the minimum branch out of this node to a subtree.
*/
idx = 0;
if (H5B_decode_keys(f, bt, idx) < 0) {
@@ -1206,8 +1209,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
my_ins = H5B_INS_RIGHT;
HDmemcpy(md_key, bt->key[idx + 1].nkey, type->sizeof_nkey);
- if ((type->new) (f, H5B_INS_RIGHT, md_key, udata, bt->key[idx + 1].nkey,
- &child_addr /*out */ ) < 0) {
+ if ((type->new) (f, H5B_INS_RIGHT, md_key, udata,
+ bt->key[idx + 1].nkey, &child_addr /*out */ ) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert maximum leaf node");
}
@@ -1284,13 +1287,16 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
if (H5B_INS_RIGHT == my_ins)
idx++;
- /* If this node is full then split it before inserting the new child. */
+ /*
+ * If this node is full then split it before inserting the new child.
+ */
if (bt->nchildren == 2 * H5B_K(f, type)) {
if (H5B_split(f, type, bt, addr, udata, new_node /*out */ ) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR,
"can't split node");
}
- if (NULL == (twin = H5AC_protect(f, H5AC_BT, new_node, type, udata))) {
+ if (NULL == (twin = H5AC_protect(f, H5AC_BT, new_node, type,
+ udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
"can't load B-tree");
}
@@ -1328,7 +1334,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
* in the new node.
*/
if (!bt->key[bt->nchildren].nkey) {
- herr_t status = H5B_decode_key(f, bt, bt->nchildren);
+ herr_t status = H5B_decode_key(f, bt, bt->nchildren);
assert(status >= 0);
}
cmp = (type->cmp2) (f, bt->key[bt->nchildren].nkey, udata,
@@ -1341,9 +1347,9 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
done:
{
- herr_t e1 = (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0);
- herr_t e2 = (twin && H5AC_unprotect(f, H5AC_BT, new_node, twin) < 0);
- if (e1 || e2) { /*use vars to prevent short-circuit of side effects */
+ herr_t e1 = (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0);
+ herr_t e2 = (twin && H5AC_unprotect(f, H5AC_BT, new_node, twin) < 0);
+ if (e1 || e2) { /*use vars to prevent short-circuit of side effects */
HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
"unable to release node(s)");
}
@@ -1403,8 +1409,11 @@ H5B_list(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
}
} else {
- for (cur_addr = addr; !H5F_addr_defined(cur_addr); cur_addr = &next_addr) {
- if (NULL == (bt = H5AC_protect(f, H5AC_BT, cur_addr, type, udata))) {
+ for (cur_addr = addr;
+ !H5F_addr_defined(cur_addr);
+ cur_addr = &next_addr) {
+ if (NULL == (bt = H5AC_protect(f, H5AC_BT, cur_addr, type,
+ udata))) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
"unable to protect B-tree node");
}
@@ -1610,7 +1619,7 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
haddr_t addr;
int level;
struct child_t *next;
- } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL;
+ } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL;
FUNC_ENTER(H5B_assert, FAIL);
if (0 == ncalls++) {
@@ -1669,7 +1678,8 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
/* Check that the keys are monotonically increasing */
status = H5B_decode_keys(f, bt, i);
assert(status >= 0);
- cmp = (type->cmp2) (f, bt->key[i].nkey, udata, bt->key[i + 1].nkey);
+ cmp = (type->cmp2) (f, bt->key[i].nkey, udata,
+ bt->key[i + 1].nkey);
assert(cmp < 0);
}
}
diff --git a/src/H5D.c b/src/H5D.c
index 1a72e38..0201499 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1,69 +1,69 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#include <H5ACprivate.h> /* Cache */
-#include <H5Cprivate.h> /* Templates */
-#include <H5Dprivate.h> /* Dataset functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5Gprivate.h> /* Group headers */
-#include <H5Mprivate.h> /* Meta data */
-#include <H5MFprivate.h> /* File space allocation header */
-#include <H5MMprivate.h> /* Memory management */
-#include <H5Mprivate.h> /* Meta-Object API */
-#include <H5Oprivate.h> /* Object headers */
-
-#define PABLO_MASK H5D_mask
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atoms */
+#include <H5ACprivate.h> /* Cache */
+#include <H5Cprivate.h> /* Templates */
+#include <H5Dprivate.h> /* Dataset functions */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5Gprivate.h> /* Group headers */
+#include <H5Mprivate.h> /* Meta data */
+#include <H5MFprivate.h> /* File space allocation header */
+#include <H5MMprivate.h> /* Memory management */
+#include <H5Mprivate.h> /* Meta-Object API */
+#include <H5Oprivate.h> /* Object headers */
+
+#define PABLO_MASK H5D_mask
/*
* A dataset is the following struct.
*/
struct H5D_t {
- H5G_entry_t ent; /*cached object header stuff */
- H5T_t *type; /*datatype of this dataset */
- H5P_t *space; /*dataspace of this dataset */
- H5D_create_t create_parms; /*creation parameters */
- H5O_layout_t layout; /*data layout */
+ H5G_entry_t ent; /*cached object header stuff */
+ H5T_t *type; /*datatype of this dataset */
+ H5P_t *space; /*dataspace of this dataset */
+ H5D_create_t create_parms; /*creation parameters */
+ H5O_layout_t layout; /*data layout */
};
/* Default dataset creation template */
-const H5D_create_t H5D_create_dflt =
+const H5D_create_t H5D_create_dflt =
{
- H5D_CONTIGUOUS, /* Layout */
- 1, /* Chunk dimensions */
- {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values.... */
- 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks.. */
- 1, 1, 1, 1, 1, 1, 1, 1, /*...produce fewer, but larger I/O...... */
- 1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */
+ H5D_CONTIGUOUS, /* Layout */
+ 1, /* Chunk dimensions */
+ {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values.... */
+ 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks.. */
+ 1, 1, 1, 1, 1, 1, 1, 1, /*...produce fewer, but larger I/O...... */
+ 1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */
};
/* Default dataset transfer template */
-const H5D_xfer_t H5D_xfer_dflt =
+const H5D_xfer_t H5D_xfer_dflt =
{
- 0, /* Place holder - remove this later */
+ 0, /* Place holder - remove this later */
};
/* Interface initialization? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5D_init_interface
-static herr_t H5D_init_interface(void);
-static void H5D_term_interface(void);
+static herr_t H5D_init_interface(void);
+static void H5D_term_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -80,14 +80,14 @@ DESCRIPTION
static herr_t
H5D_init_interface(void)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5D_init_interface, FAIL);
/* Initialize the atom group for the dataset IDs */
if ((ret_value = H5Ainit_group(H5_DATASET, H5A_DATASETID_HASHSIZE,
- H5D_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5D_close)) != FAIL) {
- ret_value = H5_add_exit(H5D_term_interface);
+ H5D_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5D_close)) != FAIL) {
+ ret_value = H5_add_exit(H5D_term_interface);
}
FUNC_LEAVE(ret_value);
}
@@ -116,40 +116,40 @@ H5D_term_interface(void)
}
/*-------------------------------------------------------------------------
- * Function: H5Dcreate
+ * Function: H5Dcreate
*
- * Purpose: Creates a new dataset named NAME in file FILE_ID, opens the
- * dataset for access, and associates with that dataset constant
- * and initial persistent properties including the type of each
- * datapoint as stored in the file (TYPE_ID), the size of the
- * dataset (SPACE_ID), and other initial miscellaneous
- * properties (CREATE_PARMS_ID).
+ * Purpose: Creates a new dataset named NAME in file FILE_ID, opens the
+ * dataset for access, and associates with that dataset constant
+ * and initial persistent properties including the type of each
+ * datapoint as stored in the file (TYPE_ID), the size of the
+ * dataset (SPACE_ID), and other initial miscellaneous
+ * properties (CREATE_PARMS_ID).
*
- * All arguments are copied into the dataset, so the caller is
- * allowed to derive new types, data spaces, and creation
- * parameters from the old ones and reuse them in calls to
- * create other datasets.
+ * All arguments are copied into the dataset, so the caller is
+ * allowed to derive new types, data spaces, and creation
+ * parameters from the old ones and reuse them in calls to
+ * create other datasets.
*
- * Return: Success: The object ID of the new dataset. At this
- * point, the dataset is ready to receive its
- * raw data. Attempting to read raw data from
- * the dataset will probably return the fill
- * value. The dataset should be closed when
- * the caller is no longer interested in it.
+ * Return: Success: The object ID of the new dataset. At this
+ * point, the dataset is ready to receive its
+ * raw data. Attempting to read raw data from
+ * the dataset will probably return the fill
+ * value. The dataset should be closed when
+ * the caller is no longer interested in it.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a data space.
- * ARGS BADTYPE Not a dataset creation template.
- * ARGS BADTYPE Not a file.
- * ARGS BADTYPE Not a type.
- * ARGS BADVALUE No name.
- * DATASET CANTINIT Can't create dataset.
- * DATASET CANTREGISTER Can't register dataset.
+ * ARGS BADTYPE Not a data space.
+ * ARGS BADTYPE Not a dataset creation template.
+ * ARGS BADTYPE Not a file.
+ * ARGS BADTYPE Not a type.
+ * ARGS BADVALUE No name.
+ * DATASET CANTINIT Can't create dataset.
+ * DATASET CANTREGISTER Can't register dataset.
*
- * Programmer: Robb Matzke
- * Wednesday, December 3, 1997
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
*
* Modifications:
*
@@ -157,76 +157,76 @@ H5D_term_interface(void)
*/
hid_t
H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
- hid_t create_parms_id)
+ hid_t create_parms_id)
{
- H5F_t *f = NULL;
- H5T_t *type = NULL;
- H5P_t *space = NULL;
- H5D_t *new_dset = NULL;
- hid_t ret_value = FAIL;
- const H5D_create_t *create_parms = NULL;
+ H5F_t *f = NULL;
+ H5T_t *type = NULL;
+ H5P_t *space = NULL;
+ H5D_t *new_dset = NULL;
+ hid_t ret_value = FAIL;
+ const H5D_create_t *create_parms = NULL;
FUNC_ENTER(H5Dcreate, FAIL);
H5ECLEAR;
/* check arguments */
if (H5_FILE != H5Aatom_group(file_id) ||
- NULL == (f = H5Aatom_object(file_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
}
if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
}
if (H5_DATATYPE != H5Aatom_group(type_id) ||
- NULL == (type = H5Aatom_object(type_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type");
+ NULL == (type = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type");
}
if (H5_DATASPACE != H5Aatom_group(space_id) ||
- NULL == (space = H5Aatom_object(space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ NULL == (space = H5Aatom_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
if (create_parms_id >= 0) {
- if (H5C_DATASET_CREATE != H5Cget_class(create_parms_id) ||
- NULL == (create_parms = H5Aatom_object(create_parms_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
- }
+ if (H5C_DATASET_CREATE != H5Cget_class(create_parms_id) ||
+ NULL == (create_parms = H5Aatom_object(create_parms_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
+ }
} else {
- create_parms = &H5D_create_dflt;
+ create_parms = &H5D_create_dflt;
}
/* build and open the new dataset */
if (NULL == (new_dset = H5D_create(f, name, type, space, create_parms))) {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create dataset");
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create dataset");
}
/* Register the new datatype and get an ID for it */
if ((ret_value = H5Aregister_atom(H5_DATASET, new_dset)) < 0) {
- H5D_close(new_dset);
- HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "can't register dataset");
+ H5D_close(new_dset);
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "can't register dataset");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Dopen
+ * Function: H5Dopen
*
- * Purpose: Finds a dataset named NAME in file FILE_ID, opens it, and
- * returns its ID. The dataset should be close when the caller
- * is no longer interested in it.
+ * Purpose: Finds a dataset named NAME in file FILE_ID, opens it, and
+ * returns its ID. The dataset should be close when the caller
+ * is no longer interested in it.
*
- * Return: Success: A new dataset ID
+ * Return: Success: A new dataset ID
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a file.
- * ARGS BADVALUE No name.
- * DATASET CANTREGISTER Can't register dataset.
- * DATASET NOTFOUND Dataset not found.
+ * ARGS BADTYPE Not a file.
+ * ARGS BADVALUE No name.
+ * DATASET CANTREGISTER Can't register dataset.
+ * DATASET NOTFOUND Dataset not found.
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -235,51 +235,51 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
hid_t
H5Dopen(hid_t file_id, const char *name)
{
- H5F_t *file = NULL; /*file holding the dataset */
- H5D_t *dataset = NULL; /*the dataset */
- hid_t ret_value = FAIL;
+ H5F_t *file = NULL; /*file holding the dataset */
+ H5D_t *dataset = NULL; /*the dataset */
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5Dopen, FAIL);
H5ECLEAR;
/* Check args */
if (H5_FILE != H5Aatom_group(file_id) ||
- NULL == (file = H5Aatom_object(file_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ NULL == (file = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
}
if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
}
/* Find the dataset */
if (NULL == (dataset = H5D_open(file, name))) {
- HRETURN_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found");
+ HRETURN_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found");
}
/* Create an atom for the dataset */
if ((ret_value = H5Aregister_atom(H5_DATASET, dataset)) < 0) {
- H5D_close(dataset);
- HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "can't register dataset");
+ H5D_close(dataset);
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "can't register dataset");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Dclose
+ * Function: H5Dclose
*
- * Purpose: Closes access to a dataset (DATASET_ID) and releases
- * resources used by it. It is illegal to subsequently use that
- * same dataset ID in calls to other dataset functions.
+ * Purpose: Closes access to a dataset (DATASET_ID) and releases
+ * resources used by it. It is illegal to subsequently use that
+ * same dataset ID in calls to other dataset functions.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a dataset.
- * DATASET CANTINIT Can't free.
+ * ARGS BADTYPE Not a dataset.
+ * DATASET CANTINIT Can't free.
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -288,64 +288,64 @@ H5Dopen(hid_t file_id, const char *name)
herr_t
H5Dclose(hid_t dataset_id)
{
- H5D_t *dataset = NULL; /* dataset object to release */
+ H5D_t *dataset = NULL; /* dataset object to release */
FUNC_ENTER(H5Dclose, FAIL);
H5ECLEAR;
/* Check args */
if (H5_DATASET != H5Aatom_group(dataset_id) ||
- NULL == (dataset = H5Aatom_object(dataset_id)) ||
- NULL == dataset->ent.file) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ NULL == (dataset = H5Aatom_object(dataset_id)) ||
+ NULL == dataset->ent.file) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
/*
* Decrement the counter on the dataset. It will be freed if the count
* reaches zero.
*/
if (H5A_dec_ref(dataset_id) < 0) {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free");
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Dread
+ * Function: H5Dread
*
- * Purpose: Reads (part of) a DATASET from the file into application
- * memory BUF. The part of the dataset to read is defined with
- * MEM_SPACE_ID and FILE_SPACE_ID. The data points are
- * converted from their file type to the MEM_TYPE_ID specified.
- * Additional miscellaneous data transfer properties can be
- * passed to this function with the XFER_PARMS_ID argument.
+ * Purpose: Reads (part of) a DATASET from the file into application
+ * memory BUF. The part of the dataset to read is defined with
+ * MEM_SPACE_ID and FILE_SPACE_ID. The data points are
+ * converted from their file type to the MEM_TYPE_ID specified.
+ * Additional miscellaneous data transfer properties can be
+ * passed to this function with the XFER_PARMS_ID argument.
*
- * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
- * that the entire file data space is to be referenced.
+ * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
+ * that the entire file data space is to be referenced.
*
- * The MEM_SPACE_ID can be the constant H5P_ALL in which case
- * the memory data space is the same as the file data space
- * defined when the dataset was created.
+ * The MEM_SPACE_ID can be the constant H5P_ALL in which case
+ * the memory data space is the same as the file data space
+ * defined when the dataset was created.
*
- * The number of elements in the memory data space must match
- * the number of elements in the file data space.
+ * The number of elements in the memory data space must match
+ * the number of elements in the file data space.
*
- * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
- * case the default data transfer properties are used.
+ * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
+ * case the default data transfer properties are used.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a data space.
- * ARGS BADTYPE Not a data type.
- * ARGS BADTYPE Not a dataset.
- * ARGS BADTYPE Not xfer parms.
- * ARGS BADVALUE No output buffer.
- * DATASET READERROR Can't read data.
+ * ARGS BADTYPE Not a data space.
+ * ARGS BADTYPE Not a data type.
+ * ARGS BADTYPE Not a dataset.
+ * ARGS BADTYPE Not xfer parms.
+ * ARGS BADVALUE No output buffer.
+ * DATASET READERROR Can't read data.
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -353,88 +353,88 @@ H5Dclose(hid_t dataset_id)
*/
herr_t
H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t xfer_parms_id, void *buf /*out */ )
+ hid_t file_space_id, hid_t xfer_parms_id, void *buf /*out */ )
{
- H5D_t *dataset = NULL;
- const H5T_t *mem_type = NULL;
- const H5P_t *mem_space = NULL;
- const H5P_t *file_space = NULL;
- const H5D_xfer_t *xfer_parms = NULL;
+ H5D_t *dataset = NULL;
+ const H5T_t *mem_type = NULL;
+ const H5P_t *mem_space = NULL;
+ const H5P_t *file_space = NULL;
+ const H5D_xfer_t *xfer_parms = NULL;
FUNC_ENTER(H5Dread, FAIL);
H5ECLEAR;
/* check arguments */
if (H5_DATASET != H5Aatom_group(dataset_id) ||
- NULL == (dataset = H5Aatom_object(dataset_id)) ||
- NULL == dataset->ent.file) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ NULL == (dataset = H5Aatom_object(dataset_id)) ||
+ NULL == dataset->ent.file) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
if (H5_DATATYPE != H5Aatom_group(mem_type_id) ||
- NULL == (mem_type = H5Aatom_object(mem_type_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ NULL == (mem_type = H5Aatom_object(mem_type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (H5P_ALL != mem_space_id) {
- if (H5_DATASPACE != H5Aatom_group(mem_space_id) ||
- NULL == (mem_space = H5Aatom_object(mem_space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+ if (H5_DATASPACE != H5Aatom_group(mem_space_id) ||
+ NULL == (mem_space = H5Aatom_object(mem_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
}
if (H5P_ALL != file_space_id) {
- if (H5_DATASPACE != H5Aatom_group(file_space_id) ||
- NULL == (file_space = H5Aatom_object(file_space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+ if (H5_DATASPACE != H5Aatom_group(file_space_id) ||
+ NULL == (file_space = H5Aatom_object(file_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
}
if (H5C_DEFAULT == xfer_parms_id) {
- xfer_parms = &H5D_xfer_dflt;
+ xfer_parms = &H5D_xfer_dflt;
} else if (H5C_DATASET_XFER != H5Cget_class(xfer_parms_id) ||
- NULL == (xfer_parms = H5Aatom_object(xfer_parms_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
+ NULL == (xfer_parms = H5Aatom_object(xfer_parms_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
}
if (!buf) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
}
/* read raw data */
if (H5D_read(dataset, mem_type, mem_space, file_space, xfer_parms,
- buf /*out */ ) < 0) {
- HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data");
+ buf /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Dwrite
+ * Function: H5Dwrite
*
- * Purpose: Writes (part of) a DATASET from application memory BUF to the
- * file. The part of the dataset to write is defined with the
- * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points
- * are converted from their current type (MEM_TYPE_ID) to their
- * file data type. Additional miscellaneous data transfer
- * properties can be passed to this function with the
- * XFER_PARMS_ID argument.
+ * Purpose: Writes (part of) a DATASET from application memory BUF to the
+ * file. The part of the dataset to write is defined with the
+ * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points
+ * are converted from their current type (MEM_TYPE_ID) to their
+ * file data type. Additional miscellaneous data transfer
+ * properties can be passed to this function with the
+ * XFER_PARMS_ID argument.
*
- * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
- * that the entire file data space is to be referenced.
+ * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
+ * that the entire file data space is to be referenced.
*
- * The MEM_SPACE_ID can be the constant H5P_ALL in which case
- * the memory data space is the same as the file data space
- * defined when the dataset was created.
+ * The MEM_SPACE_ID can be the constant H5P_ALL in which case
+ * the memory data space is the same as the file data space
+ * defined when the dataset was created.
*
- * The number of elements in the memory data space must match
- * the number of elements in the file data space.
+ * The number of elements in the memory data space must match
+ * the number of elements in the file data space.
*
- * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
- * case the default data transfer properties are used.
+ * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
+ * case the default data transfer properties are used.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -442,71 +442,71 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
*/
herr_t
H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t xfer_parms_id, const void *buf)
+ hid_t file_space_id, hid_t xfer_parms_id, const void *buf)
{
- H5D_t *dataset = NULL;
- const H5T_t *mem_type = NULL;
- const H5P_t *mem_space = NULL;
- const H5P_t *file_space = NULL;
- const H5D_xfer_t *xfer_parms = NULL;
+ H5D_t *dataset = NULL;
+ const H5T_t *mem_type = NULL;
+ const H5P_t *mem_space = NULL;
+ const H5P_t *file_space = NULL;
+ const H5D_xfer_t *xfer_parms = NULL;
FUNC_ENTER(H5Dwrite, FAIL);
H5ECLEAR;
/* check arguments */
if (H5_DATASET != H5Aatom_group(dataset_id) ||
- NULL == (dataset = H5Aatom_object(dataset_id)) ||
- NULL == dataset->ent.file) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ NULL == (dataset = H5Aatom_object(dataset_id)) ||
+ NULL == dataset->ent.file) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
if (H5_DATATYPE != H5Aatom_group(mem_type_id) ||
- NULL == (mem_type = H5Aatom_object(mem_type_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ NULL == (mem_type = H5Aatom_object(mem_type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (H5P_ALL != mem_space_id) {
- if (H5_DATASPACE != H5Aatom_group(mem_space_id) ||
- NULL == (mem_space = H5Aatom_object(mem_space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+ if (H5_DATASPACE != H5Aatom_group(mem_space_id) ||
+ NULL == (mem_space = H5Aatom_object(mem_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
}
if (H5P_ALL != file_space_id) {
- if (H5_DATASPACE != H5Aatom_group(file_space_id) ||
- NULL == (file_space = H5Aatom_object(file_space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+ if (H5_DATASPACE != H5Aatom_group(file_space_id) ||
+ NULL == (file_space = H5Aatom_object(file_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
}
if (H5C_DEFAULT == xfer_parms_id) {
- xfer_parms = &H5D_xfer_dflt;
+ xfer_parms = &H5D_xfer_dflt;
} else if (H5C_DATASET_XFER != H5Cget_class(xfer_parms_id) ||
- NULL == (xfer_parms = H5Aatom_object(xfer_parms_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
+ NULL == (xfer_parms = H5Aatom_object(xfer_parms_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
}
if (!buf) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
}
/* write raw data */
if (H5D_write(dataset, mem_type, mem_space, file_space, xfer_parms,
- buf) < 0) {
- HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't write data");
+ buf) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't write data");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5D_find_name
+ * Function: H5D_find_name
*
- * Purpose: This is a callback for H5Mfind_name(). It does the same
- * thing as H5Dopen() except it takes an extra argument which
- * isn't used.
+ * Purpose: This is a callback for H5Mfind_name(). It does the same
+ * thing as H5Dopen() except it takes an extra argument which
+ * isn't used.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -519,39 +519,39 @@ H5D_find_name(hid_t file_id, group_t UNUSED, const char *name)
}
/*-------------------------------------------------------------------------
- * Function: H5D_create
+ * Function: H5D_create
*
- * Purpose: Creates a new dataset with name NAME in file F and associates
- * with it a datatype TYPE for each element as stored in the
- * file, dimensionality information or dataspace SPACE, and
- * other miscellaneous properties CREATE_PARMS. All arguments
- * are deep-copied before being associated with the new dataset,
- * so the caller is free to subsequently modify them without
- * affecting the dataset.
+ * Purpose: Creates a new dataset with name NAME in file F and associates
+ * with it a datatype TYPE for each element as stored in the
+ * file, dimensionality information or dataspace SPACE, and
+ * other miscellaneous properties CREATE_PARMS. All arguments
+ * are deep-copied before being associated with the new dataset,
+ * so the caller is free to subsequently modify them without
+ * affecting the dataset.
*
- * Return: Success: Pointer to a new dataset
+ * Return: Success: Pointer to a new dataset
*
- * Failure: NULL
+ * Failure: NULL
*
* Errors:
- * DATASET CANTINIT Can't update dataset header.
- * DATASET CANTINIT Problem with the dataset name.
+ * DATASET CANTINIT Can't update dataset header.
+ * DATASET CANTINIT Problem with the dataset name.
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5D_t *
+H5D_t *
H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
- const H5D_create_t *create_parms)
+ const H5D_create_t *create_parms)
{
- H5D_t *new_dset = NULL;
- H5D_t *ret_value = NULL;
- size_t nbytes;
- intn i;
+ H5D_t *new_dset = NULL;
+ H5D_t *ret_value = NULL;
+ size_t nbytes;
+ intn i;
FUNC_ENTER(H5D_create, NULL);
@@ -573,14 +573,14 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
* Create (open for write access) an object header.
*/
if (H5O_create(f, 0, &(new_dset->ent)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to create dataset object header");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to create dataset object header");
}
/* Update the type and space header messages */
if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type) < 0 ||
- H5P_modify(f, &(new_dset->ent), new_dset->space) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "can't update type or space header messages");
+ H5P_modify(f, &(new_dset->ent), new_dset->space) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "can't update type or space header messages");
}
/* Total raw data size */
nbytes = H5T_get_size(type) * H5P_get_npoints(space);
@@ -591,82 +591,82 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
switch (new_dset->create_parms.layout) {
case H5D_CONTIGUOUS:
- if (H5P_get_dims(space, new_dset->layout.dim) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to initialize contiguous storage");
- }
- break;
+ if (H5P_get_dims(space, new_dset->layout.dim) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to initialize contiguous storage");
+ }
+ break;
case H5D_CHUNKED:
- if (new_dset->create_parms.chunk_ndims != H5P_get_ndims(space)) {
- HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL,
- "dimensionality of chunks doesn't match the data space");
- }
- for (i = 0; i < new_dset->layout.ndims - 1; i++) {
- new_dset->layout.dim[i] = new_dset->create_parms.chunk_size[i];
- }
- break;
+ if (new_dset->create_parms.chunk_ndims != H5P_get_ndims(space)) {
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL,
+ "dimensionality of chunks doesn't match the data space");
+ }
+ for (i = 0; i < new_dset->layout.ndims - 1; i++) {
+ new_dset->layout.dim[i] = new_dset->create_parms.chunk_size[i];
+ }
+ break;
default:
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
}
/*
* Initialize storage
*/
if (H5F_arr_create(f, &(new_dset->layout)) < 0 ||
- H5O_modify(&(new_dset->ent), H5O_LAYOUT, 0, 0,
- &(new_dset->layout)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to initialize storage");
+ H5O_modify(&(new_dset->ent), H5O_LAYOUT, 0, 0,
+ &(new_dset->layout)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to initialize storage");
}
/* Give the dataset a name */
if (H5G_insert(name, &(new_dset->ent)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset");
}
/* Success */
ret_value = new_dset;
done:
if (!ret_value && new_dset) {
- if (new_dset->type)
- H5T_close(new_dset->type);
- if (new_dset->space)
- H5P_close(new_dset->space);
- if (H5F_addr_defined(&(new_dset->ent.header))) {
- H5O_close(&(new_dset->ent));
- }
- new_dset->ent.file = NULL;
- H5MM_xfree(new_dset);
+ if (new_dset->type)
+ H5T_close(new_dset->type);
+ if (new_dset->space)
+ H5P_close(new_dset->space);
+ if (H5F_addr_defined(&(new_dset->ent.header))) {
+ H5O_close(&(new_dset->ent));
+ }
+ new_dset->ent.file = NULL;
+ H5MM_xfree(new_dset);
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5D_open
+ * Function: H5D_open
*
- * Purpose: Finds a dataset named NAME in file F and builds a descriptor
- * for it, opening it for access.
+ * Purpose: Finds a dataset named NAME in file F and builds a descriptor
+ * for it, opening it for access.
*
- * Return: Success: Pointer to a new dataset descriptor.
+ * Return: Success: Pointer to a new dataset descriptor.
*
- * Failure: NULL
+ * Failure: NULL
*
* Errors:
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5D_t *
+H5D_t *
H5D_open(H5F_t *f, const char *name)
{
- H5D_t *dataset = NULL; /*the dataset which was found */
- H5D_t *ret_value = NULL; /*return value */
- intn i;
+ H5D_t *dataset = NULL; /*the dataset which was found */
+ H5D_t *ret_value = NULL; /*return value */
+ intn i;
FUNC_ENTER(H5D_open, NULL);
@@ -680,16 +680,16 @@ H5D_open(H5F_t *f, const char *name)
/* Open the dataset object */
if (H5G_find(f, name, NULL, &(dataset->ent)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found");
+ HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found");
}
if (H5O_open(f, &(dataset->ent)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open");
}
/* Get the type and space */
if (NULL == (dataset->type = H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL)) ||
- NULL == (dataset->space = H5P_read(f, &(dataset->ent)))) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "can't load type of space info from dataset header");
+ NULL == (dataset->space = H5P_read(f, &(dataset->ent)))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "can't load type of space info from dataset header");
}
/*
* Get the raw data layout info. It's actually stored in two locations:
@@ -698,30 +698,30 @@ H5D_open(H5F_t *f, const char *name)
* them.
*/
if (H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout)) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to read data layout message");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to read data layout message");
}
switch (dataset->layout.type) {
case H5D_CONTIGUOUS:
- dataset->create_parms.layout = H5D_CONTIGUOUS;
- break;
+ dataset->create_parms.layout = H5D_CONTIGUOUS;
+ break;
case H5D_CHUNKED:
- /*
- * Chunked storage. The creation template's dimension is one less than
- * the chunk dimension because the chunk includes a dimension for the
- * individual bytes of the data type.
- */
- dataset->create_parms.layout = H5D_CHUNKED;
- dataset->create_parms.chunk_ndims = dataset->layout.ndims - 1;
- for (i = 0; i < dataset->layout.ndims - 1; i++) {
- dataset->create_parms.chunk_size[i] = dataset->layout.dim[i];
- }
- break;
+ /*
+ * Chunked storage. The creation template's dimension is one less than
+ * the chunk dimension because the chunk includes a dimension for the
+ * individual bytes of the data type.
+ */
+ dataset->create_parms.layout = H5D_CHUNKED;
+ dataset->create_parms.chunk_ndims = dataset->layout.ndims - 1;
+ for (i = 0; i < dataset->layout.ndims - 1; i++) {
+ dataset->create_parms.chunk_size[i] = dataset->layout.dim[i];
+ }
+ break;
default:
- assert("not implemented yet" && 0);
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
+ assert("not implemented yet" && 0);
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
}
/* Success */
@@ -729,36 +729,36 @@ H5D_open(H5F_t *f, const char *name)
done:
if (!ret_value && dataset) {
- if (H5F_addr_defined(&(dataset->ent.header))) {
- H5O_close(&(dataset->ent));
- }
- if (dataset->type)
- H5T_close(dataset->type);
- if (dataset->space)
- H5P_close(dataset->space);
- dataset->ent.file = NULL;
- H5MM_xfree(dataset);
+ if (H5F_addr_defined(&(dataset->ent.header))) {
+ H5O_close(&(dataset->ent));
+ }
+ if (dataset->type)
+ H5T_close(dataset->type);
+ if (dataset->space)
+ H5P_close(dataset->space);
+ dataset->ent.file = NULL;
+ H5MM_xfree(dataset);
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5D_close
+ * Function: H5D_close
*
- * Purpose: Insures that all data has been saved to the file, closes the
- * dataset object header, and frees all resources used by the
- * descriptor.
+ * Purpose: Insures that all data has been saved to the file, closes the
+ * dataset object header, and frees all resources used by the
+ * descriptor.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * DATASET CANTINIT Couldn't free the type or space,
- * but the dataset was freed anyway.
+ * DATASET CANTINIT Couldn't free the type or space,
+ * but the dataset was freed anyway.
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -767,7 +767,7 @@ H5D_open(H5F_t *f, const char *name)
herr_t
H5D_close(H5D_t *dataset)
{
- hbool_t free_failed;
+ hbool_t free_failed;
FUNC_ENTER(H5D_close, FAIL);
@@ -782,7 +782,7 @@ H5D_close(H5D_t *dataset)
* these fails, so we just continue.
*/
free_failed = (H5T_close(dataset->type) < 0 ||
- H5P_close(dataset->space) < 0);
+ H5P_close(dataset->space) < 0);
/*
* Free memory. Before freeing the memory set the file pointer to NULL.
@@ -794,25 +794,25 @@ H5D_close(H5D_t *dataset)
H5MM_xfree(dataset);
if (free_failed) {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
- "couldn't free the type or space, but the dataset was "
- "freed anyway.");
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "couldn't free the type or space, but the dataset was "
+ "freed anyway.");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5D_read
+ * Function: H5D_read
*
- * Purpose: Reads (part of) a DATASET into application memory BUF. See
- * H5Dread() for complete details.
+ * Purpose: Reads (part of) a DATASET into application memory BUF. See
+ * H5Dread() for complete details.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -820,17 +820,18 @@ H5D_close(H5D_t *dataset)
*/
herr_t
H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
- const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
- void *buf /*out */ )
+ const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
+ void *buf/*out*/)
{
- size_t nelmts, src_size, dst_size;
- size_t offset[H5O_LAYOUT_NDIMS];
- size_t size[H5O_LAYOUT_NDIMS];
- intn i;
- herr_t ret_value = FAIL;
- uint8 *conv_buf = NULL; /*data type conv buffer */
- H5T_conv_t conv_func = NULL; /*conversion function */
- hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
+ size_t nelmts, src_size, dst_size;
+ size_t offset[H5O_LAYOUT_NDIMS];
+ size_t size[H5O_LAYOUT_NDIMS];
+ size_t zero[H5O_LAYOUT_NDIMS];
+ intn i;
+ herr_t ret_value = FAIL;
+ uint8 *conv_buf = NULL; /*data type conv buffer */
+ H5T_conv_t conv_func = NULL; /*conversion function */
+ hid_t src_id = -1, dst_id = -1;/*temporary type atoms */
FUNC_ENTER(H5D_read, FAIL);
@@ -841,47 +842,53 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(buf);
if ((mem_space && H5P_cmp(mem_space, dataset->space)) ||
- (file_space && H5P_cmp(file_space, dataset->space))) {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "space conversion not supported yet");
+ (file_space && H5P_cmp(file_space, dataset->space))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "space conversion not supported yet");
}
+
/*
* Convert data types to atoms because the conversion functions are
* application-level functions.
*/
- if ((src_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(dataset->type))) < 0 ||
- (dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(mem_type))) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "unable to register types for conversion");
+ if ((src_id=H5Aregister_atom(H5_DATATYPE, H5T_copy(dataset->type))) < 0 ||
+ (dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(mem_type))) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "unable to register types for conversion");
}
+
/* Compute the size of the request and allocate scratch buffers */
nelmts = H5P_get_npoints(dataset->space);
src_size = nelmts * H5T_get_size(dataset->type);
dst_size = nelmts * H5T_get_size(mem_type);
conv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
if (NULL == (conv_func = H5T_find(dataset->type, mem_type))) {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data types");
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data types");
}
+
/*
* Read data into the data type conversion buffer.
* (We only support complete reads currently)
*/
for (i = 0; i < dataset->layout.ndims; i++) {
- offset[i] = 0;
- size[i] = dataset->layout.dim[i];
+ zero[i] = 0;
+ offset[i] = 0;
+ size[i] = dataset->layout.dim[i];
}
- if (H5F_arr_read(dataset->ent.file, &(dataset->layout), offset, size,
- conv_buf) < 0) {
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
+ if (H5F_arr_read(dataset->ent.file, &(dataset->layout), size, offset,
+ zero, size, conv_buf) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
}
+
/*
* Perform data type conversion.
*/
if ((conv_func) (src_id, dst_id, nelmts, conv_buf, NULL) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
- "data type conversion failed");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "data type conversion failed");
}
+
/*
* Copy conversion buffer into destination.
*/
@@ -890,25 +897,25 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
ret_value = SUCCEED;
done:
if (src_id >= 0)
- H5A_dec_ref(src_id);
+ H5A_dec_ref(src_id);
if (dst_id >= 0)
- H5A_dec_ref(dst_id);
+ H5A_dec_ref(dst_id);
conv_buf = H5MM_xfree(conv_buf);
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5D_write
+ * Function: H5D_write
*
- * Purpose: Writes (part of) a DATASET to a file from application memory
- * BUF. See H5Dwrite() for complete details.
+ * Purpose: Writes (part of) a DATASET to a file from application memory
+ * BUF. See H5Dwrite() for complete details.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
* Modifications:
*
@@ -916,17 +923,18 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
*/
herr_t
H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
- const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
- const void *buf)
+ const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
+ const void *buf)
{
- size_t nelmts, src_size, dst_size;
- size_t offset[H5O_LAYOUT_NDIMS];
- size_t size[H5O_LAYOUT_NDIMS];
- intn i;
- herr_t ret_value = FAIL;
- uint8 *conv_buf = NULL; /*data type conversion buffer */
- H5T_conv_t conv_func = NULL; /*data type conversion function */
- hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
+ size_t nelmts, src_size, dst_size;
+ size_t offset[H5O_LAYOUT_NDIMS];
+ size_t size[H5O_LAYOUT_NDIMS];
+ size_t zero[H5O_LAYOUT_NDIMS];
+ intn i;
+ herr_t ret_value = FAIL;
+ uint8 *conv_buf = NULL; /*data type conversion buffer */
+ H5T_conv_t conv_func = NULL; /*data type conversion function */
+ hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
FUNC_ENTER(H5D_write, FAIL);
@@ -937,13 +945,13 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(buf);
if (H5D_CONTIGUOUS != dataset->create_parms.layout) {
- HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "layout is not supported yet");
+ HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "layout is not supported yet");
}
if ((mem_space && H5P_cmp(mem_space, dataset->space)) ||
- (file_space && H5P_cmp(file_space, dataset->space))) {
- HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "space conversion not supported yet");
+ (file_space && H5P_cmp(file_space, dataset->space))) {
+ HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "space conversion not supported yet");
}
/*
* Convert data types to atoms because the conversion functions are
@@ -951,8 +959,8 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
*/
if ((src_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(mem_type))) < 0 ||
(dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(dataset->type))) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "unable to register types for conversion");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "unable to register types for conversion");
}
/* Compute the size of the request and allocate scratch buffers */
nelmts = H5P_get_npoints(dataset->space);
@@ -960,8 +968,8 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
dst_size = nelmts * H5T_get_size(dataset->type);
conv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
if (NULL == (conv_func = H5T_find(mem_type, dataset->type))) {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data types");
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data types");
}
/*
* Read data into the data type conversion buffer.
@@ -972,27 +980,28 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
* Perform data type conversion.
*/
if ((conv_func) (src_id, dst_id, nelmts, conv_buf, NULL) < 0) {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
- "data type conversion failed");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "data type conversion failed");
}
/*
* Write data into the file.
* (We only support complete writes currently.)
*/
for (i = 0; i < dataset->layout.ndims; i++) {
- offset[i] = 0;
- size[i] = dataset->layout.dim[i];
+ zero[i] = 0;
+ offset[i] = 0;
+ size[i] = dataset->layout.dim[i];
}
- if (H5F_arr_write(dataset->ent.file, &(dataset->layout), offset, size,
- conv_buf) < 0) {
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
+ if (H5F_arr_write(dataset->ent.file, &(dataset->layout), size, offset,
+ zero, size, conv_buf) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
}
ret_value = SUCCEED;
done:
if (src_id >= 0)
- H5A_dec_ref(src_id);
+ H5A_dec_ref(src_id);
if (dst_id >= 0)
- H5A_dec_ref(dst_id);
+ H5A_dec_ref(dst_id);
conv_buf = H5MM_xfree(conv_buf);
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Farray.c b/src/H5Farray.c
index 9b2d194..8f5e3b4 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -5,8 +5,11 @@
* Programmer: Robb Matzke <robb@arborea.spizella.com>
* Thursday, January 15, 1998
*
- * Purpose: Provides I/O facilities for multi-dimensional arrays of bytes
- * stored with various layout policies.
+ * Purpose: Provides I/O facilities for multi-dimensional arrays of bytes
+ * stored with various layout policies. If the caller is
+ * interested in arrays of elements >1 byte then add an extra
+ * dimension. For example, a 10x20 array of int32 would
+ * translate to a 10x20x4 array of bytes at this level.
*/
#include <H5private.h>
#include <H5Dprivate.h>
@@ -14,25 +17,25 @@
#include <H5Fprivate.h>
#include <H5MFprivate.h>
#include <H5Oprivate.h>
+#include <H5Vprivate.h>
/* Interface initialization */
-#define PABLO_MASK H5F_arr_mask
-#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+#define PABLO_MASK H5F_arr_mask
+#define INTERFACE_INIT NULL
+static intn interface_initialize_g = FALSE;
+
+
/*-------------------------------------------------------------------------
- * Function: H5F_arr_create
+ * Function: H5F_arr_create
*
- * Purpose: Creates an array of bytes. When called to create an array of
- * some type, the fastest varying dimension corresponds to an
- * instance of that type. That is, a 10x20 array of int32 is
- * really a 10x20x4 array of bytes.
+ * Purpose: Creates an array of bytes.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 16, 1998
*
* Modifications:
@@ -40,180 +43,316 @@ static intn interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ )
+H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/)
{
- intn i;
- size_t nbytes;
-
- FUNC_ENTER(H5F_arr_create, FAIL);
+ intn i;
+ size_t nbytes;
+
+ FUNC_ENTER (H5F_arr_create, FAIL);
/* check args */
- assert(f);
- assert(layout);
- H5F_addr_undef(&(layout->addr)); /*just in case we fail */
-
+ assert (f);
+ assert (layout);
+ H5F_addr_undef (&(layout->addr)); /*just in case we fail*/
+
switch (layout->type) {
case H5D_CONTIGUOUS:
- /* Reserve space in the file for the entire array */
- for (i = 0, nbytes = 1; i < layout->ndims; i++)
- nbytes *= layout->dim[i];
- assert(nbytes > 0);
- if (H5MF_alloc(f, H5MF_RAW, nbytes, &(layout->addr) /*out */ ) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_NOSPACE, FAIL,
- "unable to reserve file space");
- }
- break;
+ /* Reserve space in the file for the entire array */
+ for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
+ assert (nbytes>0);
+ if (H5MF_alloc (f, H5MF_RAW, nbytes, &(layout->addr)/*out*/)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_NOSPACE, FAIL,
+ "unable to reserve file space");
+ }
+ break;
case H5D_CHUNKED:
- /* Create the root of the B-tree that describes chunked storage */
- if (H5F_istore_create(f, layout /*out */ ) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
- "unable to initialize chunked storage");
- }
- break;
+ /* Create the root of the B-tree that describes chunked storage */
+ if (H5F_istore_create (f, layout/*out*/)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
+ "unable to initialize chunked storage");
+ }
+ break;
default:
- assert("not implemented yet" && 0);
- HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
- "unsupported storage layout");
- break;
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
}
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE (SUCCEED);
}
+
/*-------------------------------------------------------------------------
- * Function: H5F_arr_read
+ * Function: H5F_arr_read
*
- * Purpose: Reads a hyperslab of a file byte array into a byte array in
- * memory which has the same dimensions as the hyperslab.
+ * Purpose: Reads a hyperslab of a file byte array into a hyperslab of
+ * a byte array in memory. The data is read from file F and the
+ * array's size and storage information is in LAYOUT. The
+ * hyperslab offset is FILE_OFFSET[] in the file and
+ * MEM_OFFSET[] in memory (offsets are relative to the origin of
+ * the array) and the size of the hyperslab is HSLAB_SIZE[]. The
+ * total size of the file array is implied in the LAYOUT
+ * argument and the total size of the memory array is
+ * MEM_SIZE[]. The dimensionality of these vectors is implied by
+ * the LAYOUT argument.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 16, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5F_arr_read(H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- void *buf /*out */ )
+herr_t
+H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t _hslab_size[], const size_t file_offset[],
+ const size_t mem_offset[], const size_t mem_size[],
+ void *_buf/*out*/)
{
- intn i;
- size_t nbytes;
- size_t zero_offset[H5O_LAYOUT_NDIMS];
-
- FUNC_ENTER(H5F_arr_read, FAIL);
+ uint8 *buf = (uint8 *)_buf; /*cast for arithmetic */
+ size_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
+ size_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
+ size_t hslab_size[H5O_LAYOUT_NDIMS]; /*hyperslab size */
+ size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */
+ size_t mem_start, file_start; /*byte offsets to start */
+ size_t elmt_size = 1; /*bytes per element */
+ intn nelmts; /*number of elements */
+ intn ndims; /*stride dimensionality */
+ haddr_t addr; /*address in file */
+ intn i, j; /*counters */
+ hbool_t carray; /*carry for subtraction */
+
+ FUNC_ENTER (H5F_arr_read, FAIL);
/* Check args */
- assert(f);
- assert(layout);
- if (!offset) {
- HDmemset(zero_offset, 0, sizeof zero_offset);
- offset = zero_offset;
- }
- assert(size);
- assert(buf);
+ assert (f);
+ assert (layout);
+ assert (_hslab_size);
+ assert (file_offset);
+ assert (mem_offset);
+ assert (mem_size);
+ assert (buf);
+
+ /* Make a local copy of size so we can modify it */
+ H5V_vector_cpy (layout->ndims, hslab_size, _hslab_size);
switch (layout->type) {
case H5D_CONTIGUOUS:
- /*
- * We currently only support complete I/O.
- */
- for (i = 0; i < layout->ndims; i++) {
- assert(0 == offset[i]);
- assert(size[i] == layout->dim[i]);
- }
- for (i = 0, nbytes = 1; i < layout->ndims; i++)
- nbytes *= layout->dim[i];
- if (H5F_block_read(f, &(layout->addr), nbytes, buf) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
- }
- break;
+ /*
+ * Calculate the strides needed to walk through the array on disk
+ * and memory. Optimize the strides to result in the fewest number of
+ * I/O requests.
+ */
+ ndims = layout->ndims;
+ mem_start = H5V_hyper_stride (ndims, hslab_size, mem_size,
+ mem_offset, mem_stride/*out*/);
+ file_start = H5V_hyper_stride (ndims, hslab_size, layout->dim,
+ file_offset, file_stride/*out*/);
+ H5V_stride_optimize2 (&ndims, &elmt_size, hslab_size,
+ mem_stride, file_stride);
+
+ /*
+ * Initialize loop variables. The loop is a multi-dimensional loop
+ * that counts from SIZE down to zero and IDX is the counter. Each
+ * element of IDX is treated as a digit with IDX[0] being the least
+ * significant digit.
+ */
+ H5V_vector_cpy (ndims, idx, hslab_size);
+ nelmts = H5V_vector_reduce_product (ndims, hslab_size);
+ addr = layout->addr;
+ H5F_addr_inc (&addr, file_start);
+ buf += mem_start;
+
+ /*
+ * Now begin to walk through the array, copying data from disk to
+ * memory.
+ */
+ for (i=0; i<nelmts; i++) {
+
+ /* Read from file */
+ if (H5F_block_read (f, &addr, elmt_size, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL,
+ "block read failed");
+ }
+
+ /* Decrement indices and advance pointers */
+ for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) {
+
+ H5F_addr_inc (&addr, file_stride[j]);
+ buf += mem_stride[j];
+
+ if (--idx[j]) carray = FALSE;
+ else idx[j] = hslab_size[j];
+ }
+ }
+ break;
case H5D_CHUNKED:
- if (H5F_istore_read(f, layout, offset, size, buf) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
- }
- break;
+ /*
+ * This method is unable to copy into a proper hyperslab.
+ */
+ for (i=0; i<layout->ndims; i++) {
+ if (0!=mem_offset[i] || hslab_size[i]!=mem_size[i]) {
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unable to copy into a proper hyperslab");
+ }
+ }
+ if (H5F_istore_read (f, layout, file_offset, hslab_size, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
+ }
+ break;
default:
- assert("not implemented yet" && 0);
- HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
- "unsupported storage layout");
- break;
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
}
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE (SUCCEED);
}
+
/*-------------------------------------------------------------------------
- * Function: H5F_arr_write
+ * Function: H5F_arr_write
*
- * Purpose: Writes an array to a hyperslab of a file byte array. The
- * memory array and the hyperslab are the same size.
+ * Purpose: Copies a hyperslab of a memory array to a hyperslab of a
+ * file array. The data is written to file F and the file
+ * array's size and storage information is implied by LAYOUT.
+ * The hyperslab offset is FILE_OFFSET[] in the file and
+ * MEM_OFFSET[] in memory (offsets are relative to the origin of
+ * the array) and the size of the hyperslab is HSLAB_SIZE[].
+ * The total size of the file array is implied by the LAYOUT
+ * argument and the total size of the memory array is
+ * MEM_SIZE[]. The dimensionality of these vectors is implied
+ * by the LAYOUT argument.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 16, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5F_arr_write(H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf)
+herr_t
+H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t _hslab_size[], const size_t file_offset[],
+ const size_t mem_offset[], const size_t mem_size[],
+ const void *_buf)
{
- intn i;
- size_t nbytes;
-
- FUNC_ENTER(H5F_arr_write, FAIL);
+ const uint8 *buf = (const uint8 *)_buf; /*cast for arithmetic */
+ size_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */
+ size_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/
+ size_t hslab_size[H5O_LAYOUT_NDIMS]; /*hyperslab size */
+ size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */
+ size_t mem_start, file_start; /*byte offsets to start */
+ size_t elmt_size = 1; /*bytes per element */
+ intn nelmts; /*number of elements */
+ intn ndims; /*dimensionality */
+ haddr_t addr; /*address in file */
+ intn i, j; /*counters */
+ hbool_t carray; /*carry for subtraction */
+
+ FUNC_ENTER (H5F_arr_write, FAIL);
/* Check args */
- assert(f);
- assert(layout);
- assert(offset);
- assert(size);
- assert(buf);
+ assert (f);
+ assert (layout);
+ assert (_hslab_size);
+ assert (file_offset);
+ assert (mem_offset);
+ assert (mem_size);
+ assert (buf);
+
+ /* Make a local copy of _size so we can modify it */
+ H5V_vector_cpy (layout->ndims, hslab_size, _hslab_size);
+
switch (layout->type) {
case H5D_CONTIGUOUS:
- /*
- * We currently only support complete I/O.
- */
- for (i = 0; i < layout->ndims; i++) {
- assert(0 == offset[i]);
- assert(size[i] == layout->dim[i]);
- }
- for (i = 0, nbytes = 1; i < layout->ndims; i++)
- nbytes *= layout->dim[i];
- if (H5F_block_write(f, &(layout->addr), nbytes, buf) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
- }
- break;
+ /*
+ * Calculate the strides needed to walk through the array on disk.
+ * Optimize the strides to result in the fewest number of I/O
+ * requests.
+ */
+ ndims = layout->ndims;
+ mem_start = H5V_hyper_stride (ndims, hslab_size, mem_size,
+ mem_offset, mem_stride/*out*/);
+ file_start = H5V_hyper_stride (ndims, hslab_size, layout->dim,
+ file_offset, file_stride/*out*/);
+ H5V_stride_optimize2 (&ndims, &elmt_size, hslab_size,
+ mem_stride, file_stride);
+
+ /*
+ * Initialize loop variables. The loop is a multi-dimensional loop
+ * that counts from SIZE down to zero and IDX is the counter. Each
+ * element of IDX is treated as a digit with IDX[0] being the least
+ * significant digit.
+ */
+ H5V_vector_cpy (ndims, idx, hslab_size);
+ nelmts = H5V_vector_reduce_product (ndims, hslab_size);
+ addr = layout->addr;
+ H5F_addr_inc (&addr, file_start);
+ buf += mem_start;
+
+ /*
+ * Now begin to walk through the array, copying data from memory to
+ * disk.
+ */
+ for (i=0; i<nelmts; i++) {
+
+ /* Write to file */
+ if (H5F_block_write (f, &addr, elmt_size, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
+ "block write failed");
+ }
+
+ /* Decrement indices and advance pointers */
+ for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) {
+
+ H5F_addr_inc (&addr, file_stride[j]);
+ buf += mem_stride[j];
+
+ if (--idx[j]) carray = FALSE;
+ else idx[j] = hslab_size[j];
+ }
+
+ }
+ break;
case H5D_CHUNKED:
- if (H5F_istore_write(f, layout, offset, size, buf) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "chunked write failed");
- }
- break;
+ /*
+ * This method is unable to copy from a proper hyperslab.
+ */
+ for (i=0; i<layout->ndims; i++) {
+ if (0!=mem_offset[i] || hslab_size[i]!=mem_size[i]) {
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unable to copy from a proper hyperslab");
+ }
+ }
+ if (H5F_istore_write (f, layout, file_offset, hslab_size, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
+ "chunked write failed");
+ }
+ break;
default:
- assert("not implemented yet" && 0);
- HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
- "unsupported storage layout");
- break;
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
}
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE (SUCCEED);
}
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 31ea061..ec3bb94 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -1,13 +1,13 @@
/****************************************************************************
- * NCSA HDF *
- * Software Development Group *
- * National Center for Supercomputing Applications *
- * University of Illinois at Urbana-Champaign *
- * 605 E. Springfield, Champaign IL 61820 *
- * *
- * For conditions of distribution and use, see the accompanying *
- * hdf/COPYING file. *
- * *
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
****************************************************************************/
/* $Id$ */
@@ -25,9 +25,9 @@
/*
* Feature: Define this constant to be non-zero if you want to enable code
- * that minimizes the number of calls to lseek(). This has a huge
- * performance benefit on some systems. Set this constant to zero
- * on the compiler command line to disable that optimization.
+ * that minimizes the number of calls to lseek(). This has a huge
+ * performance benefit on some systems. Set this constant to zero
+ * on the compiler command line to disable that optimization.
*/
#ifndef H5F_OPT_SEEK
# define H5F_OPT_SEEK 1
@@ -35,7 +35,7 @@
/*
* Feature: Define this constant on the compiler command-line if you want to
- * see some debugging messages on stderr.
+ * see some debugging messages on stderr.
*/
#ifdef NDEBUG
# undef H5F_DEBUG
@@ -45,21 +45,21 @@
#define H5F_BOOTBLOCK_SIZE 1024
/* Define the HDF5 file signature */
-#define H5F_SIGNATURE "\211HDF\r\n\032\n"
+#define H5F_SIGNATURE "\211HDF\r\n\032\n"
#define H5F_SIGNATURE_LEN 8
/* size of size_t and off_t as they exist on disk */
-#define H5F_SIZEOF_ADDR(F) ((F)->shared->create_parms.sizeof_addr)
-#define H5F_SIZEOF_SIZE(F) ((F)->shared->create_parms.sizeof_size)
+#define H5F_SIZEOF_ADDR(F) ((F)->shared->create_parms.sizeof_addr)
+#define H5F_SIZEOF_SIZE(F) ((F)->shared->create_parms.sizeof_size)
/*
* File open flags.
*/
-#define H5F_ACC_WRITE 0x0001 /* Open file for read/write access */
-#define H5F_ACC_CREAT 0x0002 /* Create non-existing files */
-#define H5F_ACC_EXCL 0x0004 /* Fail if file exists */
-#define H5F_ACC_TRUNC 0x0008 /* Truncate existing file */
-#define H5F_ACC_DEBUG 0x00010 /* Print debug info */
+#define H5F_ACC_WRITE 0x0001 /* Open file for read/write access */
+#define H5F_ACC_CREAT 0x0002 /* Create non-existing files */
+#define H5F_ACC_EXCL 0x0004 /* Fail if file exists */
+#define H5F_ACC_TRUNC 0x0008 /* Truncate existing file */
+#define H5F_ACC_DEBUG 0x00010 /* Print debug info */
/*
* Encode and decode macros for file meta-data.
@@ -68,100 +68,100 @@
/* For non-little-endian platforms, encode each byte by itself */
#ifdef WORDS_BIGENDIAN
-# define INT16ENCODE(p, i) { \
- *(p) = (uint8)( (uintn)(i) & 0xff); (p)++; \
- *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
+# define INT16ENCODE(p, i) { \
+ *(p) = (uint8)( (uintn)(i) & 0xff); (p)++; \
+ *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
}
-# define UINT16ENCODE(p, i) { \
- *(p) = (uint8)( (i) & 0xff); (p)++; \
- *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
+# define UINT16ENCODE(p, i) { \
+ *(p) = (uint8)( (i) & 0xff); (p)++; \
+ *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
}
-# define INT32ENCODE(p, i) { \
- *(p) = (uint8)( (uint32)(i) & 0xff); (p)++; \
- *(p) = (uint8)(((uint32)(i) >> 8) & 0xff); (p)++; \
- *(p) = (uint8)(((uint32)(i) >> 16) & 0xff); (p)++; \
- *(p) = (uint8)(((uint32)(i) >> 24) & 0xff); (p)++; \
+# define INT32ENCODE(p, i) { \
+ *(p) = (uint8)( (uint32)(i) & 0xff); (p)++; \
+ *(p) = (uint8)(((uint32)(i) >> 8) & 0xff); (p)++; \
+ *(p) = (uint8)(((uint32)(i) >> 16) & 0xff); (p)++; \
+ *(p) = (uint8)(((uint32)(i) >> 24) & 0xff); (p)++; \
}
-# define UINT32ENCODE(p, i) { \
- *(p) = (uint8)( (i) & 0xff); (p)++; \
- *(p) = (uint8)(((i) >> 8) & 0xff); (p)++; \
- *(p) = (uint8)(((i) >> 16) & 0xff); (p)++; \
- *(p) = (uint8)(((i) >> 24) & 0xff); (p)++; \
+# define UINT32ENCODE(p, i) { \
+ *(p) = (uint8)( (i) & 0xff); (p)++; \
+ *(p) = (uint8)(((i) >> 8) & 0xff); (p)++; \
+ *(p) = (uint8)(((i) >> 16) & 0xff); (p)++; \
+ *(p) = (uint8)(((i) >> 24) & 0xff); (p)++; \
}
-# define INT64ENCODE(p, n) { \
- int64 _n = (n); \
- intn _i; \
- uint8 *_p = (uint8*)(p); \
- for (_i=0; _i<sizeof(int64); _i++, _n>>=8) { \
- *_p++ = _n & 0xff; \
- } \
- for (/*void*/; _i<8; _i++) { \
- *_p++ = (n)<0 ? 0xff : 0; \
- } \
- (p) = (uint8*)(p)+8; \
+# define INT64ENCODE(p, n) { \
+ int64 _n = (n); \
+ intn _i; \
+ uint8 *_p = (uint8*)(p); \
+ for (_i=0; _i<sizeof(int64); _i++, _n>>=8) { \
+ *_p++ = _n & 0xff; \
+ } \
+ for (/*void*/; _i<8; _i++) { \
+ *_p++ = (n)<0 ? 0xff : 0; \
+ } \
+ (p) = (uint8*)(p)+8; \
}
-# define UINT64ENCODE(p, n) { \
- uint64 _n = (n); \
- intn _i; \
- uint8 *_p = (uint8*)(p); \
- for (_i=0; _i<sizeof(uint64); _i++, _n>>=8) { \
- *_p++ = _n & 0xff; \
- } \
- for (/*void*/; _i<8; _i++) { \
- *_p++ = 0; \
- } \
- (p) = (uint8*)(p)+8; \
+# define UINT64ENCODE(p, n) { \
+ uint64 _n = (n); \
+ intn _i; \
+ uint8 *_p = (uint8*)(p); \
+ for (_i=0; _i<sizeof(uint64); _i++, _n>>=8) { \
+ *_p++ = _n & 0xff; \
+ } \
+ for (/*void*/; _i<8; _i++) { \
+ *_p++ = 0; \
+ } \
+ (p) = (uint8*)(p)+8; \
}
-# define INT16DECODE(p, i) { \
- (i) = (int16)((*(p) & 0xff)); (p)++; \
- (i) |= (int16)((*(p) & 0xff) << 8); (p)++; \
+# define INT16DECODE(p, i) { \
+ (i) = (int16)((*(p) & 0xff)); (p)++; \
+ (i) |= (int16)((*(p) & 0xff) << 8); (p)++; \
}
-# define UINT16DECODE(p, i) { \
- (i) = (uint16) (*(p) & 0xff); (p)++; \
- (i) |= (uint16)((*(p) & 0xff) << 8); (p)++; \
+# define UINT16DECODE(p, i) { \
+ (i) = (uint16) (*(p) & 0xff); (p)++; \
+ (i) |= (uint16)((*(p) & 0xff) << 8); (p)++; \
}
-# define INT32DECODE(p, i) { \
- (i) = ( *(p) & 0xff); (p)++; \
- (i) |= ((int32)(*(p) & 0xff) << 8); (p)++; \
- (i) |= ((int32)(*(p) & 0xff) << 16); (p)++; \
- (i) |= ((int32)(*(p) & 0xff) << 24); (p)++; \
+# define INT32DECODE(p, i) { \
+ (i) = ( *(p) & 0xff); (p)++; \
+ (i) |= ((int32)(*(p) & 0xff) << 8); (p)++; \
+ (i) |= ((int32)(*(p) & 0xff) << 16); (p)++; \
+ (i) |= ((int32)(*(p) & 0xff) << 24); (p)++; \
}
-# define UINT32DECODE(p, i) { \
- (i) = (uint32)(*(p) & 0xff); (p)++; \
- (i) |= ((uint32)(*(p) & 0xff) << 8); (p)++; \
- (i) |= ((uint32)(*(p) & 0xff) << 16); (p)++; \
- (i) |= ((uint32)(*(p) & 0xff) << 24); (p)++; \
+# define UINT32DECODE(p, i) { \
+ (i) = (uint32)(*(p) & 0xff); (p)++; \
+ (i) |= ((uint32)(*(p) & 0xff) << 8); (p)++; \
+ (i) |= ((uint32)(*(p) & 0xff) << 16); (p)++; \
+ (i) |= ((uint32)(*(p) & 0xff) << 24); (p)++; \
}
-# define INT64DECODE(p, n) { \
- /* WE DON'T CHECK FOR OVERFLOW! */ \
- int64 _n = 0; \
- intn _i; \
- (p) += 8; \
- for (_i=0; _i<sizeof(int64); _i++, _n<<=8) { \
- _n |= *(--p); \
- } \
- (p) += 8; \
+# define INT64DECODE(p, n) { \
+ /* WE DON'T CHECK FOR OVERFLOW! */ \
+ int64 _n = 0; \
+ intn _i; \
+ (p) += 8; \
+ for (_i=0; _i<sizeof(int64); _i++, _n<<=8) { \
+ _n |= *(--p); \
+ } \
+ (p) += 8; \
}
-# define UINT64DECODE(p, n) { \
- /* WE DON'T CHECK FOR OVERFLOW! */ \
- uint64 _n = 0; \
- intn _i; \
- (p) += 8; \
- for (_i=0; _i<sizeof(uint64); _i++, _n<<=8) { \
- _n |= *(--p); \
- } \
- (p) += 8; \
+# define UINT64DECODE(p, n) { \
+ /* WE DON'T CHECK FOR OVERFLOW! */ \
+ uint64 _n = 0; \
+ intn _i; \
+ (p) += 8; \
+ for (_i=0; _i<sizeof(uint64); _i++, _n<<=8) { \
+ _n |= *(--p); \
+ } \
+ (p) += 8; \
}
#else
@@ -171,26 +171,26 @@
# define INT32ENCODE(p, i) { *((int32 *)(p)) = (int32)(i); (p)+=4; }
# define UINT32ENCODE(p, i) { *((uint32 *)(p)) = (uint32)(i); (p)+=4; }
-# define INT64ENCODE(p, i) { \
- *((int64 *)(p)) = (int64)(i); \
- (p) += sizeof(int64); \
- if (4==sizeof(int64)) { \
- *(p)++ = (i)<0?0xff:0x00; \
- *(p)++ = (i)<0?0xff:0x00; \
- *(p)++ = (i)<0?0xff:0x00; \
- *(p)++ = (i)<0?0xff:0x00; \
- } \
+# define INT64ENCODE(p, i) { \
+ *((int64 *)(p)) = (int64)(i); \
+ (p) += sizeof(int64); \
+ if (4==sizeof(int64)) { \
+ *(p)++ = (i)<0?0xff:0x00; \
+ *(p)++ = (i)<0?0xff:0x00; \
+ *(p)++ = (i)<0?0xff:0x00; \
+ *(p)++ = (i)<0?0xff:0x00; \
+ } \
}
-# define UINT64ENCODE(p, i) { \
- *((uint64 *)(p)) = (uint64)(i); \
- (p) += sizeof(uint64); \
- if (4==sizeof(uint64)) { \
- *(p)++ = 0x00; \
- *(p)++ = 0x00; \
- *(p)++ = 0x00; \
- *(p)++ = 0x00; \
- } \
+# define UINT64ENCODE(p, i) { \
+ *((uint64 *)(p)) = (uint64)(i); \
+ (p) += sizeof(uint64); \
+ if (4==sizeof(uint64)) { \
+ *(p)++ = 0x00; \
+ *(p)++ = 0x00; \
+ *(p)++ = 0x00; \
+ *(p)++ = 0x00; \
+ } \
}
# define INT16DECODE(p, i) { (i) = (int16)(*(const int16 *)(p)); (p)+=2; }
@@ -202,135 +202,136 @@
#endif
-#define NBYTEENCODE(d, s, n) { HDmemcpy(d,s,n); p+=n }
+#define NBYTEENCODE(d, s, n) { HDmemcpy(d,s,n); p+=n }
/* Note! the NBYTEDECODE macro is backwards from the memcpy() routine, */
-/* in the spirit of the other DECODE macros */
-#define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n }
+/* in the spirit of the other DECODE macros */
+#define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n }
/*
* File-creation template.
*/
typedef struct H5F_create_t {
- size_t userblock_size; /* Size of the file user block in bytes */
- intn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */
- intn btree_k[8]; /* 1/2 rank for btree internal nodes */
- size_t sizeof_addr; /* Number of bytes in an address */
- size_t sizeof_size; /* Number of bytes for obj sizes */
- intn bootblock_ver; /* Version # of the bootblock */
- intn smallobject_ver; /* Version # of the small-object heap */
- intn freespace_ver; /* Version # of the free-space information */
- intn objectdir_ver; /* Version # of the object directory format */
- intn sharedheader_ver; /* Version # of the shared header format */
+ size_t userblock_size; /* Size of the file user block in bytes */
+ intn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */
+ intn btree_k[8]; /* 1/2 rank for btree internal nodes */
+ size_t sizeof_addr; /* Number of bytes in an address */
+ size_t sizeof_size; /* Number of bytes for obj sizes */
+ intn bootblock_ver; /* Version # of the bootblock */
+ intn smallobject_ver;/* Version # of the small-object heap */
+ intn freespace_ver; /* Version # of the free-space information*/
+ intn objectdir_ver; /* Version # of the object directory format*/
+ intn sharedheader_ver;/* Version # of the shared header format */
} H5F_create_t;
/*
* These things make a file unique.
*/
typedef struct H5F_search_t {
- dev_t dev; /* Device number containing file */
- ino_t ino; /* Unique file number on device */
+ dev_t dev; /* Device number containing file */
+ ino_t ino; /* Unique file number on device */
} H5F_search_t;
/* For determining what the last file operation was */
typedef enum {
- H5F_OP_UNKNOWN, /* Don't know what the last operation was */
- H5F_OP_SEEK, /* Last operation was a seek */
- H5F_OP_WRITE, /* Last operation was a write */
- H5F_OP_READ /* Last operation was a read */
+ H5F_OP_UNKNOWN, /* Don't know what the last operation was*/
+ H5F_OP_SEEK, /* Last operation was a seek */
+ H5F_OP_WRITE, /* Last operation was a write */
+ H5F_OP_READ /* Last operation was a read */
} H5F_fileop_t;
/*
* Define the low-level file interface.
*/
typedef struct H5F_low_class_t {
- hbool_t (*access) (const char *, int, H5F_search_t *);
- struct H5F_low_t *(*open) (const char *, uintn, H5F_search_t *);
- herr_t (*close) (struct H5F_low_t *);
- herr_t (*read) (struct H5F_low_t *, const haddr_t *, size_t, uint8 *);
- herr_t (*write) (struct H5F_low_t *, const haddr_t *, size_t, const uint8 *);
- herr_t (*flush) (struct H5F_low_t *);
- herr_t (*extend) (struct H5F_low_t *, intn, size_t, haddr_t *);
+ hbool_t (*access)(const char *, int, H5F_search_t *);
+ struct H5F_low_t *(*open)(const char *, uintn, H5F_search_t *);
+ herr_t (*close)(struct H5F_low_t *);
+ herr_t (*read)(struct H5F_low_t *, const haddr_t *, size_t, uint8 *);
+ herr_t (*write)(struct H5F_low_t *, const haddr_t *, size_t,
+ const uint8 *);
+ herr_t (*flush)(struct H5F_low_t *);
+ herr_t (*extend)(struct H5F_low_t *, intn, size_t, haddr_t *);
} H5F_low_class_t;
typedef struct H5F_low_t {
- const H5F_low_class_t *type; /* What type of file is this? */
- haddr_t eof; /* Address of logical end-of-file */
+ const H5F_low_class_t *type; /* What type of file is this? */
+ haddr_t eof; /* Address of logical end-of-file */
union {
- /* File families */
- struct {
- char *name; /* Family name */
- uintn flags; /* Flags for opening member files */
- intn nmemb; /* Number of family members */
- intn nalloc; /* Size of member table in elements */
- struct H5F_low_t **memb; /* An array of family members */
- size_t offset_bits; /* Number of bits in a member offset */
- } fam;
-
- /* Split meta/raw data */
- struct {
- char *name; /* Base name w/o extension */
- uint64 mask; /* Bit that determines which file to use */
- struct H5F_low_t *meta; /* Meta data file */
- struct H5F_low_t *raw; /* Raw data file */
- } split;
-
- /* Posix section 2 I/O */
- struct {
- int fd; /* The unix file descriptor */
- H5F_fileop_t op; /* Previous file operation */
- off_t cur; /* Current file position */
- } sec2;
-
- /* Posix stdio */
- struct {
- FILE *f; /* Posix stdio file */
- H5F_fileop_t op; /* Previous file operation */
- off_t cur; /* Current file position */
- } stdio;
-
- /* In-core temp file */
- struct {
- uint8 *mem; /* Mem image of the file */
- size_t size; /* Current file size */
- size_t alloc; /* Current size of MEM buffer */
- } core;
+ /* File families */
+ struct {
+ char *name; /* Family name */
+ uintn flags; /* Flags for opening member files */
+ intn nmemb; /* Number of family members */
+ intn nalloc; /* Size of member table in elements */
+ struct H5F_low_t **memb; /* An array of family members */
+ size_t offset_bits; /* Number of bits in a member offset*/
+ } fam;
+
+ /* Split meta/raw data */
+ struct {
+ char *name; /* Base name w/o extension */
+ uint64 mask; /* Bit that determines which file to use*/
+ struct H5F_low_t *meta; /* Meta data file */
+ struct H5F_low_t *raw; /* Raw data file */
+ } split;
+
+ /* Posix section 2 I/O */
+ struct {
+ int fd; /* The unix file descriptor */
+ H5F_fileop_t op; /* Previous file operation */
+ off_t cur; /* Current file position */
+ } sec2;
+
+ /* Posix stdio */
+ struct {
+ FILE *f; /* Posix stdio file */
+ H5F_fileop_t op; /* Previous file operation */
+ off_t cur; /* Current file position */
+ } stdio;
+
+ /* In-core temp file */
+ struct {
+ uint8 *mem; /* Mem image of the file */
+ size_t size; /* Current file size */
+ size_t alloc; /* Current size of MEM buffer */
+ } core;
} u;
} H5F_low_t;
/* What types of low-level files are there? */
#ifndef H5F_LOW_DFLT
-# define H5F_LOW_DFLT H5F_LOW_STDIO /* The default type */
+# define H5F_LOW_DFLT H5F_LOW_STDIO /* The default type */
#endif
-extern const H5F_low_class_t H5F_LOW_SEC2[]; /* Posix section 2 */
-extern const H5F_low_class_t H5F_LOW_STDIO[]; /* Posix stdio */
-extern const H5F_low_class_t H5F_LOW_CORE[]; /* In-core temp file */
-extern const H5F_low_class_t H5F_LOW_FAM[]; /* File family */
-extern const H5F_low_class_t H5F_LOW_SPLIT[]; /* Split meta/raw data */
+extern const H5F_low_class_t H5F_LOW_SEC2[]; /* Posix section 2 */
+extern const H5F_low_class_t H5F_LOW_STDIO[]; /* Posix stdio */
+extern const H5F_low_class_t H5F_LOW_CORE[]; /* In-core temp file */
+extern const H5F_low_class_t H5F_LOW_FAM[]; /* File family */
+extern const H5F_low_class_t H5F_LOW_SPLIT[]; /* Split meta/raw data */
/*
* Define the structure to store the file information for HDF5 files. One of
* these structures is allocated per file, not per H5Fopen().
*/
typedef struct H5F_file_t {
- H5F_search_t key; /* The key for looking up files */
- uintn flags; /* Access Permissions for file */
- H5F_low_t *lf; /* Lower level file handle for I/O */
- uintn nrefs; /* Ref count for times file is opened */
- uint32 consist_flags; /* File Consistency Flags */
- haddr_t boot_addr; /* Absolute address of boot block */
- haddr_t base_addr; /* Absolute base address for rel.addrs. */
- haddr_t smallobj_addr; /* Relative address of small-obj heap */
- haddr_t freespace_addr; /* Relative address of free-space info */
- haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data */
- struct H5AC_t *cache; /* The object cache */
- H5F_create_t create_parms; /* File-creation template */
+ H5F_search_t key; /* The key for looking up files */
+ uintn flags; /* Access Permissions for file */
+ H5F_low_t *lf; /* Lower level file handle for I/O */
+ uintn nrefs; /* Ref count for times file is opened */
+ uint32 consist_flags; /* File Consistency Flags */
+ haddr_t boot_addr; /* Absolute address of boot block */
+ haddr_t base_addr; /* Absolute base address for rel.addrs. */
+ haddr_t smallobj_addr; /* Relative address of small-obj heap */
+ haddr_t freespace_addr; /* Relative address of free-space info */
+ haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data*/
+ struct H5AC_t *cache; /* The object cache */
+ H5F_create_t create_parms; /* File-creation template */
#ifdef LATER
- file_access_temp_t file_access_parms; /* File-access template */
+ file_access_temp_t file_access_parms; /* File-access template */
#endif
- struct H5G_entry_t *root_ent; /* Root symbol table entry */
+ struct H5G_entry_t *root_ent; /* Root symbol table entry */
} H5F_file_t;
/*
@@ -339,12 +340,12 @@ typedef struct H5F_file_t {
* pointers to shared H5F_file_t structs.
*/
typedef struct H5F_t {
- uintn intent; /* The flags passed to H5F_open() */
- char *name; /* Name used to open file */
- H5F_file_t *shared; /* The shared file info */
- struct H5G_cwgstk_t *cwg_stack; /* CWG stack for push/pop functions */
- uintn nopen; /* Number of open object headers */
- hbool_t close_pending; /* File close is pending */
+ uintn intent; /* The flags passed to H5F_open()*/
+ char *name; /* Name used to open file */
+ H5F_file_t *shared; /* The shared file info */
+ struct H5G_cwgstk_t *cwg_stack; /* CWG stack for push/pop functions*/
+ uintn nopen; /* Number of open object headers*/
+ hbool_t close_pending; /* File close is pending */
} H5F_t;
#ifdef NOT_YET
@@ -358,17 +359,17 @@ typedef struct H5F_t {
case 2: UINT16ENCODE(p,o); break;}
#endif /* NOT_YET */
-#define H5F_DECODE_OFFSET(f,p,o) \
- switch (H5F_SIZEOF_ADDR (f)) { \
- case 4: \
- UINT32DECODE (p, o); \
- break; \
- case 8: \
- UINT64DECODE (p, o); \
- break; \
- case 2: \
- UINT16DECODE (p, o); \
- break; \
+#define H5F_DECODE_OFFSET(f,p,o) \
+ switch (H5F_SIZEOF_ADDR (f)) { \
+ case 4: \
+ UINT32DECODE (p, o); \
+ break; \
+ case 8: \
+ UINT64DECODE (p, o); \
+ break; \
+ case 2: \
+ UINT16DECODE (p, o); \
+ break; \
}
#ifdef NOT_YET
@@ -376,71 +377,73 @@ typedef struct H5F_t {
: H5F_SIZEOF_SIZE(f)==8 ? UINT64ENCODE(p,l) \
: H5F_SIZEOF_SIZE(f)==2 ? UINT16ENCODE(p,l) : H5FPencode_unusual_length(f,&(p),(uint8 *)&(l)))
#else
-#define H5F_encode_length(f,p,l) \
- switch(H5F_SIZEOF_SIZE(f)) { \
- case 4: UINT32ENCODE(p,l); break; \
- case 8: UINT64ENCODE(p,l); break; \
- case 2: UINT16ENCODE(p,l); break; \
+#define H5F_encode_length(f,p,l) \
+ switch(H5F_SIZEOF_SIZE(f)) { \
+ case 4: UINT32ENCODE(p,l); break; \
+ case 8: UINT64ENCODE(p,l); break; \
+ case 2: UINT16ENCODE(p,l); break; \
}
#endif
-#define H5F_decode_length(f,p,l) \
- switch(H5F_SIZEOF_SIZE(f)) { \
- case 4: UINT32DECODE(p,l); break; \
- case 8: UINT64DECODE(p,l); break; \
- case 2: UINT16DECODE(p,l); break; \
+#define H5F_decode_length(f,p,l) \
+ switch(H5F_SIZEOF_SIZE(f)) { \
+ case 4: UINT32DECODE(p,l); break; \
+ case 8: UINT64DECODE(p,l); break; \
+ case 2: UINT16DECODE(p,l); break; \
}
-struct H5O_layout_t; /*forward decl for prototype arguments */
+struct H5O_layout_t; /*forward decl for prototype arguments */
/* library variables */
extern const H5F_create_t H5F_create_dflt;
/* Private functions, not part of the publicly documented API */
-void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l);
-H5F_t *H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
- const H5F_create_t *create_parms);
-herr_t H5F_close(H5F_t *f);
-herr_t H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
- intn fwidth);
+void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l);
+H5F_t *H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
+ const H5F_create_t *create_parms);
+herr_t H5F_close(H5F_t *f);
+herr_t H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth);
/* Functions that operate on array storage */
-herr_t H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
-herr_t H5F_arr_read(H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- void *buf /*out */ );
-herr_t H5F_arr_write(H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf);
+herr_t H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
+herr_t H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t _hslab_size[], const size_t file_offset[],
+ const size_t mem_offset[], const size_t mem_size[],
+ void *_buf/*out*/);
+herr_t H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t _hslab_size[], const size_t file_offset[],
+ const size_t mem_offset[], const size_t mem_size[],
+ const void *_buf);
/* Functions that operate on indexed storage */
-herr_t H5F_istore_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
-herr_t H5F_istore_read(H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- void *buf /*out */ );
-herr_t H5F_istore_write(H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf);
+herr_t H5F_istore_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
+herr_t H5F_istore_read(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ void *buf /*out */ );
+herr_t H5F_istore_write(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf);
/* Functions that operate on contiguous storage wrt boot block */
-herr_t H5F_block_read(H5F_t *f, const haddr_t *addr, size_t size, void *buf);
-herr_t H5F_block_write(H5F_t *f, const haddr_t *addr, size_t size,
- const void *buf);
+herr_t H5F_block_read(H5F_t *f, const haddr_t *addr, size_t size, void *buf);
+herr_t H5F_block_write(H5F_t *f, const haddr_t *addr, size_t size,
+ const void *buf);
/* Functions that operate directly on low-level files */
-herr_t H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr);
-herr_t H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr);
-hbool_t H5F_low_access(const H5F_low_class_t *type, const char *name,
- int mode, H5F_search_t *key);
-H5F_low_t *H5F_low_open(const H5F_low_class_t *type, const char *name,
- uintn flags, H5F_search_t *key);
-H5F_low_t *H5F_low_close(H5F_low_t *lf);
-size_t H5F_low_size(H5F_low_t *lf, haddr_t *addr);
-herr_t H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf);
-herr_t H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf);
-herr_t H5F_low_flush(H5F_low_t *lf);
+herr_t H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr);
+herr_t H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr);
+hbool_t H5F_low_access(const H5F_low_class_t *type, const char *name,
+ int mode, H5F_search_t *key);
+H5F_low_t *H5F_low_open(const H5F_low_class_t *type, const char *name,
+ uintn flags, H5F_search_t *key);
+H5F_low_t *H5F_low_close(H5F_low_t *lf);
+size_t H5F_low_size(H5F_low_t *lf, haddr_t *addr);
+herr_t H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf);
+herr_t H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf);
+herr_t H5F_low_flush(H5F_low_t *lf);
/* Functions that operate on addresses */
#define H5F_addr_eq(A1,A2) (H5F_addr_cmp(A1,A2)==0)
@@ -449,17 +452,18 @@ herr_t H5F_low_flush(H5F_low_t *lf);
#define H5F_addr_le(A1,A2) (H5F_addr_cmp(A1,A2)<=0)
#define H5F_addr_gt(A1,A2) (H5F_addr_cmp(A1,A2)>0)
#define H5F_addr_ge(A1,A2) (H5F_addr_cmp(A1,A2)>=0)
-intn H5F_addr_cmp(const haddr_t *, const haddr_t *);
-hbool_t H5F_addr_defined(const haddr_t *);
-void H5F_addr_undef(haddr_t *);
-void H5F_addr_reset(haddr_t *);
-hbool_t H5F_addr_zerop(const haddr_t *);
-void H5F_addr_encode(H5F_t *, uint8 **, const haddr_t *);
-void H5F_addr_decode(H5F_t *, const uint8 **, haddr_t *);
-void H5F_addr_print(FILE *, const haddr_t *);
-void H5F_addr_pow2(uintn, haddr_t *);
-void H5F_addr_inc(haddr_t *, size_t);
-void H5F_addr_add(haddr_t *, const haddr_t *);
-uintn H5F_addr_hash(const haddr_t *, uintn mod);
+
+intn H5F_addr_cmp(const haddr_t *, const haddr_t *);
+hbool_t H5F_addr_defined(const haddr_t *);
+void H5F_addr_undef(haddr_t *);
+void H5F_addr_reset(haddr_t *);
+hbool_t H5F_addr_zerop(const haddr_t *);
+void H5F_addr_encode(H5F_t *, uint8 **, const haddr_t *);
+void H5F_addr_decode(H5F_t *, const uint8 **, haddr_t *);
+void H5F_addr_print(FILE *, const haddr_t *);
+void H5F_addr_pow2(uintn, haddr_t *);
+void H5F_addr_inc(haddr_t *, size_t);
+void H5F_addr_add(haddr_t *, const haddr_t *);
+uintn H5F_addr_hash(const haddr_t *, uintn mod);
#endif
diff --git a/src/H5V.c b/src/H5V.c
index 6f0808b..cd199a0 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -1,9 +1,9 @@
/*
* Copyright (C) 1997 NCSA
- * All rights reserved.
+ * All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
- * Friday, October 10, 1997
+ * Friday, October 10, 1997
*/
#include <H5private.h>
@@ -12,41 +12,36 @@
#include <H5Vprivate.h>
#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
-#define PABLO_MASK H5V_mask
-static hbool_t interface_initialize_g = TRUE;
-#define INTERFACE_INIT NULL
-
-static herr_t H5V_stride_optimize1(size_t *np, size_t *elmt_size,
- size_t *size, intn *stride1);
-static herr_t H5V_stride_optimize2(size_t *np, size_t *elmt_size,
- size_t *size, intn *stride1,
- intn *stride2);
+#define PABLO_MASK H5V_mask
+static hbool_t interface_initialize_g = TRUE;
+#define INTERFACE_INIT NULL
+
/*-------------------------------------------------------------------------
- * Function: H5V_stride_optimize1
+ * Function: H5V_stride_optimize1
*
- * Purpose: Given a stride vector which references elements of the
- * specified size, optimize the dimensionality, the stride
- * vector, and the element size to minimize the dimensionality
- * and the number of memory accesses.
+ * Purpose: Given a stride vector which references elements of the
+ * specified size, optimize the dimensionality, the stride
+ * vector, and the element size to minimize the dimensionality
+ * and the number of memory accesses.
*
- * All arguments are passed by reference and their values may be
- * modified by this function.
+ * All arguments are passed by reference and their values may be
+ * modified by this function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
- intn *stride1)
+ intn *stride1)
{
FUNC_ENTER(H5V_stride_optimize1, FAIL);
@@ -60,41 +55,40 @@ H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
* Combine adjacent memory accesses
*/
while (*np && stride1[*np - 1] == *elmt_size) {
-
- *elmt_size *= size[*np - 1];
- if (--*np) {
- stride1[*np - 1] += size[*np] * stride1[*np];
- }
+ *elmt_size *= size[*np - 1];
+ if (--*np) {
+ stride1[*np - 1] += size[*np] * stride1[*np];
+ }
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5V_stride_optimize2
+ * Function: H5V_stride_optimize2
*
- * Purpose: Given two stride vectors which reference elements of the
- * specified size, optimize the dimensionality, the stride
- * vectors, and the element size to minimize the dimensionality
- * and the number of memory accesses.
+ * Purpose: Given two stride vectors which reference elements of the
+ * specified size, optimize the dimensionality, the stride
+ * vectors, and the element size to minimize the dimensionality
+ * and the number of memory accesses.
*
- * All arguments are passed by reference and their values may be
- * modified by this function.
+ * All arguments are passed by reference and their values may be
+ * modified by this function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
- intn *stride1, intn *stride2)
+ intn *stride1, intn *stride2)
{
FUNC_ENTER(H5V_stride_optimize2, FAIL);
@@ -107,37 +101,42 @@ H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
/*
* Combine adjacent memory accesses
*/
- while (*np && stride1[*np - 1] == *elmt_size && stride2[*np - 1] == *elmt_size) {
-
- *elmt_size *= size[*np - 1];
- if (--*np) {
- stride1[*np - 1] += size[*np] * stride1[*np];
- stride2[*np - 1] += size[*np] * stride2[*np];
- }
+ while (*np && stride1[*np - 1] == *elmt_size &&
+ stride2[*np - 1] == *elmt_size) {
+ *elmt_size *= size[*np - 1];
+ if (--*np) {
+ stride1[*np - 1] += size[*np] * stride1[*np];
+ stride2[*np - 1] += size[*np] * stride2[*np];
+ }
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_stride
+ * Function: H5V_hyper_stride
+ *
+ * Purpose: Given a description of a hyperslab, this function returns
+ * (through STRIDE[]) the byte strides appropriate for accessing
+ * all bytes of the hyperslab and the byte offset where the
+ * striding will begin. The SIZE can be passed to the various
+ * stride functions.
*
- * Purpose: Given a description of a hyperslab, this function returns
- * (through STRIDE[]) the byte strides appropriate for accessing
- * all bytes of the hyperslab and the byte offset where the
- * striding will begin. The SIZE can be passed to the various
- * stride functions.
+ * The dimensionality of the whole array, the hyperslab, and the
+ * returned stride array is N. The whole array dimensions are
+ * TOTAL_SIZE and the hyperslab is at offset OFFSET and has
+ * dimensions SIZE.
*
- * The stride and starting point returned will cause the
- * hyperslab elements to be referenced in C order.
+ * The stride and starting point returned will cause the
+ * hyperslab elements to be referenced in C order.
*
- * Return: Success: Byte offset from beginning of array to start
- * of striding.
+ * Return: Success: Byte offset from beginning of array to start
+ * of striding.
*
- * Failure: abort() -- should never fail
+ * Failure: abort() -- should never fail
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -145,12 +144,12 @@ H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
*/
size_t
H5V_hyper_stride(size_t n, const size_t *size,
- const size_t *total_size, const size_t *offset,
- intn *stride /*output arg */ )
+ const size_t *total_size, const size_t *offset,
+ intn *stride/*out*/)
{
- size_t skip; /*starting point byte offset */
- size_t acc; /*accumulator */
- int i; /*counter */
+ size_t skip; /*starting point byte offset */
+ size_t acc; /*accumulator */
+ int i; /*counter */
FUNC_ENTER(H5V_hyper_stride, (abort(), 0));
@@ -165,32 +164,32 @@ H5V_hyper_stride(size_t n, const size_t *size,
/* others */
for (i = n - 2, acc = 1; i >= 0; --i) {
- stride[i] = acc * (total_size[i + 1] - size[i + 1]);
- acc *= total_size[i + 1];
- skip += acc * (offset ? offset[i] : 0);
+ stride[i] = acc * (total_size[i + 1] - size[i + 1]);
+ acc *= total_size[i + 1];
+ skip += acc * (offset ? offset[i] : 0);
}
FUNC_LEAVE(skip);
}
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_eq
+ * Function: H5V_hyper_eq
*
- * Purpose: Determines whether two hyperslabs are equal. This function
- * assumes that both hyperslabs are relative to the same array,
- * for if not, they could not possibly be equal.
+ * Purpose: Determines whether two hyperslabs are equal. This function
+ * assumes that both hyperslabs are relative to the same array,
+ * for if not, they could not possibly be equal.
*
- * Return: Success: TRUE if the hyperslabs are equal (that is,
- * both refer to exactly the same elements of an
- * array)
+ * Return: Success: TRUE if the hyperslabs are equal (that is,
+ * both refer to exactly the same elements of an
+ * array)
*
- * FALSE otherwise.
+ * FALSE otherwise.
*
- * Failure: TRUE the rank is zero or if both hyperslabs
- * are of zero size.
+ * Failure: TRUE the rank is zero or if both hyperslabs
+ * are of zero size.
*
- * Programmer: Robb Matzke
- * Friday, October 17, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 17, 1997
*
* Modifications:
*
@@ -198,43 +197,41 @@ H5V_hyper_stride(size_t n, const size_t *size,
*/
hbool_t
H5V_hyper_eq(size_t n,
- const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2)
+ const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2)
{
- size_t nelmts1 = 1, nelmts2 = 1;
- intn i;
+ size_t nelmts1 = 1, nelmts2 = 1;
+ intn i;
if (n <= 0)
- return TRUE;
+ return TRUE;
for (i = 0; i < n; i++) {
- if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) {
- return FALSE;
- }
- if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) {
- return FALSE;
- }
- if (0 == (nelmts1 *= (size1 ? size1[i] : 0)))
- return FALSE;
- if (0 == (nelmts2 *= (size2 ? size2[i] : 0)))
- return FALSE;
+ if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) {
+ return FALSE;
+ }
+ if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) {
+ return FALSE;
+ }
+ if (0 == (nelmts1 *= (size1 ? size1[i] : 0))) return FALSE;
+ if (0 == (nelmts2 *= (size2 ? size2[i] : 0))) return FALSE;
}
return TRUE;
}
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_disjointp
+ * Function: H5V_hyper_disjointp
*
- * Purpose: Determines if two hyperslabs are disjoint.
+ * Purpose: Determines if two hyperslabs are disjoint.
*
- * Return: Success: FALSE if they are not disjoint.
- * TRUE if they are disjoint.
+ * Return: Success: FALSE if they are not disjoint.
+ * TRUE if they are disjoint.
*
- * Failure: A hyperslab of zero size is disjoint from all
- * other hyperslabs.
+ * Failure: A hyperslab of zero size is disjoint from all
+ * other hyperslabs.
*
- * Programmer: Robb Matzke
- * Thursday, October 16, 1997
+ * Programmer: Robb Matzke
+ * Thursday, October 16, 1997
*
* Modifications:
*
@@ -242,45 +239,43 @@ H5V_hyper_eq(size_t n,
*/
hbool_t
H5V_hyper_disjointp(size_t n,
- const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2)
+ const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2)
{
- intn i;
+ intn i;
- if (!n || !size1 || !size2)
- return TRUE;
+ if (!n || !size1 || !size2) return TRUE;
for (i = 0; i < n; i++) {
- if (0 == size1[i] || 0 == size2[i])
- return TRUE;
- if (((offset1 ? offset1[i] : 0) < (offset2 ? offset2[i] : 0) &&
- (offset1 ? offset1[i] : 0) + size1[i] <= (offset2 ? offset2[i] : 0)) ||
- ((offset2 ? offset2[i] : 0) < (offset1 ? offset1[i] : 0) &&
- (offset2 ? offset2[i] : 0) + size2[i] <= (offset1 ? offset1[i] : 0))) {
- return TRUE;
- }
+ if (0 == size1[i] || 0 == size2[i]) return TRUE;
+ if (((offset1?offset1[i]:0) < (offset2?offset2[i]:0) &&
+ (offset1?offset1[i]:0) + size1[i] <= (offset2?offset2[i]:0)) ||
+ ((offset2?offset2[i]:0) < (offset1?offset1[i]:0) &&
+ (offset2?offset2[i]:0) + size2[i] <= (offset1?offset1[i]:0))) {
+ return TRUE;
+ }
}
return FALSE;
}
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_fill
+ * Function: H5V_hyper_fill
*
- * Purpose: Similar to memset() except it operates on hyperslabs...
+ * Purpose: Similar to memset() except it operates on hyperslabs...
*
- * Fills a hyperslab of array BUF with some value VAL. BUF
- * is treated like a C-order array with N dimensions where the
- * size of each dimension is TOTAL_SIZE[]. The hyperslab which
- * will be filled with VAL begins at byte offset OFFSET[] from
- * the minimum corner of BUF and continues for SIZE[] bytes in
- * each dimension.
- *
- * Return: Success: SUCCEED
+ * Fills a hyperslab of array BUF with some value VAL. BUF
+ * is treated like a C-order array with N dimensions where the
+ * size of each dimension is TOTAL_SIZE[]. The hyperslab which
+ * will be filled with VAL begins at byte offset OFFSET[] from
+ * the minimum corner of BUF and continues for SIZE[] bytes in
+ * each dimension.
+ *
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -288,17 +283,17 @@ H5V_hyper_disjointp(size_t n,
*/
herr_t
H5V_hyper_fill(size_t n, const size_t *_size,
- const size_t *total_size, const size_t *offset, void *_dst,
- uint8 fill_value)
+ const size_t *total_size, const size_t *offset, void *_dst,
+ uint8 fill_value)
{
- uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
- size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */
- intn dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
- size_t dst_start; /*byte offset to start of stride */
- size_t elmt_size = 1; /*bytes per element */
- herr_t status; /*function return status */
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
+ size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */
+ intn dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
+ size_t dst_start; /*byte offset to start of stride*/
+ size_t elmt_size = 1; /*bytes per element */
+ herr_t status; /*function return status */
#ifndef NDEBUG
- int i;
+ int i;
#endif
FUNC_ENTER(H5V_hyper_fill, FAIL);
@@ -310,8 +305,8 @@ H5V_hyper_fill(size_t n, const size_t *_size,
assert(dst);
#ifndef NDEBUG
for (i = 0; i < n; i++) {
- assert(_size[i] > 0);
- assert(total_size[i] > 0);
+ assert(_size[i] > 0);
+ assert(total_size[i] > 0);
}
#endif
@@ -324,39 +319,39 @@ H5V_hyper_fill(size_t n, const size_t *_size,
/* Copy */
status = H5V_stride_fill(n, elmt_size, size, dst_stride, dst + dst_start,
- fill_value);
+ fill_value);
FUNC_LEAVE(status);
}
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_copy
+ * Function: H5V_hyper_copy
*
- * Purpose: Copies a hyperslab from the source to the destination.
+ * Purpose: Copies a hyperslab from the source to the destination.
*
- * A hyperslab is a logically contiguous region of
- * multi-dimensional size SIZE of an array whose dimensionality
- * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE.
- * The minimum corner of the hyperslab begins at a
- * multi-dimensional offset from the minimum corner of the DST
- * (destination) or SRC (source) array. The sizes and offsets
- * are assumed to be in C order, that is, the first size/offset
- * varies the slowest while the last varies the fastest in the
- * mapping from N-dimensional space to linear space. This
- * function assumes that the array elements are single bytes (if
- * your array has multi-byte elements then add an additional
- * dimension whose size is that of your element).
+ * A hyperslab is a logically contiguous region of
+ * multi-dimensional size SIZE of an array whose dimensionality
+ * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE.
+ * The minimum corner of the hyperslab begins at a
+ * multi-dimensional offset from the minimum corner of the DST
+ * (destination) or SRC (source) array. The sizes and offsets
+ * are assumed to be in C order, that is, the first size/offset
+ * varies the slowest while the last varies the fastest in the
+ * mapping from N-dimensional space to linear space. This
+ * function assumes that the array elements are single bytes (if
+ * your array has multi-byte elements then add an additional
+ * dimension whose size is that of your element).
*
- * The SRC and DST array may be the same array, but the results
- * are undefined if the source hyperslab overlaps the
- * destination hyperslab.
+ * The SRC and DST array may be the same array, but the results
+ * are undefined if the source hyperslab overlaps the
+ * destination hyperslab.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -365,24 +360,24 @@ H5V_hyper_fill(size_t n, const size_t *_size,
herr_t
H5V_hyper_copy(size_t n, const size_t *_size,
- /*destination */
- const size_t *dst_size, const size_t *dst_offset,
- void *_dst,
+ /*destination*/
+ const size_t *dst_size, const size_t *dst_offset,
+ void *_dst,
- /*source */
- const size_t *src_size, const size_t *src_offset,
- const void *_src)
+ /*source*/
+ const size_t *src_size, const size_t *src_offset,
+ const void *_src)
{
- const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmtc */
- uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmtc */
- size_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */
- intn src_stride[H5V_HYPER_NDIMS]; /*source stride info */
- intn dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
- size_t dst_start, src_start; /*offset to start at */
- size_t elmt_size = 1; /*element size in bytes */
- herr_t status; /*return status */
-#ifndef NDEBUG
- intn i;
+ const uint8 *src = (const uint8 *)_src; /*cast for ptr arithmtc */
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmtc */
+ size_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */
+ intn src_stride[H5V_HYPER_NDIMS]; /*source stride info */
+ intn dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
+ size_t dst_start, src_start; /*offset to start at */
+ size_t elmt_size = 1; /*element size in bytes */
+ herr_t status; /*return status */
+#ifndef NDEBUG
+ intn i;
#endif
FUNC_ENTER(H5V_hyper_copy, FAIL);
@@ -396,9 +391,9 @@ H5V_hyper_copy(size_t n, const size_t *_size,
assert(src);
#ifndef NDEBUG
for (i = 0; i < n; i++) {
- assert(_size[i] > 0);
- assert(dst_size[i] > 0);
- assert(src_size[i] > 0);
+ assert(_size[i] > 0);
+ assert(dst_size[i] > 0);
+ assert(src_size[i] > 0);
}
#endif
@@ -414,24 +409,24 @@ H5V_hyper_copy(size_t n, const size_t *_size,
/* Perform the copy in terms of stride */
status = H5V_stride_copy(n, elmt_size, size,
- dst_stride, dst + dst_start,
- src_stride, src + src_start);
+ dst_stride, dst + dst_start,
+ src_stride, src + src_start);
FUNC_LEAVE(status);
}
/*-------------------------------------------------------------------------
- * Function: H5V_stride_fill
+ * Function: H5V_stride_fill
*
- * Purpose: Fills all bytes of a hyperslab with the same value using
- * memset().
+ * Purpose: Fills all bytes of a hyperslab with the same value using
+ * memset().
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -439,13 +434,13 @@ H5V_hyper_copy(size_t n, const size_t *_size,
*/
herr_t
H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
- const intn *stride, void *_dst, uint8 fill_value)
+ const intn *stride, void *_dst, uint8 fill_value)
{
- uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
- size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
- size_t nelmts; /*number of elements to fill */
- intn i, j; /*counters */
- hbool_t carry; /*subtraction carray value */
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
+ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
+ size_t nelmts; /*number of elements to fill */
+ intn i, j; /*counters */
+ hbool_t carry; /*subtraction carray value */
FUNC_ENTER(H5V_stride_fill, FAIL);
@@ -453,41 +448,41 @@ H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
nelmts = H5V_vector_reduce_product(n, size);
for (i = 0; i < nelmts; i++) {
- /* Copy an element */
- HDmemset(dst, fill_value, elmt_size);
+ /* Copy an element */
+ HDmemset(dst, fill_value, elmt_size);
- /* Decrement indices and advance pointer */
- for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
- dst += stride[j];
+ /* Decrement indices and advance pointer */
+ for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ dst += stride[j];
- if (--idx[j])
- carry = FALSE;
- else
- idx[j] = size[j];
- }
+ if (--idx[j])
+ carry = FALSE;
+ else
+ idx[j] = size[j];
+ }
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5V_stride_copy
+ * Function: H5V_stride_copy
*
- * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays
- * DST and SRC while copying bytes from SRC to DST. This
- * function minimizes the number of calls to memcpy() by
- * combining various strides, but it will never touch memory
- * outside the hyperslab defined by the strides.
+ * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays
+ * DST and SRC while copying bytes from SRC to DST. This
+ * function minimizes the number of calls to memcpy() by
+ * combining various strides, but it will never touch memory
+ * outside the hyperslab defined by the strides.
*
- * Note: If the src_stride is all zero and elmt_size is one, then it's
- * probably more efficient to use H5V_stride_fill() instead.
+ * Note: If the src_stride is all zero and elmt_size is one, then it's
+ * probably more efficient to use H5V_stride_fill() instead.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -495,16 +490,15 @@ H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
*/
herr_t
H5V_stride_copy(size_t n, size_t elmt_size, const size_t *size,
- const intn *dst_stride, void *_dst,
- const intn *src_stride, const void *_src)
+ const intn *dst_stride, void *_dst,
+ const intn *src_stride, const void *_src)
{
-
- uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
- const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmetic */
- size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
- size_t nelmts; /*num elements to copy */
- intn i, j; /*counters */
- hbool_t carry; /*carray for subtraction */
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic*/
+ const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmetic*/
+ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
+ size_t nelmts; /*num elements to copy */
+ intn i, j; /*counters */
+ hbool_t carry; /*carray for subtraction*/
FUNC_ENTER(H5V_stride_copy, FAIL);
@@ -512,38 +506,36 @@ H5V_stride_copy(size_t n, size_t elmt_size, const size_t *size,
nelmts = H5V_vector_reduce_product(n, size);
for (i = 0; i < nelmts; i++) {
- /* Copy an element */
- HDmemcpy(dst, src, elmt_size);
+ /* Copy an element */
+ HDmemcpy(dst, src, elmt_size);
- /* Decrement indices and advance pointers */
- for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
- src += src_stride[j];
- dst += dst_stride[j];
+ /* Decrement indices and advance pointers */
+ for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ src += src_stride[j];
+ dst += dst_stride[j];
- if (--idx[j])
- carry = FALSE;
- else
- idx[j] = size[j];
- }
+ if (--idx[j]) carry = FALSE;
+ else idx[j] = size[j];
+ }
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5V_stride_copy2
+ * Function: H5V_stride_copy2
*
- * Purpose: Similar to H5V_stride_copy() except the source and
- * destination each have their own dimensionality and size and
- * we copy exactly NELMTS elements each of size ELMT_SIZE. The
- * size counters wrap if NELMTS is more than a size counter.
+ * Purpose: Similar to H5V_stride_copy() except the source and
+ * destination each have their own dimensionality and size and
+ * we copy exactly NELMTS elements each of size ELMT_SIZE. The
+ * size counters wrap if NELMTS is more than a size counter.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -552,20 +544,20 @@ H5V_stride_copy(size_t n, size_t elmt_size, const size_t *size,
herr_t
H5V_stride_copy2(size_t nelmts, size_t elmt_size,
- /* destination */
- size_t dst_n, const size_t *dst_size, const intn *dst_stride,
- void *_dst,
+ /* destination */
+ size_t dst_n, const size_t *dst_size, const intn *dst_stride,
+ void *_dst,
- /* source */
- size_t src_n, const size_t *src_size, const intn *src_stride,
- const void *_src)
+ /* source */
+ size_t src_n, const size_t *src_size, const intn *src_stride,
+ const void *_src)
{
- uint8 *dst = (uint8 *) _dst;
- const uint8 *src = (const uint8 *) _src;
- size_t dst_idx[H5V_HYPER_NDIMS];
- size_t src_idx[H5V_HYPER_NDIMS];
- intn i, j;
- hbool_t carry;
+ uint8 *dst = (uint8 *) _dst;
+ const uint8 *src = (const uint8 *) _src;
+ size_t dst_idx[H5V_HYPER_NDIMS];
+ size_t src_idx[H5V_HYPER_NDIMS];
+ intn i, j;
+ hbool_t carry;
FUNC_ENTER(H5V_stride_copy2, FAIL);
@@ -574,24 +566,20 @@ H5V_stride_copy2(size_t nelmts, size_t elmt_size,
for (i = 0; i < nelmts; i++) {
- /* Copy an element */
- HDmemcpy(dst, src, elmt_size);
-
- /* Decrement indices and advance pointers */
- for (j = dst_n - 1, carry = TRUE; j >= 0 && carry; --j) {
- dst += dst_stride[j];
- if (--dst_idx[j])
- carry = FALSE;
- else
- dst_idx[j] = dst_size[j];
- }
- for (j = src_n - 1, carry = TRUE; j >= 0 && carry; --j) {
- src += src_stride[j];
- if (--src_idx[j])
- carry = FALSE;
- else
- src_idx[j] = src_size[j];
- }
+ /* Copy an element */
+ HDmemcpy(dst, src, elmt_size);
+
+ /* Decrement indices and advance pointers */
+ for (j = dst_n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ dst += dst_stride[j];
+ if (--dst_idx[j]) carry = FALSE;
+ else dst_idx[j] = dst_size[j];
+ }
+ for (j = src_n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ src += src_stride[j];
+ if (--src_idx[j]) carry = FALSE;
+ else src_idx[j] = src_size[j];
+ }
}
FUNC_LEAVE(SUCCEED);
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index 8afe111..34d1993 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -28,30 +28,33 @@
/* A null pointer is equivalent to a zero vector */
#define H5V_ZERO NULL
-size_t H5V_hyper_stride(size_t n, const size_t *size,
- const size_t *total_size, const size_t *offset,
- intn *stride);
-hbool_t H5V_hyper_disjointp(size_t n,
- const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2);
-hbool_t H5V_hyper_eq(size_t n, const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2);
-herr_t H5V_hyper_fill(size_t n, const size_t *total_size,
- const size_t *offset, const size_t *size,
- void *buf, uint8 val);
-herr_t H5V_hyper_copy(size_t n, const size_t *size,
- const size_t *dst_total_size, const size_t *dst_offset,
- void *_dst, const size_t *src_total_size,
- const size_t *src_offset, const void *_src);
-herr_t H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
- const intn *stride, void *_dst, uint8 fill_value);
-herr_t H5V_stride_copy(size_t n, size_t elmt_size, const size_t *_size,
- const intn *dst_stride, void *_dst,
- const intn *src_stride, const void *_src);
-herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, size_t dst_n,
- const size_t *dst_size, const intn *dst_stride,
- void *_dst, size_t src_n, const size_t *src_size,
- const intn *src_stride, const void *_src);
+size_t H5V_hyper_stride(size_t n, const size_t *size, const size_t *total_size,
+ const size_t *offset, intn *stride);
+hbool_t H5V_hyper_disjointp(size_t n, const size_t *offset1,
+ const size_t *size1, const size_t *offset2,
+ const size_t *size2);
+hbool_t H5V_hyper_eq(size_t n, const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2);
+herr_t H5V_hyper_fill(size_t n, const size_t *total_size, const size_t *offset,
+ const size_t *size, void *buf, uint8 val);
+herr_t H5V_hyper_copy(size_t n, const size_t *size,
+ const size_t *dst_total_size, const size_t *dst_offset,
+ void *_dst, const size_t *src_total_size,
+ const size_t *src_offset, const void *_src);
+herr_t H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
+ const intn *stride, void *_dst, uint8 fill_value);
+herr_t H5V_stride_copy(size_t n, size_t elmt_size, const size_t *_size,
+ const intn *dst_stride, void *_dst,
+ const intn *src_stride, const void *_src);
+herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, size_t dst_n,
+ const size_t *dst_size, const intn *dst_stride,
+ void *_dst, size_t src_n, const size_t *src_size,
+ const intn *src_stride, const void *_src);
+herr_t H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
+ intn *stride1);
+herr_t H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
+ intn *stride1, intn *stride2);
+
/*-------------------------------------------------------------------------
* Function: H5V_vector_reduce_product
diff --git a/test/istore.c b/test/istore.c
index 6115a5f..2bd092c 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -37,8 +37,9 @@
#define AT() printf (" at %s:%d in %s()...\n", \
__FILE__, __LINE__, __FUNCTION__);
-size_t align_g[3] =
-{50, 50, 50};
+size_t align_g[3] = {50, 50, 50};
+size_t zero[H5O_LAYOUT_NDIMS];
+
/*-------------------------------------------------------------------------
* Function: print_array
@@ -97,7 +98,7 @@ print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static int
-new_object(H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent /*out */ )
+new_object(H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
{
H5O_layout_t layout;
intn i;
@@ -313,7 +314,7 @@ test_extend(H5F_t *f, const char *prefix,
memset(buf, 128 + ctr, nelmts);
/* Write to disk */
- if (H5F_arr_write(f, &layout, offset, size, buf) < 0) {
+ if (H5F_arr_write(f, &layout, size, offset, zero, size, buf) < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -323,7 +324,7 @@ test_extend(H5F_t *f, const char *prefix,
}
/* Read from disk */
memset(check, 0xff, nelmts);
- if (H5F_arr_read(f, &layout, offset, size, check) < 0) {
+ if (H5F_arr_read(f, &layout, size, offset, zero, size, check) < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -356,7 +357,7 @@ test_extend(H5F_t *f, const char *prefix,
/* Now read the entire array back out and check it */
memset(buf, 0xff, nx * ny * nz);
- if (H5F_arr_read(f, &layout, H5V_ZERO, whole_size, buf) < 0) {
+ if (H5F_arr_read(f, &layout, whole_size, zero, zero, whole_size, buf)<0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -475,7 +476,7 @@ test_sparse(H5F_t *f, const char *prefix, size_t nblocks,
memset(buf, 128 + ctr, nx * ny * nz);
/* write to disk */
- if (H5F_arr_write(f, &layout, offset, size, buf) < 0) {
+ if (H5F_arr_write(f, &layout, size, offset, zero, size, buf) < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();