summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-12-10 22:41:07 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-12-10 22:41:07 (GMT)
commit082dd8cda9ef3d49be23dfce49e10dd30d0758bc (patch)
treee60a32468ba14f758849f34454fdd8722b72edaa
parent3aee91269b83b09a186d214c55873fbbfa15602d (diff)
downloadhdf5-082dd8cda9ef3d49be23dfce49e10dd30d0758bc.zip
hdf5-082dd8cda9ef3d49be23dfce49e10dd30d0758bc.tar.gz
hdf5-082dd8cda9ef3d49be23dfce49e10dd30d0758bc.tar.bz2
[svn-r139] ./src/*.[ch]
Removed the interface initialization argument from FUNC_ENTER() and made it a locally-defined preprocessor symbol, INTERFACE_INIT. Changed `offset' to `address' and `length' to `size' in documentation so it's more consistent. `Offset' still appears occassionally when it refers to a byte offset within some other data structure. Moved interface termination function prototypes from public header files to .c files and made them static. ./src/H5.c ./src/H5public.h Added H5init() because it's possible that the predefined data types are not initialized. This happens only if the first call to the hdf5 library passes a predefined data type symbol as an argument. There should be some way to fix this... ./src/H5A.c ./src/H5Aprivate.h ./src/H5Apublic.h The free_func returns SUCCEED or FAIL, although the return value is ignored by H5A. This is so we can use the various H5*_close() functions to free things. H5Ainc_ref() and H5Adec_ref() are no longer public. Many of the other atom functions should also be made private, but I'll save that for later... Added additional template groups called H5_TEMPLATE_0 through H5_TEMPLATE_7 that are used by the various template subclasses. Increased the number of bits used for atom groups to prevent negative atoms. ./src/H5AC.c ./src/H5ACprivate.h Changed H5AC_new() to H5AC_create() to make names more consistent. ./src/H5B.c ./src/H5Bprivate.h Changed H5B_new() to H5B_create() to make names more consistent. ./src/H5C.c ./src/H5Cprivate.h ./src/H5Cpublic.h Now supports multiple subclasses of templates, although it's done with big switch statements. The default values for templates are defined in the source file to which that template belongs. This got rid of lots of needless preprocessor constants. Added H5Ccreate() to create a new template. Changed H5C_release() to H5Cclose() to make the naming more consistent. ./src/H5D.c ./src/H5Dprivate.h ./src/H5Dpublic.h Enhanced to use the new dataset interface, and uses the enhanced data type and data space interfaces, which haven't been completely implemented. The dataset interface doesn't handle non-contiguous storage, compression, or data type and space conversions yet. ./src/H5F.c ./src/H5Fprivate.h ./src/H5Fpublic.h Removed H5Fflush() since just calls H5F_flush(), which doesn't do what the user would probably think it does, namely, flush everything. It only flushes those things sitting in the H5AC cache and the boot block. Changed the `file_create_parms' field of H5F_low_t to just `create_parms' since the `file' part is obvious. ./src/H5Fistore.c Added some support for external files. Mostly just in the file format and not supported much by the library yet. I need to finish some dataset functions first. Changed H5F_istore_new() to H5F_istore_create() to make names more uniform across packages. ./src/H5Flow.c Flushing a file causes the file to be physically extended to the logical eof. This prevents H5F_open() from thinking a file has been truncated. Most of the time the file will already be that large, and when it isn't Unix will often just allocate the final block anyway. ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gpkg.h ./src/H5Gprivate.h ./src/H5Gstab.c Removed H5G_basename() Removed (temporarily) data type information from symbol table entries and renamed H5G_CACHED_SDATA to H5G_CACHED_SDSPACE to reflect that it's a simple data space and has nothing to do with raw data. Changed H5G_node_new() to H5G_node_create() and H5G_stab_new() to H5G_stab_create() to make names more uniform across packages. Fixed an undefined address bug that happens when H5G_node_debug() program doesn't pass enough info to H5G_node_load(). ./src/H5H.c ./src/H5Hprivate.h Changed H5H_new() to H5H_create() to make the names more uniform across packages. ./src/H5M.c ./src/H5Mprivate.h ./src/H5Mpublic.h Nulled all the create functions. Most of the other callbacks are to public functions. Removed H5Mcreate(). Changed hobjtype_t to group_t since it has to be the same thing anyway. ./src/H5O.c ./src/H5Oprivate.h ./src/H5Osdim.c ./src/H5Osdtyp.c Changed H5O_SIM_DIM to H5O_SDSPACE (simple data space) since `simple data space' is its official name, not `simple dimensions'. Will eventually add H5O_CDSPACE for comples data spaces. Changed _sim_dim_ to _dspace_. Replaced H5O_SIM_DTYPE and the compound data type messages with a single H5O_DTYPE message. Changed _sim_dtype_ to _dtype_. Changed H5O_STD_STORE to H5O_CSTORE (contiguous storage) since contiguous storage is not necessarily standard. Changed _std_store_ to _cstore_ in H5Ocstore.c Added the H5O_EFL (external file list) message. Changed H5O_new() to H5O_create() to make names more uniform across packages. ./src/H5Oefl.c NEW External file list message for specifying which non-hdf5 files contain raw data for a dataset. ./src/H5P.c ./src/H5Pprivate.h ./src/H5Ppublic.h Renamed and moved data structures to make the names conform to our naming scheme. ./src/H5T.c ./src/H5Tprivate.h ./src/H5Tpublic.h ./src/H5Tpkg.h NEW Data structures redesigned to be more flexible. The interface was redesigned to make it more regular and to make some names more uniform across packages. ./src/H5detect.c Output was changed to produce a file that conforms to the hdf5 coding standard. ./src/Makefile.in Generates H5Tinit.c by running H5detect. ./src/debug.c Moved command argument processing.
-rw-r--r--src/H5.c82
-rw-r--r--src/H5A.c153
-rw-r--r--src/H5AC.c24
-rw-r--r--src/H5ACprivate.h2
-rw-r--r--src/H5Aprivate.h5
-rw-r--r--src/H5Apublic.h52
-rw-r--r--src/H5B.c49
-rw-r--r--src/H5Bprivate.h6
-rw-r--r--src/H5C.c951
-rw-r--r--src/H5Cprivate.h26
-rw-r--r--src/H5Cpublic.h105
-rw-r--r--src/H5D.c1482
-rw-r--r--src/H5Dconv.c5
-rw-r--r--src/H5Distore.c71
-rw-r--r--src/H5Dprivate.h41
-rw-r--r--src/H5Dpublic.h23
-rw-r--r--src/H5E.c26
-rw-r--r--src/H5F.c308
-rw-r--r--src/H5Fcore.c11
-rw-r--r--src/H5Ffamily.c13
-rw-r--r--src/H5Fistore.c71
-rw-r--r--src/H5Flow.c75
-rw-r--r--src/H5Fprivate.h38
-rw-r--r--src/H5Fpublic.h4
-rw-r--r--src/H5Fsec2.c9
-rw-r--r--src/H5Fstdio.c11
-rw-r--r--src/H5G.c93
-rw-r--r--src/H5Gent.c77
-rw-r--r--src/H5Gnode.c55
-rw-r--r--src/H5Gpkg.h4
-rw-r--r--src/H5Gprivate.h11
-rw-r--r--src/H5Gshad.c23
-rw-r--r--src/H5Gstab.c19
-rw-r--r--src/H5H.c29
-rw-r--r--src/H5Hprivate.h6
-rw-r--r--src/H5M.c508
-rw-r--r--src/H5MF.c5
-rw-r--r--src/H5Mprivate.h14
-rw-r--r--src/H5Mpublic.h9
-rw-r--r--src/H5O.c57
-rw-r--r--src/H5Ocont.c13
-rw-r--r--src/H5Ocstore.c (renamed from src/H5Ostdst.c)173
-rw-r--r--src/H5Oefl.c307
-rw-r--r--src/H5Oistore.c16
-rw-r--r--src/H5Oname.c15
-rw-r--r--src/H5Oprivate.h51
-rw-r--r--src/H5Osdim.c380
-rw-r--r--src/H5Osdtyp.c937
-rw-r--r--src/H5Ostab.c23
-rw-r--r--src/H5P.c915
-rw-r--r--src/H5Pprivate.h42
-rw-r--r--src/H5Ppublic.h33
-rw-r--r--src/H5T.c1702
-rw-r--r--src/H5Tpkg.h76
-rw-r--r--src/H5Tprivate.h63
-rw-r--r--src/H5Tpublic.h129
-rw-r--r--src/H5V.c17
-rw-r--r--src/H5detect.c356
-rw-r--r--src/H5private.h15
-rw-r--r--src/H5public.h1
-rw-r--r--src/Makefile.in16
-rw-r--r--src/debug.c27
62 files changed, 5615 insertions, 4245 deletions
diff --git a/src/H5.c b/src/H5.c
index 86f80bd..757e99d 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -41,27 +41,28 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5ACprivate.h> /*cache */
#include <H5Bprivate.h> /*B-link trees */
#include <H5Eprivate.h> /*error handling */
+#include <H5Tprivate.h> /*data types */
#define PABLO_MASK H5_mask
/*--------------------- Locally scoped variables -----------------------------*/
-/* Whether we've installed the library termination function yet for this interface */
-static hbool_t interface_initialize_g = FALSE;
hbool_t library_initialize_g = FALSE;
hbool_t thread_initialize_g = FALSE;
hbool_t install_atexit_g = TRUE;
typedef struct H5_exit {
- void (*func)(void); /* Interface function to call during exit */
- struct H5_exit *next; /* Pointer to next node with exit function */
- } H5_exit_t;
+ void (*func)(void); /* Interface function to call during exit */
+ struct H5_exit *next; /* Pointer to next node with exit function */
+} H5_exit_t;
H5_exit_t *lib_exit_head; /* Pointer to the head of the list of 'atexit' functions */
-/*------------------_-- Local function prototypes ----------------------------*/
-static herr_t H5_init_interface(void);
+/* Interface initialization */
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5_init_interface
+static herr_t H5_init_interface (void);
/*--------------------------------------------------------------------------
NAME
@@ -77,15 +78,24 @@ DESCRIPTION
--------------------------------------------------------------------------*/
herr_t H5_init_library(void)
{
- FUNC_ENTER (H5_init_library, NULL, FAIL);
-
- /* Install atexit() library cleanup routine */
- if(install_atexit_g==TRUE)
- if (HDatexit(&H5_term_library) != 0)
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL);
+ FUNC_ENTER_INIT (H5_init_library, NULL, FAIL);
+
+ /* Install atexit() library cleanup routine */
+ if(install_atexit_g==TRUE)
+ if (HDatexit(&H5_term_library) != 0)
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL);
+
+ /*
+ * Initialize interfaces that might not be able to initialize themselves
+ * soon enough.
+ */
+ if (H5T_init_interface ()<0) {
+ HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, FAIL);
+ }
+
- FUNC_LEAVE (SUCCEED);
-} /* H5_init_library */
+ FUNC_LEAVE (SUCCEED);
+}
/*--------------------------------------------------------------------------
NAME
@@ -113,7 +123,7 @@ H5_add_exit (void (*func)(void))
herr_t ret_value = SUCCEED;
H5_exit_t *new;
- FUNC_ENTER (H5_add_exit, NULL, FAIL);
+ FUNC_ENTER_INIT (H5_add_exit, NULL, FAIL);
assert(func);
@@ -174,7 +184,7 @@ DESCRIPTION
--------------------------------------------------------------------------*/
herr_t H5_init_thread(void)
{
- FUNC_ENTER (H5_init_thread, NULL, FAIL);
+ FUNC_ENTER_INIT (H5_init_thread, NULL, FAIL);
/* Create/initialize this thread's error stack */
if((thrderrid=H5Enew_err_stack(16))==FAIL)
@@ -225,7 +235,7 @@ DESCRIPTION
--------------------------------------------------------------------------*/
static herr_t H5_init_interface(void)
{
- FUNC_ENTER (H5_init_interface, NULL, FAIL);
+ FUNC_ENTER (H5_init_interface, FAIL);
FUNC_LEAVE (SUCCEED);
} /* H5_init_interface */
@@ -258,7 +268,7 @@ static herr_t H5_init_interface(void)
--------------------------------------------------------------------------*/
herr_t H5dont_atexit(void)
{
- FUNC_ENTER (H5dont_atexit, NULL, FAIL);
+ FUNC_ENTER_INIT (H5dont_atexit, NULL, FAIL);
if(install_atexit_g == TRUE)
install_atexit_g=FALSE;
@@ -286,7 +296,7 @@ herr_t H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5version, H5_init_interface, FAIL);
+ FUNC_ENTER (H5version, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -308,5 +318,35 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* H5version */
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5init
+ *
+ * Purpose: Initialize the library. This is normally called
+ * automatically, but if you find that an HDF5 library function
+ * is failing inexplicably, then try calling this function
+ * first.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5init (void)
+{
+ FUNC_ENTER (H5init, FAIL);
+ /* all work is done by FUNC_ENTER() */
+ FUNC_LEAVE (SUCCEED);
+}
+
diff --git a/src/H5A.c b/src/H5A.c
index 52622bc..b0d9965 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -69,9 +69,6 @@ MODIFICATION HISTORY
/*-------------------- Locally scoped variables -----------------------------*/
-/* Is the interface initialized? */
-static int interface_initialize_g = FALSE;
-
#ifdef ATOMS_ARE_CACHED
/* Array of pointers to atomic groups */
static hid_t atom_id_cache[ATOM_CACHE_SIZE]={-1,-1,-1,-1};
@@ -84,11 +81,15 @@ static atom_group_t *atom_group_list[MAXGROUP]={NULL};
/* Pointer to the atom node free list */
static atom_info_t *atom_free_list=NULL;
+/* Interface initialialization? */
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5A_init_interface
+static herr_t H5A_init_interface(void);
+
/*--------------------- Local function prototypes ---------------------------*/
static atom_info_t *H5A_find_atom(hid_t atm);
static atom_info_t *H5A_get_atom_node(void);
static herr_t H5A_release_atom_node(atom_info_t *atm);
-static herr_t H5A_init_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -103,7 +104,7 @@ DESCRIPTION
static herr_t H5A_init_interface(void)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5A_init_interface, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5A_init_interface, FAIL);
/* Registers the cleanup routine with the exit chain */
ret_value=H5_add_exit(&H5A_term_interface);
@@ -131,13 +132,13 @@ static herr_t H5A_init_interface(void)
intn H5Ainit_group(group_t grp, /* IN: Group to initialize */
intn hash_size, /* IN: Minimum hash table size to use for group */
uintn reserved, /* IN: Number of hash table entries to reserve */
- void (*free_func)(void *) /* IN: Function to call when releasing ref counted objects */
+ herr_t (*free_func)(void *) /* IN: Function to call when releasing ref counted objects */
)
{
atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
intn ret_value=SUCCEED;
- FUNC_ENTER (H5Ainit_group, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5Ainit_group, FAIL);
if((grp<=BADGROUP || grp>=MAXGROUP) && hash_size>0)
HGOTO_DONE(FAIL);
@@ -219,7 +220,7 @@ intn H5Adestroy_group(group_t grp /* IN: Group to destroy */
atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
intn ret_value=SUCCEED;
- FUNC_ENTER (H5Adestroy_group, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5Adestroy_group, FAIL);
if(grp<=BADGROUP || grp>=MAXGROUP)
HGOTO_DONE(FAIL);
@@ -285,7 +286,7 @@ hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in *
uintn hash_loc; /* new item's hash table location */
hid_t ret_value=SUCCEED;
- FUNC_ENTER (H5Aregister_atom, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5Aregister_atom, FAIL);
if(grp<=BADGROUP || grp>=MAXGROUP)
HGOTO_DONE(FAIL);
@@ -362,46 +363,39 @@ done:
/******************************************************************************
NAME
- H5Ainc_ref - Adds a reference to a reference counted atom.
-
+ H5A_inc_ref - Adds a reference to a reference counted atom.
+ IN: Atom to increment reference count for
DESCRIPTION
Increments the number of references outstanding for an atom. This will
fail if the group is not a reference counted group.
RETURNS
- SUCCEED/FAIL
+ atm/FAIL
*******************************************************************************/
-intn H5Ainc_ref(hid_t atm /* IN: Atom to increment reference count for */
-)
+hid_t
+H5A_inc_ref (hid_t atm)
{
- group_t grp=ATOM_TO_GROUP(atm); /* Group the object is in */
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- intn ret_value=FAIL;
-
- FUNC_ENTER (H5Ainc_ref, H5A_init_interface, FAIL);
-
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0 || grp_ptr->free_func==NULL)
- HGOTO_DONE(FAIL);
+ group_t grp = ATOM_TO_GROUP (atm); /* Group the object is in */
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ hid_t ret_value=FAIL;
- /* General lookup of the atom */
- if((atm_ptr=H5A_find_atom(atm))!=NULL)
- {
- atm_ptr->count++;
- ret_value=SUCCEED;
- } /* end if */
+ FUNC_ENTER (H5A_inc_ref, FAIL);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr==NULL || grp_ptr->count<=0 || grp_ptr->free_func==NULL) {
+ HRETURN (FAIL);
+ }
- } /* end if */
+ /* General lookup of the atom */
+ if ((atm_ptr=H5A_find_atom(atm))!=NULL) {
+ atm_ptr->count++;
+ ret_value=atm;
+ }
- /* Normal function cleanup */
- FUNC_LEAVE(ret_value);
-} /* end H5Ainc_ref() */
+ FUNC_LEAVE (ret_value);
+}
/******************************************************************************
NAME
@@ -423,7 +417,7 @@ VOIDP H5Aatom_object(hid_t atm /* IN: Atom to retrieve object for */
atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
VOIDP ret_value=NULL;
- FUNC_ENTER (H5Aatom_object, H5A_init_interface, NULL);
+ FUNC_ENTER (H5Aatom_object, NULL);
#ifdef ATOMS_ARE_CACHED
/* Look for the atom in the cache first */
@@ -479,7 +473,7 @@ group_t H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
{
group_t ret_value=BADGROUP;
- FUNC_ENTER (H5Aatom_group, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5Aatom_group, FAIL);
ret_value=ATOM_TO_GROUP(atm);
if(ret_value<=BADGROUP || ret_value>=MAXGROUP)
@@ -519,7 +513,7 @@ VOIDP H5Aremove_atom(hid_t atm /* IN: Atom to remove */
#endif /* ATOMS_ARE_CACHED */
VOIDP ret_value=NULL;
- FUNC_ENTER (H5Aremove_atom, H5A_init_interface, NULL);
+ FUNC_ENTER (H5Aremove_atom, NULL);
grp=ATOM_TO_GROUP(atm);
if(grp<=BADGROUP || grp>=MAXGROUP)
@@ -582,8 +576,8 @@ done:
/******************************************************************************
NAME
- H5Adec_ref - Decrements a reference to a reference counted atom.
-
+ H5A_dec_ref - Decrements a reference to a reference counted atom.
+ IN: Atom to decrement reference count for
DESCRIPTION
Decrements the number of references outstanding for an atom. This will
fail if the group is not a reference counted group. The atom group's
@@ -594,42 +588,37 @@ done:
SUCCEED/FAIL
*******************************************************************************/
-intn H5Adec_ref(hid_t atm /* IN: Atom to decrement reference count for */
-)
+intn
+H5A_dec_ref (hid_t atm)
{
- group_t grp=ATOM_TO_GROUP(atm); /* Group the object is in */
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- VOIDP obj; /* object to call 'free' function with */
- intn ret_value=FAIL;
-
- FUNC_ENTER (H5Adec_ref, H5A_init_interface, FAIL);
-
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0 || grp_ptr->free_func==NULL)
- HGOTO_DONE(FAIL);
-
- /* General lookup of the atom */
- if((atm_ptr=H5A_find_atom(atm))!=NULL)
- {
- /* Decrement the reference count */
- atm_ptr->count--;
-
- /* If the reference count is zero, remove the object from the group */
- if(atm_ptr->count==0 && (obj=H5Aremove_atom(atm))!=NULL)
- (*grp_ptr->free_func)(obj); /* call the user's 'free' function for the atom's information */
- ret_value=SUCCEED;
- } /* end if */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
- FUNC_LEAVE(ret_value);
-} /* end H5Adec_ref() */
+ group_t grp = ATOM_TO_GROUP(atm); /* Group the object is in */
+ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
+ VOIDP obj; /* object to call 'free' function with */
+ intn ret_value=FAIL;
+
+ FUNC_ENTER (H5A_dec_ref, FAIL);
+
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr==NULL || grp_ptr->count<=0 || grp_ptr->free_func==NULL) {
+ HRETURN (FAIL);
+ }
+
+ /* General lookup of the atom */
+ if ((atm_ptr=H5A_find_atom(atm))!=NULL) {
+ /* Decrement the reference count */
+ atm_ptr->count--;
+
+ /* If the reference count is zero, remove the object from the group */
+ if (0==atm_ptr->count && (obj=H5Aremove_atom(atm))!=NULL) {
+ /* call the user's 'free' function for the atom's information */
+ (*grp_ptr->free_func)(obj);
+ }
+ ret_value=SUCCEED;
+ }
+
+ FUNC_LEAVE (ret_value);
+}
/******************************************************************************
NAME
@@ -655,7 +644,7 @@ VOIDP H5Asearch_atom(group_t grp, /* IN: Group to search for the object i
intn i; /* local counting variable */
VOIDP ret_value=NULL;
- FUNC_ENTER (H5Asearch_atom, H5A_init_interface, NULL);
+ FUNC_ENTER (H5Asearch_atom, NULL);
if(grp<=BADGROUP || grp>=MAXGROUP)
HGOTO_DONE(NULL);
@@ -705,7 +694,7 @@ intn H5Ais_reserved(hid_t atm /* IN: Group to search for the object in */
group_t grp; /* atom's atomic group */
hbool_t ret_value=BFAIL;
- FUNC_ENTER (H5Ais_reserved, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5Ais_reserved, FAIL);
grp=ATOM_TO_GROUP(atm);
if(grp<=BADGROUP || grp>=MAXGROUP)
@@ -751,7 +740,7 @@ static atom_info_t *H5A_find_atom(hid_t atm /* IN: Atom to retrieve atom for *
uintn hash_loc; /* atom's hash table location */
atom_info_t *ret_value=NULL;
- FUNC_ENTER (H5A_find_atom, H5A_init_interface, NULL);
+ FUNC_ENTER (H5A_find_atom, NULL);
grp=ATOM_TO_GROUP(atm);
if(grp<=BADGROUP || grp>=MAXGROUP)
@@ -807,7 +796,7 @@ static atom_info_t *H5A_get_atom_node(void)
{
atom_info_t *ret_value=NULL;
- FUNC_ENTER (H5A_get_atom_node, H5A_init_interface, NULL);
+ FUNC_ENTER (H5A_get_atom_node, NULL);
if(atom_free_list!=NULL)
{
@@ -845,7 +834,7 @@ done:
static herr_t
H5A_release_atom_node(atom_info_t *atm)
{
- FUNC_ENTER (H5A_release_atom_node, H5A_init_interface, FAIL);
+ FUNC_ENTER (H5A_release_atom_node, FAIL);
/* Insert the atom at the beginning of the free list */
atm->next=atom_free_list;
diff --git a/src/H5AC.c b/src/H5AC.c
index e19a94f..19e177e 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -35,15 +35,17 @@
* Private file-scope variables.
*/
#define PABLO_MASK H5AC_mask
+#define INTERFACE_INIT NULL
static int interface_initialize_g = FALSE; /*initialized?*/
+
#ifdef H5AC_SORT_BY_ADDR
static H5AC_t *current_cache_g = NULL; /*for sorting */
#endif
/*-------------------------------------------------------------------------
- * Function: H5AC_new
+ * Function: H5AC_create
*
* Purpose: Initialize the cache just after a file is opened. The
* SIZE_HINT is the number of cache slots desired. If you
@@ -63,10 +65,10 @@ static H5AC_t *current_cache_g = NULL; /*for sorting */
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_new (H5F_t *f, intn size_hint)
+H5AC_create (H5F_t *f, intn size_hint)
{
H5AC_t *cache = NULL;
- FUNC_ENTER (H5AC_new, NULL, FAIL);
+ FUNC_ENTER (H5AC_create, FAIL);
assert (f);
assert (NULL==f->shared->cache);
@@ -103,7 +105,7 @@ herr_t
H5AC_dest (H5F_t *f)
{
H5AC_t *cache = NULL;
- FUNC_ENTER (H5AC_dest, NULL, FAIL);
+ FUNC_ENTER (H5AC_dest, FAIL);
assert (f);
assert (f->shared->cache);
@@ -184,7 +186,7 @@ H5AC_find_f (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
H5AC_slot_t *slot = NULL;
H5AC_t *cache = NULL;
- FUNC_ENTER (H5AC_find, NULL, NULL);
+ FUNC_ENTER (H5AC_find, NULL);
assert (f);
assert (f->shared->cache);
@@ -349,7 +351,7 @@ H5AC_flush (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
intn nslots;
H5AC_t *cache=NULL;
- FUNC_ENTER (H5AC_flush, NULL, FAIL);
+ FUNC_ENTER (H5AC_flush, FAIL);
assert (f);
assert (f->shared->cache);
@@ -465,7 +467,7 @@ H5AC_set (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
H5AC_slot_t *slot = NULL;
H5AC_t *cache=NULL;
- FUNC_ENTER (H5AC_set, NULL, FAIL);
+ FUNC_ENTER (H5AC_set, FAIL);
assert (f);
assert (f->shared->cache);
@@ -535,7 +537,7 @@ H5AC_rename (H5F_t *f, const H5AC_class_t *type,
herr_t status;
H5AC_t *cache=NULL;
- FUNC_ENTER (H5AC_rename, NULL, FAIL);
+ FUNC_ENTER (H5AC_rename, FAIL);
assert (f);
assert (f->shared->cache);
@@ -639,7 +641,7 @@ H5AC_protect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
}
#endif
- FUNC_ENTER (H5AC_protect, NULL, NULL);
+ FUNC_ENTER (H5AC_protect, NULL);
/* check args */
assert (f);
@@ -746,7 +748,7 @@ H5AC_unprotect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
H5AC_t *cache = NULL;
H5AC_slot_t *slot = NULL;
- FUNC_ENTER (H5AC_unprotect, NULL, FAIL);
+ FUNC_ENTER (H5AC_unprotect, FAIL);
/* check args */
assert (f);
@@ -830,7 +832,7 @@ H5AC_debug (H5F_t *f)
H5AC_t *cache = f->shared->cache;
double miss_rate;
- FUNC_ENTER (H5AC_debug, NULL, FAIL);
+ FUNC_ENTER (H5AC_debug, FAIL);
fprintf (stderr, "HDF5-DIAG: cache diagnostics for %s\n", f->name);
fprintf (stderr, " %18s %8s %8s %8s %8s+%-8s\n",
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 28710d9..f775ca0 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -111,7 +111,7 @@ 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_new (H5F_t *f, intn size_hint);
+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,
diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h
index 38a7512..501c0f9 100644
--- a/src/H5Aprivate.h
+++ b/src/H5Aprivate.h
@@ -81,9 +81,12 @@ typedef struct atom_group_struct_tag {
intn hash_size; /* size of the hash table to store the atoms in */
uintn atoms; /* current number of atoms held */
uintn nextid; /* atom ID to use for the next atom */
- void (*free_func)(void *); /* Pointer to function to call when releasing ref counted object */
+ herr_t (*free_func)(void *); /* Pointer to function to call when releasing ref counted object */
atom_info_t **atom_list;/* pointer to an array of ptrs to atoms */
}atom_group_t;
+intn H5A_dec_ref (hid_t atm);
+hid_t H5A_inc_ref (hid_t atm);
+
#endif
diff --git a/src/H5Apublic.h b/src/H5Apublic.h
index efae778..7c0d1c1 100644
--- a/src/H5Apublic.h
+++ b/src/H5Apublic.h
@@ -27,7 +27,17 @@ typedef enum {
BADGROUP=(-1), /* Invalid Group */
H5_ERR=0, /* Group ID for Error stack objects */
H5_FILE, /* Group ID for File objects */
- H5_TEMPLATE, /* Group ID for Template objects */
+ H5_TEMPLATE_0, /* Group ID for Template objects */
+ H5_TEMPLATE_1, /* Group ID for Template objects */
+ H5_TEMPLATE_2, /* Group ID for Template objects */
+ H5_TEMPLATE_3, /* Group ID for Template objects */
+ H5_TEMPLATE_4, /* Group ID for Template objects */
+ H5_TEMPLATE_5, /* Group ID for Template objects */
+ H5_TEMPLATE_6, /* Group ID for Template objects */
+ H5_TEMPLATE_7, /* Group ID for Template objects */
+#ifndef NDEBUG
+ H5_TEMPLATE_MAX, /* Not really a group ID */
+#endif
H5_DATATYPE, /* Group ID for Datatype objects */
H5_DATASPACE, /* Group ID for Dataspace objects */
H5_DATASET, /* Group ID for Dataset objects */
@@ -42,15 +52,16 @@ typedef int32 hid_t;
typedef intn (*H5Asearch_func_t)(const VOIDP obj, const VOIDP key);
/* # of bits to use for Group ID in each atom (change if MAXGROUP>16) */
-#define GROUP_BITS 4
-#define GROUP_MASK 0x0F
+#define GROUP_BITS 8
+#define GROUP_MASK 0xFF
/* # of bits to use for the Atom index in each atom (assumes 8-bit bytes) */
#define ATOM_BITS ((sizeof(hid_t)*8)-GROUP_BITS)
#define ATOM_MASK 0x0FFFFFFF
/* Combine a Group number and an atom index into an atom */
-#define MAKE_ATOM(g,i) ((((hid_t)(g)&GROUP_MASK)<<((sizeof(hid_t)*8)-GROUP_BITS))|((hid_t)(i)&ATOM_MASK))
+#define MAKE_ATOM(g,i) ((((hid_t)(g)&GROUP_MASK)<<ATOM_BITS)| \
+ ((hid_t)(i)&ATOM_MASK))
#ifdef __cplusplus
extern "C" {
@@ -73,7 +84,7 @@ extern "C" {
intn H5Ainit_group(group_t grp, /* IN: Group to initialize */
intn hash_size, /* IN: Minimum hash table size to use for group */
uintn reserved, /* IN: Number of hash table entries to reserve */
- void (*free_func)(void *) /* IN: Function to call when releasing ref counted objects */
+ herr_t (*free_func)(void *) /* IN: Function to call when releasing ref counted objects */
);
/******************************************************************************
@@ -115,21 +126,6 @@ hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in *
/******************************************************************************
NAME
- H5Ainc_ref - Adds a reference to a reference counted atom.
-
- DESCRIPTION
- Increments the number of references outstanding for an atom. This will
- fail if the group is not a reference counted group.
-
- RETURNS
- SUCCEED/FAIL
-
-*******************************************************************************/
-intn H5Ainc_ref(hid_t atm /* IN: Atom to increment reference count for */
-);
-
-/******************************************************************************
- NAME
H5Aatom_object - Returns to the object ptr for the atom
DESCRIPTION
@@ -170,22 +166,6 @@ group_t H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
VOIDP H5Aremove_atom(hid_t atm /* IN: Atom to remove */
);
-/******************************************************************************
- NAME
- H5Adec_ref - Decrements a reference to a reference counted atom.
-
- DESCRIPTION
- Decrements the number of references outstanding for an atom. This will
- fail if the group is not a reference counted group. The atom group's
- 'free' function will be called for the atom if the reference count for the
- atom reaches 0.
-
- RETURNS
- SUCCEED/FAIL
-
-*******************************************************************************/
-intn H5Adec_ref(hid_t atm /* IN: Atom to decrement reference count for */
-);
/******************************************************************************
NAME
diff --git a/src/H5B.c b/src/H5B.c
index 23bc08c..e38f482 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -131,12 +131,13 @@ static const H5AC_class_t H5AC_BT[1] = {{
(herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5B_flush,
}};
-/* Is the H5B interface initialized? */
+/* Interface initialization? */
+#define INTERFACE_INIT NULL
static interface_initialize_g = FALSE;
/*-------------------------------------------------------------------------
- * Function: H5B_new
+ * Function: H5B_create
*
* Purpose: Creates a new empty B-tree leaf node. The UDATA pointer is
* passed as an argument to the sizeof_rkey() method for the
@@ -156,14 +157,14 @@ static interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5B_new (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
+H5B_create (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
{
H5B_t *bt=NULL;
size_t size, sizeof_rkey;
size_t total_native_keysize;
intn offset, i;
- FUNC_ENTER (H5B_new, NULL, FAIL);
+ FUNC_ENTER (H5B_create, FAIL);
/*
* Check arguments.
@@ -202,7 +203,7 @@ H5B_new (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
*/
for (i=0,offset=H5B_SIZEOF_HDR(f);
i<2*H5B_K(f,type);
- i++,offset+=bt->sizeof_rkey+H5F_SIZEOF_OFFSET(f)) {
+ i++,offset+=bt->sizeof_rkey+H5F_SIZEOF_ADDR(f)) {
bt->key[i].dirty = FALSE;
bt->key[i].rkey = bt->page + offset;
@@ -258,7 +259,7 @@ H5B_load (H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
uint8 *p;
H5B_t *ret_value = NULL;
- FUNC_ENTER (H5B_load, NULL, NULL);
+ FUNC_ENTER (H5B_load, NULL);
/* Check arguments */
assert (f);
@@ -312,7 +313,7 @@ H5B_load (H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
H5F_addr_decode (f, (const uint8**)&p, bt->child+i);
} else {
H5F_addr_undef (bt->child+i);
- p += H5F_SIZEOF_OFFSET(f);
+ p += H5F_SIZEOF_ADDR(f);
}
}
@@ -358,7 +359,7 @@ H5B_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
size_t size = 0;
uint8 *p = bt->page;
- FUNC_ENTER (H5B_flush, NULL, FAIL);
+ FUNC_ENTER (H5B_flush, FAIL);
/*
* Check arguments.
@@ -408,7 +409,7 @@ H5B_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
if (i<bt->ndirty) {
H5F_addr_encode (f, &p, &(bt->child[i]));
} else {
- p += H5F_SIZEOF_OFFSET(f);
+ p += H5F_SIZEOF_ADDR(f);
}
}
@@ -469,7 +470,7 @@ H5B_find (H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
intn idx=-1, lt=0, rt, cmp=1;
int ret_value = FAIL;
- FUNC_ENTER (H5B_find, NULL, FAIL);
+ FUNC_ENTER (H5B_find, FAIL);
/*
* Check arguments.
@@ -567,7 +568,7 @@ H5B_split (H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
intn i, k;
size_t recsize = 0;
- FUNC_ENTER (H5B_split, NULL, FAIL);
+ FUNC_ENTER (H5B_split, FAIL);
/*
* Check arguments.
@@ -580,13 +581,13 @@ H5B_split (H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
* Initialize variables.
*/
assert (old_bt->nchildren == 2*H5B_K(f,type));
- recsize = old_bt->sizeof_rkey + H5F_SIZEOF_OFFSET(f);
+ recsize = old_bt->sizeof_rkey + H5F_SIZEOF_ADDR(f);
k = H5B_K(f,type);
/*
* Create the new B-tree node.
*/
- if (H5B_new (f, type, udata, new_addr/*out*/)<0) {
+ if (H5B_create (f, type, udata, new_addr/*out*/)<0) {
HGOTO_ERROR (H5E_BTREE, H5E_CANTINIT, FAIL);
}
if (NULL==(new_bt=H5AC_protect (f, H5AC_BT, new_addr, type, udata))) {
@@ -671,7 +672,7 @@ done:
static herr_t
H5B_decode_key (H5F_t *f, H5B_t *bt, intn idx)
{
- FUNC_ENTER (H5B_decode_key, NULL, FAIL);
+ FUNC_ENTER (H5B_decode_key, FAIL);
bt->key[idx].nkey = bt->native + idx * bt->type->sizeof_nkey;
if ((bt->type->decode)(f, bt, bt->key[idx].rkey,
@@ -702,7 +703,7 @@ 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)
{
- FUNC_ENTER (H5B_decode_keys, NULL, FAIL);
+ FUNC_ENTER (H5B_decode_keys, FAIL);
assert (f);
assert (bt);
@@ -750,7 +751,7 @@ H5B_insert (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
uint8 *buf;
H5B_ins_t my_ins = H5B_INS_ERROR;
- FUNC_ENTER (H5B_insert, NULL, FAIL);
+ FUNC_ENTER (H5B_insert, FAIL);
/*
* Check arguments.
@@ -891,12 +892,12 @@ H5B_insert_child (H5F_t *f, const H5B_class_t *type, H5B_t *bt,
size_t recsize;
intn i;
- FUNC_ENTER (H5B_insert_child, NULL, FAIL);
+ FUNC_ENTER (H5B_insert_child, FAIL);
assert (bt);
assert (child);
bt->dirty = TRUE;
- recsize = bt->sizeof_rkey + H5F_SIZEOF_OFFSET(f);
+ recsize = bt->sizeof_rkey + H5F_SIZEOF_ADDR(f);
if (H5B_INS_RIGHT==anchor) {
/*
@@ -1005,7 +1006,7 @@ H5B_insert_helper (H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
H5B_ins_t my_ins = H5B_INS_ERROR;
H5B_ins_t ret_value = H5B_INS_ERROR;
- FUNC_ENTER (H5B_insert_helper, NULL, H5B_INS_ERROR);
+ FUNC_ENTER (H5B_insert_helper, H5B_INS_ERROR);
/*
* Check arguments
@@ -1362,7 +1363,7 @@ H5B_list (H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
intn i;
herr_t ret_value = FAIL;
- FUNC_ENTER (H5B_list, NULL, FAIL);
+ FUNC_ENTER (H5B_list, FAIL);
/*
* Check arguments.
@@ -1442,7 +1443,7 @@ H5B_nodesize (H5F_t *f, const H5B_class_t *type,
{
size_t size;
- FUNC_ENTER (H5B_nodesize, NULL, (size_t)0);
+ FUNC_ENTER (H5B_nodesize, (size_t)0);
/*
* Check arguments.
@@ -1463,7 +1464,7 @@ H5B_nodesize (H5F_t *f, const H5B_class_t *type,
* Total node size.
*/
size = (H5B_SIZEOF_HDR(f) + /*node header */
- 2 * H5B_K(f,type) * H5F_SIZEOF_OFFSET(f) + /*child pointers*/
+ 2 * H5B_K(f,type) * H5F_SIZEOF_ADDR(f) + /*child pointers*/
(2*H5B_K(f,type)+1) * sizeof_rkey); /*keys */
FUNC_LEAVE (size);
@@ -1494,7 +1495,7 @@ H5B_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
H5B_t *bt = NULL;
int i;
- FUNC_ENTER (H5B_debug, NULL, FAIL);
+ FUNC_ENTER (H5B_debug, FAIL);
/*
* Check arguments.
@@ -1596,7 +1597,7 @@ H5B_assert (H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
struct child_t *next;
} *head=NULL, *tail=NULL, *prev=NULL, *cur=NULL, *tmp=NULL;
- FUNC_ENTER (H5B_assert, NULL, FAIL);
+ FUNC_ENTER (H5B_assert, FAIL);
if (0==ncalls++) {
fprintf (stderr, "HDF5-DIAG: debugging B-trees (expensive)\n");
}
diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h
index 8438ae2..0719238 100644
--- a/src/H5Bprivate.h
+++ b/src/H5Bprivate.h
@@ -39,10 +39,10 @@
#define H5B_SIZEOF_HDR(F) \
(H5B_SIZEOF_MAGIC + /*magic number */ \
4 + /*type, level, num entries */ \
- 2*H5F_SIZEOF_OFFSET(F)) /*left and right sibling addresses */
+ 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */
#define H5B_K(F,TYPE) /*K value given file and Btree subclass */ \
- ((F)->shared->file_create_parms.btree_k[(TYPE)->id])
+ ((F)->shared->create_parms.btree_k[(TYPE)->id])
typedef enum H5B_ins_t {
H5B_INS_ERROR =-1, /*error return value */
@@ -114,7 +114,7 @@ typedef struct H5B_t {
*/
herr_t H5B_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
intn fwidth, const H5B_class_t *type, void *udata);
-herr_t H5B_new (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t*);
+herr_t H5B_create (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t*);
herr_t H5B_find (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
void *udata);
herr_t H5B_insert (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
diff --git a/src/H5C.c b/src/H5C.c
index 0ccef61..d65e4b7 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -37,33 +37,20 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Aprivate.h> /* Atoms */
#include <H5Bprivate.h> /* B-tree subclass names */
#include <H5Cprivate.h> /* Template information */
+#include <H5Dprivate.h> /* Datasets */
#include <H5Eprivate.h> /* Error handling */
+#include <H5MMprivate.h> /* Memory management */
#define PABLO_MASK H5C_mask
-/*--------------------- Locally scoped variables -----------------------------*/
-
-/* Whether we've installed the library termination function yet for this interface */
-static intn interface_initialize_g = FALSE;
-
-/* Define the library's default file creation template (constants in hdf5lims.h) */
-const file_create_temp_t default_file_create={
- H5C_USERBLOCK_DEFAULT, /* Default user-block size */
- H5C_SYM_LEAF_K_DEFAULT, /* Default 1/2 rank for symtab leaf nodes */
- H5C_BTREE_K_DEFAULT, /* Default 1/2 rank for btree internal nodes */
- H5C_OFFSETSIZE_DEFAULT, /* Default offset size */
- H5C_LENGTHSIZE_DEFAULT, /* Default length size */
- HDF5_BOOTBLOCK_VERSION, /* Current Boot-Block version # */
- HDF5_SMALLOBJECT_VERSION, /* Current Small-Object heap version # */
- HDF5_FREESPACE_VERSION, /* Current Free-Space info version # */
- HDF5_OBJECTDIR_VERSION, /* Current Object Directory info version # */
- HDF5_SHAREDHEADER_VERSION /* Current Shared-Header format version # */
-};
-static hid_t default_file_id=FAIL; /* Atom for the default file-creation template */
-
-/*--------------------- Local function prototypes ----------------------------*/
+/* Is the interface initialized? */
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5C_init_interface
static herr_t H5C_init_interface(void);
+/* PRIVATE PROTOTYPES */
+static void H5C_term_interface (void);
+
/*--------------------------------------------------------------------------
NAME
H5C_init_interface -- Initialize interface-specific information
@@ -76,18 +63,37 @@ DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t H5C_init_interface(void)
+static herr_t
+H5C_init_interface (void)
{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER (H5C_init_interface, NULL, FAIL);
-
- /* Initialize the atom group for the file IDs */
- if((ret_value=H5Ainit_group(H5_TEMPLATE,H5A_TEMPID_HASHSIZE,0,NULL))!=FAIL)
- ret_value=H5_add_exit(&H5C_term_interface);
-
- FUNC_LEAVE(ret_value);
-} /* H5C_init_interface */
+ herr_t ret_value = SUCCEED;
+ intn i;
+ herr_t status;
+
+ FUNC_ENTER (H5C_init_interface, FAIL);
+
+ assert (H5C_NCLASSES <= H5_TEMPLATE_MAX-H5_TEMPLATE_0);
+
+ /*
+ * Initialize the mappings between template classes and atom groups. We
+ * keep the two separate because template classes are publicly visible but
+ * atom groups aren't.
+ */
+ for (i=0; i<H5C_NCLASSES; i++) {
+ status = H5Ainit_group (H5_TEMPLATE_0+i, H5A_TEMPID_HASHSIZE, 0, NULL);
+ if (status<0) ret_value = FAIL;
+ }
+ if (ret_value<0) HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL);
+
+ /*
+ * Register cleanup function.
+ */
+ if (H5_add_exit (H5C_term_interface)<0) {
+ HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL);
+ }
+
+ FUNC_LEAVE(ret_value);
+}
/*--------------------------------------------------------------------------
NAME
@@ -106,209 +112,185 @@ static herr_t H5C_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void H5C_term_interface (void)
+static void
+H5C_term_interface (void)
{
- H5Aremove_atom(default_file_id);
- H5Adestroy_group(H5_TEMPLATE);
-} /* end H5C_term_interface() */
+ intn i;
-/*--------------------------------------------------------------------------
- NAME
- H5C_get_default_atom
- PURPOSE
- Retrive an atom for a default HDF5 template.
- USAGE
- hid_t H5C_create(type)
- hobjtype_t type; IN: Type of object to retrieve default template of
- RETURNS
- Returns template ID (atom) of the default object for a template type on
- success, FAIL on failure
- DESCRIPTION
- This is function retrieves atoms for the default templates for the
- different types of HDF5 templates.
-
- MODIFICATIONS
- Robb Matzke, 4 Aug 1997
- The `FUNC' auto variable was changed from `H5C_create' to
- `H5C_get_default_atom'.
---------------------------------------------------------------------------*/
-hid_t H5C_get_default_atom(hobjtype_t type)
-{
- hid_t ret_value = FAIL;
-
- FUNC_ENTER(H5C_get_default_atom, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- switch(type)
- {
- case H5_TEMPLATE:
- if(default_file_id==FAIL)
- {
- if((default_file_id=H5Aregister_atom(H5_TEMPLATE, (const void *)&default_file_create))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
- } /* end else */
- HGOTO_DONE(default_file_id);
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
- } /* end switch */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5C_get_default_atom() */
+ for (i=0; i<H5C_NCLASSES; i++) {
+ H5Adestroy_group (H5_TEMPLATE_0+i);
+ }
+}
/*--------------------------------------------------------------------------
NAME
- H5C_init
+ H5Ccreate
PURPOSE
- Initialize a new HDF5 template with a copy of an existing template.
+ Returns a copy of the default template for some class of templates.
USAGE
- herr_t H5C_init(dst_atm, src)
- hid_t dst_atm; IN: Atom for the template to initialize
- file_create_temp_t *src; IN: Template to use to initialize with
+ herr_t H5Ccreate (type)
+ H5C_class_t type; IN: Template class whose default is desired.
RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function copies the contents of the source template into the
- newly created destination template.
---------------------------------------------------------------------------*/
-herr_t H5C_init(hid_t dst_atm, const file_create_temp_t *src)
-{
- file_create_temp_t *dst; /* destination template */
- herr_t ret_value = SUCCEED; /* return value */
-
- FUNC_ENTER(H5C_init, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(src==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- /* Get the template to initialize */
- if((dst=H5Aatom_object(dst_atm))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Copy in the source template */
- HDmemcpy(dst,src,sizeof(file_create_temp_t));
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5C_init() */
+ Template ID or FAIL
+
+ ERRORS
+ ARGS BADVALUE Unknown template class.
+ ATOM CANTINIT Can't register template.
+ INTERNAL UNSUPPORTED Not implemented yet.
-/*--------------------------------------------------------------------------
- NAME
- H5C_create
- PURPOSE
- Create a new HDF5 template.
- USAGE
- hid_t H5C_create(owner_id, type, name)
- hid_t owner_id; IN: Group/file which owns this template
- hobjtype_t type; IN: Type of template to create
- const char *name; IN: Name of the template to create
- RETURNS
- Returns template ID (atom) on success, FAIL on failure
DESCRIPTION
- This is the primary function for creating different HDF5 templates.
- Currently the name of template is not used and may be NULL.
+ Returns a copy of the default template for some class of templates.
--------------------------------------------------------------------------*/
-hid_t H5C_create(hid_t owner_id, hobjtype_t type, const char *name)
+hid_t
+H5Ccreate (H5C_class_t type)
{
- hid_t ret_value = FAIL; /* atom for template object to return */
-
- FUNC_ENTER(H5C_create, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- switch(type)
- {
- case H5_TEMPLATE:
- {
- file_create_temp_t *new_create_temp; /* new template object to create */
-
- if((new_create_temp=HDmalloc(sizeof(file_create_temp_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- if((ret_value=H5Aregister_atom(H5_TEMPLATE, (const VOIDP)new_create_temp))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
- } /* end case/block */
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
- } /* end switch */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ hid_t ret_value = FAIL;
+ void *tmpl = NULL;
+
+ FUNC_ENTER (H5Ccreate, FAIL);
+
+ /* Allocate a new template and initialize it with default values */
+ switch (type) {
+ case H5C_FILE_CREATE:
+ tmpl = H5MM_xmalloc (sizeof(H5F_create_t));
+ memcpy (tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
+ break;
+
+ case H5C_FILE_ACCESS:
+ /* Not implemented yet */
+ HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+
+ case H5C_DATASET_CREATE:
+ tmpl = H5MM_xmalloc (sizeof(H5D_create_t));
+ memcpy (tmpl, &H5D_create_dflt, sizeof(H5D_create_t));
+ break;
+
+ case H5C_DATASET_XFER:
+ tmpl = H5MM_xmalloc (sizeof(H5D_xfer_t));
+ memcpy (tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t));
+ break;
+
+ default:
+ /* Unknown template class */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
+ }
+
+ /* Atomize the new template */
+ if ((ret_value = H5C_create (type, tmpl))<0) {
+ HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL); /*can't register template*/
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5C_create
+ *
+ * Purpose: Given a pointer to some template struct, atomize the template
+ * and return its ID. The template memory is not copied, so the
+ * caller should not free it; it will be freed by H5C_release().
+ *
+ * Return: Success: A new template ID.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5C_create (H5C_class_t type, void *tmpl)
+{
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER (H5C_create, FAIL);
- /* Normal function cleanup */
+ /* check args */
+ assert (type>=0 && type<H5C_NCLASSES);
+ assert (tmpl);
- FUNC_LEAVE(ret_value);
-} /* end H5C_create() */
+ /* Atomize the new template */
+ if ((ret_value = H5Aregister_atom (H5_TEMPLATE_0+type, tmpl))<0) {
+ HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL); /*can't register template*/
+ }
+ FUNC_LEAVE (ret_value);
+}
+
/*--------------------------------------------------------------------------
NAME
- H5C_release
+ H5Cclose
PURPOSE
Release access to a template object.
USAGE
- herr_t H5C_release(oid)
+ herr_t H5Cclose(oid)
hid_t oid; IN: Template object to release access to
RETURNS
SUCCEED/FAIL
DESCRIPTION
This function releases access to a template object
--------------------------------------------------------------------------*/
-herr_t H5C_release(hid_t oid)
+herr_t
+H5Cclose (hid_t template)
{
- file_create_temp_t *template; /* template to destroy */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5C_release, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Chuck the object! :-) */
- if((template=H5Aremove_atom(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- HDfree(template);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
+ void *tmpl=NULL;
+
+ FUNC_ENTER (H5Cclose, FAIL);
+
+ /* Chuck the object! :-) */
+ if (NULL==(tmpl=H5Aremove_atom (template))) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
+ }
+ H5MM_xfree (tmpl);
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5C_class
+ *
+ * Purpose: Returns the class identifier for a template.
+ *
+ * Return: Success: A template class
+ *
+ * Failure: H5C_NO_CLASS (-1)
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5C_class_t
+H5C_class (hid_t template)
+{
+ group_t group;
+ H5C_class_t ret_value = H5C_NO_CLASS;
+
+ FUNC_ENTER (H5C_class, H5C_NO_CLASS);
+
+ if ((group = H5Aatom_group (template))<0 ||
+ group<H5_TEMPLATE_0 || group>=H5_TEMPLATE_MAX) {
+ /* not a template */
+ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, H5C_NO_CLASS);
+ }
- FUNC_LEAVE(ret_value);
-} /* end H5C_release() */
+ ret_value = group - H5_TEMPLATE_0;
+ FUNC_LEAVE (ret_value);
+}
/*--------------------------------------------------------------------------
NAME
H5Cgetparm
PURPOSE
- Get a parameter from a template
+ Get a property value from a template
USAGE
herr_t H5Cgetparm(tid, parm, buf)
hid_t tid; IN: Template object to retrieve parameter from
@@ -316,6 +298,16 @@ done:
VOIDP buf; OUT: Pointer to buffer to store parameter in
RETURNS
SUCCEED/FAIL
+
+ ERRORS
+ ARGS BADRANGE No result buffer argument supplied.
+ ARGS BADRANGE Unknown property for dataset create template.
+ ARGS BADRANGE Unknown property for dataset transfer template.
+ ARGS BADRANGE Unknown property for file access template.
+ ARGS BADRANGE Unknown property for file create template.
+ ARGS BADRANGE Unknown template class.
+ ATOM BADTYPE Can't unatomize template.
+
DESCRIPTION
This function retrieves the value of a specific parameter from a
template
@@ -328,85 +320,119 @@ done:
Robb Matzke, 17 Oct 1997
Added H5_ISTORE_K.
--------------------------------------------------------------------------*/
-herr_t H5Cgetparm(hid_t tid, file_create_param_t parm, VOIDP buf)
+herr_t
+H5Cgetparm (hid_t template, H5C_prop_t prop, void *buf)
{
- file_create_temp_t *template; /* template to query */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Cgetparm, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(H5Aatom_group(tid)!=H5_TEMPLATE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- if(buf==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- /* Get a pointer the template to query */
- if((template=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- switch(parm)
- {
- case H5_USERBLOCK_SIZE:
- *(uintn *)buf=template->userblock_size;
- break;
-
- case H5_OFFSET_SIZE:
- *(uint8 *)buf=template->sizeof_addr;
- break;
-
- case H5_LENGTH_SIZE:
- *(uint8 *)buf=template->sizeof_size;
- break;
-
- case H5_SYM_LEAF_K:
- *(uintn *)buf=template->sym_leaf_k;
- break;
-
- case H5_SYM_INTERN_K:
- *(uintn *)buf = template->btree_k[H5B_SNODE_ID];
- break;
-
- case H5_ISTORE_K:
- *(uintn *)buf = template->btree_k[H5B_ISTORE_ID];
- break;
-
- case H5_BOOTBLOCK_VER:
- *(uint8 *)buf=template->bootblock_ver;
- break;
-
- case H5_SMALLOBJECT_VER:
- *(uint8 *)buf=template->smallobject_ver;
- break;
-
- case H5_FREESPACE_VER:
- *(uint8 *)buf=template->freespace_ver;
- break;
-
- case H5_OBJECTDIR_VER:
- *(uint8 *)buf=template->objectdir_ver;
- break;
-
- case H5_SHAREDHEADER_VER:
- *(uint8 *)buf=template->sharedheader_ver;
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
- } /* end switch */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
- /* none */
- } /* end if */
-
- /* Normal function cleanup */
- /* none */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Cgetparm() */
+ H5C_class_t type;
+
+ const void *tmpl=NULL;
+ const H5F_create_t *file_create=NULL;
+ const H5D_create_t *dset_create=NULL;
+
+ FUNC_ENTER (H5Cgetparm, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (NULL==(tmpl = H5Aatom_object (template)) ||
+ (type=H5C_class (template))<0) {
+ /* Can't unatomize template */
+ HRETURN_ERROR (H5E_ATOM, H5E_BADTYPE, FAIL);
+ }
+ if (!buf) {
+ /* No result buffer argument supplied */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+
+ /* Handle each class of template */
+ switch (type) {
+ case H5C_FILE_CREATE:
+ file_create = (const H5F_create_t *)tmpl;
+ switch (prop) {
+ case H5F_USERBLOCK_SIZE:
+ *(uintn *)buf=file_create->userblock_size;
+ break;
+
+ case H5F_OFFSET_SIZE:
+ *(uint8 *)buf=file_create->sizeof_addr;
+ break;
+
+ case H5F_LENGTH_SIZE:
+ *(uint8 *)buf=file_create->sizeof_size;
+ break;
+
+ case H5F_SYM_LEAF_K:
+ *(uintn *)buf=file_create->sym_leaf_k;
+ break;
+
+ case H5F_SYM_INTERN_K:
+ *(uintn *)buf = file_create->btree_k[H5B_SNODE_ID];
+ break;
+
+ case H5F_ISTORE_K:
+ *(uintn *)buf = file_create->btree_k[H5B_ISTORE_ID];
+ break;
+
+ case H5F_BOOTBLOCK_VER:
+ *(uint8 *)buf=file_create->bootblock_ver;
+ break;
+
+ case H5F_SMALLOBJECT_VER:
+ *(uint8 *)buf=file_create->smallobject_ver;
+ break;
+
+ case H5F_FREESPACE_VER:
+ *(uint8 *)buf=file_create->freespace_ver;
+ break;
+
+ case H5F_OBJECTDIR_VER:
+ *(uint8 *)buf=file_create->objectdir_ver;
+ break;
+
+ case H5F_SHAREDHEADER_VER:
+ *(uint8 *)buf=file_create->sharedheader_ver;
+ break;
+
+ default:
+ /* Unknown property for file create template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ break;
+
+ case H5C_FILE_ACCESS:
+ /* Unknown property for file access template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+
+ case H5C_DATASET_CREATE:
+ dset_create = (const H5D_create_t *)tmpl;
+ switch (prop) {
+ case H5D_LAYOUT:
+ *(H5D_layout_t*)buf = dset_create->layout;
+ break;
+
+ case H5D_CHUNK_NDIMS:
+ case H5D_CHUNK_SIZE:
+ case H5D_COMPRESS:
+ case H5D_PRE_OFFSET:
+ case H5D_PRE_SCALE:
+ /* Not implemented yet */
+ HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+
+ default:
+ /* Unknown property for dataset create template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ break;
+
+ case H5C_DATASET_XFER:
+ /* Unknown property for dataset transfer template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+
+ default:
+ /* Unknown template class */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ FUNC_LEAVE (SUCCEED);
+}
/*--------------------------------------------------------------------------
NAME
@@ -420,6 +446,24 @@ done:
const VOIDP buf; IN: Pointer to parameter buffer
RETURNS
SUCCEED/FAIL
+
+ ERRORS
+ ARGS BADRANGE Indexed storage internal node 1/2 rank is not
+ valid.
+ ARGS BADRANGE No buffer argument specified.
+ ARGS BADRANGE Symbol internal node 1/2 rank is not valid.
+ ARGS BADRANGE Symbol leaf node 1/2 rank is not valid.
+ ARGS BADRANGE This is a read-only property.
+ ARGS BADRANGE Unknown file creation property.
+ ARGS BADRANGE Unknown property for dataset create template.
+ ARGS BADRANGE Unknown property for dataset transfer template.
+ ARGS BADRANGE Unknown property for file access template.
+ ARGS BADRANGE Unknown template class.
+ ARGS BADVALUE File haddr_t size is not valid.
+ ARGS BADVALUE File size_t size is not valid.
+ ARGS BADVALUE Userblock size is not valid.
+ ATOM BADTYPE Can't unatomize template.
+
DESCRIPTION
This function stores the value of a specific parameter for a template
@@ -441,117 +485,154 @@ done:
Robb Matzke, 17 Oct 1997
Added H5_ISTORE_K.
--------------------------------------------------------------------------*/
-herr_t H5Csetparm(hid_t tid, file_create_param_t parm, const VOIDP buf)
+herr_t
+H5Csetparm (hid_t template, H5C_prop_t prop, const void *buf)
{
- file_create_temp_t *template; /* template to query */
- herr_t ret_value = SUCCEED;
- uintn val;
- intn i;
-
- FUNC_ENTER(H5Csetparm, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(H5Aatom_group(tid)!=H5_TEMPLATE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- if(buf==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- /* Get a pointer the template to query */
- if((template=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- switch(parm)
- {
- case H5_USERBLOCK_SIZE:
- val = *(const uintn *)buf;
- for (i=8; i<8*sizeof(int); i++) {
- uintn p2 = 8==i ? 0 :1<<i;
- if (val==p2) break;
- }
- if (i>=8*sizeof(int)) {
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
- }
- template->userblock_size=val;
- break;
-
- case H5_OFFSET_SIZE:
- val = *(const uint8 *)buf;
- if(!(val==2 || val==4 || val==8 || val==16 || val==32 || val==64 || val==128 || val==256))
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
- template->sizeof_addr=val;
- break;
-
- case H5_LENGTH_SIZE:
- val = *(const uint8 *)buf;
- if(!(val==2 || val==4 || val==8 || val==16 || val==32 || val==64 || val==128 || val==256))
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
- template->sizeof_size=val;
- break;
-
- case H5_SYM_LEAF_K:
- val = *(const uintn *)buf;
- if (val<2) {
- HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
- }
- template->sym_leaf_k = val;
- break;
-
- case H5_SYM_INTERN_K:
- val = *(const uintn *)buf;
- if (val<2) {
- HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
- }
- template->btree_k[H5B_SNODE_ID] = val;
- break;
-
- case H5_ISTORE_K:
- val = *(const uintn *)buf;
- if (val<2) {
- HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
- }
- template->btree_k[H5B_ISTORE_ID] = val;
- break;
+ void *tmpl = NULL;
+ H5F_create_t *file_create = NULL;
+ H5D_create_t *dset_create = NULL;
+ H5C_class_t type;
+ H5D_layout_t layout;
+ uintn val;
+ intn i;
+
+ FUNC_ENTER (H5Csetparm, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (NULL==(tmpl = H5Aatom_object (template)) ||
+ (type = H5C_class (template))<0) {
+ /* Can't unatomize template */
+ HRETURN_ERROR (H5E_ATOM, H5E_BADTYPE, FAIL);
+ }
+ if (!buf) {
+ /* No buffer argument specified */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+
+ /* Handle each class of template */
+ switch (type) {
+ case H5C_FILE_CREATE:
+ file_create = (H5F_create_t *)tmpl;
+
+ switch (prop) {
+ case H5F_USERBLOCK_SIZE:
+ val = *(const uintn *)buf;
+ for (i=8; i<8*sizeof(int); i++) {
+ uintn p2 = 8==i ? 0 :1<<i;
+ if (val==p2) break;
+ }
+ if (i>=8*sizeof(int)) {
+ /* Userblock size is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
+ }
+ file_create->userblock_size=val;
+ break;
+
+ case H5F_OFFSET_SIZE:
+ val = *(const uint8 *)buf;
+ if (val!=2 && val!=4 && val!=8 && val!=16) {
+ /* file haddr_t size is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
+ }
+ file_create->sizeof_addr=val;
+ break;
+
+ case H5F_LENGTH_SIZE:
+ val = *(const uint8 *)buf;
+ if(val!=2 && val!=4 && val!=8 && val!=16) {
+ /* file size_t size is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL);
+ }
+ file_create->sizeof_size=val;
+ break;
+
+ case H5F_SYM_LEAF_K:
+ val = *(const uintn *)buf;
+ if (val<2) {
+ /* Symbol leaf node 1/2 rank is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ file_create->sym_leaf_k = val;
+ break;
+
+ case H5F_SYM_INTERN_K:
+ val = *(const uintn *)buf;
+ if (val<2) {
+ /* Symbol internal node 1/2 rank is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ file_create->btree_k[H5B_SNODE_ID] = val;
+ break;
+
+ case H5F_ISTORE_K:
+ val = *(const uintn *)buf;
+ if (val<2) {
+ /* Indexed storage internal node 1/2 rank is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ file_create->btree_k[H5B_ISTORE_ID] = val;
+ break;
- case H5_BOOTBLOCK_VER: /* this should be range checked */
- template->bootblock_ver=*(const uint8 *)buf;
- break;
-
- case H5_SMALLOBJECT_VER: /* this should be range checked */
- template->smallobject_ver=*(const uint8 *)buf;
- break;
-
- case H5_FREESPACE_VER: /* this should be range checked */
- template->freespace_ver=*(const uint8 *)buf;
- break;
-
- case H5_OBJECTDIR_VER: /* this should be range checked */
- template->objectdir_ver=*(const uint8 *)buf;
- break;
-
- case H5_SHAREDHEADER_VER: /* this should be range checked */
- template->sharedheader_ver=*(const uint8 *)buf;
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
- } /* end switch */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
- /* none */
- } /* end if */
-
- /* Normal function cleanup */
- /* none */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Csetparm() */
+ case H5F_BOOTBLOCK_VER:
+ case H5F_SMALLOBJECT_VER:
+ case H5F_FREESPACE_VER:
+ case H5F_OBJECTDIR_VER:
+ case H5F_SHAREDHEADER_VER:
+ /* This is a read-only property */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+
+ default:
+ /* Unknown file creation property */
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ break;
+
+ case H5C_FILE_ACCESS:
+ /* Unknown property for file access template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+
+ case H5C_DATASET_CREATE:
+ dset_create = (H5D_create_t *)tmpl;
+ switch (prop) {
+ case H5D_LAYOUT:
+ layout = *(const H5D_layout_t*)buf;
+ if (layout<0 || layout>=H5D_NLAYOUTS) {
+ /* Raw data layout method is not valid */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ dset_create->layout = layout;
+ break;
+
+ case H5D_CHUNK_NDIMS:
+ case H5D_CHUNK_SIZE:
+ case H5D_COMPRESS:
+ case H5D_PRE_OFFSET:
+ case H5D_PRE_SCALE:
+ /* Not implemented yet */
+ HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+
+ default:
+ /* Unknown property for dataset create template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+ break;
+
+ case H5C_DATASET_XFER:
+ /* Unknown property for dataset transfer template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+
+ default:
+ /* Unknown template class */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
/*--------------------------------------------------------------------------
NAME
- H5C_copy
+ H5Ccopy
PURPOSE
Copy a template
USAGE
@@ -559,43 +640,71 @@ done:
hid_t tid; IN: Template object to copy
RETURNS
Returns template ID (atom) on success, FAIL on failure
+
+ ERRORS
+ ARGS BADRANGE Unknown template class.
+ ATOM BADATOM Can't unatomize template.
+ ATOM CANTREGISTER Register the atom for the new template.
+ INTERNAL UNSUPPORTED Dataset transfer properties are not implemented
+ yet.
+ INTERNAL UNSUPPORTED File access properties are not implemented yet.
+
DESCRIPTION
This function creates a new copy of a template with all the same parameter
settings.
--------------------------------------------------------------------------*/
-hid_t H5C_copy(hid_t tid)
+hid_t
+H5Ccopy (hid_t template)
{
- file_create_temp_t *template, *new_template; /* template to query */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5C_copy, H5C_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Get a pointer the template to query */
- if((template=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Allocate space for the new template */
- if((new_template=HDmalloc(sizeof(file_create_temp_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
-
- /* Copy over the information from the old template */
- HDmemcpy(new_template,template,sizeof(file_create_temp_t));
-
- /* Register the atom for the new template */
- if((ret_value=H5Aregister_atom(H5_TEMPLATE, (const VOIDP)new_template))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5C_copy() */
-
+ const void *tmpl = NULL;
+ void *new_tmpl = NULL;
+ H5C_class_t type;
+ size_t size;
+ hid_t ret_value = FAIL;
+ group_t group;
+
+ FUNC_ENTER (H5Ccopy, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (NULL==(tmpl=H5Aatom_object (template)) ||
+ (type=H5C_class (template))<0 ||
+ (group=H5Aatom_group (template))<0) {
+ /* Can't unatomize template */
+ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL);
+ }
+
+ /* How big is the template */
+ switch (type) {
+ case H5C_FILE_CREATE:
+ size = sizeof(H5F_create_t);
+ break;
+
+ case H5C_FILE_ACCESS:
+ /* File access properties are not implemented yet */
+ HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+
+ case H5C_DATASET_CREATE:
+ size = sizeof(H5D_create_t);
+ break;
+
+ case H5C_DATASET_XFER:
+ size = sizeof(H5D_xfer_t);
+ break;
+
+ default:
+ /* Unknown template class */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);
+ }
+
+ /* Create the new template */
+ new_tmpl = H5MM_xmalloc (size);
+ HDmemcpy (new_tmpl, tmpl, size);
+
+ /* Register the atom for the new template */
+ if ((ret_value=H5Aregister_atom (group, new_tmpl))<0) {
+ HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index 168b253..2253dd2 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -24,29 +24,7 @@
#include <H5private.h>
#include <H5Fprivate.h>
-/*
- * Default file-creation template values.
- */
-#define H5C_USERBLOCK_DEFAULT 0 /* Default user blocks size in bytes */
-#define H5C_OFFSETSIZE_DEFAULT 4 /* Default file offset size in bytes */
-#define H5C_LENGTHSIZE_DEFAULT 4 /* Default file length size in bytes */
-#define H5C_SYM_LEAF_K_DEFAULT 4 /* Default K for tab leaf nodes */
-
-#define H5C_BTREE_K_DEFAULT { \
- 16, /* Symbol table internal nodes */ \
- 32, /* Indexed storage intern nodes */ \
- 0, /* unused */ \
- 0, /* unused */ \
- 0, /* unused */ \
- 0, /* unused */ \
- 0, /* unused */ \
- 0 /* unused */ \
-}
-
-hid_t H5C_create(hid_t owner_id, hobjtype_t type, const char *name);
-hid_t H5C_copy(hid_t tid);
-herr_t H5C_release(hid_t oid);
-hid_t H5C_get_default_atom(hobjtype_t type);
-herr_t H5C_init(hid_t dst_atm, const file_create_temp_t *src);
+hid_t H5C_create (H5C_class_t type, void *tmpl);
+H5C_class_t H5C_class (hid_t template);
#endif
diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h
index 4d2fd7d..dcadcdd 100644
--- a/src/H5Cpublic.h
+++ b/src/H5Cpublic.h
@@ -1,57 +1,82 @@
/****************************************************************************
- * 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$ */
-
/*
- * This file contains function prototypes for each exported function in the H5C module
+ * This file contains function prototypes for each exported function in the
+ * H5C module.
*/
-
#ifndef _H5Cpublic_H
#define _H5Cpublic_H
/* Default Template for creation, access, etc. templates */
-#define H5C_DEFAULT_TEMPLATE 0
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#define H5C_DEFAULT (-2)
/* Public headers needed by this file */
#include <H5public.h>
#include <H5Apublic.h>
+
+/* Template classes */
+typedef enum H5C_class_t {
+ H5C_NO_CLASS =-1, /* Error return value */
+ H5C_FILE_CREATE =0, /* File creation template */
+ H5C_FILE_ACCESS =1, /* File access template */
+ H5C_DATASET_CREATE =2, /* Dataset creation template */
+ H5C_DATASET_XFER =3, /* Dataset transfer template */
+
+ H5C_NCLASSES =4 /* This must be last! */
+} H5C_class_t;
+
+/* Template properties, grouped by class */
+typedef enum H5C_prop_t {
+
+ /* File Creation Properties */
+ H5F_USERBLOCK_SIZE, /* Size of the user block in the file in bytes */
+ H5F_OFFSET_SIZE, /* Number of bytes for offsets */
+ H5F_LENGTH_SIZE, /* Number of bytes for lengths */
+ H5F_SYM_LEAF_K, /* 1/2 rank for symbol table leaf nodes */
+ H5F_SYM_INTERN_K, /* 1/2 rank for symbol table internal nodes */
+ H5F_ISTORE_K, /* 1/2 rank for indexed storage nodes */
+ H5F_BOOTBLOCK_VER, /* Version # of the boot-block format */
+ H5F_SMALLOBJECT_VER, /* Version # of the small-object heap format */
+ H5F_FREESPACE_VER, /* Version # of the free-space info format */
+ H5F_OBJECTDIR_VER, /* Version # of the object-directory format */
+ H5F_SHAREDHEADER_VER,/* Version # of the shared-header format */
+
+ /* File Access Properties */
+ /* None defined yet */
+
+ /* Dataset Creation Properties */
+ H5D_LAYOUT, /* Storage layout */
+ H5D_CHUNK_NDIMS, /* Chunk dimensionality */
+ H5D_CHUNK_SIZE, /* Chunk size vector */
+ H5D_COMPRESS, /* Raw data compression */
+ H5D_PRE_OFFSET, /* Precompression offset */
+ H5D_PRE_SCALE, /* Precompression scale */
+
+ /* Dataset Transfer Properties */
+ /* None defined yet */
+
+} H5C_prop_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
-/* Parameters to use when retrieving file-creation template information */
-typedef enum {
- H5_USERBLOCK_SIZE, /* (uintn) Size of the user block in the file in bytes */
- H5_OFFSET_SIZE, /* (uint8) Number of bytes for offsets */
- H5_LENGTH_SIZE, /* (uint8) Number of bytes for lengths */
- H5_SYM_LEAF_K, /* (uintn) 1/2 rank for symbol table leaf nodes */
- H5_SYM_INTERN_K, /* (uintn) 1/2 rank for symbol table internal nodes */
- H5_ISTORE_K, /* (uintn) 1/2 rank for indexed storage nodes */
- H5_BOOTBLOCK_VER, /* (uint8) Version # of the boot-block format */
- H5_SMALLOBJECT_VER, /* (uint8) Version # of the small-object heap format */
- H5_FREESPACE_VER, /* (uint8) Version # of the free-space info format */
- H5_OBJECTDIR_VER, /* (uint8) Version # of the object-directory format */
- H5_SHAREDHEADER_VER /* (uint8) Version # of the shared-header format */
- } file_create_param_t;
-
-/* Object types for "meta" interface */
-typedef group_t hobjtype_t; /* Map the object in the "meta" interface to atom groups */
-
-/* Functions in H5C.c */
-herr_t H5Cgetparm(hid_t tid, file_create_param_t parm, VOIDP buf);
-herr_t H5Csetparm(hid_t tid, file_create_param_t parm, const VOIDP buf);
-void H5C_term_interface (void);
+/* Public functions */
+hid_t H5Ccreate (H5C_class_t type);
+herr_t H5Cclose (hid_t template);
+hid_t H5Ccopy (hid_t template);
+herr_t H5Cgetparm (hid_t template, H5C_prop_t prop, void *buf);
+herr_t H5Csetparm (hid_t template, H5C_prop_t prop, const void *buf);
#ifdef __cplusplus
}
diff --git a/src/H5D.c b/src/H5D.c
index 0b99e86..73f4933 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -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. *
+* *
****************************************************************************/
#ifdef RCSID
@@ -16,52 +16,51 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-/*LINTLIBRARY */
-/*+
- FILE
- H5D.c
- HDF5 Dataset routines
-
- EXPORTED ROUTINES
- H5Dcreate -- Create a dataset
- H5Drelease -- Release access to a dataset
-
- LIBRARY-SCOPED ROUTINES
-
- LOCAL ROUTINES
- H5P_init_interface -- initialize the interface
- + */
-
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#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 */
+
+#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.
*/
-typedef struct H5D_t {
- H5F_t *file; /* File store for this object */
- H5G_entry_t *ent; /* Cached object header stuff */
- hid_t tid; /* Datatype ID of this dataset */
- hid_t sid; /* Dataspace ID of this dataset */
- haddr_t data_addr; /* Data storage address */
- hbool_t dirty; /* Header messages not updated yet */
-} H5D_t;
-
-/*--------------------- Locally scoped variables -----------------------------*/
-
-/* Whether we've installed the library termination function yet for this interface */
-static intn interface_initialize_g = FALSE;
+struct H5D_t {
+ H5F_t *file; /* File store for this object */
+ 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 */
+ haddr_t data_addr; /* Raw data storage address */
+};
+
+/* Default dataset creation template */
+const H5D_create_t H5D_create_dflt = {
+ H5D_CONTIGUOUS, /* Layout */
+};
+
+/* Default dataset transfer template */
+const H5D_xfer_t H5D_xfer_dflt = {
+ 0, /* Place holder - remove this later */
+};
+
+
+/* Interface initialization? */
+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);
+
/*--------------------------------------------------------------------------
NAME
@@ -75,21 +74,21 @@ DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t H5D_init_interface(void)
+static herr_t
+H5D_init_interface (void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5D_init_interface, NULL, FAIL);
-
- /* Make certain the H5T & H5P interfaces have been initialized */
- H5T_init();
- H5P_init();
-
- /* Initialize the atom group for the file IDs */
- if((ret_value=H5Ainit_group(H5_DATASET,H5A_DATASETID_HASHSIZE,H5D_RESERVED_ATOMS,NULL))!=FAIL)
- ret_value=H5_add_exit(&H5D_term_interface);
-
- FUNC_LEAVE(ret_value);
-} /* H5D_init_interface */
+ 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);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
/*--------------------------------------------------------------------------
NAME
@@ -108,613 +107,802 @@ static herr_t H5D_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void H5D_term_interface (void)
+static void
+H5D_term_interface (void)
{
- H5Adestroy_group(H5_DATASET);
-} /* end H5D_term_interface() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5D_create
- PURPOSE
- Create a new HDF5 dataset object
- USAGE
- hid_t H5D_create(owner_id, type, name)
- hid_t owner_id; IN: Group/file which owns this object
- hobjtype_t type; IN: Type of object to create
- const char *name; IN: Name of the object
- RETURNS
- Returns ID (atom) on success, FAIL on failure
- DESCRIPTION
- This function actually creates a dataset object in a file (of course,
- output might not happen for some time).
---------------------------------------------------------------------------*/
-hid_t H5D_create(hid_t owner_id, hobjtype_t type, const char *name)
+ H5Adestroy_group (H5_DATASET);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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).
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Dcreate (hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
+ hid_t create_parms_id)
{
- H5D_t *new_dset; /* new dataset object to create */
- hid_t ret_value = SUCCEED;
- H5F_t *file = NULL;
-
- FUNC_ENTER(H5D_create, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Convert atom arguments to pointers */
- if(H5Aatom_group(owner_id)!=H5_FILE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- file = H5Aatom_object (owner_id);
-
- /* Allocate space for the new dataset */
- if((new_dset=HDcalloc(1, sizeof(H5D_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
-
- /* Initialize the dataset object */
- new_dset->file = file;
- new_dset->tid=(-1); /* No type yet */
- new_dset->sid=(-1); /* No dimensions yet */
- H5F_addr_undef (&(new_dset->data_addr)); /* No data yet */
- new_dset->dirty = FALSE; /* There are no messages yet */
-
- /* Open (and create) a new file object */
- if (NULL==(new_dset->ent = H5G_create (file, name, H5D_MINHDR_SIZE))) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL);
- }
-
- /* Register the new datatype and get an ID for it */
- if((ret_value=H5Aregister_atom(H5_DATASET, (const VOIDP)new_dset))<0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5D_create() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5D_find_name
- PURPOSE
- Get the OID for accessing an existing HDF5 dataset object
- USAGE
- hoid_t H5D_find_name(grp_id, type, name)
- hid_t grp_id; IN: Atom for group to search for dataset
- hobjtype_t type; IN: Type of object to search for (dataset in
- this case)
- const char *name; IN: Name of the object to search for
- RETURNS
- Returns ID (atom) on success, FAIL on failure
- DESCRIPTION
- This function finds for a dataset by name in a group.
---------------------------------------------------------------------------*/
-hid_t H5D_find_name(hid_t grp_id, hobjtype_t obj_type, const char *name)
+ 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*/
+ }
+ if (!name || !*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*/
+ }
+ if (H5_DATASPACE!=H5Aatom_group (space_id) ||
+ 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!=H5C_class (create_parms_id) ||
+ NULL==(create_parms=H5Aatom_object (create_parms_id))) {
+ /* Not a dataset creation template */
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL);
+ }
+ } else {
+ 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*/
+ }
+
+ /* Register the new datatype and get an ID for it */
+ if ((ret_value=H5Aregister_atom (H5_DATASET, new_dset))<0) {
+ H5D_close (new_dset);
+ /* Can't register dataset */
+ HRETURN_ERROR (H5E_DATASET, H5E_CANTREGISTER, FAIL);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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.
+ *
+ * Return: Success: A new dataset ID
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Dopen (hid_t file_id, const char *name)
{
- H5F_t *file; /* Pointer to the file-store of this object */
- H5D_t *dset = NULL; /* The dataset */
- h5_datatype_t *type; /* The dataset's type */
- H5P_dim_t *dim; /* The dataset's dataspace */
- hid_t ret_value = SUCCEED;
- H5O_std_store_t store;
-
- FUNC_ENTER(H5D_find_name, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Convert atom arguments to pointers */
- if(H5Aatom_group(grp_id)!=H5_FILE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- file=H5Aatom_object(grp_id);
-
- /* Allocate space for the dataset */
- if(NULL==(dset=HDcalloc(1, sizeof(H5D_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
-
- /* Initialize file, group, name fields */
- dset->file = file;
- dset->dirty = FALSE;
-
- /* Open the dataset object */
- if (NULL==(dset->ent=H5G_open (file, name))) {
- HGOTO_ERROR (H5E_DATASET, H5E_NOTFOUND, FAIL);
- }
-
- /* Get the dataset's type (currently only atomic types) */
- if((type=HDcalloc(1,sizeof(h5_datatype_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- if (NULL==H5O_read (dset->file, NO_ADDR, dset->ent, H5O_SIM_DTYPE, 0,
- type))
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
- if((dset->tid=H5Aregister_atom(H5_DATATYPE, (const VOIDP)type))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
-
- /* Get the dataset's dimensionality (currently only simple dataspaces) */
- if((dim=HDcalloc(1,sizeof(H5P_dim_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- dim->type=H5P_TYPE_SIMPLE; /* for now... */
- if (NULL==(dim->s=H5O_read (dset->file, NO_ADDR, dset->ent,
- H5O_SIM_DIM, 0, NULL)))
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
- if((dset->sid=H5Aregister_atom(H5_DATASPACE, (const VOIDP)dim))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
-
- /* Get the dataset's data offset (currently only standard storage) */
- if (NULL==H5O_read (dset->file, NO_ADDR, dset->ent, H5O_STD_STORE, 0,
- &store))
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
- dset->data_addr=store.off;
-
- /* Register the new OID and get an ID for it */
- if((ret_value=H5Aregister_atom(H5_DATASET, (const VOIDP)dset))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
- if (dset) {
-#ifdef LATER
- /* We might need to free the `type' and `dim' fields also... */
-#endif
- H5MM_xfree (dset);
- }
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5D_find_name() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Dset_info
- PURPOSE
- Set the type and dimensionality of a dataset.
- USAGE
- herr_t H5Dset_info(oid)
- hid_t oid; IN: Dataset object to modify
- hid_t tid; IN: Datatype object to use as node element
- hid_t sid; IN: Dimensionality object to use as dataspace
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function sets the datatype and dataspace of a dataset.
---------------------------------------------------------------------------*/
-herr_t H5Dset_info(hid_t oid, hid_t tid, hid_t sid)
+ 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*/
+ }
+ if (!name || !*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*/
+ }
+
+ /* Create an atom for the dataset */
+ if ((ret_value=H5Aregister_atom (H5_DATASET, dataset))<0) {
+ H5D_close (dataset);
+ /* Can't register dataset */
+ HRETURN_ERROR (H5E_DATASET, H5E_CANTREGISTER, FAIL);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ * ARGS BADTYPE Not a dataset.
+ * DATASET CANTINIT Can't free.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dclose (hid_t dataset_id)
{
- H5D_t *dataset = NULL; /* dataset object to modify */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Dset_info, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Check that we've received correctly typed parameters */
- if(H5Aatom_group(tid)!=H5_DATATYPE || H5Aatom_group(sid)!=H5_DATASPACE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
-
- /* Get the object */
- if((dataset=H5Aatom_object(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- /* Check that the datatype & dataspace haven't already been initialized */
- if(dataset->tid!=(-1) || dataset->sid!=(-1))
- HGOTO_ERROR(H5E_FUNC, H5E_ALREADYINIT, FAIL);
-
- /* Increment the reference count for the datatype */
- if(H5Ainc_ref(tid)==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- dataset->tid=tid;
-
- /* Increment the reference count for the datatype */
- if(H5Ainc_ref(sid)==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- dataset->sid=sid;
-
- /* Mark the dataset as modified (Huh? - QAK) */
- dataset->dirty = TRUE;
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Dset_info() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Dget_info
- PURPOSE
- Get the type and dimensionality of a dataset.
- USAGE
- herr_t H5Dget_info(oid, tid, sid)
- hid_t oid; IN: Dataset object to query
- hid_t *tid; OUT: Datatype object to use as node element
- hid_t *sid; OUT: Dimensionality object to use as dataspace
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function starts access to the datatype and dataspace of an
- existing dataset. H5Mendaccess must be called to release the datatype and
- dataspace returned from this function.
---------------------------------------------------------------------------*/
-herr_t H5Dget_info(hid_t oid, hid_t *tid, hid_t *sid)
+ 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->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*/
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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
+ * SPACE_ID (if SPACE_ID is negative then we assume that the
+ * caller desires to read the entire dataset). The data points
+ * are converted from their file type to the TYPE_ID specified.
+ * Additional miscellaneous data transfer properties can be
+ * passed to this function with the XFER_PARMS_ID argument.
+ *
+ * The SPACE_ID can be the constant H5P_ALL in which case the
+ * destination (memory) data space is the same as the source
+ * (file) data space defined when the dataset was created.
+ *
+ * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
+ * case the default data transfer properties are used.
+ *
+ * Return: Success: SUCCEED
+ *
+ * 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.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dread (hid_t dataset_id, hid_t type_id, hid_t space_id,
+ hid_t xfer_parms_id, void *buf/*out*/)
{
- H5D_t *dataset; /* dataset object to query */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Dget_info, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
+ H5D_t *dataset = NULL;
+ const H5T_t *type = NULL;
+ const H5P_t *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->file) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a dataset*/
+ }
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(type=H5Aatom_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+ if (H5P_ALL!=space_id) {
+ if (H5_DATASPACE!=H5Aatom_group (space_id) ||
+ NULL==(space=H5Aatom_object (space_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data space*/
+ }
+ }
+ if (H5C_DEFAULT==xfer_parms_id) {
+ xfer_parms = &H5D_xfer_dflt;
+ } else if (H5C_DATASET_XFER!=H5C_class (xfer_parms_id) ||
+ 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*/
+ }
+
+ /* read raw data */
+ if (H5D_read (dataset, type, space, xfer_parms, buf/*out*/)<0) {
+ HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL); /*can't read data*/
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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
+ * SPACE_ID (if SPACE_ID is negative then we assume that the
+ * caller desires to write the entire dataset). The data points
+ * are converted from their current type (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 SPACE_ID can be the constant H5P_ALL in which case the
+ * source (memory) data space is the same as the destination
+ * (file) memory space which was defined when the dataset was
+ * created.
+ *
+ * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
+ * case the default data transfer properties are used.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dwrite (hid_t dataset_id, hid_t type_id, hid_t space_id,
+ hid_t xfer_parms_id, const void *buf)
+{
+ H5D_t *dataset = NULL;
+ const H5T_t *type = NULL;
+ const H5P_t *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->file) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a dataset*/
+ }
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(type=H5Aatom_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+ if (H5P_ALL!=space_id) {
+ if (H5_DATASPACE!=H5Aatom_group (space_id) ||
+ NULL==(space=H5Aatom_object (space_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data space*/
+ }
+ }
+ if (H5C_DEFAULT==xfer_parms_id) {
+ xfer_parms = &H5D_xfer_dflt;
+ } else if (H5C_DATASET_XFER!=H5C_class (xfer_parms_id) ||
+ 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*/
+ }
+
+ /* write raw data */
+ if (H5D_write (dataset, type, space, xfer_parms, buf)<0) {
+ HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL); /*can't write data*/
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
- /* Check that we've received correctly typed parameters */
- if(H5Aatom_group(oid)!=H5_DATASET)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- /* Get the object */
- if((dataset=H5Aatom_object(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- /* Check that the datatype & dataspace have already been initialized */
- if(dataset->tid==(-1) || dataset->sid==(-1))
- HGOTO_ERROR(H5E_DATASET, H5E_UNINITIALIZED, FAIL);
- /* Get the Dataset's IDs */
- if(H5Ainc_ref(dataset->tid)==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- *tid=dataset->tid;
- if(H5Ainc_ref(dataset->sid)==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- *sid=dataset->sid;
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
- } /* end if */
+
+
+/*-------------------------------------------------------------------------
+ * 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.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5D_find_name (hid_t file_id, group_t UNUSED, const char *name)
+{
+ return H5Dopen (file_id, name);
+}
+
+
+
+
+
+
+
+
+
+/*-------------------------------------------------------------------------
+ * 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.
+ *
+ * Return: Success: Pointer to a new dataset
+ *
+ * Failure: NULL
+ *
+ * Errors:
+ * DATASET CANTINIT Can't update dataset header.
+ * DATASET CANTINIT Problem with the dataset name.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5D_t *
+H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
+ const H5D_create_t *create_parms)
+{
+ H5D_t *new_dset = NULL;
+ H5D_t *ret_value = NULL;
+ H5O_cstore_t cstore; /*contiguous storage message */
+
+ FUNC_ENTER (H5D_create, NULL);
+
+ /* check args */
+ assert (f);
+ assert (name && *name);
+ assert (type);
+ assert (space);
+ assert (create_parms);
+
+ /* Initialize the dataset object */
+ new_dset = H5MM_xcalloc (1, sizeof(H5D_t));
+ new_dset->file = f;
+ new_dset->type = H5T_copy (type);
+ new_dset->space = H5P_copy (space);
+ new_dset->create_parms = *create_parms;
+ H5F_addr_undef (&(new_dset->data_addr)); /* No data yet */
+
+ /*
+ * Open (and create) a new file object and update the object header
+ * immediately with the new information so when others access the dataset
+ * they see the most current info. This `write through the dataset'
+ * policy is used throughout this package, and because the object header
+ * is cached it shouldn't cause any disk activity.
+ */
+ if (NULL==(new_dset->ent = H5G_create (f, name, H5D_MINHDR_SIZE))) {
+ /* Problem with the dataset name */
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL);
+ }
+
+ /* Update the type and space header messages */
+ if (H5O_modify (f, NO_ADDR, new_dset->ent, H5O_DTYPE, 0,
+ new_dset->type)<0 ||
+ H5P_modify (f, new_dset->ent, new_dset->space)<0) {
+ /* Can't update type or space header messages */
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL);
+ }
+
+ /* Update layout message */
+ switch (new_dset->create_parms.layout) {
+ case H5D_CONTIGUOUS:
+ cstore.size = H5T_get_size (type) * H5P_get_npoints (space);
+ if (H5MF_alloc (f, H5MF_RAW, cstore.size, &(cstore.addr))<0) {
+ /* Can't allocate raw file storage */
+ HGOTO_ERROR (H5E_DATASET, H5E_NOSPACE, NULL);
+ }
+ if (H5O_modify (f, NO_ADDR, new_dset->ent, H5O_CSTORE, 0, &cstore)<0) {
+ /* Can't update dataset object header */
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL);
+ }
+ new_dset->data_addr = cstore.addr;
+ break;
+
+ default:
+ assert ("not implemented yet" && 0);
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL);
+ }
+
+ /* 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 (new_dset->ent) H5G_close (f, new_dset->ent);
+ new_dset->file = NULL;
+ H5MM_xfree (new_dset);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_open
+ *
+ * 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.
+ *
+ * Failure: NULL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+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 */
+ H5O_cstore_t cstore; /*contiguous storage message */
- /* Normal function cleanup */
+ FUNC_ENTER (H5D_open, NULL);
- FUNC_LEAVE(ret_value);
-} /* end H5Dset_info() */
+ /* check args */
+ assert (f);
+ assert (name && *name);
-/*--------------------------------------------------------------------------
- NAME
- H5Dread
- PURPOSE
- Read data from a dataset
- USAGE
- herr_t H5Dread(oid)
- hid_t oid; IN: Dataset to read
- hid_t did; IN: Dimensionality object to use as dataspace for I/O
- VOIDP buf; IN: Buffer to fill with data from the file
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function reads dataset object data from the file. The dataspace
- ID determines the slice/hyper-slab/portion of the dataset to write.
- H5P_ALL is a special value which indicates that the entire dataset is
- to be written out. (For datasets which have a scalar dataspace for the
- entire dataset, this is somewhat redundant.... :-)
---------------------------------------------------------------------------*/
-herr_t H5Dread(hid_t oid, hid_t did, VOIDP buf)
-{
- H5D_t *dataset; /* dataset object to do I/O on */
- void *readbuf=NULL; /* pointer to buffer to write out */
- uintn free_buf=0; /* if temporary conversion buffer needs to be free'd */
- uintn toread; /* number of bytes to read in */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Dread, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Check that we've received correctly typed parameters */
- if(H5Aatom_group(did)!=H5_DATASPACE || H5Aatom_group(oid)!=H5_DATASET)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- if(buf==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- /* Get the object */
- if((dataset=H5Aatom_object(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check that the datatype & dataspace have already been initialized */
- if(dataset->tid==(-1) || dataset->sid==(-1) ||
- !H5F_addr_defined (&(dataset->data_addr)))
- HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL);
-
- /* Compute the number of bytes to read */
- if(did==H5P_ALL) /* Check if we are reading the entire dataset */
- toread=H5Tsize(dataset->tid,BTRUE)*H5Pnelem(dataset->sid);
- else
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
-
- /* Check memory to disk datatype conversions, etc. */
-/* This is totally hacked up code, but I'm in a hurry. ;-/ -QAK */
- if(H5Tarch(dataset->tid)!=H5T_ARCH_TYPE)
- {
- if((readbuf=HDmalloc(toread))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- free_buf=1;
- } /* end if */
- else
- readbuf=buf;
-
+ dataset = H5MM_xcalloc (1, sizeof(H5D_t));
+ dataset->file = f;
- /* Read data from disk */
- if (H5F_block_read (dataset->file, &(dataset->data_addr), toread,
- readbuf)<0) {
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL);
- }
+ /* Open the dataset object */
+ if (NULL==(dataset->ent=H5G_open (f, name))) {
+ HGOTO_ERROR (H5E_DATASET, H5E_NOTFOUND, NULL); /*not found*/
+ }
+
+ /* Get the type and space */
+ if (NULL==(dataset->type = H5O_read (f, NO_ADDR, dataset->ent, H5O_DTYPE,
+ 0, NULL)) ||
+ NULL==(dataset->space = H5P_read (f, dataset->ent))) {
+ /* Can't load type of space info from dataset header */
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL);
+ }
+
+#if 0
+ if((type=HDcalloc(1,sizeof(H5T_t)))==NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
+ if (NULL==H5O_read (dset->file, NO_ADDR, dset->ent, H5O_SIM_DTYPE, 0,
+ type))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
+ if((dset->tid=H5Aregister_atom(H5_DATATYPE, (const VOIDP)type))==FAIL)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
- if(free_buf!=0)
- H5D_convert_buf(buf,readbuf,toread,H5Tsize(dataset->tid,BTRUE));
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
- if(free_buf!=0) /* check if we need to release the conversion buffer */
- HDfree(readbuf);
+ /* Get the dataset's dimensionality (currently only simple dataspaces) */
+ if((dim=HDcalloc(1,sizeof(H5P_t)))==NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
+ dim->type=H5P_TYPE_SIMPLE; /* for now... */
+ if (NULL==(dim->s=H5O_read (dset->file, NO_ADDR, dset->ent,
+ H5O_SDSPACE, 0, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL);
+ if((dset->sid=H5Aregister_atom(H5_DATASPACE, (const VOIDP)dim))==FAIL)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
+#endif
- FUNC_LEAVE(ret_value);
-} /* end H5Dread() */
+ /* Get the raw data storage info */
+ if (H5O_read (dataset->file, NO_ADDR, dataset->ent, H5O_CSTORE, 0,
+ &cstore)) {
+ dataset->create_parms.layout = H5D_CONTIGUOUS;
+ dataset->data_addr = cstore.addr;
+ } else {
+ assert ("not implemented yet" && 0);
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL);
+ }
+
+ /* Success */
+ ret_value = dataset;
+
-/*--------------------------------------------------------------------------
- NAME
- H5Dwrite
- PURPOSE
- Write data for a dataset
- USAGE
- herr_t H5Dwrite(oid)
- hid_t oid; IN: Dataset object to modify
- hid_t did; IN: Dimensionality object to use as dataspace for I/O
- VOIDP buf; IN: Buffer with data to write to the file
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function writes dataset object data to the file. The dataspace
- ID determines the slice/hyper-slab/portion of the dataset to write.
- H5P_ALL is a special value which indicates that the entire dataset is
- to be written out. (For datasets which have a scalar dataspace for the
- entire dataset, this is somewhat redundant.... :-)
---------------------------------------------------------------------------*/
-herr_t H5Dwrite(hid_t oid, hid_t did, VOIDP buf)
+ done:
+ if (!ret_value && dataset) {
+ if (dataset->ent) H5G_close (f, dataset->ent);
+ if (dataset->type) H5T_close (dataset->type);
+ if (dataset->space) H5P_close (dataset->space);
+ dataset->file = NULL;
+ H5MM_xfree (dataset);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ * DATASET CANTINIT Couldn't free the type or space,
+ * but the dataset was freed anyway.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_close (H5D_t *dataset)
{
- H5D_t *dataset; /* dataset object to do I/O on */
- uintn towrite; /* number of bytes to write out */
- void *writebuf=NULL; /* pointer to buffer to write out */
- uintn free_buf=0; /* if temporary conversion buffer needs to be free'd */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Dwrite, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Check that we've received correctly typed parameters */
- if(H5Aatom_group(did)!=H5_DATASPACE || H5Aatom_group(oid)!=H5_DATASET)
- HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
- if(buf==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- /* Get the object */
- if((dataset=H5Aatom_object(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check that the datatype & dataspace have already been initialized */
- if(dataset->tid==(-1) || dataset->sid==(-1))
- HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL);
-
- /* Compute the number of bytes to write out */
- if(did==H5P_ALL) /* Check if we are writing out the entire dataset */
- towrite=H5Tsize(dataset->tid,BTRUE)*H5Pnelem(dataset->sid);
- else
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
-
- /* Check if we have space for the dataset yet */
- if (!H5F_addr_defined (&(dataset->data_addr))) {
- if (H5MF_alloc (dataset->file, H5MF_RAW, towrite,
- &(dataset->data_addr)/*out*/)<0) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- }
- dataset->dirty = TRUE;
- }
-
- /* Check memory to disk datatype conversions, etc. */
-/* This is totally hacked up code, but I'm in a hurry. ;-/ -QAK */
- if(H5Tarch(dataset->tid)!=H5T_ARCH_TYPE)
- {
- if((writebuf=HDmalloc(towrite))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- H5D_convert_buf(writebuf,buf,towrite,H5Tsize(dataset->tid,BTRUE));
- free_buf=1;
- } /* end if */
- else
- writebuf=buf;
-
- /* Write the data out to disk */
- if (H5F_block_write (dataset->file, &(dataset->data_addr), towrite,
- writebuf)<0) {
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL);
- }
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
- if(free_buf!=0) /* check if we need to release the conversion buffer */
- HDfree(writebuf);
-
- FUNC_LEAVE(ret_value);
-} /* end H5Dwrite() */
+ hbool_t free_failed;
+
+ FUNC_ENTER (H5D_close, FAIL);
-/*--------------------------------------------------------------------------
- NAME
- H5D_flush
- PURPOSE
- Flush an an HDF5 dataset object to disk.
- USAGE
- herr_t H5D_flush(oid)
- hid_t oid; IN: Object to flush to disk
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function flushes a dataset to disk. (i.e. makes the disk version
- agree with what's in memory, it does _not_ update the memory version with
- any changes on disk) This function is primarily called from H5Mflush, but
- internal library routines may call it also.
---------------------------------------------------------------------------*/
-herr_t H5D_flush(hid_t oid)
+ /* check args */
+ assert (dataset && dataset->file);
+
+ /* Close the dataset object */
+ H5G_close (dataset->file, dataset->ent);
+ dataset->ent = NULL;
+
+ /*
+ * Release dataset type and space - there isn't much we can do if one of
+ * these fails, so we just continue.
+ */
+ free_failed = (H5T_close (dataset->type)<0 ||
+ H5P_close (dataset->space)<0);
+
+ /*
+ * Free memory. Before freeing the memory set the file pointer to NULL.
+ * We always check for a null file pointer in other H5D functions to be
+ * sure we're not accessing an already freed dataset (see the assert()
+ * above).
+ */
+ dataset->file = NULL;
+ H5MM_xfree (dataset);
+
+ if (free_failed) {
+ /* Couldn't free the type or space, but the dataset was freed anyway. */
+ HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL);
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_read
+ *
+ * Purpose: Reads (part of) a DATASET into application memory BUF. The
+ * SPACE argument determines what part of the dataset to read
+ * (the whole thing is read if SPACE is null) and individual
+ * data points are translated from their file data type to the
+ * specified TYPE. The XFER_PARMS contains additional
+ * miscellaneous properties that control the data transfer.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
+ const H5D_xfer_t *xfer_parms, void *buf/*out*/)
{
- H5D_t *dataset; /* dataset object to release */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5D_flush, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Get the object */
- if((dataset=H5Aatom_object(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- if (dataset->dirty) {
-
- /*
- * Modify/create messages for this dataset. Begin with the
- * type information.
- */
- if (H5Tis_atomic (dataset->tid)) {
- h5_datatype_t *type=H5Aatom_object(dataset->tid);
-
- if (H5O_modify (dataset->file, NO_ADDR, dataset->ent,
- H5O_SIM_DTYPE, 0, type)<0) {
- /* Can't create/update type message */
- HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
- }
- } else {
- /* Not an atomic datatype */
- HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
- }
-
- /*
- * Modify/create the dimensionality information.
- */
- if (H5Pis_simple (dataset->sid)) {
- H5P_dim_t *dim=H5Aatom_object(dataset->sid);
-
- if (H5O_modify (dataset->file, NO_ADDR, dataset->ent,
- H5O_SIM_DIM, 0, dim->s)<0) {
- /* Can't create/update dimensionality message */
- HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
- }
- } else {
- /* Not an atomic datatype */
- HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
- }
-
- /*
- * Modify/create the dataset's storage information.
- */
- if (H5F_addr_defined (&(dataset->data_addr))) {
- H5O_std_store_t store; /* standard storage info */
-
- store.len = H5Tsize (dataset->tid, BTRUE) * H5Pnelem (dataset->sid);
- store.off = dataset->data_addr;
- if (H5O_modify (dataset->file, NO_ADDR, dataset->ent,
- H5O_STD_STORE, 0, &store)<0) {
- /* Can't create/modify storage information */
- HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
- }
- }
-
- dataset->dirty = FALSE; /*it's clean now*/
- }
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5D_flush() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5D_release
- PURPOSE
- Release access to an HDF5 dataset object.
- USAGE
- herr_t H5D_release(oid)
- hid_t oid; IN: Object to release access to
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function releases a dataset from active use by a user.
---------------------------------------------------------------------------*/
-herr_t H5D_release(hid_t oid)
+ size_t nbytes;
+
+ FUNC_ENTER (H5D_read, FAIL);
+
+ /* check args */
+ assert (dataset && dataset->file);
+ assert (type);
+ assert (xfer_parms);
+ assert (buf);
+
+ if (H5D_CONTIGUOUS!=dataset->create_parms.layout) {
+ /* Layout is not supported yet */
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL);
+ }
+ if (H5T_cmp (type, dataset->type)) {
+ /* Type conversion not supported yet */
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL);
+ }
+ if (space && H5P_cmp (space, dataset->space)) {
+ /* Space conversion not supported yet */
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL);
+ }
+
+ /* Compute the size of the request */
+ nbytes = H5T_get_size (dataset->type) * H5P_get_npoints (dataset->space);
+
+ /* Read the data from disk */
+ if (H5F_block_read (dataset->file, &(dataset->data_addr), nbytes, buf)<0) {
+ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL); /*read failed*/
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_write
+ *
+ * Purpose: Writes (part of) a DATASET to a file from application memory
+ * BUF. The SPACE argument determines what part of the dataset
+ * to write (the whole thing is read if SPACE is null) and
+ * individual data points are translated from their memory data
+ * type (TYPE) to the file data type. The XFER_PARMS contains
+ * additional miscellaneous properties that control the data
+ * transfer.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
+ const H5D_xfer_t *xfer_parms, const void *buf)
{
- H5D_t *dataset; /* dataset object to release */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5D_release, H5D_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Get the dataset so we can check for changes and release it */
- if((dataset=H5Aatom_object(oid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check if we have information to flush to the file... */
- if(dataset->dirty && H5D_flush(oid)<0) {
- /* Can't flush dataset */
- HGOTO_ERROR (H5E_OHDR, H5E_CANTFLUSH, FAIL);
- }
-
- /* Close the dataset object */
- H5G_close (dataset->file, dataset->ent);
- dataset->ent = NULL;
+ size_t nbytes;
+
+ FUNC_ENTER (H5D_write, FAIL);
+
+ /* check args */
+ assert (dataset && dataset->file);
+ assert (type);
+ assert (xfer_parms);
+ assert (buf);
+
+ if (H5D_CONTIGUOUS!=dataset->create_parms.layout) {
+ /* Layout is not supported yet */
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL);
+ }
+ if (H5T_cmp (type, dataset->type)) {
+ /* Type conversion not supported yet */
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL);
+ }
+ if (space && H5P_cmp (space, dataset->space)) {
+ /* Space conversion not supported yet */
+ HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL);
+ }
+
+ /* Compute the size of the request */
+ nbytes = H5T_get_size (dataset->type) * H5P_get_npoints (dataset->space);
- /* Release the atoms for the datatype and dataspace */
- H5Adec_ref(dataset->tid);
- H5Adec_ref(dataset->sid);
- /* release the memory used for the dataset */
- H5MM_xfree (dataset);
-
- /* Delete the dataset from the atom group */
- if(H5Aremove_atom(oid)==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
+ /* Write the data out to disk */
+ if (H5F_block_write (dataset->file, &(dataset->data_addr), nbytes, buf)<0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL); /*write failed*/
+ }
- FUNC_LEAVE(ret_value);
-} /* end H5D_release() */
+ FUNC_LEAVE (SUCCEED);
+}
diff --git a/src/H5Dconv.c b/src/H5Dconv.c
index 63ff539..25ff762 100644
--- a/src/H5Dconv.c
+++ b/src/H5Dconv.c
@@ -37,8 +37,9 @@ static char RcsId[] = "@(#)$Revision$";
/*--------------------- Locally scoped variables -----------------------------*/
-/* Whether we've installed the library termination function yet for this interface */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
NAME
@@ -62,7 +63,7 @@ herr_t H5D_convert_buf(void *dst, const void *src, uintn len, uintn size)
char *d=(char *)dst;
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5D_convert_buf, NULL, FAIL);
+ FUNC_ENTER(H5D_convert_buf, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
diff --git a/src/H5Distore.c b/src/H5Distore.c
index b997945..d506665 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -24,8 +24,9 @@ typedef enum H5F_isop_t {
#define PABLO_MASK H5F_istore_mask
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/* PRIVATE PROTOTYPES */
static size_t H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata);
@@ -70,6 +71,7 @@ static herr_t H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore,
* The storage file address is part of the B-tree and not part of the key.
*/
typedef struct H5F_istore_key_t {
+ uintn file_number; /*external file number */
size_t offset[H5O_ISTORE_NDIMS]; /*logical offset to start*/
size_t size[H5O_ISTORE_NDIMS]; /*logical chunk size */
} H5F_istore_key_t;
@@ -122,11 +124,16 @@ static size_t
H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata)
{
const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *)_udata;
+ size_t nbytes;
assert (udata);
assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_ISTORE_NDIMS);
- return udata->mesg.ndims * (4 + 4);
+ nbytes = 4 + /*external file number */
+ udata->mesg.ndims * 4 + /*dimension indices */
+ udata->mesg.ndims * 4; /*dimension sizes */
+
+ return nbytes;
}
@@ -154,16 +161,18 @@ H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
int i;
int ndims = bt->sizeof_rkey / 8;
- FUNC_ENTER (H5F_istore_decode_key, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_decode_key, FAIL);
/* check args */
assert (f);
assert (bt);
assert (raw);
assert (key);
- assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS && 8*ndims==bt->sizeof_rkey);
+ assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS);
/* decode */
+ UINT32DECODE (raw, key->file_number);
+ assert (0==key->file_number);
for (i=0; i<ndims; i++) {
UINT32DECODE (raw, key->offset[i]);
UINT32DECODE (raw, key->size[i]);
@@ -197,16 +206,18 @@ H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
intn ndims = bt->sizeof_rkey / 8;
intn i;
- FUNC_ENTER (H5F_istore_encode_key, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_encode_key, FAIL);
/* check args */
assert (f);
assert (bt);
assert (raw);
assert (key);
- assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS && 8*ndims==bt->sizeof_rkey);
+ assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS);
/* encode */
+ UINT32ENCODE (raw, key->file_number);
+ assert (0==key->file_number);
for (i=0; i<ndims; i++) {
UINT32ENCODE (raw, key->offset[i]);
UINT32ENCODE (raw, key->size[i]);
@@ -221,7 +232,8 @@ H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
*
* Purpose: Compares two keys sort of like strcmp(). The UDATA pointer
* is only to supply extra information not carried in the keys
- * (in this case, the dimensionality).
+ * (in this case, the dimensionality) and is not compared
+ * against the keys.
*
* Return: Success: -1 if LT_KEY is less than RT_KEY;
* 1 if LT_KEY is greater than RT_KEY;
@@ -244,13 +256,14 @@ H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
intn cmp;
- FUNC_ENTER (H5F_istore_cmp2, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_cmp2, FAIL);
assert (lt_key);
assert (rt_key);
assert (udata);
assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_ISTORE_NDIMS);
-
+
+ /* Compare the offsets but ignore the other fields */
cmp = H5V_vector_cmp (udata->mesg.ndims, lt_key->offset, rt_key->offset);
FUNC_LEAVE (cmp);
@@ -294,7 +307,7 @@ H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
intn cmp = 0;
- FUNC_ENTER (H5F_istore_cmp3, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_cmp3, FAIL);
assert (lt_key);
assert (rt_key);
@@ -343,7 +356,7 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
size_t nbytes;
intn i;
- FUNC_ENTER (H5F_istore_new_node, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_new_node, FAIL);
/* check args */
assert (f);
@@ -361,6 +374,9 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL);
}
udata->addr = *addr;
+ udata->key.file_number = 0;
+ lt_key->file_number = udata->key.file_number;
+ if (H5B_INS_LEFT!=op) rt_key->file_number = 0;
/* Initialize the key(s) */
for (i=0; i<udata->mesg.ndims; i++) {
@@ -368,9 +384,9 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
* The left key describes the storage of the UDATA chunk being inserted
* into the tree.
*/
+ assert (udata->key.size[i]>0);
lt_key->offset[i] = udata->key.offset[i];
lt_key->size[i] = udata->key.size[i];
- assert (udata->key.size[i]>0);
/*
* The right key might already be present. If not, then add
@@ -416,7 +432,7 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *)_lt_key;
int i;
- FUNC_ENTER (H5F_istore_found, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_found, FAIL);
/* Check arguments */
assert (f);
@@ -426,6 +442,8 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
/* Initialize return values */
udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
+ assert (0==lt_key->file_number);
for (i=0; i<udata->mesg.ndims; i++) {
udata->key.offset[i] = lt_key->offset[i];
udata->key.size[i] = lt_key->size[i];
@@ -435,7 +453,6 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
FUNC_LEAVE (SUCCEED);
}
-
/*-------------------------------------------------------------------------
* Function: H5F_istore_insert
@@ -482,7 +499,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
H5B_ins_t ret_value = H5B_INS_ERROR;
size_t nbytes;
- FUNC_ENTER (H5F_istore_insert, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_insert, FAIL);
/* check args */
assert (f);
@@ -510,6 +527,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
* Already exists. Just return the info.
*/
udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
ret_value = H5B_INS_NOOP;
} else if (H5V_hyper_disjointp (udata->mesg.ndims,
@@ -523,6 +541,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
* Split this node, inserting the new new node to the right of the
* current node. The MD_KEY is where the split occurs.
*/
+ md_key->file_number = udata->key.file_number;
for (i=0, nbytes=1; i<udata->mesg.ndims; i++) {
assert (0==udata->key.offset[i] % udata->mesg.alignment[i]);
assert (udata->key.size[i] == udata->mesg.alignment[i]);
@@ -538,6 +557,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL);
}
udata->addr = *new_node;
+ udata->key.file_number = 0;
ret_value = H5B_INS_RIGHT;
} else {
@@ -600,7 +620,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
herr_t status;
herr_t ret_value = FAIL;
- FUNC_ENTER (H5F_istore_copy_hyperslab, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_copy_hyperslab, FAIL);
/* check args */
assert (f);
@@ -644,6 +664,9 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
/* Read/Write chunk or create it if it doesn't exist */
udata.mesg.ndims = istore->ndims;
+ H5F_addr_undef (&(udata.addr));
+ udata.key.file_number = 0;
+
for (i=0; i<istore->ndims; i++) {
/* The location and size of the chunk being accessed */
@@ -679,6 +702,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
!H5V_vector_zerop (istore->ndims, offset_wrt_chunk) ||
!H5V_vector_eq (istore->ndims, sub_size, udata.key.size)) {
if (status>=0 && H5F_addr_defined (&(udata.addr))) {
+ assert (0==udata.key.file_number);
if (H5F_block_read (f, &(udata.addr), chunk_size, chunk)<0) {
HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL);
}
@@ -692,6 +716,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
H5V_hyper_copy (istore->ndims, sub_size,
udata.key.size, offset_wrt_chunk, chunk,
size_m, sub_offset_m, buf);
+ assert (0==udata.key.file_number);
if (H5F_block_write (f, &(udata.addr), chunk_size, chunk)<0) {
HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
}
@@ -738,7 +763,7 @@ herr_t
H5F_istore_read (H5F_t *f, const H5O_istore_t *istore,
const size_t offset[], const size_t size[], void *buf)
{
- FUNC_ENTER (H5F_istore_read, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_read, FAIL);
/* Check args */
assert (f);
@@ -778,7 +803,7 @@ herr_t
H5F_istore_write (H5F_t *f, const H5O_istore_t *istore,
const size_t offset[], const size_t size[], void *buf)
{
- FUNC_ENTER (H5F_istore_write, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_write, FAIL);
/* Check args */
assert (f);
@@ -799,7 +824,7 @@ H5F_istore_write (H5F_t *f, const H5O_istore_t *istore,
/*-------------------------------------------------------------------------
- * Function: H5F_istore_new
+ * Function: H5F_istore_create
*
* Purpose: Creates a new indexed-storage B-tree and initializes the
* istore struct with information about the storage. The
@@ -821,13 +846,13 @@ H5F_istore_write (H5F_t *f, const H5O_istore_t *istore,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_new (H5F_t *f, struct H5O_istore_t *istore,
- uintn ndims, const size_t alignment[])
+H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore,
+ uintn ndims, const size_t alignment[])
{
H5F_istore_ud1_t udata;
int i;
- FUNC_ENTER (H5F_istore_new, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_create, FAIL);
/* Check args */
assert (f);
@@ -841,7 +866,7 @@ H5F_istore_new (H5F_t *f, struct H5O_istore_t *istore,
#endif
udata.mesg.ndims = istore->ndims = ndims;
- if (H5B_new (f, H5B_ISTORE, &udata, &(istore->btree_addr)/*out*/)<0) {
+ if (H5B_create (f, H5B_ISTORE, &udata, &(istore->btree_addr)/*out*/)<0) {
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL); /* Can't create B-tree */
}
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 917e001..b079c89 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -22,10 +22,10 @@
/* Private headers needed by this file */
#include <H5private.h>
-#include <H5Cprivate.h> /* for the hobjtype_t type */
+#include <H5Fprivate.h> /* for the H5F_t type */
#include <H5Gprivate.h> /* Symbol tables */
-#include <H5Tprivate.h> /* for the h5_datatype_t type */
-#include <H5Pprivate.h> /* for the H5P_sdim_t type */
+#include <H5Tprivate.h> /* for the H5T_t type */
+#include <H5Pprivate.h> /* for the H5P_t type */
#include <H5Oprivate.h> /* Object Headers */
#define H5D_RESERVED_ATOMS 0
@@ -33,13 +33,34 @@
/* Set the minimum object header size to create objects with */
#define H5D_MINHDR_SIZE 512
-/*-----------------_-- Local function prototypes ----------------------------*/
-hid_t H5D_create(hid_t owner_id, hobjtype_t type, const char *name);
-hid_t H5D_access_by_name (hid_t owner_id, const char *name);
-hid_t H5D_find_name(hid_t owner_id, hobjtype_t type, const char *name);
-herr_t H5D_flush(hid_t oid);
-herr_t H5D_release(hid_t oid);
-/* in H5Dconv.c */
+/* Dataset creation template */
+typedef struct H5D_create_t {
+ H5D_layout_t layout;
+} H5D_create_t;
+
+/* Dataset transfer template */
+typedef struct H5D_xfer_t {
+ int _placeholder; /*unused--delete this later*/
+} H5D_xfer_t;
+
+typedef struct H5D_t H5D_t;
+
+extern const H5D_create_t H5D_create_dflt;
+extern const H5D_xfer_t H5D_xfer_dflt;
+
+/* Functions defined in H5D.c */
+H5D_t *H5D_create (H5F_t *f, const char *name, const H5T_t *type,
+ const H5P_t *space, const H5D_create_t *create_parms);
+H5D_t *H5D_open (H5F_t *f, const char *name);
+herr_t H5D_close (H5D_t *dataset);
+herr_t H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
+ const H5D_xfer_t *xfer_parms, void *buf/*out*/);
+herr_t H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
+ const H5D_xfer_t *xfer_parms, const void *buf);
+hid_t H5D_find_name (hid_t file_id, group_t UNUSED, const char *name);
+
+
+/* Functions defined in in H5Dconv.c */
herr_t H5D_convert_buf(void *dst,const void *src,uintn len,uintn size);
#endif
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index ba10161..9606bb4 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -23,16 +23,27 @@
#include <H5public.h>
#include <H5Apublic.h>
+/* Values for the H5D_LAYOUT property */
+typedef enum H5D_layout_t {
+ H5D_COMPACT =0, /*raw data is very small */
+ H5D_CONTIGUOUS =1, /*the default */
+ H5D_CHUNKED =2, /*slow and fancy */
+
+ H5D_NLAYOUTS =3 /*This one must be last! */
+} H5D_layout_t;
+
#ifdef __cplusplus
extern "C" {
#endif
-/* Functions in H5D.c */
-herr_t H5Dset_info(hid_t oid, hid_t tid, hid_t did);
-herr_t H5Dget_info(hid_t oid, hid_t *tid, hid_t *sid);
-herr_t H5Dwrite(hid_t oid, hid_t did, VOIDP buf);
-herr_t H5Dread(hid_t oid, hid_t did, VOIDP buf);
-void 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 H5Dopen (hid_t file_id, const char *name);
+herr_t H5Dclose (hid_t dataset_id);
+herr_t H5Dread (hid_t dataset_id, hid_t type_id, hid_t space_id,
+ hid_t xfer_parms_id, void *buf/*out*/);
+herr_t H5Dwrite (hid_t dataset_id, hid_t type_id, hid_t space_id,
+ hid_t xfer_parms_id, const void *buf);
#ifdef __cplusplus
}
diff --git a/src/H5E.c b/src/H5E.c
index f35041c..c77c61b 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -41,9 +41,6 @@ static char RcsId[] = "@(#)$Revision$";
/*-------------------- Locally scoped variables -----------------------------*/
-/* Is the interface initialized? */
-static intn interface_initialize_g = FALSE;
-
static const hdf_maj_error_messages_t hdf_maj_error_messages[] =
{
{H5E_NONE_MAJOR, "No error"},
@@ -110,11 +107,14 @@ static const hdf_min_error_messages_t hdf_min_error_messages[] =
{H5E_LINK, "Link count failure"},
};
-/*--------------------- Globally scoped variables ---------------------------*/
+/* Interface initialization? */
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5E_init_interface
+static herr_t H5E_init_interface(void);
+
+
int32 thrderrid; /* Thread-specific "global" error-handler ID */
-/*------------------_-- Local function prototypes ---------------------------*/
-static herr_t H5E_init_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -135,7 +135,7 @@ Modifications:
static herr_t H5E_init_interface(void)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5E_init_interface, NULL, FAIL);
+ FUNC_ENTER (H5E_init_interface, FAIL);
/* Initialize the atom group for the error stacks */
if((ret_value=H5Ainit_group(H5_ERR,H5A_ERRSTACK_HASHSIZE,0,NULL))!=FAIL)
@@ -185,7 +185,7 @@ int32 H5Enew_err_stack(uintn initial_stack_size)
H5E_errstack_t *new_stack=NULL; /* Pointer to the new error stack */
int32 ret_value = FAIL;
- FUNC_ENTER(H5Enew_err_stack, H5E_init_interface,FAIL);
+ FUNC_ENTER(H5Enew_err_stack, FAIL);
/* Allocate the stack header */
if((new_stack=HDmalloc(sizeof(H5E_errstack_t)))==NULL)
@@ -234,7 +234,7 @@ intn H5Edelete_err_stack(int32 err_stack)
H5E_errstack_t *old_stack=NULL; /* Pointer to the new error stack */
intn ret_value = SUCCEED;
- FUNC_ENTER(H5Edelete_err_stack, H5E_init_interface,FAIL);
+ FUNC_ENTER(H5Edelete_err_stack, FAIL);
/* Clear errors and check args and all the boring stuff. */
if (H5Aatom_group(err_stack)!=H5_ERR)
@@ -287,7 +287,7 @@ H5Eclear (int32 err_hand)
H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */
herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5Eclear, H5E_init_interface, FAIL);
+ FUNC_ENTER (H5Eclear, FAIL);
/* Get the error stack for this error handler, initialized earlier in H5Enew_err_stack */
if (H5Aatom_group(err_hand)!=H5_ERR)
@@ -341,7 +341,7 @@ H5E_store(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const cha
H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5E_store, H5E_init_interface,FAIL);
+ FUNC_ENTER(H5E_store, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5Eclear(errid);
@@ -407,7 +407,7 @@ H5Epush(hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_nam
H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Epush, H5E_init_interface,FAIL);
+ FUNC_ENTER(H5Epush, FAIL);
/* Clear errors and check args and all the boring stuff. */
if (function_name==NULL || file_name==NULL || H5Aatom_group(thrderrid)!=H5_ERR)
@@ -453,7 +453,7 @@ H5E_push_func_t H5Eset_push(H5E_push_func_t func)
H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */
H5E_push_func_t ret_value = NULL;
- FUNC_ENTER(H5Eset_push, H5E_init_interface,NULL);
+ FUNC_ENTER(H5Eset_push, NULL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
diff --git a/src/H5F.c b/src/H5F.c
index 0fa3f71..00543ad 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -62,11 +62,38 @@ static char RcsId[] = "@(#)$Revision$";
/*--------------------- Locally scoped variables -----------------------------*/
-/* Whether we've installed the library termination function yet for this interface */
+/*
+ * Define the default file creation template.
+ */
+const H5F_create_t H5F_create_dflt = {
+ 0, /* Default user-block size */
+ 4, /* Default 1/2 rank for symtab leaf nodes */
+ { /* Default 1/2 rank for btree intern nodes*/
+ 16, /* Symbol table internal nodes */
+ 32, /* Indexed storage internal nodes */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ },
+ 4, /* Default offset size */
+ 4, /* Default length size */
+ HDF5_BOOTBLOCK_VERSION, /* Current Boot-Block version # */
+ HDF5_SMALLOBJECT_VERSION, /* Current Small-Object heap version # */
+ HDF5_FREESPACE_VERSION, /* Current Free-Space info version # */
+ HDF5_OBJECTDIR_VERSION, /* Current Object Directory info version # */
+ HDF5_SHAREDHEADER_VERSION, /* Current Shared-Header format version # */
+};
+
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
-
-/*--------------------- Local function prototypes ----------------------------*/
+#define INTERFACE_INIT H5F_init_interface
static herr_t H5F_init_interface(void);
+static void H5F_term_interface (void);
+
+/* PRIVATE PROTOTYPES */
static H5F_t *H5F_new (H5F_file_t *shared);
static H5F_t *H5F_dest (H5F_t *f);
static herr_t H5F_flush (H5F_t *f, hbool_t invalidate);
@@ -94,7 +121,7 @@ Modifications:
static herr_t H5F_init_interface(void)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5F_init_interface, NULL, FAIL);
+ FUNC_ENTER (H5F_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if((ret_value=H5Ainit_group(H5_FILE,H5A_FILEID_HASHSIZE,0,NULL))!=FAIL)
@@ -120,10 +147,11 @@ static herr_t H5F_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void H5F_term_interface (void)
+static void
+H5F_term_interface (void)
{
H5Adestroy_group(H5_FILE);
-} /* end H5F_term_interface() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -171,37 +199,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5F_compare_files -- compare file objects for the atom API
- USAGE
- intn HPcompare_filename(obj, key)
- const VOIDP obj; IN: pointer to the file record
- const VOIDP key; IN: pointer to the search key
-
- ERRORS
-
- RETURNS
- TRUE if the key matches the obj, FALSE otherwise
- DESCRIPTION
- Look inside the file record for the atom API and compare the the
- keys.
---------------------------------------------------------------------------*/
-static intn
-H5F_compare_files (const VOIDP _obj, const VOIDP _key)
-{
- const H5F_t *obj = (const H5F_t *)_obj;
- const H5F_search_t *key = (const H5F_search_t *)_key;
- int ret_value = FALSE;
-
- FUNC_ENTER (H5F_compare_files, NULL, FALSE);
-
- ret_value = (obj->shared->key.dev == key->dev &&
- obj->shared->key.ino == key->ino);
-
- FUNC_LEAVE (ret_value);
-}
-
-/*--------------------------------------------------------------------------
- NAME
H5Fget_create_template
PURPOSE
@@ -223,36 +220,64 @@ H5F_compare_files (const VOIDP _obj, const VOIDP _key)
This function returns an atom with a copy of the template parameters
used to create a file.
--------------------------------------------------------------------------*/
-hid_t H5Fget_create_template(hid_t fid)
+hid_t
+H5Fget_create_template (hid_t fid)
{
- H5F_t *file=NULL; /* file struct for file to close */
- hid_t ret_value = FAIL;
-
- FUNC_ENTER(H5Fget_create_template, H5F_init_interface, FAIL);
+ H5F_t *file = NULL;
+ hid_t ret_value = FAIL;
+ H5F_create_t *tmpl = NULL;
- /* Clear errors and check args and all the boring stuff. */
+ FUNC_ENTER (H5Fget_create_template, FAIL);
H5ECLEAR;
- /* Get the file structure */
- if((file=H5Aatom_object(fid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't get file struct*/
+ /* check args */
+ if (H5_FILE!=H5Aatom_group (fid)) {
+ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*not a file*/
+ }
+ if (NULL==(file=H5Aatom_object (fid))) {
+ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*can't get file struct*/
+ }
/* Create the template object to return */
- if((ret_value=H5Mcreate(fid,H5_TEMPLATE,NULL))==FAIL)
- HGOTO_ERROR(H5E_FUNC, H5E_CANTCREATE, FAIL); /*can't create template*/
+ tmpl = H5MM_xmalloc (sizeof(H5F_create_t));
+ *tmpl = file->shared->create_parms;
+ if ((ret_value=H5C_create (H5C_FILE_CREATE, tmpl))<0) {
+ /* Can't register template */
+ HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL);
+ }
- if(H5C_init(ret_value,&(file->shared->file_create_parms))==FAIL)
- HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL); /*can't init template*/
+ FUNC_LEAVE (ret_value);
+}
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+/*--------------------------------------------------------------------------
+ NAME
+ H5F_compare_files -- compare file objects for the atom API
+ USAGE
+ intn HPcompare_filename(obj, key)
+ const VOIDP obj; IN: pointer to the file record
+ const VOIDP key; IN: pointer to the search key
- } /* end if */
+ ERRORS
- /* Normal function cleanup */
+ RETURNS
+ TRUE if the key matches the obj, FALSE otherwise
+ DESCRIPTION
+ Look inside the file record for the atom API and compare the the
+ keys.
+--------------------------------------------------------------------------*/
+static intn
+H5F_compare_files (const VOIDP _obj, const VOIDP _key)
+{
+ const H5F_t *obj = (const H5F_t *)_obj;
+ const H5F_search_t *key = (const H5F_search_t *)_key;
+ int ret_value = FALSE;
+
+ FUNC_ENTER (H5F_compare_files, FALSE);
- FUNC_LEAVE(ret_value);
+ ret_value = (obj->shared->key.dev == key->dev &&
+ obj->shared->key.ino == key->ino);
+
+ FUNC_LEAVE (ret_value);
}
@@ -282,7 +307,7 @@ H5F_locate_signature (H5F_low_t *f_handle, haddr_t *addr/*out*/)
uint8 buf[H5F_SIGNATURE_LEN];
uintn n=9;
- FUNC_ENTER (H5F_locate_signature, H5F_init_interface, FAIL);
+ FUNC_ENTER (H5F_locate_signature, FAIL);
H5F_low_size (f_handle, &max_addr);
H5F_addr_reset (addr);
@@ -327,7 +352,7 @@ hbool_t H5Fis_hdf5(const char *filename)
haddr_t addr; /* Address of file signature & header */
hbool_t ret_value = BFALSE;
- FUNC_ENTER(H5Fis_hdf5, H5F_init_interface, BFAIL);
+ FUNC_ENTER(H5Fis_hdf5, BFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -377,7 +402,7 @@ static H5F_t *
H5F_new (H5F_file_t *shared)
{
H5F_t *f = NULL;
- FUNC_ENTER (H5F_new, H5F_init_interface, NULL);
+ FUNC_ENTER (H5F_new, NULL);
f = H5MM_xcalloc (1, sizeof(H5F_t));
f->shared = shared;
@@ -391,7 +416,7 @@ H5F_new (H5F_file_t *shared)
H5F_addr_undef (&(f->shared->hdf5_eof));
/* Create a main cache */
- H5AC_new (f, H5AC_NSLOTS);
+ H5AC_create (f, H5AC_NSLOTS);
/* Create the shadow hash table */
f->shared->nshadows = H5G_NSHADOWS;
@@ -433,7 +458,7 @@ H5F_new (H5F_file_t *shared)
static H5F_t *
H5F_dest (H5F_t *f)
{
- FUNC_ENTER (H5F_dest, H5F_init_interface, NULL);
+ FUNC_ENTER (H5F_dest, NULL);
if (f) {
if (0 == --(f->shared->nrefs)) {
@@ -546,7 +571,7 @@ H5F_dest (H5F_t *f)
*/
H5F_t *
H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
- const file_create_temp_t *create_parms)
+ const H5F_create_t *create_parms)
{
H5F_t *f = NULL; /*return value */
H5F_t *ret_value = NULL; /*a copy of `f' */
@@ -559,11 +584,11 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
const uint8 *p=NULL; /* ..and pointer into it*/
size_t fixed_size = 24; /*size of fixed part of boot blk*/
size_t variable_size; /*variable part of boot block */
- file_create_temp_t *cp=NULL; /*file creation parameters */
+ H5F_create_t *cp=NULL; /*file creation parameters */
haddr_t addr1, addr2; /*temporary address */
const char *s = name;
- FUNC_ENTER (H5F_open, H5F_init_interface, NULL);
+ FUNC_ENTER (H5F_open, NULL);
assert (name && *name);
@@ -618,17 +643,7 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
/*
* If no file creation parameters are supplied then use defaults.
*/
- if (!create_parms) {
- hid_t create_temp = H5C_get_default_atom (H5_TEMPLATE);
- if (create_temp<0) {
- /* Can't get default file create template id */
- HRETURN_ERROR (H5E_FILE, H5E_CANTINIT, NULL);
- }
- if (NULL==(create_parms=H5Aatom_object (create_temp))) {
- /* Can't unatomize default template id */
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL);
- }
- }
+ if (!create_parms) create_parms = &H5F_create_dflt;
/*
* Does the file exist? If so, get the device and i-node values so we can
@@ -742,11 +757,9 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
* first time this file is opened.
*/
if (1==f->shared->nrefs) {
- HDmemcpy (&(f->shared->file_create_parms),
- create_parms,
- sizeof(file_create_temp_t));
+ f->shared->create_parms = *create_parms;
}
- cp = &(f->shared->file_create_parms);
+ cp = &(f->shared->create_parms);
/*
* Read or write the file boot block.
@@ -760,7 +773,7 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
*/
H5F_addr_reset (&(f->shared->boot_addr));
H5F_addr_inc (&(f->shared->boot_addr),
- f->shared->file_create_parms.userblock_size);
+ f->shared->create_parms.userblock_size);
f->shared->base_addr = f->shared->boot_addr;
f->shared->consist_flags = 0x03;
@@ -786,7 +799,7 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
* user-defined data.
*/
f->shared->base_addr = f->shared->boot_addr;
- f->shared->file_create_parms.userblock_size=f->shared->base_addr.offset;
+ f->shared->create_parms.userblock_size=f->shared->base_addr.offset;
/*
* Decode the fixed size part of the boot block. For each of the
@@ -866,8 +879,8 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
assert (p-buf == fixed_size);
/* Read the variable length part of the boot block... */
- variable_size = H5F_SIZEOF_OFFSET (f) + /*global small obj heap*/
- H5F_SIZEOF_OFFSET (f) + /*global free list addr*/
+ variable_size = H5F_SIZEOF_ADDR (f) + /*global small obj heap*/
+ H5F_SIZEOF_ADDR (f) + /*global free list addr*/
H5F_SIZEOF_SIZE (f) + /*logical file size*/
H5G_SIZEOF_ENTRY (f);
assert (variable_size <= sizeof buf);
@@ -990,12 +1003,12 @@ hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
hid_t access_temp)
{
H5F_t *new_file=NULL; /* file struct for new file */
- const file_create_temp_t *create_parms; /* pointer to the parameters to
+ const H5F_create_t *create_parms; /* pointer to the parameters to
* use when creating the file
*/
hid_t ret_value = FAIL;
- FUNC_ENTER(H5Fcreate, H5F_init_interface, FAIL);
+ FUNC_ENTER(H5Fcreate, FAIL);
H5ECLEAR;
/* Check/fix arguments */
@@ -1005,15 +1018,19 @@ hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*invalid flags*/
flags = (H5F_ACC_WRITE | H5F_ACC_CREAT) |
(H5ACC_OVERWRITE==flags ? H5F_ACC_TRUNC : H5F_ACC_EXCL);
- if (0==create_temp)
- create_temp = H5C_get_default_atom (H5_TEMPLATE);
- if (NULL==(create_parms=H5Aatom_object(create_temp)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/
+
+ if (create_temp<=0) {
+ create_parms = &H5F_create_dflt;
+ } else if (NULL==(create_parms=H5Aatom_object (create_temp))) {
+ HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/
+ }
+
#ifdef LATER
- if (0==access_temp)
- access_temp = H5CPget_default_atom(H5_TEMPLATE);
- if (NULL==(access_parms=H5Aatom_object(access_temp)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/
+ if (access_temp<=0) {
+ access_parms = &H5F_access_dflt;
+ } else if (NULL==(access_parms=H5Aatom_object (access_temp))) {
+ HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/
+ }
#endif
/*
@@ -1086,7 +1103,7 @@ hid_t H5Fopen(const char *filename, uintn flags, hid_t access_temp)
H5F_t *new_file=NULL; /* file struct for new file */
hid_t ret_value = FAIL;
- FUNC_ENTER(H5Fopen, H5F_init_interface, FAIL);
+ FUNC_ENTER(H5Fopen, FAIL);
H5ECLEAR;
/* Check/fix arguments. */
@@ -1152,7 +1169,7 @@ H5F_flush (H5F_t *f, hbool_t invalidate)
uint8 buf[2048], *p=buf;
herr_t shadow_flush;
- FUNC_ENTER (H5F_flush, H5F_init_interface, FAIL);
+ FUNC_ENTER (H5F_flush, FAIL);
/*
* Nothing to do if the file is read only. This determination is made at
@@ -1177,16 +1194,16 @@ H5F_flush (H5F_t *f, hbool_t invalidate)
HDmemcpy (p, H5F_SIGNATURE, H5F_SIGNATURE_LEN);
p += H5F_SIGNATURE_LEN;
- *p++ = f->shared->file_create_parms.bootblock_ver;
- *p++ = f->shared->file_create_parms.smallobject_ver;
- *p++ = f->shared->file_create_parms.freespace_ver;
- *p++ = f->shared->file_create_parms.objectdir_ver;
- *p++ = f->shared->file_create_parms.sharedheader_ver;
- *p++ = H5F_SIZEOF_OFFSET (f);
+ *p++ = f->shared->create_parms.bootblock_ver;
+ *p++ = f->shared->create_parms.smallobject_ver;
+ *p++ = f->shared->create_parms.freespace_ver;
+ *p++ = f->shared->create_parms.objectdir_ver;
+ *p++ = f->shared->create_parms.sharedheader_ver;
+ *p++ = H5F_SIZEOF_ADDR (f);
*p++ = H5F_SIZEOF_SIZE (f);
*p++ = 0; /*reserved*/
- UINT16ENCODE (p, f->shared->file_create_parms.sym_leaf_k);
- UINT16ENCODE (p, f->shared->file_create_parms.btree_k[H5B_SNODE_ID]);
+ UINT16ENCODE (p, f->shared->create_parms.sym_leaf_k);
+ UINT16ENCODE (p, f->shared->create_parms.btree_k[H5B_SNODE_ID]);
UINT32ENCODE (p, f->shared->consist_flags);
H5F_addr_encode (f, &p, &(f->shared->smallobj_addr));
H5F_addr_encode (f, &p, &(f->shared->freespace_addr));
@@ -1218,58 +1235,6 @@ H5F_flush (H5F_t *f, hbool_t invalidate)
FUNC_LEAVE (SUCCEED);
}
-/*--------------------------------------------------------------------------
- NAME
- H5Fflush
-
- PURPOSE
- Flush all cached data to disk and optionally invalidates all cached
- data.
-
- USAGE
- herr_t H5Fflush(fid, invalidate)
- hid_t fid; IN: File ID of file to close.
- hbool_t invalidate; IN: Invalidate all of the cache?
-
- ERRORS
- ARGS BADTYPE Not a file atom.
- ATOM BADATOM Can't get file struct.
- CACHE CANTFLUSH Flush failed.
-
- RETURNS
- SUCCEED/FAIL
-
- DESCRIPTION
- This function flushes all cached data to disk and, if INVALIDATE
- is non-zero, removes cached objects from the cache so they must be
- re-read from the file on the next access to the object.
-
- MODIFICATIONS:
---------------------------------------------------------------------------*/
-herr_t
-H5Fflush (hid_t fid, hbool_t invalidate)
-{
- H5F_t *file = NULL;
-
- FUNC_ENTER (H5Fflush, H5F_init_interface, FAIL);
- H5ECLEAR;
-
- /* check arguments */
- if (H5_FILE!=H5Aatom_group (fid)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a file atom*/
- }
- if (NULL==(file=H5Aatom_object (fid))) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*can't get file struct*/
- }
-
- /* do work */
- if (H5F_flush (file, invalidate)<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); /*flush failed*/
- }
-
- FUNC_LEAVE (SUCCEED);
-}
-
/*-------------------------------------------------------------------------
* Function: H5F_close
@@ -1293,7 +1258,7 @@ H5F_close (H5F_t *f)
{
herr_t ret_value = FAIL;
- FUNC_ENTER (H5F_close, H5F_init_interface, FAIL);
+ FUNC_ENTER (H5F_close, FAIL);
if (-2==(ret_value=H5F_flush (f, TRUE))) {
/*objects are still open, but don't fail yet*/
@@ -1302,6 +1267,7 @@ H5F_close (H5F_t *f)
HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL);
}
if (f->intent & H5F_ACC_DEBUG) H5AC_debug (f);
+
H5F_low_close (f->shared->lf);
H5F_dest (f);
@@ -1351,7 +1317,7 @@ herr_t H5Fclose(hid_t fid)
H5F_t *file=NULL; /* file struct for file to close */
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Fclose, H5F_init_interface, FAIL);
+ FUNC_ENTER(H5Fclose, FAIL);
H5ECLEAR;
/* Check/fix arguments. */
@@ -1400,7 +1366,7 @@ H5F_block_read (H5F_t *f, const haddr_t *addr, size_t size, void *buf)
{
haddr_t abs_addr;
- FUNC_ENTER (H5F_block_read, H5F_init_interface, FAIL);
+ FUNC_ENTER (H5F_block_read, FAIL);
if (0==size) return 0;
@@ -1441,11 +1407,11 @@ 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, void *buf)
+H5F_block_write (H5F_t *f, const haddr_t *addr, size_t size, const void *buf)
{
haddr_t abs_addr;
- FUNC_ENTER (H5F_block_write, H5F_init_interface, FAIL);
+ FUNC_ENTER (H5F_block_write, FAIL);
if (0==size) return 0;
@@ -1492,7 +1458,7 @@ herr_t
H5F_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
intn fwidth)
{
- FUNC_ENTER (H5F_debug, H5F_init_interface, FAIL);
+ FUNC_ENTER (H5F_debug, FAIL);
/* check args */
assert (f);
@@ -1544,34 +1510,34 @@ H5F_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
fprintf (stream, "%*s%-*s %lu bytes\n", indent, "", fwidth,
"Size of user block:",
- (unsigned long)(f->shared->file_create_parms.userblock_size));
+ (unsigned long)(f->shared->create_parms.userblock_size));
fprintf (stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
"Size of file size_t type:",
- (unsigned)(f->shared->file_create_parms.sizeof_size));
+ (unsigned)(f->shared->create_parms.sizeof_size));
fprintf (stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
"Size of file haddr_t type:",
- (unsigned)(f->shared->file_create_parms.sizeof_addr));
+ (unsigned)(f->shared->create_parms.sizeof_addr));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Symbol table leaf node 1/2 rank:",
- (unsigned)(f->shared->file_create_parms.sym_leaf_k));
+ (unsigned)(f->shared->create_parms.sym_leaf_k));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Symbol table internal node 1/2 rank:",
- (unsigned)(f->shared->file_create_parms.btree_k[H5B_SNODE_ID]));
+ (unsigned)(f->shared->create_parms.btree_k[H5B_SNODE_ID]));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Boot block version number:",
- (unsigned)(f->shared->file_create_parms.bootblock_ver));
+ (unsigned)(f->shared->create_parms.bootblock_ver));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Small object heap version number:",
- (unsigned)(f->shared->file_create_parms.smallobject_ver));
+ (unsigned)(f->shared->create_parms.smallobject_ver));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Free list version number:",
- (unsigned)(f->shared->file_create_parms.freespace_ver));
+ (unsigned)(f->shared->create_parms.freespace_ver));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Object directory version number:",
- (unsigned)(f->shared->file_create_parms.objectdir_ver));
+ (unsigned)(f->shared->create_parms.objectdir_ver));
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Shared header version number:",
- (unsigned)(f->shared->file_create_parms.sharedheader_ver));
+ (unsigned)(f->shared->create_parms.sharedheader_ver));
fprintf (stream, "%*sRoot symbol table entry:\n", indent, "");
H5G_ent_debug (f, f->shared->root_sym, stream, indent+3, MAX(0, fwidth-3));
diff --git a/src/H5Fcore.c b/src/H5Fcore.c
index d520cc1..a024e20 100644
--- a/src/H5Fcore.c
+++ b/src/H5Fcore.c
@@ -24,6 +24,7 @@
#define PABLO_MASK H5F_core
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
static hbool_t H5F_core_access (const char *name, int mode, H5F_search_t *key);
static H5F_low_t *H5F_core_open (const char *name, uintn flags, H5F_search_t*);
@@ -66,7 +67,7 @@ const H5F_low_class_t H5F_LOW_CORE[1] = {{
static hbool_t
H5F_core_access (const char *name, int mode, H5F_search_t *key/*out*/)
{
- FUNC_ENTER (H5F_core_access, NULL, FAIL);
+ FUNC_ENTER (H5F_core_access, FAIL);
FUNC_LEAVE (FALSE);
}
@@ -98,7 +99,7 @@ H5F_core_open (const char *name, uintn flags, H5F_search_t *key)
H5F_low_t *lf = NULL;
static ino_t ino=0;
- FUNC_ENTER (H5F_core_open, NULL, NULL);
+ FUNC_ENTER (H5F_core_open, NULL);
if (0==(flags & H5F_ACC_WRITE) || 0==(flags & H5F_ACC_CREAT)) {
/* must creat file with write access */
@@ -141,7 +142,7 @@ H5F_core_open (const char *name, uintn flags, H5F_search_t *key)
static herr_t
H5F_core_close (H5F_low_t *lf)
{
- FUNC_ENTER (H5F_core_close, NULL, FAIL);
+ FUNC_ENTER (H5F_core_close, FAIL);
lf->u.core.mem = H5MM_xfree (lf->u.core.mem);
lf->u.core.size = 0;
@@ -177,7 +178,7 @@ H5F_core_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
size_t n;
size_t eof;
- FUNC_ENTER (H5F_core_read, NULL, FAIL);
+ FUNC_ENTER (H5F_core_read, FAIL);
assert (lf);
assert (addr && H5F_addr_defined (addr));
@@ -224,7 +225,7 @@ H5F_core_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
{
size_t inc_amount;
- FUNC_ENTER (H5F_core_write, NULL, FAIL);
+ FUNC_ENTER (H5F_core_write, FAIL);
assert (lf);
assert (addr && H5F_addr_defined (addr));
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index 6840c03..bf0431f 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -28,6 +28,7 @@
#define PABLO_MASK H5F_family
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*
* Number of bits in the member address. This can be up to (but not
@@ -97,7 +98,7 @@ H5F_fam_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
size_t nbits=H5F_FAM_DFLT_NBITS;/*num bits in an offset */
haddr_t tmp_addr; /*temporary address */
- FUNC_ENTER (H5F_fam_open, NULL, NULL);
+ FUNC_ENTER (H5F_fam_open, NULL);
/*
* If we're truncating the file then delete all but the first family
@@ -227,7 +228,7 @@ H5F_fam_close (H5F_low_t *lf)
{
intn membno;
- FUNC_ENTER (H5F_fam_close, NULL, FAIL);
+ FUNC_ENTER (H5F_fam_close, FAIL);
assert (lf);
@@ -273,7 +274,7 @@ H5F_fam_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
off_t offset;
size_t member_size;
- FUNC_ENTER (H5F_fam_read, NULL, FAIL);
+ FUNC_ENTER (H5F_fam_read, FAIL);
assert (lf);
assert (addr && H5F_addr_defined (addr));
@@ -339,7 +340,7 @@ H5F_fam_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
intn i;
size_t member_size;
- FUNC_ENTER (H5F_fam_write, NULL, FAIL);
+ FUNC_ENTER (H5F_fam_write, FAIL);
assert (lf);
assert (addr && H5F_addr_defined (addr));
@@ -440,7 +441,7 @@ H5F_fam_flush (H5F_low_t *lf)
haddr_t addr1, addr2, addr3;
size_t max_offset;
- FUNC_ENTER (H5F_fam_flush, NULL, FAIL);
+ FUNC_ENTER (H5F_fam_flush, FAIL);
/*
* Make sure that the first family member is the maximum size because
@@ -508,7 +509,7 @@ H5F_fam_access (const char *name, int mode, H5F_search_t *key/*out*/)
char member_name[4096];
hbool_t status;
- FUNC_ENTER (H5F_fam_access, NULL, FAIL);
+ FUNC_ENTER (H5F_fam_access, FAIL);
for (membno=0; /*void*/; membno++) {
sprintf (member_name, name, membno);
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index b997945..d506665 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -24,8 +24,9 @@ typedef enum H5F_isop_t {
#define PABLO_MASK H5F_istore_mask
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/* PRIVATE PROTOTYPES */
static size_t H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata);
@@ -70,6 +71,7 @@ static herr_t H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore,
* The storage file address is part of the B-tree and not part of the key.
*/
typedef struct H5F_istore_key_t {
+ uintn file_number; /*external file number */
size_t offset[H5O_ISTORE_NDIMS]; /*logical offset to start*/
size_t size[H5O_ISTORE_NDIMS]; /*logical chunk size */
} H5F_istore_key_t;
@@ -122,11 +124,16 @@ static size_t
H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata)
{
const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *)_udata;
+ size_t nbytes;
assert (udata);
assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_ISTORE_NDIMS);
- return udata->mesg.ndims * (4 + 4);
+ nbytes = 4 + /*external file number */
+ udata->mesg.ndims * 4 + /*dimension indices */
+ udata->mesg.ndims * 4; /*dimension sizes */
+
+ return nbytes;
}
@@ -154,16 +161,18 @@ H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
int i;
int ndims = bt->sizeof_rkey / 8;
- FUNC_ENTER (H5F_istore_decode_key, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_decode_key, FAIL);
/* check args */
assert (f);
assert (bt);
assert (raw);
assert (key);
- assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS && 8*ndims==bt->sizeof_rkey);
+ assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS);
/* decode */
+ UINT32DECODE (raw, key->file_number);
+ assert (0==key->file_number);
for (i=0; i<ndims; i++) {
UINT32DECODE (raw, key->offset[i]);
UINT32DECODE (raw, key->size[i]);
@@ -197,16 +206,18 @@ H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
intn ndims = bt->sizeof_rkey / 8;
intn i;
- FUNC_ENTER (H5F_istore_encode_key, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_encode_key, FAIL);
/* check args */
assert (f);
assert (bt);
assert (raw);
assert (key);
- assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS && 8*ndims==bt->sizeof_rkey);
+ assert (ndims>0 && ndims<=H5O_ISTORE_NDIMS);
/* encode */
+ UINT32ENCODE (raw, key->file_number);
+ assert (0==key->file_number);
for (i=0; i<ndims; i++) {
UINT32ENCODE (raw, key->offset[i]);
UINT32ENCODE (raw, key->size[i]);
@@ -221,7 +232,8 @@ H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
*
* Purpose: Compares two keys sort of like strcmp(). The UDATA pointer
* is only to supply extra information not carried in the keys
- * (in this case, the dimensionality).
+ * (in this case, the dimensionality) and is not compared
+ * against the keys.
*
* Return: Success: -1 if LT_KEY is less than RT_KEY;
* 1 if LT_KEY is greater than RT_KEY;
@@ -244,13 +256,14 @@ H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
intn cmp;
- FUNC_ENTER (H5F_istore_cmp2, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_cmp2, FAIL);
assert (lt_key);
assert (rt_key);
assert (udata);
assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_ISTORE_NDIMS);
-
+
+ /* Compare the offsets but ignore the other fields */
cmp = H5V_vector_cmp (udata->mesg.ndims, lt_key->offset, rt_key->offset);
FUNC_LEAVE (cmp);
@@ -294,7 +307,7 @@ H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
intn cmp = 0;
- FUNC_ENTER (H5F_istore_cmp3, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_cmp3, FAIL);
assert (lt_key);
assert (rt_key);
@@ -343,7 +356,7 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
size_t nbytes;
intn i;
- FUNC_ENTER (H5F_istore_new_node, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_new_node, FAIL);
/* check args */
assert (f);
@@ -361,6 +374,9 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL);
}
udata->addr = *addr;
+ udata->key.file_number = 0;
+ lt_key->file_number = udata->key.file_number;
+ if (H5B_INS_LEFT!=op) rt_key->file_number = 0;
/* Initialize the key(s) */
for (i=0; i<udata->mesg.ndims; i++) {
@@ -368,9 +384,9 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
* The left key describes the storage of the UDATA chunk being inserted
* into the tree.
*/
+ assert (udata->key.size[i]>0);
lt_key->offset[i] = udata->key.offset[i];
lt_key->size[i] = udata->key.size[i];
- assert (udata->key.size[i]>0);
/*
* The right key might already be present. If not, then add
@@ -416,7 +432,7 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *)_lt_key;
int i;
- FUNC_ENTER (H5F_istore_found, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_found, FAIL);
/* Check arguments */
assert (f);
@@ -426,6 +442,8 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
/* Initialize return values */
udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
+ assert (0==lt_key->file_number);
for (i=0; i<udata->mesg.ndims; i++) {
udata->key.offset[i] = lt_key->offset[i];
udata->key.size[i] = lt_key->size[i];
@@ -435,7 +453,6 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
FUNC_LEAVE (SUCCEED);
}
-
/*-------------------------------------------------------------------------
* Function: H5F_istore_insert
@@ -482,7 +499,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
H5B_ins_t ret_value = H5B_INS_ERROR;
size_t nbytes;
- FUNC_ENTER (H5F_istore_insert, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_insert, FAIL);
/* check args */
assert (f);
@@ -510,6 +527,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
* Already exists. Just return the info.
*/
udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
ret_value = H5B_INS_NOOP;
} else if (H5V_hyper_disjointp (udata->mesg.ndims,
@@ -523,6 +541,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
* Split this node, inserting the new new node to the right of the
* current node. The MD_KEY is where the split occurs.
*/
+ md_key->file_number = udata->key.file_number;
for (i=0, nbytes=1; i<udata->mesg.ndims; i++) {
assert (0==udata->key.offset[i] % udata->mesg.alignment[i]);
assert (udata->key.size[i] == udata->mesg.alignment[i]);
@@ -538,6 +557,7 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL);
}
udata->addr = *new_node;
+ udata->key.file_number = 0;
ret_value = H5B_INS_RIGHT;
} else {
@@ -600,7 +620,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
herr_t status;
herr_t ret_value = FAIL;
- FUNC_ENTER (H5F_istore_copy_hyperslab, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_copy_hyperslab, FAIL);
/* check args */
assert (f);
@@ -644,6 +664,9 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
/* Read/Write chunk or create it if it doesn't exist */
udata.mesg.ndims = istore->ndims;
+ H5F_addr_undef (&(udata.addr));
+ udata.key.file_number = 0;
+
for (i=0; i<istore->ndims; i++) {
/* The location and size of the chunk being accessed */
@@ -679,6 +702,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
!H5V_vector_zerop (istore->ndims, offset_wrt_chunk) ||
!H5V_vector_eq (istore->ndims, sub_size, udata.key.size)) {
if (status>=0 && H5F_addr_defined (&(udata.addr))) {
+ assert (0==udata.key.file_number);
if (H5F_block_read (f, &(udata.addr), chunk_size, chunk)<0) {
HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL);
}
@@ -692,6 +716,7 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_istore_t *istore, H5F_isop_t op,
H5V_hyper_copy (istore->ndims, sub_size,
udata.key.size, offset_wrt_chunk, chunk,
size_m, sub_offset_m, buf);
+ assert (0==udata.key.file_number);
if (H5F_block_write (f, &(udata.addr), chunk_size, chunk)<0) {
HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
}
@@ -738,7 +763,7 @@ herr_t
H5F_istore_read (H5F_t *f, const H5O_istore_t *istore,
const size_t offset[], const size_t size[], void *buf)
{
- FUNC_ENTER (H5F_istore_read, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_read, FAIL);
/* Check args */
assert (f);
@@ -778,7 +803,7 @@ herr_t
H5F_istore_write (H5F_t *f, const H5O_istore_t *istore,
const size_t offset[], const size_t size[], void *buf)
{
- FUNC_ENTER (H5F_istore_write, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_write, FAIL);
/* Check args */
assert (f);
@@ -799,7 +824,7 @@ H5F_istore_write (H5F_t *f, const H5O_istore_t *istore,
/*-------------------------------------------------------------------------
- * Function: H5F_istore_new
+ * Function: H5F_istore_create
*
* Purpose: Creates a new indexed-storage B-tree and initializes the
* istore struct with information about the storage. The
@@ -821,13 +846,13 @@ H5F_istore_write (H5F_t *f, const H5O_istore_t *istore,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_new (H5F_t *f, struct H5O_istore_t *istore,
- uintn ndims, const size_t alignment[])
+H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore,
+ uintn ndims, const size_t alignment[])
{
H5F_istore_ud1_t udata;
int i;
- FUNC_ENTER (H5F_istore_new, NULL, FAIL);
+ FUNC_ENTER (H5F_istore_create, FAIL);
/* Check args */
assert (f);
@@ -841,7 +866,7 @@ H5F_istore_new (H5F_t *f, struct H5O_istore_t *istore,
#endif
udata.mesg.ndims = istore->ndims = ndims;
- if (H5B_new (f, H5B_ISTORE, &udata, &(istore->btree_addr)/*out*/)<0) {
+ if (H5B_create (f, H5B_ISTORE, &udata, &(istore->btree_addr)/*out*/)<0) {
HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL); /* Can't create B-tree */
}
diff --git a/src/H5Flow.c b/src/H5Flow.c
index 55010bc..0dfd11c 100644
--- a/src/H5Flow.c
+++ b/src/H5Flow.c
@@ -21,6 +21,7 @@
#define PABLO_MASK H5F_low
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -72,7 +73,7 @@ H5F_low_open (const H5F_low_class_t *type, const char *name, uintn flags,
{
H5F_low_t *lf = NULL;
- FUNC_ENTER (H5F_low_open, NULL, NULL);
+ FUNC_ENTER (H5F_low_open, NULL);
assert (type && type->open);
assert (name && *name);
@@ -117,7 +118,7 @@ H5F_low_open (const H5F_low_class_t *type, const char *name, uintn flags,
H5F_low_t *
H5F_low_close (H5F_low_t *lf)
{
- FUNC_ENTER (H5F_low_close, NULL, NULL);
+ FUNC_ENTER (H5F_low_close, NULL);
if (lf) {
if ((lf->type->close)(lf)<0) {
@@ -163,7 +164,7 @@ H5F_low_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
{
herr_t ret_value = FAIL;
- FUNC_ENTER (H5F_low_read, NULL, FAIL);
+ FUNC_ENTER (H5F_low_read, FAIL);
assert (lf && lf->type);
assert (addr && H5F_addr_defined (addr));
@@ -213,7 +214,7 @@ H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
herr_t ret_value = FAIL;
haddr_t tmp_addr;
- FUNC_ENTER (H5F_low_write, NULL, FAIL);
+ FUNC_ENTER (H5F_low_write, FAIL);
assert (lf && lf->type);
assert (addr && H5F_addr_defined (addr));
@@ -244,10 +245,14 @@ H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
* Function: H5F_low_flush
*
* Purpose: Flushes file buffers to disk. For instance, the stdio.h
- * driver would call fflush().
- *
- * If the subclass doesn't define a flush method then this
- * function doesn't do anything.
+ * driver would call fflush(). Flushing also insures that the
+ * file exists to the current logical EOF (the library maintains
+ * a notion of EOF which is independent of the physical EOF) by
+ * reading and writing the last byte. On some systems, this
+ * allocates a single block at the end of the file while on
+ * other systems it allocates all blocks up to the end of the
+ * file. Extending the physical file is necessary because
+ * H5F_open() checks for truncated files.
*
* Return: Success: SUCCEED
*
@@ -263,10 +268,24 @@ H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
herr_t
H5F_low_flush (H5F_low_t *lf)
{
- FUNC_ENTER (H5F_low_flush, NULL, FAIL);
+ haddr_t last_byte;
+ uint8 buf[1];
+
+ FUNC_ENTER (H5F_low_flush, FAIL);
assert (lf && lf->type);
+ /* Make sure the last block of the file has been allocated on disk */
+ H5F_addr_reset (&last_byte);
+ if (H5F_addr_defined (&(lf->eof)) && H5F_addr_gt (&(lf->eof), &last_byte)) {
+ last_byte = lf->eof;
+ last_byte.offset -= 1;
+ if (H5F_low_read (lf, &last_byte, 1, buf)>=0) {
+ H5F_low_write (lf, &last_byte, 1, buf);
+ }
+ }
+
+ /* Invoke the subclass the flush method */
if (lf->type->flush) {
if ((lf->type->flush)(lf)<0) {
/* Low level flush failed */
@@ -315,7 +334,7 @@ H5F_low_size (H5F_low_t *lf, haddr_t *eof/*out*/)
{
size_t size = (size_t)(-1); /*max possible size*/
- FUNC_ENTER (H5F_low_size, NULL, 0);
+ FUNC_ENTER (H5F_low_size, 0);
assert (lf && lf->type);
assert (eof);
@@ -368,7 +387,7 @@ H5F_low_access (const H5F_low_class_t *type, const char *name, int mode,
hbool_t ret_value;
struct stat sb;
- FUNC_ENTER (H5F_low_size, NULL, 0);
+ FUNC_ENTER (H5F_low_size, 0);
assert (type);
if (type->access) {
@@ -411,7 +430,7 @@ H5F_low_access (const H5F_low_class_t *type, const char *name, int mode,
herr_t
H5F_low_extend (H5F_low_t *lf, intn op, size_t size, haddr_t *addr/*out*/)
{
- FUNC_ENTER (H5F_low_alloc, NULL, FAIL);
+ FUNC_ENTER (H5F_low_alloc, FAIL);
assert (lf);
assert (size>0);
@@ -450,7 +469,7 @@ H5F_low_extend (H5F_low_t *lf, intn op, size_t size, haddr_t *addr/*out*/)
herr_t
H5F_low_seteof (H5F_low_t *lf, const haddr_t *addr)
{
- FUNC_ENTER (H5F_low_seteof, NULL, FAIL);
+ FUNC_ENTER (H5F_low_seteof, FAIL);
assert (lf);
assert (addr && H5F_addr_defined (addr));
@@ -482,7 +501,7 @@ H5F_low_seteof (H5F_low_t *lf, const haddr_t *addr)
intn
H5F_addr_cmp (const haddr_t *a1, const haddr_t *a2)
{
- FUNC_ENTER (H5F_addr_cmp, NULL, FAIL);
+ FUNC_ENTER (H5F_addr_cmp, FAIL);
assert (a1 && H5F_addr_defined (a1));
assert (a2 && H5F_addr_defined (a2));
@@ -493,7 +512,6 @@ H5F_addr_cmp (const haddr_t *a1, const haddr_t *a2)
FUNC_LEAVE (0);
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_undef
@@ -510,8 +528,10 @@ H5F_addr_cmp (const haddr_t *a1, const haddr_t *a2)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_undef (haddr_t *addr)
+H5F_addr_undef (haddr_t *addr/*out*/)
{
+ assert (addr);
+
addr->offset = -1;
}
@@ -535,11 +555,10 @@ H5F_addr_undef (haddr_t *addr)
hbool_t
H5F_addr_defined (const haddr_t *addr)
{
- FUNC_ENTER (H5F_addr_defined, NULL, FAIL);
+ FUNC_ENTER (H5F_addr_defined, FAIL);
FUNC_LEAVE (-1!=addr->offset && addr->offset>=0);
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_reset
@@ -556,12 +575,12 @@ H5F_addr_defined (const haddr_t *addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_reset (haddr_t *addr)
+H5F_addr_reset (haddr_t *addr/*out*/)
{
+ assert (addr);
addr->offset = 0;
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_zerop
@@ -582,11 +601,10 @@ H5F_addr_reset (haddr_t *addr)
hbool_t
H5F_addr_zerop (const haddr_t *addr)
{
- FUNC_ENTER (H5F_addr_zerop, NULL, FAIL);
+ FUNC_ENTER (H5F_addr_zerop, FAIL);
FUNC_LEAVE (0==addr->offset);
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_encode
@@ -616,20 +634,19 @@ H5F_addr_encode (H5F_t *f, uint8 **pp, const haddr_t *addr)
if (H5F_addr_defined (addr)) {
tmp = *addr;
- for (i=0; i<H5F_SIZEOF_OFFSET (f); i++) {
+ for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
*(*pp)++ = tmp.offset & 0xff;
tmp.offset >>= 8;
}
assert ("overflow" && 0==tmp.offset);
} else {
- for (i=0; i<H5F_SIZEOF_OFFSET (f); i++) {
+ for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
*(*pp)++ = 0xff;
}
}
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_decode
@@ -663,7 +680,8 @@ H5F_addr_decode (H5F_t *f, const uint8 **pp, haddr_t *addr/*out*/)
assert (addr);
addr->offset = 0;
- for (i=0; i<H5F_SIZEOF_OFFSET (f); i++) {
+
+ for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
c = *(*pp)++;
if (c!=0xff) all_zero = FALSE;
@@ -678,7 +696,6 @@ H5F_addr_decode (H5F_t *f, const uint8 **pp, haddr_t *addr/*out*/)
if (all_zero) H5F_addr_undef (addr);
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_print
@@ -723,7 +740,6 @@ H5F_addr_print (FILE *stream, const haddr_t *addr)
}
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_pow2
@@ -750,7 +766,6 @@ H5F_addr_pow2 (uintn n, haddr_t *addr/*out*/)
addr->offset <<= n;
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_inc
@@ -774,7 +789,6 @@ H5F_addr_inc (haddr_t *addr/*in,out*/, size_t inc)
addr->offset += inc;
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_add
@@ -798,7 +812,6 @@ H5F_addr_add (haddr_t *a1/*in,out*/, const haddr_t *a2)
a1->offset += a2->offset;
}
-
/*-------------------------------------------------------------------------
* Function: H5F_addr_hash
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index af994c3..31748b2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -49,8 +49,8 @@
#define H5F_SIGNATURE_LEN 8
/* size of size_t and off_t as they exist on disk */
-#define H5F_SIZEOF_OFFSET(F) ((F)->shared->file_create_parms.sizeof_addr)
-#define H5F_SIZEOF_SIZE(F) ((F)->shared->file_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.
@@ -210,10 +210,10 @@
#define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n }
/*
- * File-creation template information structure
+ * File-creation template.
*/
-typedef struct {
- uintn userblock_size; /* Size of the file user block in bytes */
+typedef struct H5F_create_t {
+ uintn userblock_size; /* Size of the file user block in bytes */
uintn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */
uintn btree_k[8]; /* 1/2 rank for btree internal nodes */
uint8 sizeof_addr; /* Number of bytes in an address */
@@ -223,7 +223,7 @@ typedef struct {
uint8 freespace_ver; /* Version # of the free-space information */
uint8 objectdir_ver; /* Version # of the object directory format */
uint8 sharedheader_ver; /* Version # of the shared header format */
-} file_create_temp_t;
+} H5F_create_t;
/*
* These things make a file unique.
@@ -310,7 +310,7 @@ 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().
@@ -327,7 +327,7 @@ typedef struct H5F_file_t {
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 */
- file_create_temp_t file_create_parms; /* File-creation template */
+ H5F_create_t create_parms; /* File-creation template */
#ifdef LATER
file_access_temp_t file_access_parms; /* File-access template */
#endif
@@ -352,18 +352,18 @@ typedef struct H5F_t {
#ifdef NOT_YET
-#define H5F_ENCODE_OFFSET(f,p,o) (H5F_SIZEOF_OFFSET(f)==4 ? UINT32ENCODE(p,o) \
- : H5F_SIZEOF_OFFSET(f)==8 ? UINT64ENCODE(p,o) \
- : H5F_SIZEOF_OFFSET(f)==2 ? UINT16ENCODE(p,o) \
+#define H5F_ENCODE_OFFSET(f,p,o) (H5F_SIZEOF_ADDR(f)==4 ? UINT32ENCODE(p,o) \
+ : H5F_SIZEOF_ADDR(f)==8 ? UINT64ENCODE(p,o) \
+ : H5F_SIZEOF_ADDR(f)==2 ? UINT16ENCODE(p,o) \
: H5FPencode_unusual_offset(f,&(p),(uint8 *)&(o)))
#else /* NOT_YET */
-#define H5F_ENCODE_OFFSET(f,p,o) switch(H5F_SIZEOF_OFFSET(f)) { case 4: UINT32ENCODE(p,o); break;\
+#define H5F_ENCODE_OFFSET(f,p,o) switch(H5F_SIZEOF_ADDR(f)) { case 4: UINT32ENCODE(p,o); break;\
case 8: UINT64ENCODE(p,o); break;\
case 2: UINT16ENCODE(p,o); break;}
#endif /* NOT_YET */
#define H5F_DECODE_OFFSET(f,p,o) \
- switch (H5F_SIZEOF_OFFSET (f)) { \
+ switch (H5F_SIZEOF_ADDR (f)) { \
case 4: \
UINT32DECODE (p, o); \
break; \
@@ -397,17 +397,20 @@ typedef struct H5F_t {
struct H5O_istore_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 file_create_temp_t *create_parms);
+ 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 indexed storage */
-herr_t H5F_istore_new (H5F_t *f, struct H5O_istore_t *istore,
- uintn ndims, const size_t alignment[]);
+herr_t H5F_istore_create (H5F_t *f, struct H5O_istore_t *istore,
+ uintn ndims, const size_t alignment[]);
herr_t H5F_istore_read (H5F_t *f, const struct H5O_istore_t *mesg,
const size_t offset[], const size_t size[],
void *buf);
@@ -417,7 +420,8 @@ herr_t H5F_istore_write (H5F_t *f, const struct H5O_istore_t *mesg,
/* 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, 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);
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index aceb922..818047c 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -37,9 +37,7 @@ hbool_t H5Fis_hdf5(const char *filename);
hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_template, hid_t access_template);
hid_t H5Fopen(const char *filename, uintn flags, hid_t access_template);
herr_t H5Fclose(hid_t fid);
-herr_t H5Fflush (hid_t fid, hbool_t invalidate);
-hid_t H5Fget_create_template(hid_t fid);
-void H5F_term_interface (void);
+hid_t H5Fget_create_template (hid_t fid);
#ifdef __cplusplus
}
diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c
index 531bf10..4d82d11 100644
--- a/src/H5Fsec2.c
+++ b/src/H5Fsec2.c
@@ -25,6 +25,7 @@
#define PABLO_MASK H5F_sec2
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
static H5F_low_t *H5F_sec2_open (const char *name, uintn flags, H5F_search_t*);
static herr_t H5F_sec2_close (H5F_low_t *lf);
@@ -73,7 +74,7 @@ H5F_sec2_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
int fd;
struct stat sb;
- FUNC_ENTER (H5F_sec2_open, NULL, NULL);
+ FUNC_ENTER (H5F_sec2_open, NULL);
oflags = (flags & H5F_ACC_WRITE) ? O_RDWR : O_RDONLY;
oflags |= (flags & H5F_ACC_CREAT) ? O_CREAT : 0;
@@ -122,7 +123,7 @@ H5F_sec2_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
static herr_t
H5F_sec2_close (H5F_low_t *lf)
{
- FUNC_ENTER (H5F_sec2_close, NULL, FAIL);
+ FUNC_ENTER (H5F_sec2_close, FAIL);
if (close (lf->u.sec2.fd)<0) {
HRETURN_ERROR (H5E_IO, H5E_CLOSEERROR, FAIL); /*close failed*/
@@ -161,7 +162,7 @@ H5F_sec2_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
ssize_t n;
off_t offset;
- FUNC_ENTER (H5F_sec2_read, NULL, FAIL);
+ FUNC_ENTER (H5F_sec2_read, FAIL);
/* Check for overflow */
@@ -248,7 +249,7 @@ H5F_sec2_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
{
off_t offset;
- FUNC_ENTER (H5F_sec2_write, NULL, FAIL);
+ FUNC_ENTER (H5F_sec2_write, FAIL);
/* Check for overflow */
offset = addr->offset;
diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c
index 2cd613b..46c63b5 100644
--- a/src/H5Fstdio.c
+++ b/src/H5Fstdio.c
@@ -19,6 +19,7 @@
#define PABLO_MASK H5F_sec2
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
static H5F_low_t *H5F_stdio_open (const char *name, uintn flags,
H5F_search_t *key);
@@ -73,7 +74,7 @@ H5F_stdio_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
FILE *f=NULL;
struct stat sb;
- FUNC_ENTER (H5F_stdio_open, NULL, NULL);
+ FUNC_ENTER (H5F_stdio_open, NULL);
if (access (name, F_OK)<0) {
if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_WRITE)) {
@@ -141,7 +142,7 @@ H5F_stdio_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
static herr_t
H5F_stdio_close (H5F_low_t *lf)
{
- FUNC_ENTER (H5F_stdio_close, NULL, FAIL);
+ FUNC_ENTER (H5F_stdio_close, FAIL);
if (fclose (lf->u.stdio.f)<0) {
HRETURN_ERROR (H5E_IO, H5E_CLOSEERROR, FAIL); /*close failed*/
@@ -180,7 +181,7 @@ H5F_stdio_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
size_t n;
off_t offset;
- FUNC_ENTER (H5F_stdio_read, NULL, FAIL);
+ FUNC_ENTER (H5F_stdio_read, FAIL);
/* Check for overflow */
offset = addr->offset;
@@ -264,7 +265,7 @@ H5F_stdio_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
{
off_t offset;
- FUNC_ENTER (H5F_stdio_write, NULL, FAIL);
+ FUNC_ENTER (H5F_stdio_write, FAIL);
/* Check for overflow */
offset = addr->offset;
@@ -324,7 +325,7 @@ H5F_stdio_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
static herr_t
H5F_stdio_flush (H5F_low_t *lf)
{
- FUNC_ENTER (H5F_stdio_flush, NULL, FAIL);
+ FUNC_ENTER (H5F_stdio_flush, FAIL);
/*
* What happens to the file position? Is it guaranteed to be the same
diff --git a/src/H5G.c b/src/H5G.c
index 5c1e2cd..a45ab02 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -47,9 +47,9 @@
#define H5G_INIT_HEAP 8192
#define PABLO_MASK H5G_mask
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
-
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -92,7 +92,7 @@ H5Gnew (hid_t file, const char *name, size_t size_hint)
H5F_t *f=NULL;
H5G_entry_t *grp_handle=NULL;
- FUNC_ENTER (H5Gnew, NULL, FAIL);
+ FUNC_ENTER (H5Gnew, FAIL);
/* Check/fix arguments */
if (!name || !*name) {
@@ -158,7 +158,7 @@ H5Gset (hid_t file, const char *name)
{
H5F_t *f=NULL;
- FUNC_ENTER (H5Gset, NULL, FAIL);
+ FUNC_ENTER (H5Gset, FAIL);
/* Check/fix arguments */
if (!name || !*name) {
@@ -217,7 +217,7 @@ H5Gpush (hid_t file, const char *name)
{
H5F_t *f=NULL;
- FUNC_ENTER (H5Gpush, NULL, FAIL);
+ FUNC_ENTER (H5Gpush, FAIL);
/* Check/fix arguments */
if (!name || !*name) {
@@ -277,7 +277,7 @@ H5Gpop (hid_t file)
{
H5F_t *f=NULL;
- FUNC_ENTER (H5Gpop, NULL, FAIL);
+ FUNC_ENTER (H5Gpop, FAIL);
/* Check/fix arguments */
if (H5_FILE!=H5Aatom_group (file)) {
@@ -346,57 +346,6 @@ H5G_component (const char *name, size_t *size_p)
/*-------------------------------------------------------------------------
- * Function: H5G_basename
- *
- * Purpose: Returns a pointer into NAME for the start of the last
- * component of NAME. On return, the optional SIZE_P is
- * initialized to point to the size of the base name not
- * counting trailing slashes or the null character.
- *
- * Errors:
- *
- * Return: Success: Ptr to base name within NAME with SIZE_P
- * pointing to the number of characters in the
- * base name.
- *
- * Failure: Ptr to the null terminator of NAME.
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 11 1997
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-#if 0
-static const char *
-H5G_basename (const char *name, size_t *size_p)
-{
- const char *s;
-
- assert (name);
-
- s = name + HDstrlen(name);
- while (s>name && '/'==s[-1]) --s; /*skip past trailing slashes*/
- while (s>name && '/'!=s[-1]) --s; /*skip past base name*/
-
- /*
- * If the input was the name of the root group `/' (or
- * equivalent) then return the null string.
- */
- if ('/'==*s) {
- if (size_p) *size_p = 0;
- return s + HDstrlen(s); /*null terminator*/
- }
-
- if (size_p) *size_p = HDstrcspn (s, "/");
- return s;
-}
-#endif
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_namei
*
* Purpose: (Partially) translates a name to a symbol table entry.
@@ -476,7 +425,7 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
H5F_addr_undef (&(grp_ent->header));
}
- FUNC_ENTER (H5G_namei, NULL, NULL);
+ FUNC_ENTER (H5G_namei, NULL);
/* check args */
assert (f);
@@ -619,7 +568,7 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
H5G_entry_t *ent_ptr=NULL; /*pointer to a symbol table entry*/
const char *obj_name=NULL; /*name of old root object */
- FUNC_ENTER (H5G_mkroot, NULL, FAIL);
+ FUNC_ENTER (H5G_mkroot, FAIL);
/*
* Make sure that the file descriptor has the latest info -- someone might
@@ -657,7 +606,7 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
* something goes wrong at this step, closing the `handle' will rewrite
* info back into f->root_sym because we set the dirty bit.
*/
- if (H5G_stab_new (f, f->shared->root_sym, size_hint)<0) {
+ if (H5G_stab_create (f, f->shared->root_sym, size_hint)<0) {
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*cant create root*/
}
if (1!=H5O_link (f, f->shared->root_sym, 1)) {
@@ -753,7 +702,7 @@ H5G_new (H5F_t *f, const char *name, size_t size_hint)
size_t nchars; /*number of characters in compon*/
herr_t status; /*function return status */
- FUNC_ENTER (H5G_new, NULL, NULL);
+ FUNC_ENTER (H5G_new, NULL);
/* check args */
assert (f);
@@ -800,7 +749,7 @@ H5G_new (H5F_t *f, const char *name, size_t size_hint)
}
/* create group */
- if (H5G_stab_new (f, &ent, size_hint)<0) {
+ if (H5G_stab_create (f, &ent, size_hint)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL); /*can't create grp*/
}
@@ -851,7 +800,7 @@ H5G_set (H5F_t *f, const char *name)
H5O_stab_t stab_mesg;
herr_t ret_value=FAIL;
- FUNC_ENTER (H5G_set, NULL, FAIL);
+ FUNC_ENTER (H5G_set, FAIL);
if (NULL==(handle=H5G_open (f, name))) {
/* Can't open group */
@@ -913,7 +862,7 @@ H5G_getcwg (H5F_t *f)
{
H5G_entry_t *handle=NULL;
- FUNC_ENTER (H5G_getcwg, NULL, NULL);
+ FUNC_ENTER (H5G_getcwg, NULL);
if (f->cwg_stack && f->cwg_stack->handle) {
handle = f->cwg_stack->handle;
@@ -955,7 +904,7 @@ H5G_push (H5F_t *f, const char *name)
H5O_stab_t stab_mesg;
herr_t ret_value = FAIL;
- FUNC_ENTER (H5G_pushd, NULL, FAIL);
+ FUNC_ENTER (H5G_push, FAIL);
if (NULL==(handle=H5G_open (f, name))) {
/* Can't open group */
@@ -1009,7 +958,7 @@ H5G_pop (H5F_t *f)
{
H5G_cwgstk_t *stack=NULL;
- FUNC_ENTER (H5G_pop, NULL, FAIL);
+ FUNC_ENTER (H5G_pop, FAIL);
if ((stack=f->cwg_stack)) {
if (H5G_close (f, stack->handle)<0) {
@@ -1075,7 +1024,7 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
size_t nchars; /*number of characters in name */
char _comp[1024]; /*name component */
- FUNC_ENTER (H5G_create, NULL, NULL);
+ FUNC_ENTER (H5G_create, NULL);
/* Check args. */
assert (f);
@@ -1105,7 +1054,7 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
if (H5F_addr_defined (&(f->shared->root_sym->header))) {
HRETURN_ERROR (H5E_SYM, H5E_EXISTS, NULL); /*root exists*/
}
- if (H5O_new (f, 0, ohdr_hint, &(ent.header)/*out*/)<0) {
+ if (H5O_create (f, 0, ohdr_hint, &(ent.header)/*out*/)<0) {
/* can't create header */
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL);
}
@@ -1141,7 +1090,7 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
/*
* Create the object header.
*/
- if (H5O_new (f, 0, ohdr_hint, &(ent.header)/*out*/)<0) {
+ if (H5O_create (f, 0, ohdr_hint, &(ent.header)/*out*/)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL);
}
@@ -1238,7 +1187,7 @@ H5G_open (H5F_t *f, const char *name)
H5G_entry_t grp;
H5G_entry_t *cwg=NULL;
- FUNC_ENTER (H5G_open, NULL, NULL);
+ FUNC_ENTER (H5G_open, NULL);
/* check args */
assert (f);
@@ -1287,7 +1236,7 @@ H5G_open (H5F_t *f, const char *name)
herr_t
H5G_close (H5F_t *f, H5G_entry_t *ent)
{
- FUNC_ENTER (H5G_close, NULL, FAIL);
+ FUNC_ENTER (H5G_close, FAIL);
assert (f);
@@ -1345,7 +1294,7 @@ H5G_find (H5F_t *f, const char *name,
H5G_entry_t *ent_p = NULL;
H5G_entry_t *cwg = NULL;
- FUNC_ENTER (H5G_find, NULL, FAIL);
+ FUNC_ENTER (H5G_find, FAIL);
/* check args */
assert (f);
diff --git a/src/H5Gent.c b/src/H5Gent.c
index e7da78b..29860e0 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -13,8 +13,8 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5G_ent_mask
-
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -64,7 +64,7 @@ H5G_ent_calloc (void)
herr_t
H5G_ent_invalidate (H5G_entry_t *ent)
{
- FUNC_ENTER (H5G_ent_invalidate, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_invalidate, FAIL);
if (ent && H5G_NOTHING_CACHED!=ent->type) {
ent->dirty = TRUE;
@@ -97,7 +97,7 @@ H5G_ent_invalidate (H5G_entry_t *ent)
herr_t
H5G_ent_addr (H5G_entry_t *ent, haddr_t *addr/*out*/)
{
- FUNC_ENTER (H5G_ent_addr, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_addr, FAIL);
assert (ent);
*addr = ent->header;
@@ -128,7 +128,7 @@ H5G_ent_addr (H5G_entry_t *ent, haddr_t *addr/*out*/)
H5G_cache_t *
H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type)
{
- FUNC_ENTER (H5G_ent_cache, NULL, NULL);
+ FUNC_ENTER (H5G_ent_cache, NULL);
if (!ent) {
HRETURN_ERROR (H5E_SYM, H5E_BADVALUE, NULL);
}
@@ -162,7 +162,7 @@ H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type)
herr_t
H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type)
{
- FUNC_ENTER (H5G_ent_modified, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_modified, FAIL);
assert (ent);
if (H5G_NO_CHANGE!=ent->type) ent->type = cache_type;
ent->dirty = TRUE;
@@ -197,7 +197,7 @@ H5G_ent_decode_vec (H5F_t *f, const uint8 **pp, H5G_entry_t *ent, intn n)
{
intn i;
- FUNC_ENTER (H5G_ent_decode_vec, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_decode_vec, FAIL);
/* check arguments */
assert (f);
@@ -241,7 +241,7 @@ H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
{
const uint8 *p_ret = *pp;
- FUNC_ENTER (H5G_ent_decode, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_decode, FAIL);
/* check arguments */
assert (f);
@@ -258,20 +258,17 @@ H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
case H5G_NOTHING_CACHED:
break;
- case H5G_CACHED_SDATA:
- assert (1+1+2+(5*4) <= H5G_SIZEOF_SCRATCH);
- ent->cache.sdata.nt.length= *(*pp)++;
- ent->cache.sdata.nt.arch= *(*pp)++;
- UINT16DECODE (*pp, ent->cache.sdata.nt.type);
- UINT32DECODE (*pp, ent->cache.sdata.ndim);
- UINT32DECODE (*pp, ent->cache.sdata.dim[0]);
- UINT32DECODE (*pp, ent->cache.sdata.dim[1]);
- UINT32DECODE (*pp, ent->cache.sdata.dim[2]);
- UINT32DECODE (*pp, ent->cache.sdata.dim[3]);
+ case H5G_CACHED_SDSPACE:
+ assert (5*4 <= H5G_SIZEOF_SCRATCH);
+ UINT32DECODE (*pp, ent->cache.sdspace.ndim);
+ UINT32DECODE (*pp, ent->cache.sdspace.dim[0]);
+ UINT32DECODE (*pp, ent->cache.sdspace.dim[1]);
+ UINT32DECODE (*pp, ent->cache.sdspace.dim[2]);
+ UINT32DECODE (*pp, ent->cache.sdspace.dim[3]);
break;
case H5G_CACHED_STAB:
- assert (2*H5F_SIZEOF_OFFSET (f) <= H5G_SIZEOF_SCRATCH);
+ assert (2*H5F_SIZEOF_ADDR (f) <= H5G_SIZEOF_SCRATCH);
H5F_addr_decode (f, pp, &(ent->cache.stab.btree_addr));
H5F_addr_decode (f, pp, &(ent->cache.stab.heap_addr));
break;
@@ -312,7 +309,7 @@ H5G_ent_encode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n)
{
intn i;
- FUNC_ENTER (H5G_ent_encode_vec, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_encode_vec, FAIL);
/* check arguments */
assert (f);
@@ -362,7 +359,7 @@ H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent)
{
uint8 *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
- FUNC_ENTER (H5G_ent_encode, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_encode, FAIL);
/* check arguments */
assert (f);
@@ -379,20 +376,17 @@ H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent)
case H5G_NOTHING_CACHED:
break;
- case H5G_CACHED_SDATA:
- assert (1+1+2+(5*4) <= H5G_SIZEOF_SCRATCH);
- *(*pp)++= ent->cache.sdata.nt.length;
- *(*pp)++= ent->cache.sdata.nt.arch;
- UINT16ENCODE (*pp, ent->cache.sdata.nt.type);
- UINT32ENCODE (*pp, ent->cache.sdata.ndim);
- UINT32ENCODE (*pp, ent->cache.sdata.dim[0]);
- UINT32ENCODE (*pp, ent->cache.sdata.dim[1]);
- UINT32ENCODE (*pp, ent->cache.sdata.dim[2]);
- UINT32ENCODE (*pp, ent->cache.sdata.dim[3]);
+ case H5G_CACHED_SDSPACE:
+ assert (5*4 <= H5G_SIZEOF_SCRATCH);
+ UINT32ENCODE (*pp, ent->cache.sdspace.ndim);
+ UINT32ENCODE (*pp, ent->cache.sdspace.dim[0]);
+ UINT32ENCODE (*pp, ent->cache.sdspace.dim[1]);
+ UINT32ENCODE (*pp, ent->cache.sdspace.dim[2]);
+ UINT32ENCODE (*pp, ent->cache.sdspace.dim[3]);
break;
case H5G_CACHED_STAB:
- assert (2*H5F_SIZEOF_OFFSET (f) <= H5G_SIZEOF_SCRATCH);
+ assert (2*H5F_SIZEOF_ADDR (f) <= H5G_SIZEOF_SCRATCH);
H5F_addr_encode (f, pp, &(ent->cache.stab.btree_addr));
H5F_addr_encode (f, pp, &(ent->cache.stab.heap_addr));
break;
@@ -435,7 +429,7 @@ H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent,
int i;
char buf[64];
- FUNC_ENTER (H5G_ent_debug, NULL, FAIL);
+ FUNC_ENTER (H5G_ent_debug, FAIL);
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Name offset into private heap:",
@@ -461,25 +455,16 @@ H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent,
fprintf (stream, "Nothing Cached\n");
break;
- case H5G_CACHED_SDATA:
- fprintf (stream, "S-data\n");
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Number type length:",
- (unsigned)(ent->cache.sdata.nt.length));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Number type architecture:",
- (unsigned)(ent->cache.sdata.nt.arch));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Number type type:",
- (unsigned)(ent->cache.sdata.nt.type));
+ case H5G_CACHED_SDSPACE:
+ fprintf (stream, "Simple data space\n");
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Dimensionality:",
- (unsigned)(ent->cache.sdata.ndim));
- for (i=0; i<ent->cache.sdata.ndim && i<4; i++) {
+ (unsigned)(ent->cache.sdspace.ndim));
+ for (i=0; i<ent->cache.sdspace.ndim && i<4; i++) {
sprintf (buf, "Dimension %d", i);
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
buf,
- (unsigned)(ent->cache.sdata.dim[i]));
+ (unsigned)(ent->cache.sdspace.dim[i]));
}
break;
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 1ec6daf..f912c55 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -44,8 +44,9 @@ static herr_t H5G_node_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
static herr_t H5G_node_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
void *_key);
static size_t H5G_node_size (H5F_t *f);
-static herr_t H5G_node_new (H5F_t *f, H5B_ins_t op, void *_lt_key,
- void *_udata, void *_rt_key, haddr_t *addr/*out*/);
+static herr_t H5G_node_create (H5F_t *f, H5B_ins_t op, void *_lt_key,
+ void *_udata, void *_rt_key,
+ haddr_t *addr/*out*/);
static herr_t H5G_node_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr,
H5G_node_t *sym);
static H5G_node_t *H5G_node_load (H5F_t *f, const haddr_t *addr,
@@ -77,7 +78,7 @@ H5B_class_t H5B_SNODE[1] = {{
H5B_SNODE_ID, /*id */
sizeof (H5G_node_key_t), /*sizeof_nkey */
H5G_node_sizeof_rkey, /*get_sizeof_rkey */
- H5G_node_new, /*new */
+ H5G_node_create, /*new */
H5G_node_cmp2, /*cmp2 */
H5G_node_cmp3, /*cmp3 */
H5G_node_found, /*found */
@@ -89,8 +90,9 @@ H5B_class_t H5B_SNODE[1] = {{
H5G_node_encode_key, /*encode */
}};
-/* Has the interface been initialized? */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -140,7 +142,7 @@ H5G_node_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
H5G_node_key_t *key = (H5G_node_key_t *)_key;
- FUNC_ENTER (H5G_node_decode_key, NULL, FAIL);
+ FUNC_ENTER (H5G_node_decode_key, FAIL);
assert (f);
assert (raw);
@@ -174,7 +176,7 @@ H5G_node_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
H5G_node_key_t *key = (H5G_node_key_t *)_key;
- FUNC_ENTER (H5G_node_encode_key, NULL, FAIL);
+ FUNC_ENTER (H5G_node_encode_key, FAIL);
assert (f);
assert (raw);
@@ -212,7 +214,7 @@ H5G_node_size (H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5G_node_new
+ * Function: H5G_node_create
*
* Purpose: Creates a new empty symbol table. This function is called
* by the B-tree insert function for an empty tree. It is
@@ -233,16 +235,16 @@ H5G_node_size (H5F_t *f)
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_new (H5F_t *f, H5B_ins_t op,
- void *_lt_key, void *_udata, void *_rt_key,
- haddr_t *addr/*out*/)
+H5G_node_create (H5F_t *f, H5B_ins_t op,
+ void *_lt_key, void *_udata, void *_rt_key,
+ haddr_t *addr/*out*/)
{
H5G_node_key_t *lt_key = (H5G_node_key_t*)_lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t*)_rt_key;
H5G_node_t *sym = NULL;
size_t size = 0;
- FUNC_ENTER (H5G_node_new, NULL, FAIL);
+ FUNC_ENTER (H5G_node_create, FAIL);
/*
* Check arguments.
@@ -307,7 +309,7 @@ H5G_node_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr,
herr_t status;
int i;
- FUNC_ENTER (H5G_node_flush, NULL, FAIL);
+ FUNC_ENTER (H5G_node_flush, FAIL);
/*
* Check arguments.
@@ -402,7 +404,7 @@ H5G_node_load (H5F_t *f, const haddr_t *addr, const void *_udata1,
const H5G_ac_ud1_t *ac_udata = (const H5G_ac_ud1_t*)_udata1;
H5G_node_t *ret_value = NULL; /*for error handling*/
- FUNC_ENTER (H5G_node_load, NULL, NULL);
+ FUNC_ENTER (H5G_node_load, NULL);
/*
* Check arguments.
@@ -447,8 +449,13 @@ H5G_node_load (H5F_t *f, const haddr_t *addr, const void *_udata1,
}
buf = H5MM_xfree (buf);
- /* shadows */
- if (H5G_shadow_assoc_node (f, sym, ac_udata)<0) {
+ /*
+ * shadows. If we are running this under the debugger, then the grp_addr
+ * field of ac_udata might be undefined. If that's the case, then we
+ * don't try to associate any shadows with this symbol table node.
+ */
+ if (H5F_addr_defined (&(ac_udata->grp_addr)) &&
+ H5G_shadow_assoc_node (f, sym, ac_udata)<0) {
HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, NULL);
}
@@ -499,7 +506,7 @@ H5G_node_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
const char *s1, *s2;
intn cmp;
- FUNC_ENTER (H5G_node_cmp2, NULL, FAIL);
+ FUNC_ENTER (H5G_node_cmp2, FAIL);
assert (udata);
assert (lt_key);
@@ -553,7 +560,7 @@ H5G_node_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key;
const char *s;
- FUNC_ENTER (H5G_node_cmp3, NULL, FAIL);
+ FUNC_ENTER (H5G_node_cmp3, FAIL);
/* left side */
if (NULL==(s=H5H_peek (f, &(udata->heap_addr), lt_key->offset))) {
@@ -610,7 +617,7 @@ H5G_node_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
const char *s;
herr_t ret_value = FAIL;
- FUNC_ENTER (H5G_node_found, NULL, FAIL);
+ FUNC_ENTER (H5G_node_found, FAIL);
/*
* Check arguments.
@@ -746,7 +753,7 @@ H5G_node_insert (H5F_t *f, const haddr_t *addr,
H5G_node_t *insert_into=NULL; /*node that gets new entry*/
haddr_t insert_addr; /*address of that node */
- FUNC_ENTER (H5G_node_insert, NULL, H5B_INS_ERROR);
+ FUNC_ENTER (H5G_node_insert, H5B_INS_ERROR);
/*
* Check arguments.
@@ -813,8 +820,8 @@ H5G_node_insert (H5F_t *f, const haddr_t *addr,
ret_value = H5B_INS_RIGHT;
/* The right node */
- if (H5G_node_new (f, H5B_INS_FIRST, NULL, NULL, NULL,
- new_node/*out*/)<0) {
+ if (H5G_node_create (f, H5B_INS_FIRST, NULL, NULL, NULL,
+ new_node/*out*/)<0) {
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR);
}
if (NULL==(snrt=H5AC_find (f, H5AC_SNODE, new_node, &ac_udata, NULL))) {
@@ -944,7 +951,7 @@ H5G_node_list (H5F_t *f, const haddr_t *addr, void *_udata)
herr_t ret_value = FAIL;
H5G_ac_ud1_t ac_udata;
- FUNC_ENTER (H5G_node_list, NULL, FAIL);
+ FUNC_ENTER (H5G_node_list, FAIL);
/*
* Check arguments.
@@ -1030,7 +1037,7 @@ H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
const char *s;
H5G_ac_ud1_t ac_udata;
- FUNC_ENTER (H5G_node_debug, NULL, FAIL);
+ FUNC_ENTER (H5G_node_debug, FAIL);
/*
* Check arguments.
@@ -1045,7 +1052,7 @@ H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
* We have absolutely no idea where the object header for the symbol table
* to which this node belongs is located. In fact, if the file is corrupt,
* there may not even be an object header for that symbol table. So we
- * supply `-1' as the group address which causes no open objects to be
+ * supply UNDEF as the group address which causes no open objects to be
* associated with the node. For that reason, we flush this node from the
* cache when we're done so if some later caller knows the header address
* they'll be able to access the open objects.
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 89152c2..473c3c5 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -21,7 +21,7 @@
#define H5G_NODE_VERS 1 /*symbol table node version number */
#define H5G_SIZE_HINT 1024 /*default root grp size hint */
-#define H5G_NODE_K(F) ((F)->shared->file_create_parms.sym_leaf_k)
+#define H5G_NODE_K(F) ((F)->shared->create_parms.sym_leaf_k)
#define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4)
#define H5G_DEFAULT_ROOT_SIZE 32
@@ -158,7 +158,7 @@ extern const H5AC_class_t H5AC_SNODE[1];
* functions that understand names are exported to the rest of
* the library and appear in H5Gprivate.h.
*/
-herr_t H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init);
+herr_t H5G_stab_create (H5F_t *f, H5G_entry_t *self, size_t init);
H5G_entry_t *H5G_stab_find (H5F_t *f, const haddr_t *addr, H5G_entry_t *self,
const char *name);
H5G_entry_t *H5G_stab_insert (H5F_t *f, H5G_entry_t *self,
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index b15ea0e..6b8989e 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -45,7 +45,7 @@
#define H5G_SIZEOF_SCRATCH 24
#define H5G_SIZEOF_ENTRY(F) \
(H5F_SIZEOF_SIZE(F) + /*offset of name into heap */ \
- H5F_SIZEOF_OFFSET(F) + /*address of object header */ \
+ H5F_SIZEOF_ADDR(F) + /*address of object header */ \
4 + /*entry type */ \
H5G_SIZEOF_SCRATCH) /*scratch pad space */
@@ -57,7 +57,7 @@
*/
typedef enum H5G_type_t {
H5G_NOTHING_CACHED =0, /*nothing is cached, must be 0 */
- H5G_CACHED_SDATA =1, /*simple dataset, `sdata' */
+ H5G_CACHED_SDSPACE =1, /*simple data space */
H5G_CACHED_STAB =2 /*symbol table, `stab' */
} H5G_type_t;
@@ -67,14 +67,9 @@ typedef enum H5G_type_t {
*/
typedef union H5G_cache_t {
struct {
- struct {
- uint8 length;
- uint8 arch;
- uint16 type;
- } nt ; /*number type */
uint32 ndim; /*number of dimensions */
uint32 dim[4]; /*dimension sizes */
- } sdata;
+ } sdspace;
struct {
haddr_t btree_addr; /*file address of symbol table B-tree */
diff --git a/src/H5Gshad.c b/src/H5Gshad.c
index 5636585..f7941ef 100644
--- a/src/H5Gshad.c
+++ b/src/H5Gshad.c
@@ -16,8 +16,9 @@
#define PABLO_MASK H5G_shadow_mask
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
typedef struct H5G_hash_t {
haddr_t grp_addr;
@@ -111,7 +112,7 @@ H5G_shadow_check (H5F_t *f)
fprintf (stderr, "), ");
shadow_error = TRUE;
}
-
+
/* Linked to symbol table entry */
if (shadow->main && shadow!=shadow->main->shadow) {
fprintf (stderr, "entry linkage problem, ");
@@ -167,7 +168,7 @@ H5G_shadow_p (H5G_entry_t *ent)
size_t delta = (char*)&(tmp.entry) - (char*)&tmp;
hbool_t ret_value = FALSE;
- FUNC_ENTER (H5G_shadow_p, NULL, FALSE);
+ FUNC_ENTER (H5G_shadow_p, FALSE);
if (!ent || !ent->shadow) return FALSE;
ret_value = ((char*)ent - (char*)(ent->shadow) == delta);
@@ -197,7 +198,7 @@ H5G_shadow_p (H5G_entry_t *ent)
herr_t
H5G_shadow_dissociate (H5G_entry_t *ent)
{
- FUNC_ENTER (H5G_shadow_dissociate, NULL, FAIL);
+ FUNC_ENTER (H5G_shadow_dissociate, FAIL);
if (H5G_shadow_p (ent)) {
if (ent->shadow->main) {
@@ -239,7 +240,7 @@ herr_t
H5G_shadow_sync (H5G_entry_t *ent)
{
H5G_shadow_t *shadow = NULL;
- FUNC_ENTER (H5G_shadow_sync, NULL, FAIL);
+ FUNC_ENTER (H5G_shadow_sync, FAIL);
/*
* If the caller supplied us with a shadow instead of the main entry, then
@@ -287,7 +288,7 @@ H5G_shadow_list (H5F_t *f, const haddr_t *grp_addr)
uintn idx = H5F_addr_hash (grp_addr, f->shared->nshadows);
H5G_hash_t *bucket = NULL;
- FUNC_ENTER (H5G_shadows, NULL, NULL);
+ FUNC_ENTER (H5G_shadows, NULL);
for (bucket=f->shared->shadow[idx]; bucket; bucket=bucket->next) {
if (0==idx &&
@@ -331,7 +332,7 @@ H5G_shadow_assoc_node (H5F_t *f, H5G_node_t *sym, const H5G_ac_ud1_t *ac_udata)
intn i = 0;
haddr_t heap_addr;
- FUNC_ENTER (H5G_shadow_assoc_node, NULL, FAIL);
+ FUNC_ENTER (H5G_shadow_assoc_node, FAIL);
/* Check arguments */
assert (f); /* The file */
@@ -405,7 +406,7 @@ H5G_shadow_open (H5F_t *f, H5G_entry_t *grp, H5G_entry_t *ent)
H5G_entry_t *ret_value = NULL;
haddr_t grp_header;
- FUNC_ENTER (H5G_shadow_open, NULL, NULL);
+ FUNC_ENTER (H5G_shadow_open, NULL);
/* check args */
assert (f);
@@ -563,7 +564,7 @@ H5G_shadow_close (H5F_t *f, H5G_entry_t *ent)
H5G_hash_t *hash=NULL;
H5G_shadow_t *hash_ent=NULL, *shadow=NULL;
- FUNC_ENTER (H5G_shadow_close, NULL, FAIL);
+ FUNC_ENTER (H5G_shadow_close, FAIL);
/* check args */
assert (ent);
@@ -662,7 +663,7 @@ H5G_shadow_move (H5F_t *f, H5G_shadow_t *shadow, const char *new_name,
H5G_hash_t *hash;
uintn idx;
- FUNC_ENTER (H5G_shadow_move, NULL, FAIL);
+ FUNC_ENTER (H5G_shadow_move, FAIL);
assert (shadow);
assert (new_entry);
@@ -735,7 +736,7 @@ H5G_shadow_flush (H5F_t *f, hbool_t invalidate)
H5G_shadow_t *shadow = NULL;
intn nfound=0;
- FUNC_ENTER (H5G_shadow_flush, NULL, FAIL);
+ FUNC_ENTER (H5G_shadow_flush, FAIL);
for (idx=0; idx<f->shared->nshadows; idx++) {
for (hash=f->shared->shadow[idx]; hash; hash=hash->next) {
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 4e16a2c..30bca74 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -18,10 +18,11 @@
#define PABLO_MASK H5G_stab_mask
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5G_stab_new
+ * Function: H5G_stab_create
*
* Purpose: Creates a new empty symbol table (object header, name heap,
* and B-tree). The caller can specify an initial size for the
@@ -54,13 +55,13 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init)
+H5G_stab_create (H5F_t *f, H5G_entry_t *self, size_t init)
{
size_t name; /*offset of "" name */
haddr_t addr; /*object header address */
H5O_stab_t stab; /*symbol table message */
- FUNC_ENTER (H5G_stab_new, NULL, FAIL);
+ FUNC_ENTER (H5G_stab_create, FAIL);
/*
* Check arguments.
@@ -70,7 +71,7 @@ H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init)
init = MAX(init, H5H_SIZEOF_FREE(f)+2);
/* Create symbol table private heap */
- if (H5H_new (f, H5H_LOCAL, init, &(stab.heap_addr)/*out*/)<0) {
+ if (H5H_create (f, H5H_LOCAL, init, &(stab.heap_addr)/*out*/)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't create heap*/
}
if ((name = H5H_insert (f, &(stab.heap_addr), 1, "")<0)) {
@@ -85,7 +86,7 @@ H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init)
}
/* Create the B-tree */
- if (H5B_new (f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/)<0) {
+ if (H5B_create (f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't create B-tree*/
}
@@ -94,7 +95,7 @@ H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init)
* since nothing refers to it yet. The link count will be
* incremented if the object is added to the group directed graph.
*/
- if (H5O_new (f, 0, 4+2*H5F_SIZEOF_OFFSET(f), &addr/*out*/)<0) {
+ if (H5O_create (f, 0, 4+2*H5F_SIZEOF_ADDR(f), &addr/*out*/)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't create header*/
}
@@ -146,7 +147,7 @@ H5G_stab_find (H5F_t *f, const haddr_t *addr, H5G_entry_t *self,
H5G_bt_ud1_t udata; /*data to pass through B-tree */
H5O_stab_t stab; /*symbol table message */
- FUNC_ENTER (H5G_stab_find, NULL, NULL);
+ FUNC_ENTER (H5G_stab_find, NULL);
/* Check arguments */
assert (f);
@@ -227,7 +228,7 @@ H5G_stab_insert (H5F_t *f, H5G_entry_t *self, const char *name,
H5O_stab_t stab; /*symbol table message */
H5G_bt_ud1_t udata; /*data to pass through B-tree */
- FUNC_ENTER (H5G_stab_insert, NULL, NULL);
+ FUNC_ENTER (H5G_stab_insert, NULL);
/* check arguments */
assert (f);
@@ -311,7 +312,7 @@ H5G_stab_list (H5F_t *f, H5G_entry_t *self, intn maxentries,
H5O_stab_t stab;
intn i;
- FUNC_ENTER (H5G_stab_list, NULL, FAIL);
+ FUNC_ENTER (H5G_stab_list, FAIL);
/* check args */
assert (f);
diff --git a/src/H5H.c b/src/H5H.c
index f6a429c..3fed8e9 100644
--- a/src/H5H.c
+++ b/src/H5H.c
@@ -59,12 +59,13 @@ static const H5AC_class_t H5AC_HEAP[1] = {{
(herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5H_flush,
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5H_new
+ * Function: H5H_create
*
* Purpose: Creates a new heap data structure on disk and caches it
* in memory. SIZE_HINT is a hint for the initial size of the
@@ -91,20 +92,20 @@ static intn interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5H_new (H5F_t *f, H5H_type_t heap_type, size_t size_hint,
- haddr_t *addr/*out*/)
+H5H_create (H5F_t *f, H5H_type_t heap_type, size_t size_hint,
+ haddr_t *addr/*out*/)
{
H5H_t *heap = NULL;
size_t total_size; /*total heap size on disk */
- FUNC_ENTER (H5H_new, NULL, FAIL);
+ FUNC_ENTER (H5H_create, FAIL);
/* check arguments */
assert (f);
assert (addr);
if (H5H_GLOBAL==heap_type) {
#ifndef NDEBUG
- fprintf (stderr, "H5H_new: a local heap is used as the global heap\n");
+ fprintf (stderr, "H5H_create: a local heap is used as the global heap\n");
#endif
}
@@ -176,7 +177,7 @@ H5H_load (H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
size_t free_block=H5H_FREE_NULL;
H5H_t *ret_value=NULL;
- FUNC_ENTER (H5H_load, NULL, NULL);
+ FUNC_ENTER (H5H_load, NULL);
/* check arguments */
assert (f);
@@ -279,7 +280,7 @@ H5H_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5H_t *heap)
H5H_free_t *fl = heap->freelist;
haddr_t hdr_end_addr;
- FUNC_ENTER (H5H_flush, NULL, FAIL);
+ FUNC_ENTER (H5H_flush, FAIL);
/* check arguments */
assert (f);
@@ -401,7 +402,7 @@ H5H_read (H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
{
H5H_t *heap = NULL;
- FUNC_ENTER (H5H_read, NULL, NULL);
+ FUNC_ENTER (H5H_read, NULL);
/* check arguments */
assert (f);
@@ -461,7 +462,7 @@ H5H_peek (H5F_t *f, const haddr_t *addr, size_t offset)
H5H_t *heap = NULL;
const void *retval = NULL;
- FUNC_ENTER (H5H_peek, NULL, NULL);
+ FUNC_ENTER (H5H_peek, NULL);
/* check arguments */
assert (f);
@@ -538,7 +539,7 @@ H5H_insert (H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
static nmessages = 0;
#endif
- FUNC_ENTER (H5H_insert, NULL, FAIL);
+ FUNC_ENTER (H5H_insert, FAIL);
/* check arguments */
assert (f);
@@ -693,7 +694,7 @@ H5H_write (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
{
H5H_t *heap = NULL;
- FUNC_ENTER (H5H_write, NULL, FAIL);
+ FUNC_ENTER (H5H_write, FAIL);
/* check arguments */
assert (f);
@@ -755,7 +756,7 @@ H5H_remove (H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
static int nmessages = 0;
#endif
- FUNC_ENTER (H5H_remove, NULL, FAIL);
+ FUNC_ENTER (H5H_remove, FAIL);
/* check arguments */
assert (f);
@@ -870,7 +871,7 @@ H5H_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent, intn fwidth
uint8 *marker = NULL;
size_t amount_free = 0;
- FUNC_ENTER (H5H_debug, NULL, FAIL);
+ FUNC_ENTER (H5H_debug, FAIL);
/* check arguments */
assert (f);
diff --git a/src/H5Hprivate.h b/src/H5Hprivate.h
index f649bbf..ab1c401 100644
--- a/src/H5Hprivate.h
+++ b/src/H5Hprivate.h
@@ -29,7 +29,7 @@
(H5H_SIZEOF_MAGIC + /*heap signature */ \
H5F_SIZEOF_SIZE (F) + /*data size */ \
H5F_SIZEOF_SIZE (F) + /*free list head */ \
- H5F_SIZEOF_OFFSET (F)) /*data address */
+ H5F_SIZEOF_ADDR (F)) /*data address */
#define H5H_SIZEOF_FREE(F) \
(H5F_SIZEOF_SIZE (F) + /*ptr to next free block */ \
@@ -44,8 +44,8 @@ typedef enum H5H_type_t {
/*
* Library prototypes...
*/
-herr_t H5H_new (H5F_t *f, H5H_type_t type, size_t size_hint,
- haddr_t *addr/*out*/);
+herr_t H5H_create (H5F_t *f, H5H_type_t type, size_t size_hint,
+ haddr_t *addr/*out*/);
void *H5H_read (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
void *buf);
const void *H5H_peek (H5F_t *f, const haddr_t *addr, size_t offset);
diff --git a/src/H5M.c b/src/H5M.c
index 750fe17..d1911bd 100644
--- a/src/H5M.c
+++ b/src/H5M.c
@@ -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. *
+* *
****************************************************************************/
#ifdef RCSID
@@ -23,20 +23,19 @@ static char RcsId[] = "@(#)$Revision$";
HDF5 "Meta-Object" routines
EXPORTED ROUTINES
- H5Mcreate -- Create an object
H5Maccess -- Start access to an existing object
- H5Mcopy -- Copy an object
- H5Mfind_name -- Find an object by name
+ H5Mcopy -- Copy an object
+ H5Mopen -- Find an object by name
H5Mname_len -- Get the length of an object's name
H5Mget_name -- Get an object's name
H5Mset_name -- Set an object's name
H5Msearch -- Wildcard search for an object by name
- H5Mindex -- Get an object by index
- H5Mflush -- Flush an object out to disk
+ H5Mindex -- Get an object by index
+ H5Mflush -- Flush an object out to disk
H5Mdelete -- Delete an object from disk
H5Mget_file -- Get the file ID for an object
H5Mget_file -- Get the parent ID for an object
- H5Mrelease -- Release access to an object
+ H5Mclose -- Release access to an object
LIBRARY-SCOPED ROUTINES
@@ -44,94 +43,93 @@ static char RcsId[] = "@(#)$Revision$";
H5M_init_interface -- initialize the interface
+ */
-#include <H5private.h> /* Generic functions */
-#include <H5Cprivate.h> /* Template interface */
+#include <H5private.h> /* Generic functions */
+#include <H5Cprivate.h> /* Template interface */
#include <H5Dprivate.h> /* Dataset interface */
-#include <H5Eprivate.h> /*error handling */
+#include <H5Eprivate.h> /*error handling */
#include <H5Pprivate.h> /* Dataspace functions */
-#include <H5Tprivate.h> /* Datatype interface */
+#include <H5Tprivate.h> /* Datatype interface */
#include <H5Mprivate.h> /* Meta-object interface */
-#include <H5Cprivate.h> /* Template interface */
+#include <H5Cprivate.h> /* Template interface */
#define PABLO_MASK H5M_mask
/*--------------------- Locally scoped variables -----------------------------*/
-/* Whether we've installed the library termination function yet for this interface */
-static intn interface_initialize_g = FALSE;
-
static meta_func_t meta_func_arr[]={
- { /* Template object meta-functions (defined in H5C.c) */
- H5_TEMPLATE, /* File-Creation Template Type ID */
- H5C_create, /* File-Creation Template Create */
- NULL, /* File-Creation Template Access */
- H5C_copy, /* File-Creation Template Copy */
- NULL, /* File-Creation Template FindName */
- NULL, /* File-Creation Template NameLen */
- NULL, /* File-Creation Template GetName */
- NULL, /* File-Creation Template SetName */
- NULL, /* File-Creation Template Search */
- NULL, /* File-Creation Template Index */
- NULL, /* File-Creation Template Flush */
- NULL, /* File-Creation Template Delete */
- NULL, /* File-Creation Template GetParent */
- NULL, /* File-Creation Template GetFile */
- H5C_release /* File-Creation Template Release */
+ { /* Template object meta-functions (defined in H5C.c) */
+ H5_TEMPLATE_0, /* File-Creation Template Type ID */
+ NULL, /* File-Creation Template Create */
+ NULL, /* File-Creation Template Access */
+ H5Ccopy, /* File-Creation Template Copy */
+ NULL, /* File-Creation Template FindName */
+ NULL, /* File-Creation Template NameLen */
+ NULL, /* File-Creation Template GetName */
+ NULL, /* File-Creation Template SetName */
+ NULL, /* File-Creation Template Search */
+ NULL, /* File-Creation Template Index */
+ NULL, /* File-Creation Template Flush */
+ NULL, /* File-Creation Template Delete */
+ NULL, /* File-Creation Template GetParent */
+ NULL, /* File-Creation Template GetFile */
+ H5Cclose /* File-Creation Template Release */
},
- { /* Datatype object meta-functions (defined in H5T.c) */
- H5_DATATYPE, /* Datatype Type ID */
- H5T_create, /* Datatype Create */
- NULL, /* Datatype Access */
- NULL, /* Dataspace Copy */
- NULL, /* Datatype FindName */
- NULL, /* Datatype NameLen */
- NULL, /* Datatype GetName */
- NULL, /* Datatype SetName */
- NULL, /* Datatype Search */
- NULL, /* Datatype Index */
- NULL, /* Datatype Flush */
- NULL, /* Datatype Delete */
- NULL, /* Datatype GetParent */
- NULL, /* Datatype GetFile */
- H5T_release /* Datatype Release */
+ { /* Datatype object meta-functions (defined in H5T.c) */
+ H5_DATATYPE, /* Datatype Type ID */
+ NULL, /* Datatype Create */
+ NULL, /* Datatype Access */
+ H5Tcopy, /* Dataspace Copy */
+ NULL, /* Datatype FindName */
+ NULL, /* Datatype NameLen */
+ NULL, /* Datatype GetName */
+ NULL, /* Datatype SetName */
+ NULL, /* Datatype Search */
+ NULL, /* Datatype Index */
+ NULL, /* Datatype Flush */
+ NULL, /* Datatype Delete */
+ NULL, /* Datatype GetParent */
+ NULL, /* Datatype GetFile */
+ H5Tclose /* Datatype Release */
},
- { /* Dimensionality object meta-functions (defined in H5P.c) */
- H5_DATASPACE, /* Dimensionality Type ID */
- H5P_create, /* Dimensionality Create */
- NULL, /* Dimensionality Access */
- NULL, /* Dimensionality Copy */
- NULL, /* Dimensionality FindName */
- NULL, /* Dimensionality NameLen */
- NULL, /* Dimensionality GetName */
- NULL, /* Dimensionality SetName */
- NULL, /* Dimensionality Search */
- NULL, /* Dimensionality Index */
- NULL, /* Dimensionality Flush */
- NULL, /* Dimensionality Delete */
- NULL, /* Dimensionality GetParent */
- NULL, /* Dimensionality GetFile */
- H5P_release /* Dimensionality Release */
+ { /* Dimensionality object meta-functions (defined in H5P.c) */
+ H5_DATASPACE, /* Dimensionality Type ID */
+ NULL, /* Dimensionality Create */
+ NULL, /* Dimensionality Access */
+ NULL, /* Dimensionality Copy */
+ NULL, /* Dimensionality FindName */
+ NULL, /* Dimensionality NameLen */
+ NULL, /* Dimensionality GetName */
+ NULL, /* Dimensionality SetName */
+ NULL, /* Dimensionality Search */
+ NULL, /* Dimensionality Index */
+ NULL, /* Dimensionality Flush */
+ NULL, /* Dimensionality Delete */
+ NULL, /* Dimensionality GetParent */
+ NULL, /* Dimensionality GetFile */
+ H5Pclose /* Dimensionality Release */
},
- { /* Dataset object meta-functions (defined in H5D.c) */
- H5_DATASET, /* Dataset Type ID */
- H5D_create, /* Dataset Create */
- NULL, /* Dataset Access */
- NULL, /* Dataset Copy */
- H5D_find_name, /* Dataset FindName */
- NULL, /* Dataset NameLen */
- NULL, /* Dataset GetName */
- NULL, /* Dataset SetName */
- NULL, /* Dataset Search */
- NULL, /* Dataset Index */
- H5D_flush, /* Dataset Flush */
- NULL, /* Dataset Delete */
- NULL, /* Dataset GetParent */
- NULL, /* Dataset GetFile */
- H5D_release /* Dataset Release */
+ { /* Dataset object meta-functions (defined in H5D.c) */
+ H5_DATASET, /* Dataset Type ID */
+ NULL, /* Dataset Create */
+ NULL, /* Dataset Access */
+ NULL, /* Dataset Copy */
+ H5D_find_name, /* Dataset FindName */
+ NULL, /* Dataset NameLen */
+ NULL, /* Dataset GetName */
+ NULL, /* Dataset SetName */
+ NULL, /* Dataset Search */
+ NULL, /* Dataset Index */
+ NULL, /* Dataset Flush */
+ NULL, /* Dataset Delete */
+ NULL, /* Dataset GetParent */
+ NULL, /* Dataset GetFile */
+ H5Dclose /* Dataset Release */
},
};
-/*------------------_-- Local function prototypes ----------------------------*/
+/* Interface initialization */
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5M_init_interface
static herr_t H5M_init_interface(void);
/*--------------------------------------------------------------------------
@@ -153,7 +151,7 @@ MODIFICATIONS
static herr_t H5M_init_interface(void)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5M_init_interface, NULL, FAIL);
+ FUNC_ENTER (H5M_init_interface, FAIL);
FUNC_LEAVE(ret_value);
} /* H5M_init_interface */
@@ -165,20 +163,21 @@ static herr_t H5M_init_interface(void)
Find the type of meta-object to issue a method call on
USAGE
intn H5M_find_type(type)
- hobjtype_t type; IN: Type of object to create
+ hobjtype_t type; IN: Type of object to create
RETURNS
Returns the index of the type in the array of methods on success, or FAIL
- on failure.
+ on failure.
DESCRIPTION
- This function performs a search to find the index of the type of a
+ This function performs a search to find the index of the type of a
meta-object in the array of function pointers.
--------------------------------------------------------------------------*/
-static intn H5M_find_type(hobjtype_t type)
+static intn
+H5M_find_type (group_t type)
{
- intn i; /* local counting variable */
+ intn i; /* local counting variable */
intn ret_value = FAIL;
- FUNC_ENTER(H5M_find_type, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5M_find_type, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -188,8 +187,8 @@ static intn H5M_find_type(hobjtype_t type)
* to a binary search when it becomes too slow.
*/
for(i=0; i<(sizeof(meta_func_arr)/sizeof(meta_func_t)); i++)
- if(type==meta_func_arr[i].type)
- HGOTO_DONE(i);
+ if(type==meta_func_arr[i].type)
+ HGOTO_DONE(i);
done:
if(ret_value == FAIL)
@@ -204,69 +203,25 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5Mcreate
- PURPOSE
- Create a new HDF5 object.
- USAGE
- hid_t H5Mcreate(owner_id, type, name)
- hid_t owner_id; IN: Group/file which owns this object
- hobjtype_t type; IN: Type of object to create
- const char *name; IN: Name of the object
- RETURNS
- Returns ID (atom) on success, FAIL on failure
- DESCRIPTION
- This function re-directs the object's creation into the appropriate
- interface, as defined by the function pointers in hdf5fptr.h
---------------------------------------------------------------------------*/
-hid_t H5Mcreate(hid_t owner_id, hobjtype_t type, const char *name)
-{
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Mcreate, H5M_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(type<=BADGROUP || type>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- i=H5M_find_type(type);
- if(meta_func_arr[i].create==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
- ret_value=(meta_func_arr[i].create)(owner_id,type,name);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Mcreate() */
-
-/*--------------------------------------------------------------------------
- NAME
H5Maccess
PURPOSE
Start access to an existing HDF5 object.
USAGE
hid_t H5Maccess(owner_id)
- hid_t oid; IN: OID of the object to access.
+ hid_t oid; IN: OID of the object to access.
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's access into the appropriate
+ This function re-directs the object's access into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t H5Maccess(hid_t oid)
{
- group_t group;
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group;
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER(H5Maccess, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Maccess, FAIL);
/* Atom group for incoming object */
group = H5Aatom_group (oid);
@@ -274,15 +229,15 @@ hid_t H5Maccess(hid_t oid)
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].access==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].access)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -299,33 +254,33 @@ done:
Copy an HDF5 object.
USAGE
hid_t H5Mcopy(oid)
- hid_t oid; IN: Object to copy
+ hid_t oid; IN: Object to copy
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's copy into the appropriate
+ This function re-directs the object's copy into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t H5Mcopy(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mcopy, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mcopy, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].copy==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].copy)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -342,44 +297,45 @@ done:
Find an HDF5 object by name.
USAGE
hid_t H5Mfind_name(owner_id, type, name)
- hid_t owner_id; IN: Group/file in which to search
- hobjtype_t type; IN: Type of object to search names of
- const char *name; IN: Name of the object to search for
+ hid_t owner_id; IN: Group/file in which to search
+ hobjtype_t type; IN: Type of object to search names of
+ const char *name; IN: Name of the object to search for
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's "find name" into the appropriate
+ This function re-directs the object's "find name" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Mfind_name(hid_t owner_id, hobjtype_t type, const char *name)
+hid_t
+H5Mfind_name (hid_t owner_id, group_t type, const char *name)
{
#ifdef OLD_WAY
group_t group=H5Aatom_group(owner_id); /* Atom group for incoming object */
#endif /* OLD_WAY */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mfind_name, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mfind_name, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
#ifdef OLD_WAY
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
#else /* OLD_WAY */
if(type<=BADGROUP || type>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(type);
#endif /* OLD_WAY */
if(meta_func_arr[i].find_name==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].find_name)(owner_id,type,name);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -396,33 +352,33 @@ done:
Determine the length of the name of an HDF5 object.
USAGE
uint32 H5Mname_len(oid)
- hid_t oid; IN: Object to get name's length
+ hid_t oid; IN: Object to get name's length
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's "name length" into the appropriate
+ This function re-directs the object's "name length" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
uint32 H5Mname_len(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mname_len, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mname_len, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].name_len==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].name_len)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -439,34 +395,34 @@ done:
Get the name of an HDF5 object.
USAGE
herr_t H5Mget_name(oid, name)
- hid_t oid; IN: Object to retreive name of
- char *name; OUT: Buffer to place object's name in
+ hid_t oid; IN: Object to retreive name of
+ char *name; OUT: Buffer to place object's name in
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's "get name" into the appropriate
+ This function re-directs the object's "get name" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
herr_t H5Mget_name(hid_t oid, char *name)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mget_name, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mget_name, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].get_name==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].get_name)(oid,name);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -483,34 +439,34 @@ done:
Set the name of an HDF5 object.
USAGE
herr_t H5Mget_name(oid, name)
- hid_t oid; IN: Object to set name of
- const char *name; IN: Name to use for object
+ hid_t oid; IN: Object to set name of
+ const char *name; IN: Name to use for object
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's "set name" into the appropriate
+ This function re-directs the object's "set name" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
herr_t H5Mset_name(hid_t oid, const char *name)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mset_name, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mset_name, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].set_name==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].set_name)(oid,name);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -527,35 +483,36 @@ done:
Wildcard search for an HDF5 object by name.
USAGE
hid_t H5Mfind_name(owner_id, type, name)
- hid_t owner_id; IN: Group/file in which to search
- hobjtype_t type; IN: Type of object to search names of
- const char *name; IN: Name of the object to search for
+ hid_t owner_id; IN: Group/file in which to search
+ hobjtype_t type; IN: Type of object to search names of
+ const char *name; IN: Name of the object to search for
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's "search" into the appropriate
+ This function re-directs the object's "search" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Msearch(hid_t oid, hobjtype_t type, const char *name)
+hid_t
+H5Msearch (hid_t oid, group_t type, const char *name)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER(H5Msearch, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Msearch, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].search==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].search)(oid,type,name);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -572,35 +529,36 @@ done:
Get an HDF5 object by index.
USAGE
hid_t H5Mindex(oid, type, idx)
- hid_t oid; IN: Group/file in which to find items
- hobjtype_t type; IN: Type of object to get
- uint32 idx; IN: Index of the object to get
+ hid_t oid; IN: Group/file in which to find items
+ hobjtype_t type; IN: Type of object to get
+ uint32 idx; IN: Index of the object to get
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's "index" into the appropriate
+ This function re-directs the object's "index" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Mindex(hid_t oid, hobjtype_t type, uint32 idx)
+hid_t
+H5Mindex (hid_t oid, group_t type, uint32 idx)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mindex, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mindex, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].index==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].index)(oid,type,idx);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -617,35 +575,35 @@ done:
Flush an HDF5 object out to a file.
USAGE
hid_t H5Mflush(oid)
- hid_t oid; IN: Object to flush
+ hid_t oid; IN: Object to flush
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's flush into the appropriate
+ This function re-directs the object's flush into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t H5Mflush(hid_t oid)
{
group_t group; /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mflush, H5M_init_interface, FAIL); /* Insert function initialization code and variables */
+ FUNC_ENTER(H5Mflush, FAIL); /* Insert function initialization code and variables */
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- group=H5Aatom_group(oid); /* look up group for incoming object */
+ group=H5Aatom_group(oid); /* look up group for incoming object */
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
/* Find correct function pointer set from static array */
i=H5M_find_type(group);
if(meta_func_arr[i].flush==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].flush)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -662,34 +620,34 @@ done:
Delete an HDF5 object from a file.
USAGE
herr_t H5Mdelete(oid)
- hid_t oid; IN: Object to delete
+ hid_t oid; IN: Object to delete
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's delete into the appropriate
+ This function re-directs the object's delete into the appropriate
interface, as defined by the function pointers in hdf5fptr.h. Deleting
an object implicitly ends access to it.
--------------------------------------------------------------------------*/
herr_t H5Mdelete(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mdelete, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mdelete, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].delete==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].delete)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -706,33 +664,33 @@ done:
Get the parent ID an HDF5 object.
USAGE
hid_t H5Mget_parent(oid)
- hid_t oid; IN: Object to query
+ hid_t oid; IN: Object to query
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's query into the appropriate
+ This function re-directs the object's query into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t H5Mget_parent(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mget_parent, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mget_parent, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].get_parent==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].get_parent)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -749,33 +707,33 @@ done:
Get the file ID an HDF5 object.
USAGE
hid_t H5Mget_file(oid)
- hid_t oid; IN: Object to query
+ hid_t oid; IN: Object to query
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's query into the appropriate
+ This function re-directs the object's query into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t H5Mget_file(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mget_file, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mget_file, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
if(meta_func_arr[i].get_file==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
ret_value=(meta_func_arr[i].get_file)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -787,38 +745,38 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5Mrelease
+ H5Mclose
PURPOSE
Release access to an HDF5 object.
USAGE
- herr_t H5Mrelease(oid)
- hid_t oid; IN: Object to release access to
+ herr_t H5Mclose(oid)
+ hid_t oid; IN: Object to release access to
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's release into the appropriate
+ This function re-directs the object's release into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-herr_t H5Mrelease(hid_t oid)
+herr_t H5Mclose(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Mrelease, H5M_init_interface, FAIL);
+ FUNC_ENTER(H5Mclose, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
i=H5M_find_type(group);
- if(meta_func_arr[i].release==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
- ret_value=(meta_func_arr[i].release)(oid);
+ if(meta_func_arr[i].close==NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ ret_value=(meta_func_arr[i].close)(oid);
done:
- if(ret_value == FAIL)
+ if(ret_value == FAIL)
{ /* Error condition cleanup */
} /* end if */
@@ -826,5 +784,5 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Mrelease() */
+}
diff --git a/src/H5MF.c b/src/H5MF.c
index 47ec30d..e8d1fda 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -26,6 +26,7 @@
/* Is the interface initialized? */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -55,7 +56,7 @@ H5MF_alloc (H5F_t *f, intn op, size_t size, haddr_t *addr/*out*/)
{
haddr_t tmp_addr;
- FUNC_ENTER (H5MF_alloc, NULL, FAIL);
+ FUNC_ENTER (H5MF_alloc, FAIL);
/* check arguments */
assert (f);
@@ -109,7 +110,7 @@ H5MF_alloc (H5F_t *f, intn op, size_t size, haddr_t *addr/*out*/)
herr_t
H5MF_free (H5F_t *f, const haddr_t *addr, size_t size)
{
- FUNC_ENTER (H5MF_free, NULL, FAIL);
+ FUNC_ENTER (H5MF_free, FAIL);
/* check arguments */
assert (f);
diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h
index 8f48a8c..3620df2 100644
--- a/src/H5Mprivate.h
+++ b/src/H5Mprivate.h
@@ -25,25 +25,25 @@
/*
* A function table record for accessing interfaces which use the "meta"
- * interface to create/access/release objects.
+ * interface to create/open/close objects.
*/
typedef struct meta_func_t
{
- hobjtype_t type; /* Object type this interface is for */
- hid_t (*create) (hid_t , hobjtype_t, const char *); /* Object creation function */
+ group_t type; /* Object type this interface is for */
+ hid_t (*create) (hid_t , group_t, const char *); /* Object creation function */
hid_t (*access) (hid_t ); /* Object access function */
hid_t (*copy) (hid_t ); /* Object copy function */
- hid_t (*find_name) (hid_t , hobjtype_t, const char *); /* Find first object */
+ hid_t (*find_name) (hid_t , group_t, const char *); /* Find first object */
uint32 (*name_len) (hid_t ); /* Get length of object name */
herr_t (*get_name) (hid_t , char *); /* Get object name */
herr_t (*set_name) (hid_t , const char *); /* Set object name */
- hid_t (*search) (hid_t , hobjtype_t, const char *); /* Search for list of objects */
- hid_t (*index) (hid_t , hobjtype_t, uint32); /* Get the OID for the n'th object */
+ hid_t (*search) (hid_t , group_t, const char *); /* Search for list of objects */
+ hid_t (*index) (hid_t , group_t, uint32); /* Get the OID for the n'th object */
herr_t (*flush) (hid_t ); /* Flush the object to disk */
herr_t (*delete) (hid_t ); /* Delete an object from file */
hid_t (*get_parent) (hid_t ); /* Get the parent object of an object */
hid_t (*get_file) (hid_t ); /* Get the file ID of an object */
- herr_t (*release) (hid_t ); /* End access to an object */
+ herr_t (*close) (hid_t ); /* End access to an object */
}
meta_func_t;
diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h
index 6bb3eb3..8d5b905 100644
--- a/src/H5Mpublic.h
+++ b/src/H5Mpublic.h
@@ -29,20 +29,19 @@ extern "C" {
#endif
/* Functions in H5M.c */
-hid_t H5Mcreate(hid_t owner_id, hobjtype_t type, const char *name);
hid_t H5Maccess(hid_t oid);
hid_t H5Mcopy(hid_t oid);
-hid_t H5Mfind_name(hid_t oid, hobjtype_t type, const char *name);
+hid_t H5Mfind_name(hid_t oid, group_t type, const char *name);
uint32 H5Mname_len(hid_t oid);
herr_t H5Mget_name(hid_t oid, char *name);
herr_t H5Mset_name(hid_t oid, const char *name);
-hid_t H5Msearch(hid_t oid, hobjtype_t type, const char *name);
-hid_t H5Mindex(hid_t oid, hobjtype_t type, uint32 idx);
+hid_t H5Msearch(hid_t oid, group_t type, const char *name);
+hid_t H5Mindex(hid_t oid, group_t type, uint32 idx);
hid_t H5Mflush(hid_t oid);
herr_t H5Mdelete(hid_t oid);
hid_t H5Mget_file(hid_t oid);
hid_t H5Mget_parent(hid_t oid);
-herr_t H5Mrelease(hid_t oid);
+herr_t H5Mclose(hid_t oid);
#ifdef __cplusplus
}
diff --git a/src/H5O.c b/src/H5O.c
index 045b98e..2eb177d 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -43,34 +43,35 @@ static const H5AC_class_t H5AC_OHDR[1] = {{
(herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5O_flush,
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/* ID to type mapping */
static const H5O_class_t *const message_type_g[] = {
- H5O_NULL, /*0x0000 Null */
- H5O_SIM_DIM, /*0x0001 Simple dimensionality */
+ H5O_NULL, /*0x0000 Null */
+ H5O_SDSPACE, /*0x0001 Simple Dimensionality */
NULL, /*0x0002 Data space (fiber bundle?) */
- H5O_SIM_DTYPE, /*0x0003 Simple data type */
- NULL, /*0x0004 Compound data type */
- H5O_STD_STORE, /*0x0005 Data storage -- standard object */
+ H5O_DTYPE, /*0x0003 Data Type */
+ NULL, /*0x0004 Not assigned */
+ H5O_CSTORE, /*0x0005 Contiguous Data Storage */
NULL, /*0x0006 Data storage -- compact object */
NULL, /*0x0007 Data storage -- external object */
- H5O_ISTORE, /*0x0008 Data storage -- indexed object */
- NULL, /*0x0009 Not assigned */
+ H5O_ISTORE, /*0x0008 Indexed Data Storage */
+ H5O_EFL, /*0x0009 External File List */
NULL, /*0x000A Not assigned */
NULL, /*0x000B Data storage -- compressed object */
NULL, /*0x000C Attribute list */
- H5O_NAME, /*0x000D Object name */
+ H5O_NAME, /*0x000D Object name */
NULL, /*0x000E Object modification date and time */
NULL, /*0x000F Shared header message */
- H5O_CONT, /*0x0010 Object header continuation */
- H5O_STAB, /*0x0011 Symbol table */
+ H5O_CONT, /*0x0010 Object header continuation */
+ H5O_STAB, /*0x0011 Symbol table */
};
/*-------------------------------------------------------------------------
- * Function: H5O_new
+ * Function: H5O_create
*
* Purpose: Creates a new object header, sets the link count
* to NLINK, and caches the header.
@@ -89,13 +90,13 @@ static const H5O_class_t *const message_type_g[] = {
*-------------------------------------------------------------------------
*/
herr_t
-H5O_new (H5F_t *f, intn nlink, size_t size_hint, haddr_t *addr/*out*/)
+H5O_create (H5F_t *f, intn nlink, size_t size_hint, haddr_t *addr/*out*/)
{
size_t size; /*total size of object header */
H5O_t *oh = NULL;
haddr_t tmp_addr;
- FUNC_ENTER (H5O_new, NULL, FAIL);
+ FUNC_ENTER (H5O_create, FAIL);
/* check args */
assert (f);
@@ -184,7 +185,7 @@ H5O_load (H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
size_t chunk_size;
H5O_cont_t *cont=NULL;
- FUNC_ENTER (H5O_load, NULL, NULL);
+ FUNC_ENTER (H5O_load, NULL);
/* check args */
assert (f);
@@ -344,7 +345,7 @@ H5O_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
int i;
H5O_cont_t *cont = NULL;
- FUNC_ENTER (H5O_flush, NULL, FAIL);
+ FUNC_ENTER (H5O_flush, FAIL);
/* check args */
assert (f);
@@ -476,7 +477,7 @@ H5O_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
herr_t
H5O_reset (const H5O_class_t *type, void *native)
{
- FUNC_ENTER (H5O_reset, NULL, FAIL);
+ FUNC_ENTER (H5O_reset, FAIL);
if (native) {
if (type->reset) {
@@ -517,7 +518,7 @@ H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust)
H5O_t *oh = NULL;
haddr_t addr;
- FUNC_ENTER (H5O_link, NULL, FAIL);
+ FUNC_ENTER (H5O_link, FAIL);
/* check args */
assert (f);
@@ -582,7 +583,7 @@ H5O_read (H5F_t *f, const haddr_t *addr, H5G_entry_t *ent,
H5G_type_t cache_type;
haddr_t _addr;
- FUNC_ENTER (H5O_read, NULL, NULL);
+ FUNC_ENTER (H5O_read, NULL);
/* check args */
assert (f);
@@ -650,7 +651,7 @@ H5O_find_in_ohdr (H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
H5O_t *oh = NULL;
int i;
- FUNC_ENTER (H5O_find_in_ohdr, NULL, FAIL);
+ FUNC_ENTER (H5O_find_in_ohdr, FAIL);
/* check args */
assert (f);
@@ -717,7 +718,7 @@ H5O_peek (H5F_t *f, const haddr_t *addr, const H5O_class_t *type,
intn idx;
H5O_t *oh = NULL;
- FUNC_ENTER (H5O_peek, NULL, NULL);
+ FUNC_ENTER (H5O_peek, NULL);
/* check args */
assert (f);
@@ -775,7 +776,7 @@ H5O_modify (H5F_t *f, const haddr_t *addr, H5G_entry_t *ent,
size_t size;
haddr_t _addr;
- FUNC_ENTER (H5O_modify, NULL, FAIL);
+ FUNC_ENTER (H5O_modify, FAIL);
/* check args */
assert (f);
@@ -879,7 +880,7 @@ H5O_remove (H5F_t *f, const haddr_t *addr, H5G_entry_t *ent,
intn i, seq;
haddr_t _addr;
- FUNC_ENTER (H5O_remove, NULL, FAIL);
+ FUNC_ENTER (H5O_remove, FAIL);
/* check args */
assert (f);
@@ -954,7 +955,7 @@ H5O_alloc_extend_chunk (H5O_t *oh, intn chunkno, size_t size)
size_t delta;
uint8 *old_addr;
- FUNC_ENTER (H5O_alloc_extend_chunk, NULL, FAIL);
+ FUNC_ENTER (H5O_alloc_extend_chunk, FAIL);
/* check args */
assert (oh);
@@ -1071,7 +1072,7 @@ H5O_alloc_new_chunk (H5F_t *f, H5O_t *oh, size_t size)
H5O_cont_t *cont = NULL; /*native continuation message */
intn i, chunkno;
- FUNC_ENTER (H5O_alloc_new_chunk, NULL, FAIL);
+ FUNC_ENTER (H5O_alloc_new_chunk, FAIL);
/* check args */
assert (oh);
@@ -1083,7 +1084,7 @@ H5O_alloc_new_chunk (H5F_t *f, H5O_t *oh, size_t size)
* that could be moved to make room for the continuation message.
* Don't ever move continuation message from one chunk to another.
*/
- cont_size = H5F_SIZEOF_OFFSET(f) + H5F_SIZEOF_SIZE(f);
+ cont_size = H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f);
for (i=0; i<oh->nmesgs; i++) {
if (H5O_NULL_ID == oh->mesg[i].type->id) {
if (cont_size == oh->mesg[i].raw_size) {
@@ -1228,7 +1229,7 @@ H5O_alloc (H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
intn idx;
intn null_idx;
- FUNC_ENTER (H5O_alloc, NULL, FAIL);
+ FUNC_ENTER (H5O_alloc, FAIL);
/* check args */
assert (oh);
@@ -1330,7 +1331,7 @@ H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
int *sequence;
haddr_t tmp_addr;
- FUNC_ENTER (H5O_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_debug, FAIL);
/* check args */
assert (f);
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 4d63fdb..14b1517 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -47,8 +47,9 @@ const H5O_class_t H5O_CONT[1] = {{
H5O_cont_debug, /*debugging */
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -73,11 +74,11 @@ H5O_cont_decode (H5F_t *f, size_t raw_size, const uint8 *p)
{
H5O_cont_t *cont = NULL;
- FUNC_ENTER (H5O_cont_decode, NULL, NULL);
+ FUNC_ENTER (H5O_cont_decode, NULL);
/* check args */
assert (f);
- assert (raw_size == H5F_SIZEOF_OFFSET(f) + H5F_SIZEOF_SIZE(f));
+ assert (raw_size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
assert (p);
/* decode */
@@ -111,11 +112,11 @@ H5O_cont_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg)
{
const H5O_cont_t *cont = (const H5O_cont_t *)_mesg;
- FUNC_ENTER (H5O_cont_encode, NULL, FAIL);
+ FUNC_ENTER (H5O_cont_encode, FAIL);
/* check args */
assert (f);
- assert (size == H5F_SIZEOF_OFFSET(f) + H5F_SIZEOF_SIZE(f));
+ assert (size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
assert (p);
assert (cont);
@@ -150,7 +151,7 @@ H5O_cont_debug (H5F_t *f, const void *_mesg, FILE *stream,
{
const H5O_cont_t *cont = (const H5O_cont_t *)_mesg;
- FUNC_ENTER (H5O_cont_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_cont_debug, FAIL);
/* check args */
assert (f);
diff --git a/src/H5Ostdst.c b/src/H5Ocstore.c
index d0156f2..5e69d48 100644
--- a/src/H5Ostdst.c
+++ b/src/H5Ocstore.c
@@ -10,17 +10,11 @@
* *
****************************************************************************/
-#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
-#endif
-
-/* $Id$ */
-
/*LINTLIBRARY */
/*+
FILE
- H5Ostdst.c
- HDF5 Standard Data Storage Object Header Message routines
+ H5Ocstore.c
+ HDF5 Contiguous Data Storage Object Header Message routines
EXPORTED ROUTINES
@@ -35,71 +29,72 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_std_store_mask
+#define PABLO_MASK H5O_cstore_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_std_store_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_std_store_encode (H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
-static void *H5O_std_store_copy (const void *_mesg, void *_dest);
-static size_t H5O_std_store_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_std_store_debug (H5F_t *f, const void *_mesg,
- FILE *stream, intn indent, intn fwidth);
+static void *H5O_cstore_decode (H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_cstore_encode (H5F_t *f, size_t size, uint8 *p,
+ const void *_mesg);
+static void *H5O_cstore_copy (const void *_mesg, void *_dest);
+static size_t H5O_cstore_size (H5F_t *f, const void *_mesg);
+static herr_t H5O_cstore_debug (H5F_t *f, const void *_mesg,
+ FILE *stream, intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_STD_STORE[1] = {{
- H5O_STD_STORE_ID, /* message id number */
- "std_store", /* message name for debugging */
- sizeof (H5O_std_store_t),/* native message size */
- H5G_NOTHING_CACHED, /* symtab entry `type' field */
- H5O_std_store_decode, /* decode message */
- H5O_std_store_encode, /* encode message */
- NULL, /* get message from stab entry */
- NULL, /* put message into stab entry */
- H5O_std_store_copy, /* copy the native value */
- H5O_std_store_size, /* size of symbol table entry */
- NULL, /* default reset method */
- H5O_std_store_debug, /* debug the message */
+const H5O_class_t H5O_CSTORE[1] = {{
+ H5O_CSTORE_ID, /* message id number */
+ "cstore", /* message name for debugging */
+ sizeof (H5O_cstore_t), /* native message size */
+ H5G_NOTHING_CACHED, /* symtab entry `type' field */
+ H5O_cstore_decode, /* decode message */
+ H5O_cstore_encode, /* encode message */
+ NULL, /* get message from stab entry */
+ NULL, /* put message into stab entry */
+ H5O_cstore_copy, /* copy the native value */
+ H5O_cstore_size, /* size of symbol table entry */
+ NULL, /* default reset method */
+ H5O_cstore_debug, /* debug the message */
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
NAME
- H5O_std_store_decode
+ H5O_cstore_decode
PURPOSE
- Decode a standard data storage and return a pointer to a memory
+ Decode a contiguous data storage and return a pointer to a memory
struct with the decoded information
USAGE
- void *H5O_std_store_decode(f, raw_size, p)
+ void *H5O_cstore_decode(f, raw_size, p)
H5F_t *f; IN: pointer to the HDF5 file struct
size_t raw_size; IN: size of the raw information buffer
const uint8 *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
- This function decodes the "raw" disk form of a standard data storage
+ This function decodes the "raw" disk form of a contiguous data storage
message into a struct in memory native format. The struct is allocated
within this function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
-H5O_std_store_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+H5O_cstore_decode (H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_std_store_t *store=NULL; /* New standard storage structure */
+ H5O_cstore_t *store=NULL; /* New contiguous storage structure */
- FUNC_ENTER (H5O_std_store_decode, NULL, NULL);
+ FUNC_ENTER (H5O_cstore_decode, NULL);
/* check args */
assert (f);
- assert (raw_size == H5F_SIZEOF_OFFSET(f)+H5F_SIZEOF_SIZE(f));
+ assert (raw_size == H5F_SIZEOF_ADDR(f)+H5F_SIZEOF_SIZE(f));
assert (p);
/* decode */
- if((store = H5MM_xcalloc (1, sizeof(H5O_std_store_t)))!=NULL)
+ if((store = H5MM_xcalloc (1, sizeof(H5O_cstore_t)))!=NULL)
{
- H5F_addr_decode (f, &p,&(store->off));
- H5F_decode_length(f,p,store->len);
+ H5F_addr_decode (f, &p,&(store->addr));
+ H5F_decode_length(f,p,store->size);
} /* end if */
#ifdef LATER
@@ -113,117 +108,121 @@ done:
/* Normal function cleanup */
FUNC_LEAVE (store);
-} /* end H5O_std_store_decode() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_std_store_encode
+ H5O_cstore_encode
PURPOSE
- Encode a standard data storage message
+ Encode a contiguous data storage message
USAGE
- herr_t H5O_std_store_encode(f, raw_size, p, mesg)
+ herr_t H5O_cstore_encode(f, raw_size, p, mesg)
H5F_t *f; IN: pointer to the HDF5 file struct
size_t raw_size; IN: size of the raw information buffer
const uint8 *p; IN: the raw information buffer
- const void *mesg; IN: Pointer to the standard storage struct
+ const void *mesg; IN: Pointer to the contiguous storage struct
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function encodes the native memory form of the standard data
+ This function encodes the native memory form of the contiguous data
storage message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_std_store_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_cstore_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
{
- const H5O_std_store_t *store = (const H5O_std_store_t *)mesg;
+ const H5O_cstore_t *store = (const H5O_cstore_t *)mesg;
- FUNC_ENTER (H5O_std_store_encode, NULL, FAIL);
+ FUNC_ENTER (H5O_cstore_encode, FAIL);
/* check args */
assert (f);
- assert (raw_size == H5F_SIZEOF_OFFSET(f)+H5F_SIZEOF_SIZE(f));
+ assert (raw_size == H5F_SIZEOF_ADDR(f)+H5F_SIZEOF_SIZE(f));
assert (p);
assert (store);
/* encode */
- H5F_addr_encode (f, &p, &(store->off));
- H5F_encode_length(f,p,store->len);
+ H5F_addr_encode (f, &p, &(store->addr));
+ H5F_encode_length(f,p,store->size);
FUNC_LEAVE (SUCCEED);
-} /* end H5O_std_store_encode() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_std_store_copy
+ H5O_cstore_copy
PURPOSE
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
- void *H5O_std_store_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source standard storage struct
- const void *dest; IN: Pointer to the destination standard storage struct
+ void *H5O_cstore_copy(mesg, dest)
+ const void *mesg; IN: Pointer to the source contiguous storage
+ struct
+ const void *dest; IN: Pointer to the destination contiguous
+ storage struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
- This function copies a native (memory) standard storage message,
+ This function copies a native (memory) contiguous storage message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
-H5O_std_store_copy (const void *mesg, void *dest)
+H5O_cstore_copy (const void *mesg, void *dest)
{
- const H5O_std_store_t *src = (const H5O_std_store_t *)mesg;
- H5O_std_store_t *dst = (H5O_std_store_t *)dest;
+ const H5O_cstore_t *src = (const H5O_cstore_t *)mesg;
+ H5O_cstore_t *dst = (H5O_cstore_t *)dest;
- FUNC_ENTER (H5O_std_store_copy, NULL, NULL);
+ FUNC_ENTER (H5O_cstore_copy, NULL);
/* check args */
assert (src);
if (!dst)
- dst = H5MM_xcalloc (1, sizeof(H5O_std_store_t));
+ dst = H5MM_xcalloc (1, sizeof(H5O_cstore_t));
/* copy */
- HDmemcpy(dst,src,sizeof(H5O_std_store_t));
+ HDmemcpy(dst,src,sizeof(H5O_cstore_t));
FUNC_LEAVE ((void*)dst);
-} /* end H5O_std_store_copy() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_std_store_size
+ H5O_cstore_size
PURPOSE
Return the raw message size in bytes
USAGE
- void *H5O_std_store_copy(f, mesg)
+ void *H5O_cstore_copy(f, mesg)
H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source standard storage struct
+ const void *mesg; IN: Pointer to the source contiguous storage
+ struct
RETURNS
Size of message on success, FAIL on failure
DESCRIPTION
- This function returns the size of the raw standard storage message on
+ This function returns the size of the raw contiguous storage message on
success. (Not counting the message type or size fields, only the data
portion of the message). It doesn't take into account alignment.
--------------------------------------------------------------------------*/
static size_t
-H5O_std_store_size (H5F_t *f, const void *mesg)
+H5O_cstore_size (H5F_t *f, const void *mesg)
{
size_t ret_value;
- FUNC_ENTER (H5O_std_store_size, NULL, FAIL);
+ FUNC_ENTER (H5O_cstore_size, FAIL);
- /* All standard data storage messages have the same data */
- ret_value=H5F_SIZEOF_OFFSET(f)+H5F_SIZEOF_SIZE(f);
+ /* All contiguous data storage messages have the same data */
+ ret_value=H5F_SIZEOF_ADDR(f)+H5F_SIZEOF_SIZE(f);
FUNC_LEAVE (ret_value);
-} /* end H5O_std_store_size() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_std_store_debug
+ H5O_cstore_debug
PURPOSE
- Prints debugging information for a standard storage message
+ Prints debugging information for a contiguous storage message
USAGE
- void *H5O_std_store_debug(f, mesg, stream, indent, fwidth)
+ void *H5O_cstore_debug(f, mesg, stream, indent, fwidth)
H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source standard storage struct
+ const void *mesg; IN: Pointer to the source contiguous storage
+ struct
FILE *stream; IN: Pointer to the stream for output data
intn indent; IN: Amount to indent information by
intn fwidth; IN: Field width (?)
@@ -234,12 +233,12 @@ H5O_std_store_size (H5F_t *f, const void *mesg)
parameter.
--------------------------------------------------------------------------*/
static herr_t
-H5O_std_store_debug (H5F_t *f, const void *mesg, FILE *stream,
+H5O_cstore_debug (H5F_t *f, const void *mesg, FILE *stream,
intn indent, intn fwidth)
{
- const H5O_std_store_t *store = (const H5O_std_store_t *)mesg;
+ const H5O_cstore_t *store = (const H5O_cstore_t *)mesg;
- FUNC_ENTER (H5O_std_store_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_cstore_debug, FAIL);
/* check args */
assert (f);
@@ -249,14 +248,14 @@ H5O_std_store_debug (H5F_t *f, const void *mesg, FILE *stream,
assert (fwidth>=0);
fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Offset:");
- H5F_addr_print (stream, &(store->off));
+ "Address:");
+ H5F_addr_print (stream, &(store->addr));
fprintf (stream, "\n");
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Length:",
- (unsigned long)(store->len));
+ "Size (bytes):",
+ (unsigned long)(store->size));
FUNC_LEAVE (SUCCEED);
-} /* end H5O_std_store_debug() */
+}
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
new file mode 100644
index 0000000..2e10e91
--- /dev/null
+++ b/src/H5Oefl.c
@@ -0,0 +1,307 @@
+/*
+ * Copyright (C) 1997 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Tuesday, November 25, 1997
+ */
+#include <H5private.h>
+#include <H5Eprivate.h>
+#include <H5MMprivate.h>
+#include <H5Oprivate.h>
+
+#define PABLO_MASK H5O_efl_mask
+
+/* PRIVATE PROTOTYPES */
+static void *H5O_efl_decode (H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_efl_encode (H5F_t *f, size_t size, uint8 *p,
+ const void *_mesg);
+static void *H5O_efl_copy (const void *_mesg, void *_dest);
+static size_t H5O_efl_size (H5F_t *f, const void *_mesg);
+static herr_t H5O_efl_reset (void *_mesg);
+static herr_t H5O_efl_debug (H5F_t *f, const void *_mesg, FILE *stream,
+ intn indent, intn fwidth);
+
+/* This message derives from H5O */
+const H5O_class_t H5O_EFL[1] = {{
+ H5O_EFL_ID, /*message id number */
+ "external file list", /*message name for debugging */
+ sizeof(H5O_efl_t), /*native message size */
+ H5G_NOTHING_CACHED, /*symtab entry `type' field */
+ H5O_efl_decode, /*decode message */
+ H5O_efl_encode, /*encode message */
+ NULL, /*get messaage from stab entry */
+ NULL, /*put message into stab entry */
+ H5O_efl_copy, /*copy native value */
+ H5O_efl_size, /*size of message on disk */
+ H5O_efl_reset, /*reset method */
+ H5O_efl_debug, /*debug the message */
+}};
+
+
+/* Interface initialization */
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_decode
+ *
+ * Purpose: Decode an external file list message and return a pointer to
+ * the message (and some other data).
+ *
+ * Return: Success: Ptr to a new message struct.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_efl_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+{
+ H5O_efl_t *mesg = NULL;
+ int i;
+
+ FUNC_ENTER (H5O_efl_decode, NULL);
+
+ /* check args */
+ assert (f);
+ assert (p);
+
+ /* decode */
+ mesg = H5MM_xcalloc (1, sizeof(H5O_efl_t));
+ H5F_addr_decode (f, &p, &(mesg->heap_addr));
+ UINT32DECODE (p, mesg->nalloc);
+ assert (mesg->nalloc>0);
+ UINT32DECODE (p, mesg->nused);
+ assert (mesg->nused<=mesg->nalloc);
+
+ mesg->offset = H5MM_xmalloc (mesg->nalloc * sizeof(size_t));
+ for (i=0; i<mesg->nused; i++) {
+ UINT32DECODE (p, mesg->offset[i]);
+ }
+
+ FUNC_LEAVE (mesg);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_encode
+ *
+ * Purpose: Encodes a message
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_efl_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+{
+ const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
+ int i;
+
+ FUNC_ENTER (H5O_efl_encode, FAIL);
+
+ /* check args */
+ assert (f);
+ assert (mesg);
+ assert (raw_size == H5O_efl_size (f, _mesg));
+ assert (p);
+
+ /* encode */
+ H5F_addr_encode (f, &p, &(mesg->heap_addr));
+ UINT32ENCODE (p, mesg->nalloc);
+ UINT32ENCODE (p, mesg->nused);
+ for (i=0; i<mesg->nused; i++) {
+ UINT32ENCODE (p, mesg->offset[i]);
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_copy
+ *
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
+ *
+ * Return: Success: Ptr to _DEST
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_efl_copy (const void *_mesg, void *_dest)
+{
+ const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
+ H5O_efl_t *dest = (H5O_efl_t *)_dest;
+ int i;
+
+ FUNC_ENTER (H5O_efl_copy, NULL);
+
+ /* check args */
+ assert (mesg);
+ if (!dest) {
+ dest = H5MM_xcalloc (1, sizeof(H5O_efl_t));
+ dest->offset = H5MM_xmalloc (mesg->nalloc * sizeof(size_t));
+ } else if (dest->nalloc<mesg->nalloc) {
+ H5MM_xfree (dest->offset);
+ dest->offset = H5MM_xmalloc (mesg->nalloc * sizeof(size_t));
+ }
+
+ dest->heap_addr = mesg->heap_addr;
+ dest->nalloc = mesg->nalloc;
+ dest->nused = mesg->nused;
+
+ for (i=0; i<mesg->nused; i++) {
+ dest->offset[i] = mesg->offset[i];
+ }
+
+ FUNC_LEAVE ((void*)dest);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_size
+ *
+ * Purpose: Returns the size of the raw message in bytes not counting the
+ * message type or size fields, but only the data fields. This
+ * function doesn't take into account message alignment.
+ *
+ * Return: Success: Message data size in bytes.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+H5O_efl_size (H5F_t *f, const void *_mesg)
+{
+ const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
+ size_t ret_value = FAIL;
+
+ FUNC_ENTER (H5O_efl_size, FAIL);
+
+ /* check args */
+ assert (f);
+ assert (mesg);
+
+ ret_value = H5F_SIZEOF_ADDR (f) + /*heap address */
+ 4 + /*num slots allocated */
+ 4 + /*num slots used */
+ mesg->nalloc * 4; /*name offsets in heap */
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_reset
+ *
+ * Purpose: Frees internal pointers and resets the message to an
+ * initialial state.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_efl_reset (void *_mesg)
+{
+ H5O_efl_t *mesg = (H5O_efl_t *)_mesg;
+
+ FUNC_ENTER (H5O_efl_reset, FAIL);
+
+ /* check args */
+ assert (mesg);
+
+ /* reset */
+ mesg->nused = mesg->nalloc = 0;
+ mesg->offset = H5MM_xfree (mesg->offset);
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_efl_debug
+ *
+ * Purpose: Prints debugging info for a message.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, November 25, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_efl_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
+ intn fwidth)
+{
+ const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
+ char buf[64];
+ intn i;
+
+ FUNC_ENTER (H5O_efl_debug, FAIL);
+
+ /* check args */
+ assert (f);
+ assert (mesg);
+ assert (stream);
+ assert (indent>=0);
+ assert (fwidth>=0);
+
+ fprintf (stream, "%*s%-*s ", indent, "", fwidth,
+ "Heap address:");
+ H5F_addr_print (stream, &(mesg->heap_addr));
+ fprintf (stream, "\n");
+
+ fprintf (stream, "%*s%-*s %u/%u\n", indent, "", fwidth,
+ "Slots used/allocated:",
+ mesg->nused, mesg->nalloc);
+
+ for (i=0; i<mesg->nused; i++) {
+ sprintf (buf, "Name %d:", i+1);
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ buf,
+ (unsigned long)(mesg->offset[i]));
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
diff --git a/src/H5Oistore.c b/src/H5Oistore.c
index 89812a4..3c04c17 100644
--- a/src/H5Oistore.c
+++ b/src/H5Oistore.c
@@ -37,9 +37,9 @@ const H5O_class_t H5O_ISTORE[1] = {{
H5O_istore_debug, /*debug the message */
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
-
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -65,7 +65,7 @@ H5O_istore_decode (H5F_t *f, size_t raw_size, const uint8 *p)
H5O_istore_t *mesg = NULL;
intn i;
- FUNC_ENTER (H5O_istore_decode, NULL, NULL);
+ FUNC_ENTER (H5O_istore_decode, NULL);
/* check args */
assert (f);
@@ -112,7 +112,7 @@ H5O_istore_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
const H5O_istore_t *mesg = (const H5O_istore_t *)_mesg;
int i;
- FUNC_ENTER (H5O_istore_encode, NULL, FAIL);
+ FUNC_ENTER (H5O_istore_encode, FAIL);
/* check args */
assert (f);
@@ -163,7 +163,7 @@ H5O_istore_copy (const void *_mesg, void *_dest)
const H5O_istore_t *mesg = (const H5O_istore_t *)_mesg;
H5O_istore_t *dest = (H5O_istore_t *)_dest;
- FUNC_ENTER (H5O_istore_copy, NULL, NULL);
+ FUNC_ENTER (H5O_istore_copy, NULL);
/* check args */
assert (mesg);
@@ -201,14 +201,14 @@ H5O_istore_size (H5F_t *f, const void *_mesg)
const H5O_istore_t *mesg = (const H5O_istore_t *)_mesg;
size_t ret_value = FAIL;
- FUNC_ENTER (H5O_istore_size, NULL, FAIL);
+ FUNC_ENTER (H5O_istore_size, FAIL);
/* check args */
assert (f);
assert (mesg);
assert (mesg->ndims>0 && mesg->ndims<=H5O_ISTORE_NDIMS);
- ret_value = H5F_SIZEOF_OFFSET (f) + /* B-tree address */
+ ret_value = H5F_SIZEOF_ADDR (f) + /* B-tree address */
1 + /* max dimension index */
7 + /* reserved bytes */
mesg->ndims * 4; /* alignment */
@@ -241,7 +241,7 @@ H5O_istore_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
const H5O_istore_t *mesg = (const H5O_istore_t *)_mesg;
intn i;
- FUNC_ENTER (H5O_istore_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_istore_debug, FAIL);
/* check args */
assert (f);
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 9d8aa09..379b179 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -47,8 +47,9 @@ const H5O_class_t H5O_NAME[1] = {{
H5O_name_debug, /*debug the message */
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -75,7 +76,7 @@ H5O_name_decode (H5F_t *f, size_t raw_size, const uint8 *p)
H5O_name_t *mesg;
char *s;
- FUNC_ENTER (H5O_name_decode, NULL, NULL);
+ FUNC_ENTER (H5O_name_decode, NULL);
/* check args */
assert (f);
@@ -114,7 +115,7 @@ H5O_name_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
size_t size;
- FUNC_ENTER (H5O_name_encode, NULL, FAIL);
+ FUNC_ENTER (H5O_name_encode, FAIL);
/* check args */
assert (f);
@@ -157,7 +158,7 @@ H5O_name_copy (const void *_mesg, void *_dest)
const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
H5O_name_t *dest = (H5O_name_t *)_dest;
- FUNC_ENTER (H5O_name_copy, NULL, NULL);
+ FUNC_ENTER (H5O_name_copy, NULL);
/* check args */
assert (mesg);
@@ -197,7 +198,7 @@ H5O_name_size (H5F_t *f, const void *_mesg)
const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
size_t size;
- FUNC_ENTER (H5O_name_size, NULL, FAIL);
+ FUNC_ENTER (H5O_name_size, FAIL);
/* check args */
assert (f);
@@ -231,7 +232,7 @@ H5O_name_reset (void *_mesg)
{
H5O_name_t *mesg = (H5O_name_t *)_mesg;
- FUNC_ENTER (H5O_name_reset, NULL, FAIL);
+ FUNC_ENTER (H5O_name_reset, FAIL);
/* check args */
assert (mesg);
@@ -266,7 +267,7 @@ H5O_name_debug (H5F_t *f, const void *_mesg, FILE *stream,
{
const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
- FUNC_ENTER (H5O_name_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_name_debug, FAIL);
/* check args */
assert (f);
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index d6c9ab2..23086e8 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -87,40 +87,38 @@ typedef struct H5O_t {
} H5O_t;
/*
- * Null message.
+ * Null Message.
*/
#define H5O_NULL_ID 0x0000
extern const H5O_class_t H5O_NULL[1];
/*
- * Simple Dimensionality message.
+ * Simple Dimensionality Message.
*/
-#define H5O_SIM_DIM_ID 0x0001
-extern const H5O_class_t H5O_SIM_DIM[1];
-
-typedef H5P_sdim_t H5O_sim_dim_t;
+#define H5O_SDSPACE_ID 0x0001
+extern const H5O_class_t H5O_SDSPACE[1];
+/* operates on an H5P_simple_t struct */
/*
- * Simple Datatype message.
+ * Data Type Message.
*/
-#define H5O_SIM_DTYPE_ID 0x0003
-extern const H5O_class_t H5O_SIM_DTYPE[1];
-
-typedef h5_atomic_type_t H5O_sim_dtype_t;
+#define H5O_DTYPE_ID 0x0003
+extern const H5O_class_t H5O_DTYPE[1];
+/* operates on an H5T_t struct */
/*
- * Standard Data Storage message.
+ * Contiguous Data Storage Message.
*/
-#define H5O_STD_STORE_ID 0x0005
-extern const H5O_class_t H5O_STD_STORE[1];
+#define H5O_CSTORE_ID 0x0005
+extern const H5O_class_t H5O_CSTORE[1];
-typedef struct H5O_std_store_t {
- haddr_t off;
- size_t len;
-} H5O_std_store_t;
+typedef struct H5O_cstore_t {
+ haddr_t addr;
+ size_t size;
+} H5O_cstore_t;
/*
- * Indexed Data Storage message.
+ * Indexed Data Storage Message.
*/
#define H5O_ISTORE_ID 0x0008
#define H5O_ISTORE_NDIMS 32
@@ -133,6 +131,19 @@ typedef struct H5O_istore_t {
} H5O_istore_t;
/*
+ * External File List Message
+ */
+#define H5O_EFL_ID 0x0009
+extern const H5O_class_t H5O_EFL[1];
+
+typedef struct H5O_efl_t {
+ haddr_t heap_addr; /*Address of name heap */
+ uintn nalloc; /*Number of slots allocated */
+ uintn nused; /*Number of slots used */
+ size_t *offset; /*Array of name offsets in heap */
+} H5O_efl_t;
+
+/*
* Object name message.
*/
#define H5O_NAME_ID 0x000d
@@ -169,7 +180,7 @@ typedef struct H5O_stab_t {
-herr_t H5O_new (H5F_t *f, intn nlink, size_t size_hint, haddr_t*);
+herr_t H5O_create (H5F_t *f, intn nlink, size_t size_hint, haddr_t*);
intn H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust);
void *H5O_read (H5F_t *f, const haddr_t *addr, H5G_entry_t *ent,
const H5O_class_t *type, intn sequence, void *mesg);
diff --git a/src/H5Osdim.c b/src/H5Osdim.c
index ffd9743..3bc1e04 100644
--- a/src/H5Osdim.c
+++ b/src/H5Osdim.c
@@ -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. *
+* *
****************************************************************************/
#ifdef RCSID
@@ -16,83 +16,71 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-/*LINTLIBRARY */
-/*+
- FILE
- H5Osdim.c
- HDF5 Simple Dimensionality Object Header Message routines
-
- EXPORTED ROUTINES
-
- LIBRARY-SCOPED ROUTINES
-
- LOCAL ROUTINES
- + */
-
#include <H5private.h>
#include <H5Eprivate.h>
#include <H5Gprivate.h>
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_sim_dim_mask
+#define PABLO_MASK H5O_sdspace_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_sim_dim_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_sim_dim_encode (H5F_t *f, size_t size, uint8 *p,
+static void *H5O_sdspace_decode (H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_sdspace_encode (H5F_t *f, size_t size, uint8 *p,
const void *_mesg);
-static void *H5O_sim_dim_fast (const H5G_cache_t *cache, void *_mesg);
-static hbool_t H5O_sim_dim_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
+static void *H5O_sdspace_fast (const H5G_cache_t *cache, void *_mesg);
+static hbool_t H5O_sdspace_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
const void *_mesg);
-static void *H5O_sim_dim_copy (const void *_mesg, void *_dest);
-static size_t H5O_sim_dim_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_sim_dim_debug (H5F_t *f, const void *_mesg,
+static void *H5O_sdspace_copy (const void *_mesg, void *_dest);
+static size_t H5O_sdspace_size (H5F_t *f, const void *_mesg);
+static herr_t H5O_sdspace_debug (H5F_t *f, const void *_mesg,
FILE *stream, intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_SIM_DIM[1] = {{
- H5O_SIM_DIM_ID, /* message id number */
- "sim_dim", /* message name for debugging */
- sizeof (H5O_sim_dim_t), /* native message size */
- H5G_CACHED_SDATA, /* symtab entry `type' field */
- H5O_sim_dim_decode, /* decode message */
- H5O_sim_dim_encode, /* encode message */
- H5O_sim_dim_fast, /* get message from stab entry */
- H5O_sim_dim_cache, /* put message into stab entry */
- H5O_sim_dim_copy, /* copy the native value */
- H5O_sim_dim_size, /* size of symbol table entry */
- NULL, /* default reset method */
- H5O_sim_dim_debug, /* debug the message */
+const H5O_class_t H5O_SDSPACE[1] = {{
+ H5O_SDSPACE_ID, /* message id number */
+ "simple_dspace", /* message name for debugging */
+ sizeof (H5P_simple_t), /* native message size */
+ H5G_CACHED_SDSPACE, /* symtab entry `type' field */
+ H5O_sdspace_decode, /* decode message */
+ H5O_sdspace_encode, /* encode message */
+ H5O_sdspace_fast, /* get message from stab entry */
+ H5O_sdspace_cache, /* put message into stab entry */
+ H5O_sdspace_copy, /* copy the native value */
+ H5O_sdspace_size, /* size of symbol table entry */
+ NULL, /* default reset method */
+ H5O_sdspace_debug, /* debug the message */
}};
/* Is the interface initialized? */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_decode
+ H5O_sdspace_decode
PURPOSE
Decode a simple dimensionality message and return a pointer to a memory
- struct with the decoded information
+ struct with the decoded information
USAGE
- void *H5O_sim_dim_decode(f, raw_size, p)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
+ void *H5O_sdspace_decode(f, raw_size, p)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
- This function decodes the "raw" disk form of a simple dimensionality
+ This function decodes the "raw" disk form of a simple dimensionality
message into a struct in memory native format. The struct is allocated
within this function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
-H5O_sim_dim_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+H5O_sdspace_decode (H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_sim_dim_t *sdim=NULL; /* New simple dimensionality structure */
- uintn u; /* local counting variable */
+ H5P_simple_t *sdim=NULL; /* New simple dimensionality structure */
+ uintn u; /* local counting variable */
- FUNC_ENTER (H5O_sim_dim_decode, NULL, NULL);
+ FUNC_ENTER (H5O_sdspace_decode, NULL);
/* check args */
assert (f);
@@ -100,28 +88,28 @@ H5O_sim_dim_decode (H5F_t *f, size_t raw_size, const uint8 *p)
assert (p);
/* decode */
- if((sdim = H5MM_xcalloc (1, sizeof(H5O_sim_dim_t)))!=NULL)
+ if((sdim = H5MM_xcalloc (1, sizeof(H5P_simple_t)))!=NULL)
{
- UINT32DECODE(p,sdim->rank);
- UINT32DECODE(p,sdim->dim_flags);
- if(sdim->rank>0)
- {
- sdim->size=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->size[u]);
- if(sdim->dim_flags&0x01)
- {
- sdim->max=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->max[u]);
- } /* end if */
- if(sdim->dim_flags&0x02)
- {
- sdim->perm=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->perm[u]);
- } /* end if */
- } /* end if */
+ UINT32DECODE(p,sdim->rank);
+ UINT32DECODE(p,sdim->dim_flags);
+ if(sdim->rank>0)
+ {
+ sdim->size=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
+ for(u=0; u<sdim->rank; u++)
+ UINT32DECODE(p,sdim->size[u]);
+ if(sdim->dim_flags&0x01)
+ {
+ sdim->max=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
+ for(u=0; u<sdim->rank; u++)
+ UINT32DECODE(p,sdim->max[u]);
+ } /* end if */
+ if(sdim->dim_flags&0x02)
+ {
+ sdim->perm=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
+ for(u=0; u<sdim->rank; u++)
+ UINT32DECODE(p,sdim->perm[u]);
+ } /* end if */
+ } /* end if */
} /* end if */
#ifdef LATER
@@ -135,32 +123,32 @@ done:
/* Normal function cleanup */
FUNC_LEAVE (sdim);
-} /* end H5O_sim_dim_decode() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_encode
+ H5O_sdspace_encode
PURPOSE
Encode a simple dimensionality message
USAGE
- herr_t H5O_sim_dim_encode(f, raw_size, p, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
- const void *mesg; IN: Pointer to the simple dimensionality struct
+ herr_t H5O_sdspace_encode(f, raw_size, p, mesg)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
+ const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function encodes the native memory form of the simple
+ This function encodes the native memory form of the simple
dimensionality message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sim_dim_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_sdspace_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
{
- const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg;
- uintn u; /* Local counting variable */
+ const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
+ uintn u; /* Local counting variable */
- FUNC_ENTER (H5O_sim_dim_encode, NULL, FAIL);
+ FUNC_ENTER (H5O_sdspace_encode, FAIL);
/* check args */
assert (f);
@@ -173,165 +161,165 @@ H5O_sim_dim_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
UINT32ENCODE(p,sdim->dim_flags);
if(sdim->rank>0)
{
- for(u=0; u<sdim->rank; u++)
- UINT32ENCODE(p,sdim->size[u]);
- if(sdim->dim_flags&0x01)
- {
- for(u=0; u<sdim->rank; u++)
- UINT32ENCODE(p,sdim->max[u]);
- } /* end if */
- if(sdim->dim_flags&0x02)
- {
- for(u=0; u<sdim->rank; u++)
- UINT32ENCODE(p,sdim->perm[u]);
- } /* end if */
+ for(u=0; u<sdim->rank; u++)
+ UINT32ENCODE(p,sdim->size[u]);
+ if(sdim->dim_flags&0x01)
+ {
+ for(u=0; u<sdim->rank; u++)
+ UINT32ENCODE(p,sdim->max[u]);
+ } /* end if */
+ if(sdim->dim_flags&0x02)
+ {
+ for(u=0; u<sdim->rank; u++)
+ UINT32ENCODE(p,sdim->perm[u]);
+ } /* end if */
} /* end if */
FUNC_LEAVE (SUCCEED);
-} /* end H5O_sim_dim_encode() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_fast
+ H5O_sdspace_fast
PURPOSE
Initializes a new simple dimensionality struct with info from a symbol
- table entry.
+ table entry.
USAGE
- void *H5O_sim_dim_fast(ent, mesg)
- const H5G_entry_t *ent; IN: pointer to the symbol table entry
- const void *mesg; IN: Pointer to the simple dimensionality struct
+ void *H5O_sdspace_fast(ent, mesg)
+ const H5G_entry_t *ent; IN: pointer to the symbol table entry
+ const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
Pointer to the message structure (allocated if none is supplied) on success,
- NULL on failure
+ NULL on failure
DESCRIPTION
- This function fills the native memory form of the simple dimensionality
+ This function fills the native memory form of the simple dimensionality
message from a symbol-table entry cache fields. (This method is required
for simple dimensionality, as they can be cached in the symbol-table entry)
--------------------------------------------------------------------------*/
static void *
-H5O_sim_dim_fast (const H5G_cache_t *cache, void *mesg)
+H5O_sdspace_fast (const H5G_cache_t *cache, void *mesg)
{
- H5O_sim_dim_t *sdim = (H5O_sim_dim_t *)mesg;
- uintn u; /* local counting variable */
+ H5P_simple_t *sdim = (H5P_simple_t *)mesg;
+ uintn u; /* local counting variable */
- FUNC_ENTER (H5O_sim_dim_fast, NULL, NULL);
+ FUNC_ENTER (H5O_sdspace_fast, NULL);
/* check args */
assert (cache);
- if (!sdim) sdim = H5MM_xcalloc (1, sizeof(H5O_sim_dim_t));
- sdim->rank = cache->sdata.ndim;
- assert (sdim->rank<=NELMTS (cache->sdata.dim));
+ if (!sdim) sdim = H5MM_xcalloc (1, sizeof(H5P_simple_t));
+ sdim->rank = cache->sdspace.ndim;
+ assert (sdim->rank<=NELMTS (cache->sdspace.dim));
sdim->dim_flags = 0;
sdim->size = H5MM_xmalloc (sizeof(uint32) * sdim->rank);
for (u=0; u<sdim->rank; u++) {
- sdim->size[u] = cache->sdata.dim[u];
+ sdim->size[u] = cache->sdspace.dim[u];
}
FUNC_LEAVE (sdim);
-} /* end H5O_sim_dim_fast() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_cache
+ H5O_sdspace_cache
PURPOSE
Copies a simple dimensionality message into the cache portion of a symbol
- table entry.
+ table entry.
USAGE
- hbool_t H5O_sim_dim_cache(ent, mesg)
- const H5G_entry_t *ent; IN: Pointer to the symbol table entry
- const void *mesg; IN: Pointer to the simple dimensionality struct
+ hbool_t H5O_sdspace_cache(ent, mesg)
+ const H5G_entry_t *ent; IN: Pointer to the symbol table entry
+ const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
BTRUE if symbol-table modified, BFALSE if not modified, BFAIL on failure.
The new cache type is returned through the CACHE_TYPE argument.
DESCRIPTION
- This function is the opposite of the H5O_sim_dim_fast method, it
+ This function is the opposite of the H5O_sdspace_fast method, it
copies a message into the cached portion of a symbol-table entry. (This
method is required for simple dimensionalities, as they can be cached in
the symbol-table entry)
--------------------------------------------------------------------------*/
static hbool_t
-H5O_sim_dim_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
+H5O_sdspace_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
const void *mesg)
{
- const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg;
- uintn u; /* Local counting variable */
+ const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
+ uintn u; /* Local counting variable */
hbool_t modified = BFALSE;
- FUNC_ENTER (H5O_sim_dim_cache, NULL, BFAIL);
+ FUNC_ENTER (H5O_sdspace_cache, BFAIL);
/* check args */
assert (cache_type);
assert (cache);
assert (sdim);
- if (sdim->rank <= NELMTS (cache->sdata.dim)) {
- if (H5G_CACHED_SDATA != *cache_type) {
+ if (sdim->rank <= NELMTS (cache->sdspace.dim)) {
+ if (H5G_CACHED_SDSPACE != *cache_type) {
modified = BTRUE;
- *cache_type = H5G_CACHED_SDATA;
- cache->sdata.ndim = sdim->rank;
+ *cache_type = H5G_CACHED_SDSPACE;
+ cache->sdspace.ndim = sdim->rank;
for (u=0; u<=sdim->rank; u++) {
- cache->sdata.dim[u] = sdim->size[u];
+ cache->sdspace.dim[u] = sdim->size[u];
}
} else {
- if(cache->sdata.ndim != sdim->rank) {
+ if(cache->sdspace.ndim != sdim->rank) {
modified = BTRUE;
- cache->sdata.ndim = sdim->rank;
- }
+ cache->sdspace.ndim = sdim->rank;
+ }
/* Check each dimension */
- if (NULL==cache->sdata.dim) {
+ if (NULL==cache->sdspace.dim) {
modified = BTRUE;
} else {
for (u=0; u<sdim->rank; u++) {
- if (cache->sdata.dim[u] != sdim->size[u]) {
- modified = BTRUE;
- cache->sdata.dim[u] = sdim->size[u];
+ if (cache->sdspace.dim[u] != sdim->size[u]) {
+ modified = BTRUE;
+ cache->sdspace.dim[u] = sdim->size[u];
}
}
- }
+ }
}
- } else if (H5G_CACHED_SDATA == *cache_type) {
+ } else if (H5G_CACHED_SDSPACE == *cache_type) {
/*
- * Number of dimensions is too large to cache.
- */
+ * Number of dimensions is too large to cache.
+ */
modified = TRUE;
*cache_type = H5G_NOTHING_CACHED;
}
FUNC_LEAVE (modified);
-} /* end H5O_sim_dim_cache() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_copy
+ H5O_sdspace_copy
PURPOSE
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
- void *H5O_sim_dim_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source simple dimensionality struct
- const void *dest; IN: Pointer to the destination simple dimensionality struct
+ void *H5O_sdspace_copy(mesg, dest)
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
+ const void *dest; IN: Pointer to the destination simple dimensionality struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
- This function copies a native (memory) simple dimensionality message,
+ This function copies a native (memory) simple dimensionality message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
-H5O_sim_dim_copy (const void *mesg, void *dest)
+H5O_sdspace_copy (const void *mesg, void *dest)
{
- const H5O_sim_dim_t *src = (const H5O_sim_dim_t *)mesg;
- H5O_sim_dim_t *dst = (H5O_sim_dim_t *)dest;
+ const H5P_simple_t *src = (const H5P_simple_t *)mesg;
+ H5P_simple_t *dst = (H5P_simple_t *)dest;
- FUNC_ENTER (H5O_sim_dim_copy, NULL, NULL);
+ FUNC_ENTER (H5O_sdspace_copy, NULL);
/* check args */
assert (src);
if (!dst)
- dst = H5MM_xcalloc (1, sizeof(H5O_sim_dim_t));
+ dst = H5MM_xcalloc (1, sizeof(H5P_simple_t));
/* deep copy -- pointed-to values are copied also */
- HDmemcpy(dst,src,sizeof(H5O_sim_dim_t));
+ HDmemcpy(dst,src,sizeof(H5P_simple_t));
if (src->size) dst->size = H5MM_xcalloc (src->rank, sizeof(uint32));
if (src->max) dst->max = H5MM_xcalloc (src->rank, sizeof(uint32));
if (src->perm) dst->perm = H5MM_xcalloc (src->rank, sizeof(uint32));
@@ -341,76 +329,76 @@ H5O_sim_dim_copy (const void *mesg, void *dest)
HDmemcpy(dst->size,src->size,src->rank*sizeof(uint32));
/* Check for maximum dimensions and copy those */
if((src->dim_flags&0x01)>0)
- {
- HDmemcpy(dst->max,src->max,src->rank*sizeof(uint32));
- } /* end if */
+ {
+ HDmemcpy(dst->max,src->max,src->rank*sizeof(uint32));
+ } /* end if */
/* Check for dimension permutation and copy those */
if((src->dim_flags&0x02)>0)
- {
- HDmemcpy(dst->perm,src->perm,src->rank*sizeof(uint32));
- } /* end if */
+ {
+ HDmemcpy(dst->perm,src->perm,src->rank*sizeof(uint32));
+ } /* end if */
} /* end if */
FUNC_LEAVE ((void*)dst);
-} /* end H5O_sim_dim_copy() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_size
+ H5O_sdspace_size
PURPOSE
Return the raw message size in bytes
USAGE
- void *H5O_sim_dim_copy(f, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple dimensionality struct
+ void *H5O_sdspace_copy(f, mesg)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
RETURNS
Size of message on success, FAIL on failure
DESCRIPTION
- This function returns the size of the raw simple dimensionality message on
+ This function returns the size of the raw simple dimensionality message on
success. (Not counting the message type or size fields, only the data
portion of the message). It doesn't take into account alignment.
--------------------------------------------------------------------------*/
static size_t
-H5O_sim_dim_size (H5F_t *f, const void *mesg)
+H5O_sdspace_size (H5F_t *f, const void *mesg)
{
- const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg;
- size_t ret_value=8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */
+ const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
+ size_t ret_value=8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */
- FUNC_ENTER (H5O_sim_dtype_size, NULL, FAIL);
+ FUNC_ENTER (H5O_sim_dtype_size, FAIL);
ret_value+=sdim->rank*4; /* add in the dimension sizes */
- ret_value+=((sdim->dim_flags&0x01)>0)*sdim->rank*4; /* add in the space for the maximum dimensions, if they are present */
- ret_value+=((sdim->dim_flags&0x02)>0)*sdim->rank*4; /* add in the space for the dimension permutations, if they are present */
+ ret_value+=((sdim->dim_flags&0x01)>0)*sdim->rank*4; /* add in the space for the maximum dimensions, if they are present */
+ ret_value+=((sdim->dim_flags&0x02)>0)*sdim->rank*4; /* add in the space for the dimension permutations, if they are present */
FUNC_LEAVE (ret_value);
-} /* end H5O_sim_dim_size() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dim_debug
+ H5O_sdspace_debug
PURPOSE
Prints debugging information for a simple dimensionality message
USAGE
- void *H5O_sim_dim_debug(f, mesg, stream, indent, fwidth)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple dimensionality struct
- FILE *stream; IN: Pointer to the stream for output data
- intn indent; IN: Amount to indent information by
- intn fwidth; IN: Field width (?)
+ void *H5O_sdspace_debug(f, mesg, stream, indent, fwidth)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
+ FILE *stream; IN: Pointer to the stream for output data
+ intn indent; IN: Amount to indent information by
+ intn fwidth; IN: Field width (?)
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function prints debugging output to the stream passed as a
+ This function prints debugging output to the stream passed as a
parameter.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sim_dim_debug (H5F_t *f, const void *mesg, FILE *stream,
+H5O_sdspace_debug (H5F_t *f, const void *mesg, FILE *stream,
intn indent, intn fwidth)
{
- const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg;
- uintn u; /* local counting variable */
+ const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
+ uintn u; /* local counting variable */
- FUNC_ENTER (H5O_sim_dim_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_sdspace_debug, FAIL);
/* check args */
assert (f);
@@ -427,19 +415,19 @@ H5O_sim_dim_debug (H5F_t *f, const void *mesg, FILE *stream,
(unsigned long)(sdim->dim_flags));
for(u=0; u<sdim->rank; u++)
fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Size:",
- (unsigned long)(sdim->size[u]));
+ "Dim Size:",
+ (unsigned long)(sdim->size[u]));
if(sdim->dim_flags&0x01)
- for(u=0; u<sdim->rank; u++)
- fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Max:",
- (unsigned long)(sdim->max[u]));
+ for(u=0; u<sdim->rank; u++)
+ fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
+ "Dim Max:",
+ (unsigned long)(sdim->max[u]));
if(sdim->dim_flags&0x02)
- for(u=0; u<sdim->rank; u++)
- fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Perm:",
- (unsigned long)(sdim->perm[u]));
+ for(u=0; u<sdim->rank; u++)
+ fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
+ "Dim Perm:",
+ (unsigned long)(sdim->perm[u]));
FUNC_LEAVE (SUCCEED);
-} /* end H5O_sim_dim_debug() */
+}
diff --git a/src/H5Osdtyp.c b/src/H5Osdtyp.c
index 0800e30..edc4c82 100644
--- a/src/H5Osdtyp.c
+++ b/src/H5Osdtyp.c
@@ -16,67 +16,387 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-/*LINTLIBRARY */
-/*+
- FILE
- H5Osdtyp.c
- HDF5 Simple Datatype Object Header Message routines
-
- EXPORTED ROUTINES
-
- LIBRARY-SCOPED ROUTINES
-
- LOCAL ROUTINES
- + */
+#define H5T_PACKAGE /*prevent warning from including H5Tpkg.h */
#include <H5private.h>
#include <H5Eprivate.h>
#include <H5Gprivate.h>
#include <H5MMprivate.h>
#include <H5Oprivate.h>
+#include <H5Tpkg.h>
-#define PABLO_MASK H5O_sim_dtype_mask
+#define PABLO_MASK H5O_dtype_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_sim_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_sim_dtype_encode (H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
-static void *H5O_sim_dtype_fast (const H5G_cache_t *cache, void *_mesg);
-static hbool_t H5O_sim_dtype_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
- const void *_mesg);
-static void *H5O_sim_dtype_copy (const void *_mesg, void *_dest);
-static size_t H5O_sim_dtype_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_sim_dtype_debug (H5F_t *f, const void *_mesg,
- FILE *stream, intn indent, intn fwidth);
+static herr_t H5O_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p,
+ const void *mesg);
+static void *H5O_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p);
+static void *H5O_dtype_copy (const void *_mesg, void *_dest);
+static size_t H5O_dtype_size (H5F_t *f, const void *_mesg);
+static herr_t H5O_dtype_reset (void *_mesg);
+static herr_t H5O_dtype_debug (H5F_t *f, const void *_mesg,
+ FILE *stream, intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_SIM_DTYPE[1] = {{
- H5O_SIM_DTYPE_ID, /* message id number */
- "sim_dtype", /* message name for debugging */
- sizeof (H5O_sim_dtype_t), /* native message size */
- H5G_CACHED_SDATA, /* symtab entry `type' field */
- H5O_sim_dtype_decode, /* decode message */
- H5O_sim_dtype_encode, /* encode message */
- H5O_sim_dtype_fast, /* get message from stab entry */
- H5O_sim_dtype_cache, /* put message into stab entry */
- H5O_sim_dtype_copy, /* copy the native value */
- H5O_sim_dtype_size, /* size of symbol table entry */
- NULL, /* default reset method */
- H5O_sim_dtype_debug, /* debug the message */
+const H5O_class_t H5O_DTYPE[1] = {{
+ H5O_DTYPE_ID, /* message id number */
+ "data_type", /* message name for debugging */
+ sizeof (H5T_t), /* native message size */
+ H5G_NOTHING_CACHED, /* symtab entry `type' field */
+ H5O_dtype_decode, /* decode message */
+ H5O_dtype_encode, /* encode message */
+ NULL, /* get message from stab entry */
+ NULL, /* put message into stab entry */
+ H5O_dtype_copy, /* copy the native value */
+ H5O_dtype_size, /* size of raw message */
+ H5O_dtype_reset, /* reset method */
+ H5O_dtype_debug, /* debug the message */
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dtype_decode_helper
+ *
+ * Purpose: Decodes a data type
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_dtype_decode_helper (const uint8 **pp, H5T_t *dt)
+{
+ uintn flags, perm_word;
+ intn i, j;
+
+ FUNC_ENTER (H5O_dtype_decode_helper, FAIL);
+
+ /* check args */
+ assert (pp && *pp);
+ assert (dt);
+
+ /* decode */
+ UINT32DECODE (*pp, flags);
+ dt->type = flags & 0xff;
+ flags >>= 8;
+ UINT32DECODE (*pp, dt->size);
+
+ switch (dt->type) {
+ case H5T_FIXED:
+ /*
+ * Fixed-point types...
+ */
+ dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
+ dt->u.atomic.lo_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.hi_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE;
+ UINT16DECODE (*pp, dt->u.atomic.offset);
+ UINT16DECODE (*pp, dt->u.atomic.prec);
+ break;
+
+ case H5T_FLOAT:
+ /*
+ * Floating-point types...
+ */
+ dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
+ dt->u.atomic.lo_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.hi_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ switch ((flags>>4) & 0x03) {
+ case 0:
+ dt->u.atomic.u.f.norm = H5T_NORM_NONE;
+ break;
+ case 1:
+ dt->u.atomic.u.f.norm = H5T_NORM_MSBSET;
+ break;
+ case 2:
+ dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED;
+ break;
+ default:
+ /* unknown floating-point normalization */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+ dt->u.atomic.u.f.sign = (flags>>8) & 0xff;
+ UINT16DECODE (*pp, dt->u.atomic.offset);
+ UINT16DECODE (*pp, dt->u.atomic.prec);
+ dt->u.atomic.u.f.epos = *(*pp)++;
+ dt->u.atomic.u.f.esize = *(*pp)++;
+ assert (dt->u.atomic.u.f.esize>0);
+ dt->u.atomic.u.f.mpos = *(*pp)++;
+ dt->u.atomic.u.f.msize = *(*pp)++;
+ assert (dt->u.atomic.u.f.msize>0);
+ UINT32DECODE (*pp, dt->u.atomic.u.f.ebias);
+ break;
+
+ case H5T_COMPOUND:
+ /*
+ * Compound data types...
+ */
+ dt->u.compnd.nmembs = flags & 0xffff;
+ assert (dt->u.compnd.nmembs>0);
+ dt->u.compnd.nalloc = dt->u.compnd.nmembs;
+ dt->u.compnd.memb = H5MM_xcalloc (dt->u.compnd.nalloc,
+ sizeof(H5T_member_t));
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ dt->u.compnd.memb[i].name = H5MM_xstrdup (*pp);
+ *pp += ((strlen (*pp)+8)/8) * 8; /*multiple of 8 w/ null terminator*/
+ UINT32DECODE (*pp, dt->u.compnd.memb[i].offset);
+ dt->u.compnd.memb[i].ndims = *(*pp)++;
+ assert (dt->u.compnd.memb[i].ndims<=4);
+ *pp += 3; /*reserved bytes*/
+ for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
+ UINT32DECODE (*pp, dt->u.compnd.memb[i].dim[j]);
+ }
+ UINT32DECODE (*pp, perm_word);
+ dt->u.compnd.memb[i].perm[0] = (perm_word >> 0) & 0xff;
+ dt->u.compnd.memb[i].perm[1] = (perm_word >> 8) & 0xff;
+ dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff;
+ dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff;
+ if (H5O_dtype_decode_helper (pp, &(dt->u.compnd.memb[i].type))<0 ||
+ H5T_COMPOUND==dt->u.compnd.memb[i].type.type) {
+ for (j=0; j<=i; j++) H5MM_xfree (dt->u.compnd.memb[i].name);
+ H5MM_xfree (dt->u.compnd.memb);
+ /* Can't decode member type */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTDECODE, FAIL);
+ }
+ }
+ break;
+
+ default:
+ if (flags) {
+ /* class flags are non-zero */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+ break;
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dtype_encode_helper
+ *
+ * Purpose: Encodes a data type.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_dtype_encode_helper (uint8 **pp, const H5T_t *dt)
+{
+ uintn flags = 0;
+ uintn perm_word;
+ char *hdr = *pp;
+ intn i, j, n;
+
+ FUNC_ENTER (H5O_dtype_encode_helper, FAIL);
+
+ /* check args */
+ assert (pp && *pp);
+ assert (dt);
+
+ /* skip the type and class bit field for now */
+ *pp += 4;
+ UINT32ENCODE (*pp, dt->size);
+
+ switch (dt->type) {
+ case H5T_FIXED:
+ /*
+ * Fixed-point data types...
+ */
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_LE:
+ break; /*nothing*/
+ case H5T_ORDER_BE:
+ flags |= 0x01;
+ break;
+ default:
+ /* Byte order is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.lo_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing*/
+ case H5T_PAD_ONE:
+ flags |= 0x02;
+ break;
+ default:
+ /* Bit padding is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.hi_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing*/
+ case H5T_PAD_ONE:
+ flags |= 0x04;
+ break;
+ default:
+ /* Bit padding is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.u.i.sign) {
+ case H5T_SGN_NONE:
+ break; /*nothing*/
+ case H5T_SGN_2:
+ flags |= 0x08;
+ break;
+ default:
+ /* Sign scheme is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ UINT16ENCODE (*pp, dt->u.atomic.offset);
+ UINT16ENCODE (*pp, dt->u.atomic.prec);
+ break;
+
+ case H5T_FLOAT:
+ /*
+ * Floating-point types...
+ */
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_LE:
+ break; /*nothing*/
+ case H5T_ORDER_BE:
+ flags |= 0x01;
+ break;
+ default:
+ /* Byte order is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.lo_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing*/
+ case H5T_PAD_ONE:
+ flags |= 0x02;
+ break;
+ default:
+ /* Bit padding is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.hi_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing*/
+ case H5T_PAD_ONE:
+ flags |= 0x04;
+ break;
+ default:
+ /* Bit padding is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.u.f.pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing*/
+ case H5T_PAD_ONE:
+ flags |= 0x08;
+ break;
+ default:
+ /* Bit padding is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ switch (dt->u.atomic.u.f.norm) {
+ case H5T_NORM_NONE:
+ break; /*nothing*/
+ case H5T_NORM_MSBSET:
+ flags |= 0x10;
+ break;
+ case H5T_NORM_IMPLIED:
+ flags |= 0x20;
+ break;
+ default:
+ /* Normalization scheme is not supported in file format yet */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL);
+ }
+
+ flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00;
+ UINT16ENCODE (*pp, dt->u.atomic.offset);
+ UINT16ENCODE (*pp, dt->u.atomic.prec);
+ *(*pp)++ = dt->u.atomic.u.f.epos;
+ *(*pp)++ = dt->u.atomic.u.f.esize;
+ *(*pp)++ = dt->u.atomic.u.f.mpos;
+ *(*pp)++ = dt->u.atomic.u.f.msize;
+ UINT32ENCODE (*pp, dt->u.atomic.u.f.ebias);
+ break;
+
+ case H5T_COMPOUND:
+ /*
+ * Compound data types...
+ */
+ flags = dt->u.compnd.nmembs & 0xffff;
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ n = strlen (dt->u.compnd.memb[i].name);
+ for (j=0; j<=n && j%8; j++) {
+ if (j<n) *(*pp)++ = dt->u.compnd.memb[i].name[j];
+ else *(*pp)++ = '\0';
+ }
+ UINT32ENCODE (*pp, dt->u.compnd.memb[i].offset);
+ *(*pp)++ = dt->u.compnd.memb[i].ndims;
+ assert (dt->u.compnd.memb[i].ndims<=4);
+ *(*pp)++ = '\0';
+ *(*pp)++ = '\0';
+ *(*pp)++ = '\0';
+ for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
+ UINT32ENCODE (*pp, dt->u.compnd.memb[i].dim[j]);
+ }
+ for (j=0, perm_word=0; j<dt->u.compnd.memb[i].ndims; j++) {
+ perm_word |= dt->u.compnd.memb[i].perm[j] << (8*j);
+ }
+ UINT32ENCODE (*pp, perm_word);
+ if (H5O_dtype_encode_helper (pp, &(dt->u.compnd.memb[i].type))<0) {
+ /* Can't encode member type */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTENCODE, FAIL);
+ }
+ }
+ break;
+
+ default:
+ /*nothing*/
+ break;
+ }
+
+ *hdr++ = dt->type;
+ *hdr++ = (flags >> 0) & 0xff;
+ *hdr++ = (flags >> 8) & 0xff;
+ *hdr++ = (flags >> 16) & 0xff;
+
+ FUNC_LEAVE (SUCCEED);
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dtype_decode
+ H5O_dtype_decode
PURPOSE
- Decode a simple datatype message and return a pointer to a memory struct
+ Decode a datatype message and return a pointer to a memory struct
with the decoded information
USAGE
- void *H5O_sim_dtype_decode(f, raw_size, p)
- H5F_t *f; IN: pointer to the HDF5 file struct
+ void *H5O_dtype_decode(f, raw_size, p)
+ H5F_t *f; IN: pointer to the HDF5 file struct
size_t raw_size; IN: size of the raw information buffer
const uint8 *p; IN: the raw information buffer
RETURNS
@@ -87,36 +407,36 @@ static hbool_t interface_initialize_g = FALSE;
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
-H5O_sim_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+H5O_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_sim_dtype_t *sdtype;
+ H5T_t *dt = NULL;
- FUNC_ENTER (H5O_sim_dtype_decode, NULL, NULL);
+ FUNC_ENTER (H5O_dtype_decode, NULL);
- /* check args */
- assert (f);
- assert (raw_size == 4);
- assert (p);
+ /* check args */
+ assert (f);
+ assert (raw_size>0);
+ assert (p);
- /* decode */
- if((sdtype = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t)))!=NULL)
- {
- sdtype->len=*p++;
- sdtype->arch=*p++;
- UINT16DECODE(p,sdtype->base);
- sdtype->base=MAKE_ATOM(H5_DATATYPE,sdtype->base); /* convert into atomic base type */
- } /* end if */
+ dt = H5MM_xcalloc (1, sizeof(H5T_t));
- FUNC_LEAVE (sdtype);
-} /* end H5O_sim_dtype_decode() */
+ if (H5O_dtype_decode_helper (&p, dt)<0) {
+ H5MM_xfree (dt);
+ /* can't decode type */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTDECODE, NULL);
+ }
+ assert (raw_size==H5O_dtype_size (f, (void*)dt));
+
+ FUNC_LEAVE (dt);
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dtype_encode
+ H5O_dtype_encode
PURPOSE
Encode a simple datatype message
USAGE
- herr_t H5O_sim_dtype_encode(f, raw_size, p, mesg)
+ herr_t H5O_dtype_encode(f, raw_size, p, mesg)
H5F_t *f; IN: pointer to the HDF5 file struct
size_t raw_size; IN: size of the raw information buffer
const uint8 *p; IN: the raw information buffer
@@ -128,139 +448,38 @@ H5O_sim_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p)
message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sim_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
{
- const H5O_sim_dtype_t *sdtype = (const H5O_sim_dtype_t *)mesg;
-
- FUNC_ENTER (H5O_sim_dtype_encode, NULL, FAIL);
-
- /* check args */
- assert (f);
- assert (raw_size == 4);
- assert (p);
- assert (sdtype);
-
- /* encode */
- *p++=sdtype->len;
- *p++=sdtype->arch;
- UINT16ENCODE(p,sdtype->base);
+ const H5T_t *dt = (const H5T_t *)mesg;
- FUNC_LEAVE (SUCCEED);
-} /* end H5O_sim_dtype_encode() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5O_sim_dtype_fast
- PURPOSE
- Initializes a new simple datatype struct with info from a symbol table
- entry.
- USAGE
- void *H5O_sim_dtype_fast(ent, mesg)
- const H5G_entry_t *ent; IN: pointer to the symbol table entry
- const void *mesg; IN: Pointer to the simple datatype struct
- RETURNS
- Pointer to the message structure (allocated if none is supplied) on success,
- NULL on failure
- DESCRIPTION
- This function fills the native memory form of the simple datatype
- message from a symbol-table entry cache fields. (This method is required
- for simple datatypes, as they can be cached in the symbol-table entry)
---------------------------------------------------------------------------*/
-static void *
-H5O_sim_dtype_fast (const H5G_cache_t *cache, void *mesg)
-{
- H5O_sim_dtype_t *sdtype = (H5O_sim_dtype_t *)mesg;
-
- FUNC_ENTER (H5O_sim_dtype_fast, NULL, NULL);
+ FUNC_ENTER (H5O_dtype_encode, FAIL);
/* check args */
- assert (cache);
-
- if (!sdtype) sdtype = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t));
- sdtype->len = cache->sdata.nt.length;
- sdtype->arch = cache->sdata.nt.arch;
-
- /* Convert into atomic base type. */
- sdtype->base = MAKE_ATOM (H5_DATATYPE, cache->sdata.nt.type);
+ assert (f);
+ assert (raw_size==H5O_dtype_size (f, mesg));
+ assert (p);
+ assert (dt);
- FUNC_LEAVE (sdtype);
-} /* end H5O_sim_dtype_fast() */
+ /* encode */
+ if (H5O_dtype_encode_helper (&p, dt)<0) {
+ /* can't encode type */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTENCODE, FAIL);
+ }
-/*--------------------------------------------------------------------------
- NAME
- H5O_sim_dtype_cache
- PURPOSE
- Copies a simple datatype message into the cache portion of a symbol table
- entry.
- USAGE
- hbool_t H5O_sim_dtype_cache(ent, mesg)
- const H5G_entry_t *ent; IN: Pointer to the symbol table entry
- const void *mesg; IN: Pointer to the simple datatype struct
- RETURNS
- BTRUE if symbol-table modified, BFALSE if not modified, BFAIL on failure.
- The new cache type is returned through the CACHE_TYPE argument.
- DESCRIPTION
- This function is the opposite of the H5O_sim_dtype_fast method, it
- copies a message into the cached portion of a symbol-table entry. (This
- method is required for simple datatypes, as they can be cached in the
- symbol-table entry)
---------------------------------------------------------------------------*/
-static hbool_t
-H5O_sim_dtype_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
- const void *mesg)
-{
- const H5O_sim_dtype_t *sdtype = (const H5O_sim_dtype_t *)mesg;
- hbool_t modified = BFALSE;
-
- FUNC_ENTER (H5O_sim_dtype_cache, NULL, BFAIL);
-
- /* check args */
- assert (cache_type);
- assert (cache);
- assert (sdtype);
-
- if (H5G_CACHED_SDATA != *cache_type) {
- /*
- * No sdata cached yet.
- */
- modified = BTRUE;
- *cache_type = H5G_CACHED_SDATA;
- cache->sdata.nt.length = sdtype->len;
- cache->sdata.nt.arch = sdtype->arch;
- cache->sdata.nt.type = sdtype->base;
-
- } else {
- /*
- * Some sdata already cached.
- */
- if (cache->sdata.nt.length != sdtype->len) {
- modified = BTRUE;
- cache->sdata.nt.length = sdtype->len;
- }
-
- if (cache->sdata.nt.arch != sdtype->arch) {
- modified = BTRUE;
- cache->sdata.nt.arch = sdtype->arch;
- }
-
- if (cache->sdata.nt.type != (uint16)sdtype->base) {
- modified = BTRUE;
- cache->sdata.nt.type = (uint16)sdtype->base;
- }
- }
-
- FUNC_LEAVE (modified);
-} /* end H5O_sim_dtype_cache() */
+ FUNC_LEAVE (SUCCEED);
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dtype_copy
+ H5O_dtype_copy
PURPOSE
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
- void *H5O_sim_dtype_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source simple datatype struct
- const void *dest; IN: Pointer to the destination simple datatype struct
+ void *H5O_dtype_copy(mesg, dest)
+ const void *mesg; IN: Pointer to the source simple datatype
+ struct
+ const void *dest; IN: Pointer to the destination simple
+ datatype struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
@@ -268,32 +487,40 @@ H5O_sim_dtype_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
-H5O_sim_dtype_copy (const void *mesg, void *dest)
+H5O_dtype_copy (const void *_src, void *_dst)
{
- const H5O_sim_dtype_t *src = (const H5O_sim_dtype_t *)mesg;
- H5O_sim_dtype_t *dst = (H5O_sim_dtype_t *)dest;
+ const H5T_t *src = (const H5T_t *)_src;
+ H5T_t *dst = NULL;
- FUNC_ENTER (H5O_sim_dtype_copy, NULL, NULL);
+ FUNC_ENTER (H5O_dtype_copy, NULL);
/* check args */
assert (src);
- if (!dst) dst = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t));
/* copy */
- HDmemcpy(dst,src,sizeof(H5O_sim_dtype_t));
+ if (NULL==(dst=H5T_copy (src))) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL); /*can't copy type*/
+ }
+
+ /* was result already allocated? */
+ if (_dst) {
+ *((H5T_t*)_dst) = *dst;
+ H5MM_xfree (dst);
+ dst = (H5T_t*)_dst;
+ }
FUNC_LEAVE ((void*)dst);
-} /* end H5O_sim_dtype_copy() */
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dtype_size
+ H5O_dtype_size
PURPOSE
Return the raw message size in bytes
USAGE
- void *H5O_sim_dtype_copy(f, mesg)
+ void *H5O_dtype_size(f, mesg)
H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple datatype struct
+ const void *mesg; IN: Pointer to the source simple datatype struct
RETURNS
Size of message on success, FAIL on failure
DESCRIPTION
@@ -302,21 +529,88 @@ H5O_sim_dtype_copy (const void *mesg, void *dest)
portion of the message). It doesn't take into account alignment.
--------------------------------------------------------------------------*/
static size_t
-H5O_sim_dtype_size (H5F_t *f, const void *mesg)
+H5O_dtype_size (H5F_t *f, const void *mesg)
{
- FUNC_ENTER (H5O_sim_dtype_size, NULL, FAIL);
- FUNC_LEAVE (4);
-} /* end H5O_sim_dtype_size() */
+ intn i;
+ size_t ret_value = 8;
+ const H5T_t *dt = (const H5T_t *)mesg;
+
+ FUNC_ENTER (H5O_dtype_size, FAIL);
+
+ assert (mesg);
+
+ switch (dt->type) {
+ case H5T_FIXED:
+ ret_value += 4;
+ break;
+
+ case H5T_FLOAT:
+ ret_value += 12;
+ break;
+
+ case H5T_COMPOUND:
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ ret_value += ((HDstrlen (dt->u.compnd.memb[i].name)+8)/8)*8;
+ ret_value += 12 + dt->u.compnd.memb[i].ndims * 4;
+ ret_value += H5O_dtype_size (f, &(dt->u.compnd.memb[i].type));
+ }
+ break;
+
+ default:
+ /*no properties*/
+ break;
+ }
+
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dtype_reset
+ *
+ * Purpose: Frees resources within a data type message, but doesn't free
+ * the message itself.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_dtype_reset (void *_mesg)
+{
+ H5T_t *dt = (H5T_t *)_mesg;
+ H5T_t *tmp = NULL;
+
+ FUNC_ENTER (H5O_dtype_reset, FAIL);
+
+ if (dt) {
+ tmp = H5MM_xmalloc (sizeof(H5T_t));
+ *tmp = *dt;
+ H5T_close (tmp);
+ HDmemset (dt, 0, sizeof(H5T_t));
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
/*--------------------------------------------------------------------------
NAME
- H5O_sim_dtype_debug
+ H5O_dtype_debug
PURPOSE
- Prints debugging information for a simple datatype message
+ Prints debugging information for a data type message
USAGE
- void *H5O_sim_dtype_debug(f, mesg, stream, indent, fwidth)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple datatype struct
+ void *H5O_dtype_debug(f, mesg, stream, indent, fwidth)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple datatype
+ struct
FILE *stream; IN: Pointer to the stream for output data
intn indent; IN: Amount to indent information by
intn fwidth; IN: Field width (?)
@@ -327,30 +621,243 @@ H5O_sim_dtype_size (H5F_t *f, const void *mesg)
parameter.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sim_dtype_debug (H5F_t *f, const void *mesg, FILE *stream,
+H5O_dtype_debug (H5F_t *f, const void *mesg, FILE *stream,
intn indent, intn fwidth)
{
- const H5O_sim_dtype_t *sdtype = (const H5O_sim_dtype_t *)mesg;
+ const H5T_t *dt = (const H5T_t *)mesg;
+ const char *s;
+ char buf[256];
+ intn i, j;
- FUNC_ENTER (H5O_sim_dtype_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_dtype_debug, FAIL);
/* check args */
assert (f);
- assert (sdtype);
+ assert (dt);
assert (stream);
assert (indent>=0);
assert (fwidth>=0);
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Length:",
- (unsigned long)(sdtype->len));
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Architecture:",
- (unsigned long)(sdtype->arch));
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Data-Type:",
- (unsigned long)((uint16)sdtype->base));
+ switch (dt->type) {
+ case H5T_FIXED:
+ s = "fixed-point";
+ break;
+ case H5T_FLOAT:
+ s = "floating-point";
+ break;
+ case H5T_DATE:
+ s = "date and time";
+ break;
+ case H5T_STRING:
+ s = "text string";
+ break;
+ case H5T_BITFIELD:
+ s = "bit field";
+ break;
+ case H5T_OPAQUE:
+ s = "opaque";
+ break;
+ case H5T_COMPOUND:
+ s = "compound";
+ break;
+ default:
+ sprintf (buf, "H5T_CLASS_%d", (int)(dt->type));
+ s = buf;
+ break;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type class:",
+ s);
+
+ fprintf (stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth,
+ "Size:",
+ (unsigned long)(dt->size), 1==dt->size?"":"s");
+
+ if (H5T_COMPOUND==dt->type) {
+ fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Number of members:",
+ dt->u.compnd.nmembs);
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ sprintf (buf, "Member %d:", i);
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ buf,
+ dt->u.compnd.memb[i].name);
+ fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (0, fwidth-3),
+ "Byte offset:",
+ (unsigned long)(dt->u.compnd.memb[i].offset));
+ fprintf (stream, "%*s%-*s %d%s\n", indent+3, "", MAX (0, fwidth-3),
+ "Dimensionality:",
+ dt->u.compnd.memb[i].ndims,
+ 0==dt->u.compnd.memb[i].ndims?" (scalar)":"");
+ if (dt->u.compnd.memb[i].ndims>0) {
+ fprintf (stream, "%*s%-*s {", indent+3, "", MAX (0, fwidth-3),
+ "Size:");
+ for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
+ fprintf (stream, "%s%lu", j?", ":"",
+ (unsigned long)(dt->u.compnd.memb[i].dim[j]));
+ }
+ fprintf (stream, "}\n");
+ fprintf (stream, "%*s%-*s {", indent+3, "", MAX (0, fwidth-3),
+ "Permutation:");
+ for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
+ fprintf (stream, "%s%lu", j?", ":"",
+ (unsigned long)(dt->u.compnd.memb[i].perm[j]));
+ }
+ fprintf (stream, "}\n");
+ }
+ H5O_dtype_debug (f, &(dt->u.compnd.memb[i].type), stream,
+ indent+3, MAX (0, fwidth-3));
+ }
+ } else {
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_LE:
+ s = "little endian";
+ break;
+ case H5T_ORDER_BE:
+ s = "big endian";
+ break;
+ case H5T_ORDER_VAX:
+ s = "VAX";
+ break;
+ case H5T_ORDER_NONE:
+ s = "none";
+ break;
+ default:
+ sprintf (buf, "H5T_ORDER_%d", dt->u.atomic.order);
+ s = buf;
+ break;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Byte order:",
+ s);
+
+ fprintf (stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
+ "Precision:",
+ (unsigned long)(dt->u.atomic.prec),
+ 1==dt->u.atomic.prec?"":"s");
+
+ fprintf (stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
+ "Offset:",
+ (unsigned long)(dt->u.atomic.offset),
+ 1==dt->u.atomic.offset?"":"s");
+
+ switch (dt->u.atomic.lo_pad) {
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ if (dt->u.atomic.lo_pad<0) {
+ sprintf (buf, "H5T_PAD_%d", -(dt->u.atomic.lo_pad));
+ } else {
+ sprintf (buf, "bit-%d", dt->u.atomic.lo_pad);
+ }
+ s = buf;
+ break;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Low pad type:", s);
+
+ switch (dt->u.atomic.hi_pad) {
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ if (dt->u.atomic.hi_pad<0) {
+ sprintf (buf, "H5T_PAD_%d", -(dt->u.atomic.hi_pad));
+ } else {
+ sprintf (buf, "bit-%d", dt->u.atomic.hi_pad);
+ }
+ s = buf;
+ break;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "High pad type:", s);
+
+ if (H5T_FLOAT==dt->type) {
+ switch (dt->u.atomic.u.f.pad) {
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ if (dt->u.atomic.u.f.pad<0) {
+ sprintf (buf, "H5T_PAD_%d", -(dt->u.atomic.u.f.pad));
+ } else {
+ sprintf (buf, "bit-%d", dt->u.atomic.u.f.pad);
+ }
+ s = buf;
+ break;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Internal pad type:", s);
+
+ switch (dt->u.atomic.u.f.norm) {
+ case H5T_NORM_IMPLIED:
+ s = "implied";
+ break;
+ case H5T_NORM_MSBSET:
+ s = "msb set";
+ break;
+ case H5T_NORM_NONE:
+ s = "none";
+ break;
+ default:
+ sprintf (buf, "H5T_NORM_%d", (int)(dt->u.atomic.u.f.norm));
+ s = buf;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Normalization:", s);
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Sign bit location:",
+ (unsigned long)(dt->u.atomic.u.f.sign));
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Exponent location:",
+ (unsigned long)(dt->u.atomic.u.f.epos));
+
+ fprintf (stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
+ "Exponent bias:",
+ (unsigned long)(dt->u.atomic.u.f.ebias));
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Exponent size:",
+ (unsigned long)(dt->u.atomic.u.f.esize));
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Mantissa location:",
+ (unsigned long)(dt->u.atomic.u.f.mpos));
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Mantissa size:",
+ (unsigned long)(dt->u.atomic.u.f.msize));
+
+ } else if (H5T_FIXED==dt->type) {
+ switch (dt->u.atomic.u.i.sign) {
+ case H5T_SGN_NONE:
+ s = "none";
+ break;
+ case H5T_SGN_2:
+ s = "2's comp";
+ break;
+ default:
+ sprintf (buf, "H5T_SGN_%d", (int)(dt->u.atomic.u.i.sign));
+ s = buf;
+ break;
+ }
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Sign scheme:", s);
+
+ }
+ }
FUNC_LEAVE (SUCCEED);
-} /* end H5O_sim_dtype_debug() */
-
+}
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index c02885a..db5ccdd 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -50,8 +50,9 @@ const H5O_class_t H5O_STAB[1] = {{
H5O_stab_debug, /*debug the message */
}};
-/* Is the interface initialized? */
+/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -77,11 +78,11 @@ H5O_stab_decode (H5F_t *f, size_t raw_size, const uint8 *p)
{
H5O_stab_t *stab;
- FUNC_ENTER (H5O_stab_decode, NULL, NULL);
+ FUNC_ENTER (H5O_stab_decode, NULL);
/* check args */
assert (f);
- assert (raw_size == 2*H5F_SIZEOF_OFFSET(f));
+ assert (raw_size == 2*H5F_SIZEOF_ADDR(f));
assert (p);
/* decode */
@@ -115,11 +116,11 @@ H5O_stab_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
{
const H5O_stab_t *stab = (const H5O_stab_t *)_mesg;
- FUNC_ENTER (H5O_stab_encode, NULL, FAIL);
+ FUNC_ENTER (H5O_stab_encode, FAIL);
/* check args */
assert (f);
- assert (raw_size == 2 * H5F_SIZEOF_OFFSET(f));
+ assert (raw_size == 2 * H5F_SIZEOF_ADDR(f));
assert (p);
assert (stab);
@@ -155,7 +156,7 @@ H5O_stab_fast (const H5G_cache_t *cache, void *_mesg)
{
H5O_stab_t *stab = (H5O_stab_t *)_mesg;
- FUNC_ENTER (H5O_stab_fast, NULL, NULL);
+ FUNC_ENTER (H5O_stab_fast, NULL);
/* check args */
assert (cache);
@@ -194,7 +195,7 @@ H5O_stab_cache (H5G_type_t *cache_type, H5G_cache_t *cache, const void *_mesg)
const H5O_stab_t *stab = (const H5O_stab_t *)_mesg;
hbool_t modified = FALSE;
- FUNC_ENTER (H5O_stab_cache, NULL, FAIL);
+ FUNC_ENTER (H5O_stab_cache, FAIL);
/* check args */
assert (cache_type);
@@ -246,7 +247,7 @@ H5O_stab_copy (const void *_mesg, void *_dest)
const H5O_stab_t *stab = (const H5O_stab_t *)_mesg;
H5O_stab_t *dest = (H5O_stab_t *)_dest;
- FUNC_ENTER (H5O_stab_copy, NULL, NULL);
+ FUNC_ENTER (H5O_stab_copy, NULL);
/* check args */
assert (stab);
@@ -281,8 +282,8 @@ H5O_stab_copy (const void *_mesg, void *_dest)
static size_t
H5O_stab_size (H5F_t *f, const void *_mesg)
{
- FUNC_ENTER (H5O_stab_size, NULL, FAIL);
- FUNC_LEAVE (2 * H5F_SIZEOF_OFFSET(f));
+ FUNC_ENTER (H5O_stab_size, FAIL);
+ FUNC_LEAVE (2 * H5F_SIZEOF_ADDR(f));
}
@@ -309,7 +310,7 @@ H5O_stab_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
{
const H5O_stab_t *stab = (const H5O_stab_t *)_mesg;
- FUNC_ENTER (H5O_stab_debug, NULL, FAIL);
+ FUNC_ENTER (H5O_stab_debug, FAIL);
/* check args */
assert (f);
diff --git a/src/H5P.c b/src/H5P.c
index c6f3bcb..716f874 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -16,34 +16,21 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-/*LINTLIBRARY */
-/*+
- FILE
- H5P.c
- HDF5 Data-space routines
- EXPORTED ROUTINES
- H5Pcreate -- Create a data-space
- H5Prelease -- Release access to a data-space
-
- LIBRARY-SCOPED ROUTINES
-
- LOCAL ROUTINES
- H5P_init_interface -- initialize the interface
- + */
-
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atom Functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5MMprivate.h> /* Memory Management functions */
-#include <H5Pprivate.h> /* Data-space functions */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atom Functions */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5MMprivate.h> /* Memory Management functions */
+#include <H5Oprivate.h> /*object headers */
+#include <H5Pprivate.h> /* Data-space functions */
#define PABLO_MASK H5P_mask
-/*--------------------- Locally scoped variables -----------------------------*/
-
-/* Whether we've installed the library termination function yet for this interface */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5P_init_interface
+static herr_t H5P_init_interface (void);
+static void H5P_term_interface (void);
/*--------------------------------------------------------------------------
NAME
@@ -57,40 +44,21 @@ DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t H5P_init_interface(void)
+static herr_t
+H5P_init_interface (void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5P_init_interface, NULL, FAIL);
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER (H5P_init_interface, FAIL);
- /* Initialize the atom group for the file IDs */
- if((ret_value=H5Ainit_group(H5_DATASPACE,H5A_DATASPACEID_HASHSIZE,H5P_RESERVED_ATOMS,H5P_destroy))!=FAIL)
- ret_value=H5_add_exit(&H5P_term_interface);
+ /* Initialize the atom group for the file IDs */
+ if ((ret_value=H5Ainit_group (H5_DATASPACE, H5A_DATASPACEID_HASHSIZE,
+ H5P_RESERVED_ATOMS,
+ (herr_t (*)(void*))H5P_close))!=FAIL) {
+ ret_value=H5_add_exit(&H5P_term_interface);
+ }
- FUNC_LEAVE(ret_value);
-} /* H5P_init_interface */
-
-/*--------------------------------------------------------------------------
-NAME
- H5P_init -- Make certain that the interface has been initialized
-USAGE
- herr_t H5P_init()
-
-RETURNS
- SUCCEED/FAIL
-DESCRIPTION
- Library public routine to make certain the H5P interface has been properly
- initialized.
-
---------------------------------------------------------------------------*/
-herr_t H5P_init(void)
-{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5P_init, H5P_init_interface, FAIL);
-
- /* Actual work is done in the FUNC_ENTER macro */
-
- FUNC_LEAVE(ret_value);
-} /* H5P_init */
+ FUNC_LEAVE (ret_value);
+}
/*--------------------------------------------------------------------------
NAME
@@ -109,58 +77,470 @@ herr_t H5P_init(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void H5P_term_interface (void)
+static void
+H5P_term_interface (void)
+{
+ H5Adestroy_group (H5_DATASPACE);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pcreate
+ *
+ * Purpose: Creates a new data space object and opens it for access.
+ *
+ * Return: Success: The ID for the new data space object.
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Pcreate (H5P_class_t type)
{
- H5Adestroy_group(H5_DATASPACE);
-} /* end H5P_term_interface() */
+ H5P_t *ds = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER (H5Pcreate, FAIL);
+ H5ECLEAR;
-/*--------------------------------------------------------------------------
- NAME
- H5P_create
- PURPOSE
- Create a new HDF5 dimensionality object
- USAGE
- hid_t H5P_create(owner_id, type, name)
- hid_t owner_id; IN: Group/file which owns this object
- hobjtype_t type; IN: Type of object to create
- const char *name; IN: Name of the object
- RETURNS
- Returns ID (atom) on success, FAIL on failure
- DESCRIPTION
- This function actually creates the dimensionality object.
---------------------------------------------------------------------------*/
-hid_t H5P_create(hid_t owner_id, hobjtype_t type, const char *name)
+ ds = H5MM_xcalloc (1, sizeof(H5P_t));
+ ds->type = type;
+
+ switch (type) {
+ case H5P_SCALAR:
+ /*void*/
+ break;
+
+ case H5P_SIMPLE:
+ ds->u.simple.rank = 0;
+ break;
+
+ case H5P_COMPLEX:
+ /* Complex types are not supported yet */
+ HGOTO_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
+
+ default:
+ /* Unknown data space type */
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL);
+ }
+
+ /* Register the new data space and get an ID for it */
+ if ((ret_value = H5Aregister_atom (H5_DATASPACE, ds))<0) {
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL);
+ }
+
+ done:
+ if (ret_value<0) {
+ H5MM_xfree (ds);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pclose
+ *
+ * Purpose: Release access to a data space object.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pclose (hid_t space_id)
+{
+ FUNC_ENTER (H5Pclose, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_DATASPACE!=H5Aatom_group (space_id) ||
+ NULL==H5Aatom_object (space_id)) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data space*/
+ }
+
+ /* When the reference count reaches zero the resources are freed */
+ if (H5A_dec_ref (space_id)<0) {
+ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*problem freeing id*/
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_close
+ *
+ * Purpose: Releases all memory associated with a data space.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5P_close (H5P_t *ds)
+{
+ FUNC_ENTER (H5P_close, FAIL);
+
+ assert (ds);
+
+ switch (ds->type) {
+ case H5P_SCALAR:
+ /*void*/
+ break;
+
+ case H5P_SIMPLE:
+ H5MM_xfree (ds->u.simple.size);
+ H5MM_xfree (ds->u.simple.max);
+ H5MM_xfree (ds->u.simple.perm);
+ break;
+
+ case H5P_COMPLEX:
+ /* nothing */
+ break;
+
+ default:
+ assert ("unknown data space type" && 0);
+ break;
+ }
+ H5MM_xfree (ds);
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_copy
+ *
+ * Purpose: Copies a data space.
+ *
+ * Return: Success: A pointer to a new copy of SRC
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5P_t *
+H5P_copy (const H5P_t *src)
+{
+ H5P_t *dst = NULL;
+ int i;
+
+ FUNC_ENTER (H5P_copy, NULL);
+
+ dst = H5MM_xmalloc (sizeof(H5P_t));
+ *dst = *src;
+
+ switch (dst->type) {
+ case H5P_SCALAR:
+ /*void*/
+ break;
+
+ case H5P_SIMPLE:
+ if (dst->u.simple.size) {
+ dst->u.simple.size = H5MM_xmalloc (dst->u.simple.rank * sizeof(intn));
+ for (i=0; i<dst->u.simple.rank; i++) {
+ dst->u.simple.size[i] = src->u.simple.size[i];
+ }
+ }
+ if (dst->u.simple.max) {
+ dst->u.simple.max = H5MM_xmalloc (dst->u.simple.rank * sizeof(intn));
+ for (i=0; i<dst->u.simple.rank; i++) {
+ dst->u.simple.max[i] = src->u.simple.max[i];
+ }
+ }
+ if (dst->u.simple.perm) {
+ dst->u.simple.perm = H5MM_xmalloc (dst->u.simple.rank * sizeof(intn));
+ for (i=0; i<dst->u.simple.rank; i++) {
+ dst->u.simple.perm[i] = src->u.simple.perm[i];
+ }
+ }
+ break;
+
+ case H5P_COMPLEX:
+ /*void*/
+ break;
+
+ default:
+ assert ("unknown data space type" && 0);
+ break;
+ }
+
+ FUNC_LEAVE (dst);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_npoints
+ *
+ * Purpose: Determines how many data points a data set has.
+ *
+ * Return: Success: Number of data points in the data set.
+ *
+ * Failure: 0
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5Pget_npoints (hid_t space_id)
+{
+ H5P_t *ds = NULL;
+ size_t ret_value = 0;
+
+ FUNC_ENTER(H5Pget_npoints, 0);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_DATASPACE!=H5Aatom_group (space_id) ||
+ NULL==(ds=H5Aatom_object (space_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0); /*not a data space*/
+ }
+
+ ret_value = H5P_get_npoints (ds);
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_get_npoints
+ *
+ * Purpose: Determines how many data points a data set has.
+ *
+ * Return: Success: Number of data points in the data set.
+ *
+ * Failure: 0
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5P_get_npoints (const H5P_t *ds)
{
- H5P_dim_t *new_dim; /* new dimensionality object to create */
- hid_t ret_value = SUCCEED;
+ size_t ret_value = 0;
+ intn i;
+
+ FUNC_ENTER(H5P_get_npoints, 0);
- FUNC_ENTER(H5P_create, H5P_init_interface, FAIL);
+ /* check args */
+ assert (ds);
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
+ switch (ds->type) {
+ case H5P_SCALAR:
+ ret_value = 1;
+ break;
- /* Allocate space for the new data-type */
- if((new_dim=HDcalloc(1,sizeof(H5P_dim_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
-
- /* Initialize the dimensionality object */
- new_dim->type=H5P_TYPE_UNKNOWN;
- new_dim->s=NULL;
+ case H5P_SIMPLE:
+ for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
+ ret_value *= ds->u.simple.size[i];
+ }
+ break;
+
+ case H5P_COMPLEX:
+ /* complex data spaces are not supported yet */
+ HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0);
+
+ default:
+ /* unknown data space class */
+ HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_modify
+ *
+ * Purpose: Updates a data space by writing a message to an object
+ * header.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5P_modify (H5F_t *f, H5G_entry_t *ent, const H5P_t *ds)
+{
+ FUNC_ENTER (H5O_modify, FAIL);
- /* Register the new datatype and get an ID for it */
- if((ret_value=H5Aregister_atom(H5_DATASPACE, (const VOIDP)new_dim))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
+ assert (f);
+ assert (ent);
+ assert (ds);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ switch (ds->type) {
+ case H5P_SCALAR:
+ /* Scalar data spaces are not implemented yet */
+ HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
- } /* end if */
+ case H5P_SIMPLE:
+ if (H5O_modify (f, NO_ADDR, ent, H5O_SDSPACE, 0, &(ds->u.simple))<0) {
+ /* Can't update simple data space message */
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL);
+ }
+ break;
+
+ case H5P_COMPLEX:
+ /* Complex data spaces are not implemented yet */
+ HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
+
+ default:
+ assert ("unknown data space class" && 0);
+ break;
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_read
+ *
+ * Purpose: Reads the data space from an object header.
+ *
+ * Return: Success: Pointer to a new data space.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5P_t *
+H5P_read (H5F_t *f, H5G_entry_t *ent)
+{
+ H5P_t *ds = NULL;
+
+ FUNC_ENTER (H5P_read, NULL);
+
+ /* check args */
+ assert (f);
+ assert (ent);
+
+ ds = H5MM_xcalloc (1, sizeof(H5P_t));
+
+ if (H5O_read (f, NO_ADDR, ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
+ ds->type = H5P_SIMPLE;
+
+ } else {
+ ds->type = H5P_SCALAR;
+ }
+
+ FUNC_LEAVE (ds);
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_cmp
+ *
+ * Purpose: Compares two data spaces.
+ *
+ * Return: Success: 0 if DS1 and DS2 are the same.
+ * <0 if DS1 is less than DS2.
+ * >0 if DS1 is greater than DS2.
+ *
+ * Failure: 0, never fails
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 10, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+intn
+H5P_cmp (const H5P_t *ds1, const H5P_t *ds2)
+{
+ intn i;
+
+ FUNC_ENTER (H5P_cmp, 0);
- /* Normal function cleanup */
+ /* check args */
+ assert (ds1);
+ assert (ds2);
- FUNC_LEAVE(ret_value);
-} /* end H5P_create() */
+ /* compare */
+ if (ds1->type < ds2->type) HRETURN (-1);
+ if (ds1->type > ds2->type) HRETURN (1);
+
+ switch (ds1->type) {
+ case H5P_SIMPLE:
+ if (ds1->u.simple.rank < ds2->u.simple.rank) HRETURN (-1);
+ if (ds1->u.simple.rank > ds2->u.simple.rank) HRETURN (1);
+
+ /* don't compare flags */
+
+ for (i=0; i<ds1->u.simple.rank; i++) {
+ if (ds1->u.simple.size[i] < ds2->u.simple.size[i]) HRETURN (-1);
+ if (ds1->u.simple.size[i] > ds2->u.simple.size[i]) HRETURN (1);
+ }
+
+ /* don't compare max dimensions */
+
+ for (i=0; i<ds1->u.simple.rank; i++) {
+ if ((ds1->u.simple.perm?ds1->u.simple.perm[i]:i) <
+ (ds2->u.simple.perm?ds2->u.simple.perm[i]:i)) HRETURN (-1);
+ if ((ds1->u.simple.perm?ds2->u.simple.perm[i]:i) >
+ (ds2->u.simple.perm?ds2->u.simple.perm[i]:i)) HRETURN (1);
+ }
+
+ break;
+
+ default:
+ assert ("not implemented yet" && 0);
+ }
+
+ FUNC_LEAVE (0);
+}
/*--------------------------------------------------------------------------
NAME
@@ -168,8 +548,8 @@ done:
PURPOSE
Return the logical rank of a dataspace (internal)
USAGE
- uint32 H5P_get_lrank(sdim)
- H5P_sdim_t *sdim; IN: Pointer to dataspace object to query
+ intn H5P_get_lrank(sdim)
+ H5P_t *sdim; IN: Pointer to dataspace object to query
RETURNS
The logical rank of a dataspace on success, UFAIL on failure
DESCRIPTION
@@ -178,11 +558,12 @@ done:
dataspace, not the dimensionality of the space its embedded in.
UFAIL is returned on an error, otherwise the rank is returned.
--------------------------------------------------------------------------*/
-uint32 H5P_get_lrank(const H5P_sdim_t *sdim)
+intn
+H5P_get_lrank (const H5P_simple_t *sdim)
{
- uint32 ret_value = UFAIL;
+ intn ret_value = UFAIL;
- FUNC_ENTER(H5P_get_lrank, H5P_init_interface, UFAIL);
+ FUNC_ENTER(H5P_get_lrank, UFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -201,7 +582,7 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5P_get_lrank() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -209,7 +590,7 @@ done:
PURPOSE
Return the logical rank of a dataspace
USAGE
- uint32 H5P_get_lrank(sid)
+ intn H5P_get_lrank(sid)
hid_t sid; IN: ID of dataspace object to query
RETURNS
The logical rank of a dataspace on success, UFAIL on failure
@@ -219,12 +600,13 @@ done:
dataspace, not the dimensionality of the space its embedded in.
UFAIL is returned on an error, otherwise the rank is returned.
--------------------------------------------------------------------------*/
-uint32 H5Pget_lrank(hid_t sid)
+intn
+H5Pget_lrank (hid_t sid)
{
- H5P_dim_t *space=NULL; /* dataspace to modify */
- uint32 ret_value = UFAIL;
+ H5P_t *space=NULL; /* dataspace to modify */
+ intn ret_value = UFAIL;
- FUNC_ENTER(H5Pget_lrank, H5P_init_interface, UFAIL);
+ FUNC_ENTER(H5Pget_lrank, UFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -232,7 +614,7 @@ uint32 H5Pget_lrank(hid_t sid)
if((space=H5Aatom_object(sid))==NULL)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- ret_value=H5P_get_lrank(space->s);
+ ret_value=H5P_get_lrank(&(space->u.simple));
done:
if(ret_value == UFAIL)
@@ -243,7 +625,7 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Pget_lrank() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -252,8 +634,8 @@ done:
Return the logical dimensions of a dataspace (internal)
USAGE
herr_t H5P_get_ldims(sdim, dims)
- H5P_sdim_t *sdim; IN: Pointer to dataspace object to query
- uint32 *dims; OUT: Pointer to array to store dimensions in
+ H5P_simple_t *sdim; IN: Pointer to dataspace object to query
+ intn *dims; OUT: Pointer to array to store dimensions in
RETURNS
SUCCEED/FAIL
DESCRIPTION
@@ -261,18 +643,19 @@ done:
dataspace. The logical dimensions are the actual sizes of the
dataspace, not the size of the space it is embedded in.
--------------------------------------------------------------------------*/
-herr_t H5P_get_ldims(const H5P_sdim_t *sdim, uint32 *dims)
+herr_t
+H5P_get_ldims (const H5P_simple_t *sdim, intn *dims)
{
herr_t ret_value = FAIL;
- FUNC_ENTER(H5P_get_ldims, H5P_init_interface, UFAIL);
+ FUNC_ENTER(H5P_get_ldims, UFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
assert(sdim);
assert(dims);
- HDmemcpy(dims, sdim->size,sdim->rank*sizeof(uint32));
+ HDmemcpy(dims, sdim->size,sdim->rank*sizeof(intn));
ret_value=SUCCEED;
#ifdef LATER
@@ -286,7 +669,7 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5P_get_ldims() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -296,7 +679,7 @@ done:
USAGE
herr_t H5P_get_ldims(sdim, dims)
hid_t sid; IN: ID of dataspace object to query
- uint32 *dims; OUT: Pointer to array to store dimensions in
+ intn *dims; OUT: Pointer to array to store dimensions in
RETURNS
SUCCEED/FAIL
DESCRIPTION
@@ -304,12 +687,12 @@ done:
dataspace. The logical dimensions are the actual sizes of the
dataspace, not the size of the space it is embedded in.
--------------------------------------------------------------------------*/
-herr_t H5Pget_ldims(hid_t sid, uint32 *dims)
+herr_t H5Pget_ldims(hid_t sid, intn *dims)
{
- H5P_dim_t *space=NULL; /* dataspace to modify */
- uint32 ret_value = UFAIL;
+ H5P_t *space=NULL; /* dataspace to modify */
+ intn ret_value = UFAIL;
- FUNC_ENTER(H5Pget_lrank, H5P_init_interface, UFAIL);
+ FUNC_ENTER(H5Pget_lrank, UFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -320,7 +703,7 @@ herr_t H5Pget_ldims(hid_t sid, uint32 *dims)
if(dims==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL);
- ret_value=H5P_get_ldims(space->s,dims);
+ ret_value=H5P_get_ldims(&(space->u.simple),dims);
done:
if(ret_value == FAIL)
@@ -331,7 +714,7 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Pget_ldims() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -340,40 +723,29 @@ done:
Check if a dataspace is simple (internal)
USAGE
hbool_t H5P_is_simple(sdim)
- H5P_sdim_t *sdim; IN: Pointer to dataspace object to query
+ H5P_t *sdim; IN: Pointer to dataspace object to query
RETURNS
BTRUE/BFALSE/BFAIL
DESCRIPTION
This function determines the if a dataspace is "simple". ie. if it
has orthogonal, evenly spaced dimensions.
--------------------------------------------------------------------------*/
-hbool_t H5P_is_simple(const H5P_dim_t *sdim)
+hbool_t
+H5P_is_simple (const H5P_t *sdim)
{
hbool_t ret_value = BFAIL;
- FUNC_ENTER(H5P_is_simple, H5P_init_interface, UFAIL);
+ FUNC_ENTER(H5P_is_simple, UFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
assert(sdim);
- if(sdim->type==H5P_TYPE_UNKNOWN)
- {
- HGOTO_ERROR (H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
- }
- else
- ret_value=sdim->type==H5P_TYPE_SIMPLE ? BTRUE : BFALSE; /* Currently all dataspaces are simple, but check anyway */
+ ret_value=sdim->type==H5P_SIMPLE ? BTRUE : BFALSE; /* Currently all dataspaces are simple, but check anyway */
-done:
- if(ret_value == BFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5P_is_simple() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -391,10 +763,10 @@ done:
--------------------------------------------------------------------------*/
hbool_t H5Pis_simple(hid_t sid)
{
- H5P_dim_t *space=NULL; /* dataspace to modify */
+ H5P_t *space=NULL; /* dataspace to modify */
hbool_t ret_value = BFAIL;
- FUNC_ENTER(H5Pis_simple, H5P_init_interface, BFAIL);
+ FUNC_ENTER(H5Pis_simple, BFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -413,7 +785,7 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Pis_simple() */
+}
/*--------------------------------------------------------------------------
NAME
@@ -423,8 +795,8 @@ done:
USAGE
herr_t H5Pset_space(sid, rank, dims)
hid_t sid; IN: Dataspace object to query
- uint32 rank; IN: # of dimensions for the dataspace
- const uint32 *dims; IN: Size of each dimension for the dataspace
+ intn rank; IN: # of dimensions for the dataspace
+ const intn *dims; IN: Size of each dimension for the dataspace
RETURNS
SUCCEED/FAIL
DESCRIPTION
@@ -436,13 +808,13 @@ done:
expand. Currently, only the first dimension in the array (the slowest) may
be unlimited in size.
--------------------------------------------------------------------------*/
-herr_t H5Pset_space(hid_t sid, uint32 rank, const uint32 *dims)
+herr_t H5Pset_space(hid_t sid, intn rank, const intn *dims)
{
- H5P_dim_t *space=NULL; /* dataspace to modify */
- uintn u; /* local counting variable */
+ H5P_t *space=NULL; /* dataspace to modify */
+ intn u; /* local counting variable */
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5Pset_space, H5P_init_interface, FAIL);
+ FUNC_ENTER(H5Pset_space, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
@@ -456,64 +828,62 @@ herr_t H5Pset_space(hid_t sid, uint32 rank, const uint32 *dims)
/* shift out of the previous state to a "simple" dataspace */
switch(space->type)
{
- case H5P_TYPE_UNKNOWN:
- if((space->s=HDcalloc(sizeof(H5P_sdim_t),1))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- break;
-
- case H5P_TYPE_SIMPLE:
+ case H5P_SIMPLE:
/* do nothing */
break;
- case H5P_TYPE_COMPLEX:
- /* eventually this will destroy whatever "complex" dataspace info is retained, right now it's an error */
+ case H5P_COMPLEX:
+ /*
+ * eventually this will destroy whatever "complex" dataspace info
+ * is retained, right now it's an error
+ */
/* Fall through to report error */
default:
HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL);
} /* end switch */
- space->type=H5P_TYPE_SIMPLE;
+ space->type=H5P_SIMPLE;
if(rank==0)
{ /* scalar variable */
- space->s->rank=0; /* set to scalar rank */
- space->s->dim_flags=0; /* no maximum dimensions or dimension permutations */
- if(space->s->size!=NULL)
- space->s->size=H5MM_xfree(space->s->size);
- if(space->s->max!=NULL)
- space->s->max=H5MM_xfree(space->s->max);
- if(space->s->perm!=NULL)
- space->s->max=H5MM_xfree(space->s->perm);
+ space->u.simple.rank=0; /* set to scalar rank */
+ space->u.simple.dim_flags=0; /* no maximum dimensions or dimension permutations */
+ if(space->u.simple.size!=NULL)
+ space->u.simple.size=H5MM_xfree(space->u.simple.size);
+ if(space->u.simple.max!=NULL)
+ space->u.simple.max=H5MM_xfree(space->u.simple.max);
+ if(space->u.simple.perm!=NULL)
+ space->u.simple.max=H5MM_xfree(space->u.simple.perm);
} /* end if */
else
{
/* Reset the dataspace flags */
- space->s->dim_flags=0;
+ space->u.simple.dim_flags=0;
/* Free the old space for now */
- if(space->s->size!=NULL)
- space->s->size=H5MM_xfree(space->s->size);
- if(space->s->max!=NULL)
- space->s->max=H5MM_xfree(space->s->max);
- if(space->s->perm!=NULL)
- space->s->perm=H5MM_xfree(space->s->perm);
+ if(space->u.simple.size!=NULL)
+ space->u.simple.size=H5MM_xfree(space->u.simple.size);
+ if(space->u.simple.max!=NULL)
+ space->u.simple.max=H5MM_xfree(space->u.simple.max);
+ if(space->u.simple.perm!=NULL)
+ space->u.simple.perm=H5MM_xfree(space->u.simple.perm);
/* Set the rank and copy the dims */
- space->s->rank=rank;
- if((space->s->size=HDcalloc(sizeof(uint32),rank))==NULL)
+ space->u.simple.rank=rank;
+ if((space->u.simple.size=HDcalloc(sizeof(intn),rank))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- HDmemcpy(space->s->size,dims,sizeof(uint32)*rank);
+ HDmemcpy(space->u.simple.size,dims,sizeof(intn)*rank);
/* check if there are unlimited dimensions and create the maximum dims array */
- for(u=0; u<(uintn)rank; u++)
+ for(u=0; u<rank; u++)
if(dims[u]==0)
{
if(u>0) /* sanity check for unlimited dimensions not in the lowest dimensionality */
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
- if((space->s->max=HDcalloc(sizeof(uint32),rank))==NULL)
+ if((space->u.simple.max=HDcalloc(sizeof(intn),rank))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- HDmemcpy(space->s->max,dims,sizeof(uint32)*rank);
- space->s->dim_flags|=H5P_VALID_MAX;
+ HDmemcpy(space->u.simple.max,dims,sizeof(intn)*rank);
+ space->u.simple.dim_flags|=H5P_VALID_MAX;
break;
} /* end if */
} /* end else */
@@ -527,191 +897,4 @@ done:
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Pset_space() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5P_nelem
- PURPOSE
- Return the number of elements in a dataspace (internal)
- USAGE
- uintn H5P_nelem(space)
- const H5P_dim_t *space; IN: Pointer to the dataspace object to query
- RETURNS
- The number of elements in a dataspace on success, UFAIL on failure
- DESCRIPTION
- This function determines the number of dataset elements in a
- dataspace. For example, a simple 3-dimensional dataspace with dimensions
- 2, 3 and 4 would have 24 elements.
- UFAIL is returned on an error, otherwise the number of elements is returned.
---------------------------------------------------------------------------*/
-uintn H5P_nelem(const H5P_dim_t *space)
-{
- uintn u; /* local counting variable */
- uintn ret_value = UFAIL;
-
- FUNC_ENTER(H5P_nelem, H5P_init_interface, UFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- assert(space);
-
- /* Check for anything but simple dataspaces for now */
- if(space->type!=H5P_TYPE_SIMPLE)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL);
-
- /* Check for other form of scalar dataspaces */
- if(space->s->rank==0)
- ret_value=1;
- else
- {
- for(ret_value=1, u=0; u<(uintn)space->s->rank; u++)
- ret_value*=space->s->size[u];
- } /* end else */
-
-done:
- if(ret_value == UFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5P_nelem() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Pnelem
- PURPOSE
- Return the number of elements in a dataspace
- USAGE
- uintn H5Pnelem(sid)
- hid_t sid; IN: Dataspace object to query
- RETURNS
- The number of elements in a dataspace on success, UFAIL on failure
- DESCRIPTION
- This function determines the number of dataset elements in a
- dataspace. For example, a simple 3-dimensional dataspace with dimensions
- 2, 3 and 4 would have 24 elements.
- UFAIL is returned on an error, otherwise the number of elements is returned.
---------------------------------------------------------------------------*/
-uintn H5Pnelem(hid_t sid)
-{
- H5P_dim_t *space=NULL; /* dataspace to modify */
- uintn ret_value = UFAIL;
-
- FUNC_ENTER(H5Pnelem, H5P_init_interface, UFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- if(sid==H5P_SCALAR)
- ret_value=1;
- else
- {
- if((space=H5Aatom_object(sid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- ret_value=H5P_nelem(space);
- } /* end else */
-
-done:
- if(ret_value == UFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Pnelem() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5P_destroy
- PURPOSE
- Private function to destroy dataspace objects.
- USAGE
- void H5P_destroy(dataspace)
- void *dataspace; IN: Pointer to dataspace object to destroy
- RETURNS
- none
- DESCRIPTION
- This function releases whatever memory is used by a dataspace object.
- It should only be called from the atom manager when the reference count
- for a dataspace drops to zero.
---------------------------------------------------------------------------*/
-void H5P_destroy(void *dataspace)
-{
- H5P_dim_t *dim=(H5P_dim_t *)dataspace; /* dimensionality object to release */
-
- /* Don't call standard init/leave code, this is a private void function */
- /* FUNC_ENTER(H5T_destroy, H5T_init_interface, FAIL); */
-
- if(dim->type==H5P_TYPE_SIMPLE)
- {
- if(dim->s!=NULL)
- {
- if(dim->s->size!=NULL)
- HDfree(dim->s->size);
- if(dim->s->max!=NULL)
- HDfree(dim->s->max);
- if(dim->s->perm!=NULL)
- HDfree(dim->s->perm);
- HDfree(dim->s);
- } /* end if */
- } /* end if */
- HDfree(dim);
-
-#ifdef LATER
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
- FUNC_LEAVE(ret_value);
-#endif /* LATER */
-
-} /* H5P_destroy */
-
-/*--------------------------------------------------------------------------
- NAME
- H5P_release
- PURPOSE
- Release access to an HDF5 dimensionality object.
- USAGE
- herr_t H5P_release(oid)
- hid_t oid; IN: Object to release access to
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function releases a dimensionality from active use by a user.
---------------------------------------------------------------------------*/
-herr_t H5P_release(hid_t oid)
-{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5P_release, H5P_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Chuck the object! :-) */
- if(H5Adec_ref(oid)==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5P_release() */
-
+}
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 1df27c5..161fcf5 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -22,29 +22,39 @@
/* Private headers needed by this file */
#include <H5private.h>
-#include <H5Cprivate.h> /*for hobjtype_t defn*/
+#include <H5Gprivate.h> /*for H5G_entry_t */
/* Flags to indicate special dataspace features are active */
#define H5P_VALID_MAX 0x01
#define H5P_VALID_PERM 0x02
-typedef struct H5P_sdim_t {
- uint32 rank; /* Number of dimensions */
- uint32 dim_flags; /* Dimension flags */
- uint32 *size; /* Dimension sizes */
- uint32 *max; /* Maximum dimension sizes */
- uint32 *perm; /* Dimension permutations */
-} H5P_sdim_t;
+typedef struct H5P_simple_t {
+ intn rank; /*number of dimensions */
+ intn dim_flags; /*dimension flags */
+ intn *size; /*dimension sizes */
+ intn *max; /*maximum dimension sizes */
+ intn *perm; /*dimension permutations */
+} H5P_simple_t;
+
+typedef struct {
+ H5P_class_t type; /*type of dimensionality object */
+ union {
+ H5P_simple_t simple;/*simple dimensionality information */
+ } u;
+} H5P_t;
#define H5P_RESERVED_ATOMS 2
-/* Private functions */
-herr_t H5P_init(void);
-hid_t H5P_create(hid_t owner_id, hobjtype_t type, const char *name);
-uint32 H5P_get_lrank(const H5P_sdim_t *sdim);
-herr_t H5P_get_ldims(const H5P_sdim_t *sdim, uint32 *dims);
-hbool_t H5P_is_simple(const H5P_dim_t *sdim);
-uintn H5P_nelem(const H5P_dim_t *space);
-herr_t H5P_release(hid_t oid);
+H5P_t *H5P_copy (const H5P_t *src);
+herr_t H5P_close (H5P_t *ds);
+size_t H5P_get_npoints (const H5P_t *ds);
+herr_t H5P_modify (H5F_t *f, H5G_entry_t *ent, const H5P_t *space);
+H5P_t *H5P_read (H5F_t *f, H5G_entry_t *ent);
+intn H5P_cmp (const H5P_t *ds1, const H5P_t *ds2);
+
+intn H5P_get_lrank (const H5P_simple_t *sdim);
+herr_t H5P_get_ldims (const H5P_simple_t *sdim, intn *dims);
+hbool_t H5P_is_simple (const H5P_t *sdim);
+uintn H5P_nelem (const H5P_t *space);
#endif
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 94e25c3..5a8a0b0 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -24,33 +24,30 @@
#include <H5Apublic.h>
/* Define atomic datatypes */
-#define H5P_SCALAR MAKE_ATOM(H5_DATASPACE,0) /* Atom for scalar dataspace */
-#define H5P_ALL MAKE_ATOM(H5_DATASPACE,1) /* Atom for "entire" dataspace */
+#define H5P_ALL (-2)
/* Different types of dataspaces */
-#define H5P_TYPE_UNKNOWN 0 /* Dataspace is not unitialized */
-#define H5P_TYPE_SIMPLE 1 /* Dataspace is simple */
-#define H5P_TYPE_COMPLEX 2 /* Dataspace is complex */
+typedef enum H5P_class_t {
+ H5P_NO_CLASS =-1, /*error */
+ H5P_SCALAR =0, /*scalar variable */
+ H5P_SIMPLE =1, /*simple data space */
+ H5P_COMPLEX =2 /*complex data space */
+} H5P_class_t;
-typedef struct {
- uintn type; /* Type of dimensionality object */
- struct H5P_sdim_t *s; /* Pointer to simple dimensionality information */
- } H5P_dim_t;
#ifdef __cplusplus
extern "C" {
#endif
/* Functions in H5P.c */
-uintn H5Pnelem(hid_t dim_id);
-uint32 H5Pget_lrank(hid_t dim_id);
-herr_t H5Pget_ldims(hid_t dim_id, uint32 *dims);
-hbool_t H5Pis_simple(hid_t dim_id);
-herr_t H5Pset_space(hid_t sid, uint32 rank, const uint32 *dims);
-
-/* Private functions which need to be globally visible */
-void H5P_term_interface (void);
-void H5P_destroy(void *dataspace);
+hid_t H5Pcreate (H5P_class_t type);
+herr_t H5Pclose (hid_t space_id);
+size_t H5Pget_npoints (hid_t space_id);
+
+intn H5Pget_lrank(hid_t space_id);
+herr_t H5Pget_ldims(hid_t space_id, intn *dims);
+hbool_t H5Pis_simple(hid_t space_id);
+herr_t H5Pset_space(hid_t space_id, intn rank, const intn *dims);
#ifdef __cplusplus
}
diff --git a/src/H5T.c b/src/H5T.c
index 7c6fdb6..cc19d1a 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -14,47 +14,24 @@
static char RcsId[] = "@(#)$Revision$";
#endif
-/* $Id$ */
-
-/*LINTLIBRARY */
-/*+
- FILE
- H5T.c
- HDF5 Data-type routines
-
- EXPORTED ROUTINES
- H5Tget_num_fields -- Get the number of fields in a compound datatype
- H5Tis_field_atomic -- Check if a field is atomic
- H5Tis_atomic/H5T_is_atomic -- Check if a datatype is atomic
- H5Tset_type -- Set the base type of a user-defined datatype
- H5Tget_type -- Get the base type of a datatype
- H5Tadd_field -- Add a field to a compound datatype
- H5Tsize -- Determine the size of a datatype
-
- LIBRARY-SCOPED ROUTINES
- H5T_create -- (Meta-Object) Create a datatype
- H5T_release -- (Meta-Object) Release access to a datatype
-
- LOCAL ROUTINES
- H5T_init_interface -- initialize the interface
- + */
-
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atom functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5Mprivate.h> /* Meta data */
-#include <H5Pprivate.h> /* Data space */
-#include <H5Tprivate.h> /* Data-type functions */
+#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+
+#include <H5private.h> /*generic functions */
+#include <H5Aprivate.h> /*atom functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Mprivate.h> /*meta data */
+#include <H5MMprivate.h> /*memory management */
+#include <H5Pprivate.h> /*data space */
+#include <H5Tpkg.h> /*data-type functions */
#define PABLO_MASK H5T_mask
-/*--------------------- Locally scoped variables -----------------------------*/
+#define H5T_COMPND_INC 64 /*typical max numb of members per struct*/
-/* Whether we've installed the library termination function yet for this interface */
+/* Interface initialization */
static intn interface_initialize_g = FALSE;
-
-/*------------------_-- Local function prototypes ----------------------------*/
-static herr_t H5T_init_interface(void);
+#define INTERFACE_INIT H5T_init_interface
+static void H5T_term_interface (void);
/*--------------------------------------------------------------------------
NAME
@@ -68,40 +45,24 @@ DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t H5T_init_interface(void)
+herr_t
+H5T_init_interface (void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5T_init_interface, NULL, FAIL);
-
- /* Initialize the atom group for the file IDs */
- if((ret_value=H5Ainit_group(H5_DATATYPE,H5A_DATATYPEID_HASHSIZE,H5T_RESERVED_ATOMS,H5T_destroy))!=FAIL)
- ret_value=H5_add_exit(&H5T_term_interface);
-
- FUNC_LEAVE(ret_value);
-} /* H5T_init_interface */
-
-/*--------------------------------------------------------------------------
-NAME
- H5T_init -- Make certain that the interface has been initialized
-USAGE
- herr_t H5T_init()
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER (H5T_init_interface, FAIL);
+
+ /* Initialize the atom group for the file IDs */
+ if ((ret_value=H5Ainit_group (H5_DATATYPE, H5A_DATATYPEID_HASHSIZE,
+ H5T_RESERVED_ATOMS,
+ (herr_t (*)(void*))H5T_close))!=FAIL) {
+ ret_value=H5_add_exit (&H5T_term_interface);
+ }
+
+ /* Initialize pre-defined data types */
+ ret_value = H5T_init ();
-RETURNS
- SUCCEED/FAIL
-DESCRIPTION
- Library public routine to make certain the H5T interface has been properly
- initialized.
-
---------------------------------------------------------------------------*/
-herr_t H5T_init(void)
-{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5T_init, H5T_init_interface, FAIL);
-
- /* Actual work is done in the FUNC_ENTER macro */
-
- FUNC_LEAVE(ret_value);
-} /* H5T_init */
+ FUNC_LEAVE (ret_value);
+}
/*--------------------------------------------------------------------------
NAME
@@ -120,814 +81,835 @@ herr_t H5T_init(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void H5T_term_interface (void)
+static void
+H5T_term_interface (void)
{
- H5Adestroy_group(H5_DATATYPE);
-} /* end H5T_term_interface() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_create
- PURPOSE
- Create a new HDF5 data-type object
- USAGE
- hid_t H5T_create(owner_id, type, name)
- hid_t owner_id; IN: Group/file which owns this object
- hobjtype_t type; IN: Type of object to create
- const char *name; IN: Name of the object
- RETURNS
- Returns ID (atom) on success, FAIL on failure
- DESCRIPTION
- This function actually creates the data-type object.
---------------------------------------------------------------------------*/
-hid_t H5T_create(hid_t owner_id, hobjtype_t type, const char *name)
-{
- h5_datatype_t *new_dt; /* new data-type object to create */
- hid_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5T_create, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Allocate space for the new data-type */
- if((new_dt=HDmalloc(sizeof(h5_datatype_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
-
- /* Initialize the datatype */
- new_dt->dt.base=0; /* No Default datatype */
- new_dt->name=HDstrdup(name); /* Make a copy of the datatype's name */
- new_dt->ci=NULL; /* Set the complex information to NULL */
-
- /* Register the new datatype and get an ID for it */
- if((ret_value=H5Aregister_atom(H5_DATATYPE, (const VOIDP)new_dt))==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5T_create() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tget_num_fields
- PURPOSE
- Return the number of fields in a compound datatype
- USAGE
- uint32 H5Tget_num_fields(tid)
- hid_t tid; IN: Datatype object to query
- RETURNS
- The number of fields in a compound datatype on success, UFAIL on failure
- DESCRIPTION
- This function checks the number of fields in a compound user-defined
- datatype. UFAIL is returned on an error or if an atomic datatype is
- queried, otherwise the number of fields is returned.
---------------------------------------------------------------------------*/
-uint32 H5Tget_num_fields(hid_t tid)
+ H5Adestroy_group (H5_DATATYPE);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tcreate
+ *
+ * Purpose: Create a new type and initialize it to reasonable values.
+ * The type is a member of type class TYPE and is SIZE bytes.
+ *
+ * Return: Success: A new type identifier.
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ * ARGS BADVALUE Invalid size.
+ * DATATYPE CANTINIT Can't create type.
+ * DATATYPE CANTREGISTER Can't register data type atom.
+ *
+ * Programmer: Robb Matzke
+ * Friday, December 5, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Tcreate (H5T_class_t type, size_t size)
{
- h5_datatype_t *dt; /* new data-type object to create */
- uint32 ret_value = UFAIL;
-
- FUNC_ENTER(H5Tget_num_fields, H5T_init_interface, UFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check the base type of the datatype */
- if(H5T_COMPOUND!=dt->dt.base)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
-
- /* Check if the compound information has been initialized */
- if(NULL==dt->ci)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
-
- /* Grab the number of fields */
- ret_value=dt->ci->n;
-
-done:
- if(ret_value == UFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tget_num_fields() */
+ H5T_t *dt = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER (H5Tcreate, FAIL);
-/*--------------------------------------------------------------------------
- NAME
- H5Tis_field_atomic
- PURPOSE
- Check if a field in a compound datatype is atomic
- USAGE
- hbool_t H5Tis_field_atomic(tid, fidx)
- hid_t tid; IN: Datatype object to query
- uintn fidx; IN: Index of the field to query
- RETURNS
- BFAIL/BTRUE/BFALSE
- DESCRIPTION
- This function checks the basic type of field in a user-defined datatype.
- BTRUE is returned if the datatype is atomic (i.e. not compound), BFALSE is
- returned if the datatype is compound, BFAIL on error.
---------------------------------------------------------------------------*/
-hbool_t H5Tis_field_atomic(hid_t tid, uintn fidx)
+ /* check args */
+ if (size<=0) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*invalid size*/
+ }
+
+ /* create the type */
+ if (NULL==(dt=H5T_create (type, size))) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL);/*can't create type*/
+ }
+
+ /* Make it an atom */
+ if ((ret_value=H5Aregister_atom (H5_DATATYPE, dt))<0) {
+ /* Can't register data type atom */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_create
+ *
+ * Purpose: Creates a new data type and initializes it to reasonable
+ * values. The new data type is SIZE bytes and an instance of
+ * the class TYPE.
+ *
+ * Return: Success: Pointer to the new type.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Friday, December 5, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_create (H5T_class_t type, size_t size)
{
- h5_datatype_t *dt; /* new data-type object to create */
- hbool_t ret_value = BTRUE;
-
- FUNC_ENTER(H5Tis_field_atomic, H5T_init_interface, BFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check the base type of the datatype */
- if(H5T_COMPOUND!=dt->dt.base)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
-
- /* Check if the compound information has been initialized */
- if(NULL==dt->ci)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
-
- /* Check if the field is valid*/
- if(fidx>=dt->ci->n)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL);
-
- /* Check the base type of the field */
- if(H5T_COMPOUND==dt->ci->flist[fidx].dt.base || H5P_SCALAR!=dt->ci->flist[fidx].dim_id)
- ret_value=BFALSE;
-
-done:
- if(ret_value == BFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tis_field_atomic() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_is_atomic
- PURPOSE
- Check if a datatype is atomic (internal)
- USAGE
- hbool_t H5Tis_atomic(type)
- h5_datatype_t *type; IN: Ptr to datatype object to query
- RETURNS
- BFAIL/BTRUE/BFALSE
- DESCRIPTION
- This function checks the basic type of a user-defined datatype. BTRUE
- is returned if the datatype is atomic (i.e. not compound), BFALSE is
- returned if the datatype is compound, BFAIL on error.
---------------------------------------------------------------------------*/
-hbool_t H5T_is_atomic(h5_datatype_t *type)
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER (H5T_create, NULL);
+
+ assert (size>0);
+
+ switch (type) {
+ case H5T_FIXED:
+ /* Default type is a native `int' */
+ if (NULL==(dt=H5T_copy (H5Aatom_object (H5T_NATIVE_INT)))) {
+ /* Can't derive type from native int */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL);
+ }
+ break;
+
+ case H5T_FLOAT:
+ /* Default type is a native `double' */
+ if (NULL==(dt=H5T_copy (H5Aatom_object (H5T_NATIVE_DOUBLE)))) {
+ /* Can't derive type from native double */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL);
+ }
+ break;
+
+ case H5T_DATE:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ assert ("not implemented yet" && 0);
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, NULL);
+
+ case H5T_COMPOUND:
+ dt = H5MM_xcalloc (1, sizeof(H5T_t));
+ dt->type = type;
+ break;
+
+ default:
+ /* Unknown data type class */
+ HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, NULL);
+ }
+
+ dt->size = size;
+ FUNC_LEAVE (dt);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tget_num_members
+ *
+ * Purpose: Determines how many members compound data type TYPE_ID has.
+ *
+ * Return: Success: Number of members defined in a compound data
+ * type.
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+intn
+H5Tget_num_members (hid_t type_id)
{
- hbool_t ret_value = BTRUE;
-
- FUNC_ENTER(H5T_is_atomic, H5T_init_interface, BFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- assert (type);
- /* Check the base type of the datatype */
- if(H5T_COMPOUND==type->dt.base)
- ret_value=BFALSE;
-
-#ifdef LATER
-done:
-#endif /* LATER */
- if(ret_value == BFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5T_is_atomic() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tis_atomic
- PURPOSE
- Check if a datatype is atomic (API)
- USAGE
- hbool_t H5Tis_atomic(tid)
- hid_t tid; IN: Datatype object to query
- RETURNS
- BFAIL/BTRUE/BFALSE
- DESCRIPTION
- This function checks the basic type of a user-defined datatype. BTRUE
- is returned if the datatype is atomic (i.e. not compound), BFALSE is
- returned if the datatype is compound, BFAIL on error.
---------------------------------------------------------------------------*/
-hbool_t H5Tis_atomic(hid_t tid)
+
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER (H5Tget_num_members, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(dt=H5Aatom_object (type_id)) ||
+ H5T_COMPOUND!=dt->type) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a compound data type*/
+ }
+
+ FUNC_LEAVE (dt->u.compnd.nmembs);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tget_class
+ *
+ * Purpose: Returns the data type class identifier for data type TYPE_ID.
+ *
+ * Return: Success: One of the non-negative data type class
+ * constants.
+ *
+ * Failure: H5T_NO_CLASS (-1)
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_class_t
+H5Tget_class (hid_t type_id)
{
- h5_datatype_t *dt; /* new data-type object to create */
- hbool_t ret_value = BTRUE;
-
- FUNC_ENTER(H5Tis_atomic, H5T_init_interface, BFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(H5Aatom_group(tid)!=H5_DATATYPE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check the base type of the datatype */
- ret_value=H5T_is_atomic(dt);
-
-done:
- if(ret_value == BFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tis_atomic() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tset_type
- PURPOSE
- Set the base type of a user-defined datatype
- USAGE
- herr_t H5Tset_type(tid, base, len, arch)
- hid_t tid; IN: Datatype object to modify
- hid_t base; IN: Base type to set the datatype to
- uint8 len; IN: Length of the object in bytes
- uint8 arch; IN: Architecture format to store type with
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function sets the basic type of a user-defined datatype. Each
- datatype is either an atomic type (i.e. has no further divisions of the
- type) or is a compound type (like a C structure). If the datatype is set
- to a compound type, the 'len' argument is not used.
---------------------------------------------------------------------------*/
-herr_t H5Tset_type(hid_t tid,hid_t base,uint8 len,uint8 arch)
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER (H5Tget_class, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(dt=H5Aatom_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+
+ FUNC_LEAVE (dt->type);
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tget_size
+ *
+ * Purpose: Determines the total size of a data type in bytes.
+ *
+ * Return: Success: Size of the data type in bytes. The size of
+ * data type is the size of an instance of that
+ * data type.
+ *
+ * Failure: 0 (valid data types are never zero size)
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5Tget_size (hid_t type_id)
{
- h5_datatype_t *dt; /* new data-type object to create */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Tset_type, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(base<H5T_CHAR || base>H5T_COMPOUND)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- if(dt->dt.base!=0)
- HGOTO_ERROR(H5E_FUNC, H5E_ALREADYINIT, FAIL);
-
- /* Set the basic datatype information */
- dt->dt.base=base;
- dt->dt.len=len;
- dt->dt.arch=arch;
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tset_type() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tget_type
- PURPOSE
- Get the base type of a datatype
- USAGE
- herr_t H5Tget_type(tid, base, len, arch)
- hid_t tid; IN: Datatype object to modify
- hid_t *base; IN: Base type of the datatype
- uint8 *len; IN: Length of the object in bytes
- uint8 *arch; IN: Architecture format type stored with
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function gets the basic type of a user-defined datatype. Each
- datatype is either an atomic type (i.e. has no further divisions of the
- type) or is a compound type (like a C structure). If the datatype is
- to a compound type, the 'len' argument is not used.
---------------------------------------------------------------------------*/
-herr_t H5Tget_type(hid_t tid,hid_t *base,uint8 *len,uint8 *arch)
+ H5T_t *dt = NULL;
+ size_t size;
+
+ FUNC_ENTER (H5Tget_size, 0);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(dt=H5Aatom_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+
+ /* size */
+ size = H5T_get_size (dt);
+
+ FUNC_LEAVE (size);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_get_size
+ *
+ * Purpose: Determines the total size of a data type in bytes.
+ *
+ * Return: Success: Size of the data type in bytes. The size of
+ * the data type is the size of an instance of
+ * that data type.
+ *
+ * Failure: 0 (valid data types are never zero size)
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5T_get_size (const H5T_t *dt)
{
- h5_datatype_t *dt; /* new data-type object to create */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Tget_type, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(H5Aatom_group(tid)!=H5_DATATYPE)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- if(dt->dt.base==0)
- HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL);
-
- /* Set the basic datatype information */
- if(base!=NULL)
- *base=dt->dt.base;
- if(len!=NULL)
- *len=dt->dt.len;
- if(arch!=NULL)
- *arch=dt->dt.arch;
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tget_type() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tadd_field
- PURPOSE
- Add a field to a compound datatype
- USAGE
- herr_t H5Tadd_field(tid, name, base, len, arch, space)
- hid_t tid; IN: Datatype object to query
- const char *fidx; IN: Field name
- hid_t base; IN: Field's base type, either an atom ID for
- an existing compound type, or an atomic
- base type
- uint8 len; IN: Length of an atomic base type
- uint8 arch; IN: Architecture format of an atomic base type
- hid_t space; IN: The dimensionality of the field to add
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function adds a field to a user-defined compound datatype. The
- field can either be a base/len/arch triplet or an existing compound type
- (passed in the base argument). The space parameter is either H5P_SCALAR
- (to indicate a scalar field) or the atom of a datatype for more complex
- dimensionality fields.
---------------------------------------------------------------------------*/
-herr_t H5Tadd_field(hid_t tid, const char *name, hid_t base, uint8 len, uint8 arch, hid_t space)
+ FUNC_ENTER (H5T_get_size, 0);
+
+ /* check args */
+ assert (dt);
+
+ FUNC_LEAVE (dt->size);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tinsert_member
+ *
+ * Purpose: Adds another member to the compound data type PARENT_ID. The
+ * new member has a NAME which must be unique within the
+ * compound data type. The OFFSET argument defines the start of
+ * the member in an instance of the compound data type, and
+ * MEMBER_ID is the type of the new member.
+ *
+ * Note: All members of a compound data type must be atomic; a
+ * compound data type cannot have a member which is a compound
+ * data type.
+ *
+ * Return: Success: SUCCEED, the PARENT_ID compound data type is
+ * modified to include a copy of the member type
+ * MEMBER_ID.
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tinsert_member (hid_t parent_id, const char *name, off_t offset,
+ hid_t member_id)
{
- h5_field_info_t *new_field; /* pointer to new field to add */
- h5_datatype_t *dt; /* data-type object to manipulate */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5Tadd_field, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- /* Check the base type of the datatype */
- if(H5T_COMPOUND!=dt->dt.base)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
-
- /* Check if the compound information has been initialized */
- if(NULL==dt->ci)
- {
- if(NULL==(dt->ci=HDmalloc(sizeof(h5_compound_info_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- dt->ci->n=0; /* Set the number of fields to 0 */
- dt->ci->mem_size=0; /* Set the size of the structure */
- dt->ci->disk_size=0; /* Set the size of the structure */
- dt->ci->flist=NULL; /* No field information yet */
- } /* end if */
-
- if(NULL==(new_field=HDrealloc(dt->ci->flist,(dt->ci->n+1)*sizeof(h5_field_info_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
- dt->ci->n++; /* increment the number of fields */
- dt->ci->flist=new_field; /* save the pointer to the increased array of fields */
- new_field=&dt->ci->flist[dt->ci->n-1]; /* get a "convenience" pointer to the new field */
-
- new_field->name=HDstrdup(name); /* copy the name */
- new_field->name_off=0; /* name isn't stored yet */
- new_field->struct_off=dt->ci->disk_size; /* Set the offset of the field on disk */
- new_field->dim_id=H5Mcopy(space); /* Make a copy of the dimension space for the field */
- if((H5Ais_reserved(base)==BTRUE) && base!=H5T_COMPOUND) /* Check if this is a "simple" datatype */
- {
- new_field->dt.base=base; /* Make a copy of the datatype for the field */
- new_field->dt.len=len;
- new_field->dt.arch=arch;
- } /* end if */
- else
- {
- new_field->dt.base=H5Mcopy(base); /* Make a copy of the datatype for the field */
- new_field->dt.len=H5Tsize(base,BTRUE);
- new_field->dt.arch=arch;
- } /* end else */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tadd_field() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_size
- PURPOSE
- Determine the size of a datatype (internal)
- USAGE
- uintn H5T_size(dt, mem_flag)
- h5_datatype_t *dt; IN: Pointer to Datatype object to query
- hbool_t mem_flag; IN: Whether the memory or disk size is desired
- RETURNS
- The size of the datatype on success or UFAIL on failure.
- DESCRIPTION
- Ths function returns the size of the datatype in bytes as it is stored
- on disk or in memory, depending on the mem_flag. Setting the mem_flag to
- BTRUE returns the size in memory, BFALSE returns the size on disk.
---------------------------------------------------------------------------*/
-uintn H5T_size(h5_datatype_t *dt, hbool_t mem_flag)
+ H5T_t *parent = NULL; /*the compound parent data type */
+ H5T_t *member = NULL; /*the atomic member type */
+
+ FUNC_ENTER (H5Tinsert_member, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE!=H5Aatom_group (parent_id) ||
+ NULL==(parent=H5Aatom_object (parent_id)) ||
+ H5T_COMPOUND!=parent->type) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a compound data type*/
+ }
+ if (parent->locked) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*parent is locked*/
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*no member name*/
+ }
+ if (H5_DATATYPE!=H5Aatom_group (member_id) ||
+ NULL==(member=H5Aatom_object (member_id)) ||
+ H5T_COMPOUND==member->type) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not an atomic data type*/
+ }
+
+ if (H5T_insert_member (parent, name, offset, member)<0) {
+ /* Can't insert member. */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINSERT, FAIL);
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_insert_member
+ *
+ * Purpose: Adds a new MEMBER to the compound data type PARENT. The new
+ * member will have a NAME that is unique within PARENT and an
+ * instance of PARENT will have the member begin at byte offset
+ * OFFSET from the beginning.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_insert_member (H5T_t *parent, const char *name, off_t offset,
+ const H5T_t *member)
{
- uintn ret_value = UFAIL;
-
- FUNC_ENTER(H5T_size, H5T_init_interface, UFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- assert(dt);
-
- if(dt->dt.base==H5T_COMPOUND)
- {
- intn i; /* local counting variable */
-
- /* Check the base type of the datatype */
- if(H5T_COMPOUND!=dt->dt.base)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);
-
- /* Check if the compound information has been initialized */
- if(NULL==dt->ci)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, FAIL);
-
- /* Grab the number of fields */
- for(i=0; i<=dt->ci->n; i++)
- ret_value+=H5Tsize(dt->ci->flist[i].dt.base,mem_flag)*H5Pnelem(dt->ci->flist[i].dim_id);
- } /* end if */
- else
- { /* Simple, user-defined datatypes */
- switch(dt->dt.base)
- {
- case H5T_CHAR:
- case H5T_INT:
- case H5T_FLOAT: /* All three of thes types use the length as the number of bytes */
- ret_value=dt->dt.len;
- break;
-
- case H5T_DATE:
- ret_value=8; /* Number of characters for ISO 8601 format */
- break;
-
- case H5T_TIME:
- ret_value=6; /* Number of characters for ISO 8601 format */
- break;
-
- case H5T_SPTR:
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
- break;
-
- case H5T_PPTR:
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL);
- } /* end switch */
- } /* end else */
-
-done:
- if(ret_value == UFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5T_size() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tsize
- PURPOSE
- Determine the size of a datatype
- USAGE
- uintn H5Tsize(tid, mem_flag)
- hid_t tid; IN: Datatype object to query
- hbool_t mem_flag; IN: Whether the memory or disk size is desired
- RETURNS
- The size of the datatype on success or UFAIL on failure.
- DESCRIPTION
- This function returns the size of the datatype in bytes as it is stored
- on disk or in memory, depending on the mem_flag. Setting the mem_flag to
- BTRUE returns the size in memory, BFALSE returns the size on disk.
- NOTE:
- This function does not compute the number of bytes for a predefined
- library type (ie. H5T_CHAR, H5T_INT) which has not been "named" by the
- user as field or new type.
---------------------------------------------------------------------------*/
-uintn H5Tsize(hid_t tid, hbool_t mem_flag)
+ intn i;
+ H5T_t *tmp = NULL;
+
+ FUNC_ENTER (H5T_insert_member, FAIL);
+
+ /* check args */
+ assert (parent && H5T_COMPOUND==parent->type);
+ assert (!parent->locked);
+ assert (member && H5T_COMPOUND!=member->type);
+ assert (name && *name);
+
+ /* Does NAME already exist in PARENT? */
+ for (i=0; i<parent->u.compnd.nmembs; i++) {
+ if (!HDstrcmp (parent->u.compnd.memb[i].name, name)) {
+ /* Member name is not unique */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINSERT, FAIL);
+ }
+ }
+
+ /* Increase member array if necessary */
+ if (parent->u.compnd.nmembs>=parent->u.compnd.nalloc) {
+ parent->u.compnd.nalloc += H5T_COMPND_INC;
+ parent->u.compnd.memb = H5MM_xrealloc (parent->u.compnd.memb,
+ (parent->u.compnd.nalloc*
+ sizeof(H5T_member_t)));
+ }
+
+ /* Add member to end of member array */
+ i = parent->u.compnd.nmembs;
+ parent->u.compnd.memb[i].name = H5MM_xstrdup (name);
+ parent->u.compnd.memb[i].offset = offset;
+ parent->u.compnd.memb[i].ndims = 0; /*defaults to scalar*/
+
+ tmp = H5T_copy (member);
+ parent->u.compnd.memb[i].type = *tmp;
+ H5MM_xfree (tmp);
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tcopy
+ *
+ * Purpose: Copies a data type. The resulting data type is not locked.
+ *
+ * Return: Success: The ID of a new data type.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Tcopy (hid_t type_id)
{
- uintn ret_value = UFAIL;
-
- FUNC_ENTER(H5Tsize, H5T_init_interface, UFAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- if((H5Ais_reserved(tid)==BTRUE) && tid!=H5T_COMPOUND) /* Check if this is a "simple" datatype */
- {
-#ifdef LATER
- switch(tid)
- {
- case H5T_CHAR:
- case H5T_INT:
- case H5T_FLOAT: /* All three of thes types use the length as the number of bytes */
- ret_value=len;
- break;
-
- case H5T_DATE:
- ret_value=8; /* Number of characters for ISO 8601 format */
- break;
-
- case H5T_TIME:
- ret_value=6; /* Number of characters for ISO 8601 format */
- break;
-
- case H5T_SPTR:
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
- break;
-
- case H5T_PPTR:
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, UFAIL);
- break;
-
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL);
- } /* end switch */
-#endif /* LATER */
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL);
- } /* end if */
- else
- {
- h5_datatype_t *dt; /* datatype pointer */
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- ret_value=H5T_size(dt,mem_flag);
- } /* end else */
-
-done:
- if(ret_value == UFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tsize() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_arch
- PURPOSE
- Determine the architecture of a datatype (internal)
- USAGE
- uintn H5T_arch(dt)
- h5_datatype_t *dt; IN: Pointer to Datatype object to query
- RETURNS
- The architure type of the datatype on success or FAIL on failure.
- DESCRIPTION
- Ths function returns the architure type of the datatype.
---------------------------------------------------------------------------*/
-intn H5T_arch(h5_datatype_t *dt)
+ H5T_t *dt = NULL;
+ H5T_t *new_dt = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER (H5Tcopy, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(dt=H5Aatom_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+
+ /* copy */
+ if (NULL==(new_dt = H5T_copy (dt))) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL); /*can't copy*/
+ }
+
+ /* atomize result */
+ if ((ret_value=H5Aregister_atom (H5_DATATYPE, new_dt))<0) {
+ H5T_close (new_dt);
+ /* Can't register data type atom */
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL);
+ }
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_copy
+ *
+ * Purpose: Copies datatype OLD_DT. The resulting data type is not
+ * locked.
+ *
+ * Return: Success: Pointer to a new copy of the OLD_DT argument.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_copy (const H5T_t *old_dt)
{
- intn ret_value = FAIL;
-
- FUNC_ENTER(H5T_arch, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- assert(dt);
-
- ret_value=dt->dt.arch;
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
+ H5T_t *new_dt = NULL;
+ intn i;
+ char *s;
+
+ FUNC_ENTER (H5T_copy, NULL);
- FUNC_LEAVE(ret_value);
-} /* end H5T_arch() */
+ /* check args */
+ assert (old_dt);
-/*--------------------------------------------------------------------------
- NAME
- H5Tarch
- PURPOSE
- Determine the architecture of a datatype
- USAGE
- intn H5Tarch(tid)
- hid_t tid; IN: Datatype object to query
- RETURNS
- The architecture of the datatype on success or FAIL on failure.
- DESCRIPTION
- Ths function returns the architecture of the datatype.
---------------------------------------------------------------------------*/
-intn H5Tarch(hid_t tid)
+ /* copy */
+ new_dt = H5MM_xcalloc (1, sizeof(H5T_t));
+ *new_dt = *old_dt;
+ new_dt->locked = FALSE;
+
+ if (H5T_COMPOUND==new_dt->type) {
+ new_dt->u.compnd.memb = H5MM_xmalloc (new_dt->u.compnd.nmembs *
+ sizeof(H5T_member_t));
+ HDmemcpy (new_dt->u.compnd.memb, old_dt->u.compnd.memb,
+ new_dt->u.compnd.nmembs * sizeof(H5T_member_t));
+ for (i=0; i<new_dt->u.compnd.nmembs; i++) {
+ s = new_dt->u.compnd.memb[i].name;
+ new_dt->u.compnd.memb[i].name = H5MM_xstrdup (s);
+ }
+ }
+
+ FUNC_LEAVE (new_dt);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tclose
+ *
+ * Purpose: Frees a data type and all associated memory.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tclose (hid_t type_id)
{
- h5_datatype_t *dt; /* datatype pointer */
- intn ret_value = FAIL;
-
- FUNC_ENTER(H5Tarch, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Go get the object */
- if((dt=H5Aatom_object(tid))==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
- ret_value=H5T_arch(dt);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tarch() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5Tget_fields
- PURPOSE
- Determine the size of a datatype
- USAGE
- herr_t H5Tget_fields(tid, field_list)
- hid_t tid; IN: Datatype object to query
- hoid_t *field_list; IN: Array to store list of fields
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- Ths function returns a list of OIDs for the fields in a compound
- datatype. Atomic fields are returned in the list of OIDs, but have special
- OID values which cannot be further dereferenced.
---------------------------------------------------------------------------*/
-herr_t H5Tget_fields(hid_t tid, hid_t *field_list)
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER (H5Tclose, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_DATATYPE!=H5Aatom_group (type_id) ||
+ NULL==(dt=H5Aatom_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+ if (dt->locked) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*predefined data type*/
+ }
+
+ /* When the reference count reaches zero the resources are freed */
+ if (H5A_dec_ref (type_id)<0) {
+ HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*problem freeing id*/
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_close
+ *
+ * Purpose: Frees a data type and all associated memory.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_close (H5T_t *dt)
{
- herr_t ret_value = FAIL;
-
- FUNC_ENTER(H5Tget_fields, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
- if(H5Aatom_group(tid)!=H5_DATATYPE)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
- if(field_list==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
-
-done:
- if(ret_value == UFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5Tget_fields() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_destroy
- PURPOSE
- Private function to destroy datatype objects.
- USAGE
- void H5T_destroy(datatype)
- void *datatype; IN: Pointer to datatype object to destroy
- RETURNS
- none
- DESCRIPTION
- This function releases whatever memory is used by a datatype object.
- It should only be called from the atom manager when the reference count
- for a datatype drops to zero.
---------------------------------------------------------------------------*/
-void H5T_destroy(void *datatype)
+ intn i;
+
+ FUNC_ENTER (H5T_close, FAIL);
+
+ assert (dt);
+ assert (!dt->locked);
+
+ if (dt && H5T_COMPOUND==dt->type) {
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ H5MM_xfree (dt->u.compnd.memb[i].name);
+ }
+ H5MM_xfree (dt->u.compnd.memb);
+ H5MM_xfree (dt);
+
+ } else if (dt) {
+ H5MM_xfree (dt);
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tequal
+ *
+ * Purpose: Determines if two data types are equal.
+ *
+ * Return: Success: TRUE if equal, FALSE if unequal
+ *
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 10, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5Tequal (hid_t type1_id, hid_t type2_id)
{
- h5_datatype_t *dt=(h5_datatype_t *)datatype; /* data-type object to destroy */
-
- /* Don't call standard init/leave code, this is a private void function */
- /* FUNC_ENTER(H5T_destroy, H5T_init_interface, FAIL); */
-
- if(dt->name!=NULL)
- HDfree(dt->name);
- if(dt->ci!=NULL)
- {
- } /* end if */
- HDfree(dt);
-
-#ifdef LATER
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
- FUNC_LEAVE(ret_value);
-#endif /* LATER */
-
-} /* H5T_destroy */
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_release
- PURPOSE
- Release access to an HDF5 datatype object.
- USAGE
- herr_t H5T_release(oid)
- hid_t oid; IN: Object to release access to
- RETURNS
- SUCCEED/FAIL
- DESCRIPTION
- This function releases a datatype from active use by a user.
---------------------------------------------------------------------------*/
-herr_t H5T_release(hid_t oid)
+ const H5T_t *dt1 = NULL;
+ const H5T_t *dt2 = NULL;
+ hbool_t ret_value = FAIL;
+
+ FUNC_ENTER (H5Tequal, FAIL);
+
+ /* check args */
+ if (H5_DATATYPE!=H5Aatom_group (type1_id) ||
+ NULL==(dt1=H5Aatom_object (type1_id)) ||
+ H5_DATATYPE!=H5Aatom_group (type2_id) ||
+ NULL==(dt2=H5Aatom_object (type2_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL); /*not a data type*/
+ }
+
+ ret_value = (0==H5T_cmp (dt1, dt2));
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_cmp
+ *
+ * Purpose: Compares two data types.
+ *
+ * Return: Success: 0 if DT1 and DT2 are equal.
+ * <0 if DT1 is less than DT2.
+ * >0 if DT1 is greater than DT2.
+ *
+ * Failure: 0, never fails
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 10, 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+intn
+H5T_cmp (const H5T_t *dt1, const H5T_t *dt2)
{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER(H5T_release, H5T_init_interface, FAIL);
-
- /* Clear errors and check args and all the boring stuff. */
- H5ECLEAR;
-
- /* Chuck the object! :-) */
- if(H5Adec_ref(oid)==FAIL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE(ret_value);
-} /* end H5T_release() */
+ intn *idx1=NULL, *idx2=NULL;
+ intn ret_value = 0;
+ intn i, j, tmp;
+ hbool_t swapped;
+
+ FUNC_ENTER (H5T_equal, 0);
+
+ /* check args */
+ assert (dt1);
+ assert (dt2);
+
+ /* the easy case */
+ if (dt1==dt2) HGOTO_DONE (0);
+
+ /* compare */
+ if (dt1->type < dt2->type) HGOTO_DONE (-1);
+ if (dt1->type > dt2->type) HGOTO_DONE (1);
+
+ if (dt1->size < dt2->size) HGOTO_DONE (-1);
+ if (dt1->size > dt2->size) HGOTO_DONE (1);
+
+ if (H5T_COMPOUND==dt1->type) {
+ /*
+ * Compound data types...
+ */
+ if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) HGOTO_DONE (-1);
+ if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE (1);
+
+ /* Build an index for each type so the names are sorted */
+ idx1 = H5MM_xmalloc (dt1->u.compnd.nmembs * sizeof(intn));
+ idx2 = H5MM_xmalloc (dt1->u.compnd.nmembs * sizeof(intn));
+ for (i=0; i<dt1->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i;
+ for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp (dt1->u.compnd.memb[idx1[j]].name,
+ dt1->u.compnd.memb[idx1[j+1]].name)>0) {
+ tmp = idx1[j];
+ idx1[j] = idx1[j+1];
+ idx1[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+ for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp (dt2->u.compnd.memb[idx2[j]].name,
+ dt2->u.compnd.memb[idx2[j+1]].name)>0) {
+ tmp = idx2[j];
+ idx2[j] = idx2[j+1];
+ idx2[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+
+#ifndef NDEBUG
+ for (i=0; i<dt1->u.compnd.nmembs; i++) {
+ assert (HDstrcmp (dt1->u.compnd.memb[idx1[i]].name,
+ dt1->u.compnd.memb[idx1[i+1]].name));
+ assert (HDstrcmp (dt2->u.compnd.memb[idx2[i]].name,
+ dt2->u.compnd.memb[idx2[i+1]].name));
+ }
+#endif
+ /* Compare the members */
+ for (i=0; i<dt1->u.compnd.nmembs; i++) {
+ tmp = HDstrcmp (dt1->u.compnd.memb[idx1[i]].name,
+ dt2->u.compnd.memb[idx2[i]].name);
+ if (tmp<0) HGOTO_DONE (-1);
+ if (tmp>0) HGOTO_DONE (1);
+
+ if (dt1->u.compnd.memb[idx1[i]].offset <
+ dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE (-1);
+ if (dt1->u.compnd.memb[idx1[i]].offset >
+ dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE (1);
+
+ if (dt1->u.compnd.memb[idx1[i]].ndims <
+ dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE (-1);
+ if (dt1->u.compnd.memb[idx1[i]].ndims >
+ dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE (1);
+
+ for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
+ if (dt1->u.compnd.memb[idx1[i]].dim[j] <
+ dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE (-1);
+ if (dt1->u.compnd.memb[idx1[i]].dim[j] >
+ dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE (1);
+ }
+
+ for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
+ if (dt1->u.compnd.memb[idx1[i]].perm[j] <
+ dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE (-1);
+ if (dt1->u.compnd.memb[idx1[i]].perm[j] >
+ dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE (1);
+ }
+
+ tmp = H5T_cmp (&(dt1->u.compnd.memb[idx1[i]].type),
+ &(dt2->u.compnd.memb[idx2[i]].type));
+ if (tmp<0) HGOTO_DONE (-1);
+ if (tmp>0) HGOTO_DONE (1);
+ }
+
+ } else {
+ /*
+ * Atomic data types...
+ */
+ if (dt1->u.atomic.order < dt2->u.atomic.order) HGOTO_DONE (-1);
+ if (dt1->u.atomic.order > dt2->u.atomic.order) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.prec < dt2->u.atomic.prec) HGOTO_DONE (-1);
+ if (dt1->u.atomic.prec > dt2->u.atomic.prec) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.offset < dt2->u.atomic.offset) HGOTO_DONE (-1);
+ if (dt1->u.atomic.offset > dt2->u.atomic.offset) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.lo_pad < dt2->u.atomic.lo_pad) HGOTO_DONE (-1);
+ if (dt1->u.atomic.lo_pad > dt2->u.atomic.lo_pad) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.hi_pad < dt2->u.atomic.hi_pad) HGOTO_DONE (-1);
+ if (dt1->u.atomic.hi_pad > dt2->u.atomic.hi_pad) HGOTO_DONE (1);
+
+ switch (dt1->type) {
+ case H5T_FIXED:
+ if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) HGOTO_DONE (1);
+ break;
+
+ case H5T_FLOAT:
+ if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.esize <
+ dt2->u.atomic.u.f.esize) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.esize >
+ dt2->u.atomic.u.f.esize) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.ebias <
+ dt2->u.atomic.u.f.ebias) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.ebias >
+ dt2->u.atomic.u.f.ebias) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.msize <
+ dt2->u.atomic.u.f.msize) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.msize >
+ dt2->u.atomic.u.f.msize) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) HGOTO_DONE (1);
+
+ break;
+
+ case H5T_DATE:
+ /*void*/
+ break;
+
+ case H5T_STRING:
+ if (dt1->u.atomic.u.s.cset < dt1->u.atomic.u.s.cset) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.s.cset > dt1->u.atomic.u.s.cset) HGOTO_DONE (1);
+
+ if (dt1->u.atomic.u.s.spad < dt1->u.atomic.u.s.spad) HGOTO_DONE (-1);
+ if (dt1->u.atomic.u.s.spad > dt1->u.atomic.u.s.spad) HGOTO_DONE (1);
+
+ break;
+
+ case H5T_BITFIELD:
+ /*void*/
+ break;
+
+ case H5T_OPAQUE:
+ /*void*/
+ break;
+
+ default:
+ assert ("not implemented yet" && 0);
+ }
+ }
+
+ done:
+ H5MM_xfree (idx1);
+ H5MM_xfree (idx2);
+
+ FUNC_LEAVE (ret_value);
+}
+
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
new file mode 100644
index 0000000..1267e83
--- /dev/null
+++ b/src/H5Tpkg.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 1997 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Monday, December 8, 1997
+ *
+ * Purpose: This file contains declarations which are visible only within
+ * the H5T package. Source files outside the H5T package should
+ * include H5Tprivate.h instead.
+ */
+#ifndef H5T_PACKAGE
+#error "Do not include this file outside the H5T package!"
+#endif
+
+#ifndef _H5Tpkg_H
+#define _H5Tpkg_H
+
+#include <H5Tprivate.h>
+
+typedef struct H5T_atomic_t {
+ H5T_order_t order; /*byte order */
+ size_t prec; /*precision in bits */
+ size_t offset; /*bit position of lsb of value */
+ intn lo_pad; /*type of lsb padding */
+ intn hi_pad; /*type of msb padding */
+ union {
+ struct {
+ H5T_sign_t sign; /*type of fixed-point sign */
+ } i; /*integer; fixed-point types */
+
+ struct {
+ size_t sign; /*bit position of sign bit */
+ size_t epos; /*position of lsb of exponent */
+ size_t esize; /*size of exponent in bits */
+ uint64 ebias; /*exponent bias */
+ size_t mpos; /*position of lsb of mantissa */
+ size_t msize; /*size of mantissa */
+ H5T_norm_t norm; /*normalization */
+ intn pad; /*type of padding for internal bits */
+ } f; /*floating-point types */
+
+ struct {
+ H5T_cset_t cset; /*character set */
+ H5T_str_t spad; /*space or null padding of extra bytes */
+ } s;
+ } u;
+} H5T_atomic_t;
+
+typedef struct H5T_compnd_t {
+ intn nalloc; /*num entries allocated in MEMB array */
+ intn nmembs; /*number of members defined in struct */
+ struct H5T_member_t *memb; /*array of struct members */
+} H5T_compnd_t;
+
+struct H5T_t {
+ hbool_t locked; /*if locked, then can't be modified */
+ H5T_class_t type; /*which class of type is this? */
+ size_t size; /*total size of an instance of this type*/
+ union {
+ H5T_atomic_t atomic; /*an atomic data type */
+ H5T_compnd_t compnd; /*a compound data type (struct) */
+ } u;
+};
+
+typedef struct H5T_member_t {
+ char *name; /*name of this member */
+ size_t offset; /*offset from beginning of struct */
+ intn ndims; /*member dimensionality */
+ size_t dim[4]; /*size in each dimension */
+ size_t perm[4];/*index permutation */
+ struct H5T_t type; /*type of this member */
+} H5T_member_t;
+
+
+#endif
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 3483405..5a9fbcb 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.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$ */
@@ -22,40 +22,23 @@
/* Private headers needed by this file */
#include <H5private.h>
-#include <H5Cprivate.h> /*for hobjtype_t defn*/
+#include <H5Gprivate.h> /*for H5G_entry_t */
#define H5T_RESERVED_ATOMS 8
-/* Structure for storing information about a field in a compound datatype */
-typedef struct {
- char *name; /* Name of the field */
- uintn name_off; /* Offset of name in global small-data heap */
- uintn struct_off; /* Offset of field within structure */
- h5_atomic_type_t dt; /* Datatype of the field */
- hid_t dim_id; /* dimensionality ID of the field */
- } h5_field_info_t;
-
-/* Structure for storing information about a compound datatype */
-typedef struct {
- uintn n; /* Number of fields */
- uintn mem_size; /* Size of the compound structure in memory */
- uintn disk_size; /* Size of the compound structure on disk */
- h5_field_info_t *flist; /* List of fields in the compound object */
- } h5_compound_info_t;
-
-/* Structure for storing information any datatype */
-typedef struct {
- h5_atomic_type_t dt; /* Base type of this object */
- char *name; /* Name of datatype */
- h5_compound_info_t *ci; /* Information for compound datatypes */
- } h5_datatype_t;
+typedef struct H5T_t H5T_t;
+
+herr_t H5T_init (void);
-/* Private functions */
-herr_t H5T_init(void);
-hid_t H5T_create(hid_t owner_id, hobjtype_t type, const char *name);
-hbool_t H5T_is_atomic(h5_datatype_t *type);
-uintn H5T_size(h5_datatype_t *dt, hbool_t mem_flag);
-intn H5T_arch(h5_datatype_t *dt);
-herr_t H5T_release(hid_t oid);
+/* Private functions */
+herr_t H5T_init_interface (void);
+H5T_t *H5T_create (H5T_class_t type, size_t size);
+H5T_t *H5T_copy (const H5T_t *old_dt);
+herr_t H5T_close (H5T_t *dt);
+size_t H5T_get_size (const H5T_t *dt);
+intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2);
+
+herr_t H5T_insert_member (H5T_t *parent, const char *name, off_t offset,
+ const H5T_t *member);
#endif
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 10f86b5..f1bbe9e 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -23,62 +23,89 @@
#include <H5public.h>
#include <H5Apublic.h>
-/* Define atomic datatype bases */
-#define H5T_CHAR MAKE_ATOM(H5_DATATYPE,0)
-#define H5T_INT MAKE_ATOM(H5_DATATYPE,1)
-#define H5T_FLOAT MAKE_ATOM(H5_DATATYPE,2)
-#define H5T_DATE MAKE_ATOM(H5_DATATYPE,3)
-#define H5T_TIME MAKE_ATOM(H5_DATATYPE,4)
-#define H5T_SPTR MAKE_ATOM(H5_DATATYPE,5)
-#define H5T_PPTR MAKE_ATOM(H5_DATATYPE,6)
-#define H5T_COMPOUND MAKE_ATOM(H5_DATATYPE,7)
-
-/* Define atomic datatype architectures */
-#define H5T_BIGENDIAN 0
-#define H5T_LITTLEENDIAN 1
-
-/* Define the machine's architecture */
-/*
-WARNING!
- This is _extremly_ crude is is only valid for very generic architectures,
- anything with a wierd size of integer or wacky floating-point format will
- _not_ work with this hack. It needs to be replaced with Robb's much more
- comprehensive code from H5detect.c. -QAK
-WARNING!
-*/
-#define H5T_ARCH_BIGENDIAN 0
-#define H5T_ARCH_LITTLEENDIAN 1
-#ifdef WORDS_BIGENDIAN
-#define H5T_ARCH_TYPE H5T_ARCH_BIGENDIAN
-#else /* WORDS_BIGENDIAN */
-#define H5T_ARCH_TYPE H5T_ARCH_LITTLEENDIAN
-#endif /* WORDS_BIGENDIAN */
-
-typedef struct {
- hid_t base; /* Basic datatype */
- uint8 len; /* Length of base-type, in bytes */
- uint8 arch; /* Architecture of the base-type */
- } h5_atomic_type_t;
+/* These are the various classes of data types */
+typedef enum H5T_class_t {
+ H5T_NO_CLASS =-1, /*error */
+ H5T_FIXED =0, /*fixed-point types */
+ H5T_FLOAT =1, /*floating-point types */
+ H5T_DATE =2, /*date and time types */
+ H5T_STRING =3, /*character string types */
+ H5T_BITFIELD =4, /*bit field types */
+ H5T_OPAQUE =5, /*opaque types */
+ H5T_COMPOUND =6 /*compound types */
+} H5T_class_t;
+
+/* Byte orders */
+typedef enum H5T_order_t {
+ H5T_ORDER_ERROR =-1, /*error */
+ H5T_ORDER_LE =0, /*little endian */
+ H5T_ORDER_BE =1, /*bit endian */
+ H5T_ORDER_VAX =2, /*VAX mixed endian */
+ H5T_ORDER_NONE =3 /*no particular order (strings, bits,..)*/
+} H5T_order_t;
+
+/* Types of fixed-point sign schemes */
+typedef enum H5T_sign_t {
+ H5T_SGN_ERROR =-1, /*error */
+ H5T_SGN_NONE =0, /*this is an unsigned type */
+ H5T_SGN_2 =1 /*two's complement */
+} H5T_sign_t;
+
+/* Floating-point normalization schemes */
+typedef enum H5T_norm_t {
+ H5T_NORM_ERROR =-1, /*error */
+ H5T_NORM_IMPLIED =0, /*msb of mantissa isn't stored, always 1*/
+ H5T_NORM_MSBSET =1, /*msb of mantissa is always 1 */
+ H5T_NORM_NONE =2 /*not normalized */
+} H5T_norm_t;
+
+/* Character set to use for text strings */
+typedef enum H5T_cset_t {
+ H5T_CSET_ERROR =-1, /*error */
+ H5T_CSET_ASCII =0 /*US ASCII */
+} H5T_cset_t;
+
+/* Type of padding to use in character strings */
+typedef enum H5T_str_t {
+ H5T_STR_ERROR =-1, /*error */
+ H5T_STR_NULL =0, /*pad with null term like in C */
+ H5T_STR_SPACE =1, /*pad with spaces like in Fortran */
+} H5T_str_t;
+
+
+
+#define H5T_PAD_ZERO (-1) /*pad with all zeros */
+#define H5T_PAD_ONE (-2) /*pad with all ones */
+#define H5T_PAD_FROM(X) (X) /*pad with value of bit X */
+
+/* The predefined types */
+extern hid_t H5T_NATIVE_CHAR;
+extern hid_t H5T_NATIVE_UCHAR;
+extern hid_t H5T_NATIVE_SHORT;
+extern hid_t H5T_NATIVE_USHORT;
+extern hid_t H5T_NATIVE_INT;
+extern hid_t H5T_NATIVE_UINT;
+extern hid_t H5T_NATIVE_LONG;
+extern hid_t H5T_NATIVE_ULONG;
+extern hid_t H5T_NATIVE_FLOAT;
+extern hid_t H5T_NATIVE_DOUBLE;
#ifdef __cplusplus
extern "C" {
#endif
-/* Functions in H5T.c */
-uint32 H5Tget_num_fields(hid_t tid);
-hbool_t H5Tis_field_atomic(hid_t tid,uintn fidx);
-hbool_t H5Tis_atomic(hid_t tid);
-herr_t H5Tset_type(hid_t tid,hid_t base,uint8 len,uint8 arch);
-herr_t H5Tget_type(hid_t tid,hid_t *base,uint8 *len,uint8 *arch);
-uintn H5Tsize(hid_t tid, hbool_t mem_flag);
-intn H5Tarch(hid_t tid);
-herr_t H5Tadd_field (hid_t tid, const char *name, hid_t base, uint8 len,
- uint8 arch, hid_t space);
-herr_t H5Tget_fields(hid_t tid, hid_t *field_list);
-
-/* Private functions which need to be globally visible */
-void H5T_term_interface (void);
-void H5T_destroy(void *datatype);
+hid_t H5Tcreate (H5T_class_t type, size_t size);
+hid_t H5Tcopy (hid_t type_id);
+herr_t H5Tclose (hid_t type_id);
+hbool_t H5Tequal (hid_t type1_id, hid_t type2_id);
+
+H5T_class_t H5Tget_class (hid_t type_id);
+size_t H5Tget_size (hid_t type_id);
+intn H5Tget_num_members (hid_t type_id);
+
+herr_t H5Tinsert_member (hid_t parent_id, const char *name, off_t offset,
+ hid_t member_id);
+
#ifdef __cplusplus
}
diff --git a/src/H5V.c b/src/H5V.c
index 7612ad9..d079399 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -14,6 +14,7 @@
#define H5V_HYPER_NDIMS H5O_ISTORE_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);
@@ -48,7 +49,7 @@ static herr_t
H5V_stride_optimize1 (size_t *np, size_t *elmt_size, size_t *size,
intn *stride1)
{
- FUNC_ENTER (H5V_stride_optimize1, NULL, FAIL);
+ FUNC_ENTER (H5V_stride_optimize1, FAIL);
/*
* This has to be true because if we optimize the dimensionality down to
@@ -97,7 +98,7 @@ static herr_t
H5V_stride_optimize2 (size_t *np, size_t *elmt_size, size_t *size,
intn *stride1, intn *stride2)
{
- FUNC_ENTER (H5V_stride_optimize2, NULL, FAIL);
+ FUNC_ENTER (H5V_stride_optimize2, FAIL);
/*
* This has to be true because if we optimize the dimensionality down to
@@ -154,7 +155,7 @@ H5V_hyper_stride (size_t n, const size_t *size,
size_t acc; /*accumulator */
int i; /*counter */
- FUNC_ENTER (H5V_hyper_stride, NULL, (abort(),0));
+ FUNC_ENTER (H5V_hyper_stride, (abort(),0));
assert (n>=0 && n<H5V_HYPER_NDIMS);
assert (size);
@@ -302,7 +303,7 @@ H5V_hyper_fill (size_t n, const size_t *_size,
int i;
#endif
- FUNC_ENTER (H5V_hyper_fill, NULL, FAIL);
+ FUNC_ENTER (H5V_hyper_fill, FAIL);
/* check args */
assert (n>0 && n<=H5V_HYPER_NDIMS);
@@ -388,7 +389,7 @@ H5V_hyper_copy (size_t n, const size_t *_size,
intn i;
#endif
- FUNC_ENTER (H5V_hyper_copy, NULL, FAIL);
+ FUNC_ENTER (H5V_hyper_copy, FAIL);
/* check args */
assert (n>0 && n<=H5V_HYPER_NDIMS);
@@ -451,7 +452,7 @@ H5V_stride_fill (size_t n, size_t elmt_size, const size_t *size,
intn i, j; /*counters */
hbool_t carry; /*subtraction carray value */
- FUNC_ENTER (H5V_stride_fill, NULL, FAIL);
+ FUNC_ENTER (H5V_stride_fill, FAIL);
H5V_vector_cpy (n, idx, size);
nelmts = H5V_vector_reduce_product (n, size);
@@ -509,7 +510,7 @@ H5V_stride_copy (size_t n, size_t elmt_size, const size_t *size,
intn i, j; /*counters */
hbool_t carry; /*carray for subtraction*/
- FUNC_ENTER (H5V_stride_copy, NULL, FAIL);
+ FUNC_ENTER (H5V_stride_copy, FAIL);
H5V_vector_cpy (n, idx, size);
nelmts = H5V_vector_reduce_product (n, size);
@@ -570,7 +571,7 @@ H5V_stride_copy2 (size_t nelmts, size_t elmt_size,
intn i, j;
hbool_t carry;
- FUNC_ENTER (H5V_stride_copy2, NULL, FAIL);
+ FUNC_ENTER (H5V_stride_copy2, FAIL);
H5V_vector_cpy (dst_n, dst_idx, dst_size);
H5V_vector_cpy (src_n, src_idx, src_size);
diff --git a/src/H5detect.c b/src/H5detect.c
index 83beb4d..18a8d60 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -1,20 +1,21 @@
-static char *FileHeader = "\n\
+/**/
+static const char *FileHeader = "\n\
/*-------------------------------------------------------------------------\n\
- * Copyright (C) 1997 National Center for Supercomputing Applications. \n\
- * All rights reserved. \n\
- * \n\
+ * Copyright (C) 1997 National Center for Supercomputing Applications. \n\
+ * All rights reserved. \n\
+ * \n\
*-------------------------------------------------------------------------";
/*
*
* Created: H5detect.c
- * 10 Aug 1997
- * Robb Matzke
+ * 10 Aug 1997
+ * Robb Matzke
*
* Purpose: This code was borrowed heavily from the `detect.c'
- * program in the AIO distribution from Lawrence
- * Livermore National Laboratory.
+ * program in the AIO distribution from Lawrence
+ * Livermore National Laboratory.
*
- * Detects machine byte order and floating point
+ * Detects machine byte order and floating point
* format and generates a C source file (native.c)
* to describe those paramters.
*
@@ -50,8 +51,7 @@ static char *FileHeader = "\n\
* was detected.
*/
typedef struct detected_t {
- char *typename;
- char *varname;
+ const char *varname;
int size;
int padding;
int perm[32];
@@ -61,11 +61,11 @@ typedef struct detected_t {
} detected_t;
static void print_results (int nd, detected_t *d);
-static void iprint (detected_t*, int);
-static void print_known_formats (detected_t*, int);
+static void iprint (detected_t*);
+static void print_known_formats (detected_t*);
static int byte_cmp (int, void*, void*);
static int bit_cmp (int, int*, void*, void*);
-static void fix_order (int, int, int, int*, char**);
+static void fix_order (int, int, int, int*, const char **);
static void fix_padding (detected_t*);
static int imp_bit (int, int*, void*, void*);
static int find_bias (int, int, int, int*, void*);
@@ -95,31 +95,31 @@ static void print_header (void);
static detected_t Known[] = {
/* Single-byte quantities */
- {"char", "Byte addressable",
+ {"Byte addressable",
1, 0, LE_1, INTEGER},
/* Little-endian fixed-point */
- {"int16", "Little-endian",
+ {"Little-endian",
2, 0, LE_2, INTEGER},
- {"int32", "Little-endian",
+ {"Little-endian",
4, 0, LE_4, INTEGER},
/* Big-endian fixed-point */
- {"int16", "Big-endian",
+ {"Big-endian",
2, 0, BE_2, INTEGER},
- {"int32", "Big-endian",
+ {"Big-endian",
4, 0, BE_4, INTEGER},
/* Little-endian IEEE floating-point */
- {"float32", "Little-endian IEEE",
+ {"Little-endian IEEE",
4, 0, LE_4, 31, 0, 23, 1, 23, 8, 127},
- {"float64", "Little-endian IEEE",
+ {"Little-endian IEEE",
8, 0, LE_8, 63, 0, 52, 1, 52, 11, 1023},
/* Big-endian IEEE floating-point */
- {"float32", "Big-endian IEEE",
+ {"Big-endian IEEE",
4, 0, BE_4, 31, 0, 23, 1, 23, 8, 127},
- {"float64", "Big-endian IEEE",
+ {"Big-endian IEEE",
8, 0, BE_8, 63, 0, 52, 1, 52, 11, 1023},
};
@@ -129,47 +129,45 @@ static detected_t Known[] = {
*
* Purpose: This macro takes a type like `int' and a base name like
* `nati' and detects the byte order. The VAR is used to
- * construct the names of the C variables defined.
+ * construct the names of the C variables defined.
*
* Return: void
*
* Programmer: Robb Matzke
* matzke@llnl.gov
- * Jun 12 1996
+ * Jun 12 1996
*
* Modifications:
*
- * Robb Matzke, 4 Nov 1996
+ * Robb Matzke, 4 Nov 1996
* The INFO.perm now contains `-1' for bytes that aren't used and
* are always zero. This happens on the Cray for `short' where
* sizeof(short) is 8, but only the low-order 4 bytes are ever used.
*
- * Robb Matzke, 4 Nov 1996
+ * Robb Matzke, 4 Nov 1996
* Added a `padding' field to indicate how many zero bytes appear to
* the left (N) or right (-N) of the value.
*
- * Robb Matzke, 5 Nov 1996
+ * Robb Matzke, 5 Nov 1996
* Removed HFILE and CFILE arguments.
*
*-------------------------------------------------------------------------
*/
-#define DETECT_I(TYPE,TYPE_S,VAR,VAR_S,INFO) { \
+#define DETECT_I(TYPE,VAR,INFO) { \
TYPE _v; \
int _i, _j; \
unsigned char *_x; \
memset (&INFO, 0, sizeof(INFO)); \
- INFO.typename = TYPE_S; \
- INFO.varname = VAR_S; \
+ INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
- for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
+ for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
for (_i=0,_x=(unsigned char *)&_v; _i<sizeof(TYPE); _i++) { \
_j = (*_x++)-1; \
- assert (_j<(signed)sizeof(TYPE)); \
+ assert (_j<(signed)sizeof(TYPE)); \
INFO.perm[_i] = _j; \
} \
fix_padding (&(INFO)); \
- if (!strncmp(TYPE_S, "unsigned", 8)) INFO.sign = 0; \
- else INFO.sign = 1; \
+ INFO.sign = ('U'!=*(#VAR)); \
}
@@ -191,22 +189,21 @@ static detected_t Known[] = {
* Modifications:
*
* Robb Matzke, 14 Aug 1996
- * The byte order detection has been changed because on the Cray
- * the last pass causes a rounding to occur that causes the least
- * significant mantissa byte to change unexpectedly.
+ * The byte order detection has been changed because on the Cray
+ * the last pass causes a rounding to occur that causes the least
+ * significant mantissa byte to change unexpectedly.
*
- * Robb Matzke, 5 Nov 1996
+ * Robb Matzke, 5 Nov 1996
* Removed HFILE and CFILE arguments.
*-------------------------------------------------------------------------
*/
-#define DETECT_F(TYPE,TYPE_S,VAR,VAR_S,INFO) { \
+#define DETECT_F(TYPE,VAR,INFO) { \
TYPE _v1, _v2, _v3; \
- int _i, _j, _first=(-1), _last=(-1); \
- char *_mesg; \
+ int _i, _j, _first=(-1), _last=(-1); \
+ char *_mesg; \
\
memset (&INFO, 0, sizeof(INFO)); \
- INFO.typename = TYPE_S; \
- INFO.varname = VAR_S; \
+ INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
INFO.padding = 0; \
\
@@ -215,13 +212,13 @@ static detected_t Known[] = {
_v3 = _v1; _v1 += _v2; _v2 /= 256.0; \
if ((_j=byte_cmp(sizeof(TYPE), &_v3, &_v1))>=0) { \
if (0==_i || INFO.perm[_i-1]!=_j) { \
- INFO.perm[_i] = _j; \
- _last = _i; \
+ INFO.perm[_i] = _j; \
+ _last = _i; \
if (_first<0) _first = _i; \
} \
} \
} \
- fix_order (sizeof(TYPE), _first, _last, INFO.perm, &_mesg); \
+ fix_order (sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \
\
/* Implicit mantissa bit */ \
_v1 = 0.5; \
@@ -247,7 +244,7 @@ static detected_t Known[] = {
INFO.esize = INFO.sign - INFO.epos; \
\
_v1 = 1.0; \
- INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.imp, INFO.perm, &_v1); \
+ INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.imp, INFO.perm, &_v1); \
}
@@ -269,106 +266,100 @@ static detected_t Known[] = {
static void
print_results (int nd, detected_t *d) {
- int i, j;
-
- printf ("#define DEFAULT_INTEGER_FIELDS {FALSE,0,0,0,0,0}\n\n");
- printf ("#define FALSE 0\n");
- printf ("#define TRUE 1\n");
+ int i;
- printf ("\ntypedef struct {\n");
- printf (" uintn class, bytes, padding, size, align;\n");
- printf (" uintn order[32], sign, imp, mloc, msize, eloc, esize;\n");
- printf (" uint32 bias;\n");
- printf ("};\n\n");
+ /* Include files */
+ printf ("\
+#define H5T_PACKAGE /*suppress error about including H5Tpkg.h*/
+\n\
+#include <H5private.h>\n\
+#include <H5Eprivate.h>\n\
+#include <H5MMprivate.h>\n\
+#include <H5Tpkg.h>\n\
+\n\
+static hbool_t interface_initialize_g = FALSE;\n\
+#define INTERFACE_INIT NULL\n\
+\n");
+
+ /* Global definitions for each type */
for (i=0; i<nd; i++) {
- printf ("\n/*\n");
- iprint (d+i, 0);
- print_known_formats (d+i, 0);
- printf (" */\n");
- printf ("const H5T_desc_t H5T_%s[1] = {{\n",
- d[i].varname);
- printf (" /* Class */ %s,\n",
- d[i].msize?"H5T_FLOAT":"H5T_FIXED");
- printf (" /* Number of bytes */ %d,\n", d[i].size);
- printf (" /* Zero padding */ %d,\n", d[i].padding);
- printf (" /* sizeof() */ %d,\n",
- d[i].size + abs (d[i].padding));
-
- /* alignment isn't detected yet */
- printf (" /* Alignment */ %d,\n",
- d[i].size + abs (d[i].padding));
-
- printf (" /* Byte order */ {");
- for (j=0; j<32; j++) {
- if (j && 0==j%8) printf ("\n ");
- printf ("%3d%s", j<d[i].size?d[i].perm[j]:-1, j+1<32?",":"");
- }
- printf ("},\n");
-
- if (d[i].msize) {
- printf (" /* Float sign loc */ %d,\n", d[i].sign);
- printf (" /* Float implicit bit */ %s,\n",
- d[i].imp?"TRUE":"FALSE");
- printf (" /* Float mantissa loc */ %d,\n", d[i].mpos);
- printf (" /* Float matnissa size */ %d,\n", d[i].msize);
- printf (" /* Float exponent loc */ %d,\n", d[i].epos);
- printf (" /* Float exponent size */ %d,\n", d[i].esize);
- printf (" /* Float exponent bias */ 0x%x,\n", d[i].bias);
- } else {
- printf (" /* Signed? */ %s,\n",
- d[i].sign?"TRUE":"FALSE");
- printf (" DEFAULT_INTEGER_FIELDS,\n");
- }
- printf ("}};\n\n");
+ printf ("hid_t H5T_NATIVE_%s;\n", d[i].varname);
}
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: tprint
- *
- * Purpose: Prints a binary number beginning with the most
- * significant bit and continuing to the least
- * significant bit.
- *
- * If PERM is the null pointer then it isn't used and
- * _A is assumed to be in big endian order.
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-#if 0
-static void
-tprint (int nbytes, int *perm, void *_a) {
-
- int i, j;
- unsigned char *a = (unsigned char *)_a;
- unsigned char b;
+
+ /* Function declaration */
+ printf ("\n\
+herr_t\n\
+H5T_init (void)\n\
+{\n\
+ H5T_t *dt = NULL;\n\
+ static intn ncalls = 0;\n\
+\n\
+ FUNC_ENTER (H5T_init, FAIL);\n\
+\n\
+ if (ncalls++) return SUCCEED; /*already initialized*/\n\
+\n");
- for (i=0; i<nbytes; i++) {
- if (perm) {
- assert (perm[i]<nbytes);
- b = a[perm[i]];
+ for (i=0; i<nd; i++) {
+
+ /* Print a comment to describe this section of definitions. */
+ printf ("\n /*\n");
+ iprint (d+i);
+ print_known_formats (d+i);
+ printf (" */\n");
+
+ /* The part common to fixed and floating types */
+ printf ("\
+ dt = H5MM_xcalloc (1, sizeof(H5T_t));\n\
+ dt->locked = TRUE;\n\
+ dt->type = H5T_%s;\n\
+ dt->size = %d;\n\
+ dt->u.atomic.order = H5T_ORDER_%s;\n\
+ dt->u.atomic.prec = %d;\n\
+ dt->u.atomic.lo_pad = H5T_PAD_ZERO;\n\
+ dt->u.atomic.hi_pad = H5T_PAD_ZERO;\n",
+ d[i].msize?"FLOAT":"FIXED", /*class */
+ d[i].size+abs (d[i].padding), /*size */
+ d[i].perm[0]?"BE":"LE", /*byte order */
+ 8*d[i].size); /*precision */
+
+ if (0==d[i].msize) {
+ /* The part unique to fixed point types */
+ printf ("\
+ dt->u.atomic.u.i.sign = H5T_SGN_%s;\n",
+ d[i].sign?"2":"NONE");
} else {
- b = a[i];
- }
- for (j=0; j<8; j++,b<<=1) putchar (b & 0x80 ? '1' : '0');
- if (i+1<nbytes) {
- putchar (' ');
- if (0==(i+1)%4) putchar (' ');
+ /* The part unique to floating point types */
+ printf ("\
+ dt->u.atomic.u.f.sign = %d;\n\
+ dt->u.atomic.u.f.epos = %d;\n\
+ dt->u.atomic.u.f.esize = %d;\n\
+ dt->u.atomic.u.f.ebias = 0x%08x;\n\
+ dt->u.atomic.u.f.mpos = %d;\n\
+ dt->u.atomic.u.f.msize = %d;\n\
+ dt->u.atomic.u.f.norm = H5T_NORM_%s;\n\
+ dt->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
+ d[i].sign, /*sign location */
+ d[i].epos, /*exponent loc */
+ d[i].esize, /*exponent size */
+ d[i].bias, /*exponent bias */
+ d[i].mpos, /*mantissa loc */
+ d[i].msize, /*mantissa size */
+ d[i].imp?"IMPLIED":"NONE"); /*normalization */
}
+
+ /* Atomize the type */
+ printf ("\
+ if ((H5T_NATIVE_%s = H5Aregister_atom (H5_DATATYPE, dt))<0) {\n\
+ /* Can't initialize type system - atom registration failure */\n\
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL);\n\
+ }\n",
+ d[i].varname);
+
}
- putchar ('\n');
+
+ printf (" FUNC_LEAVE (SUCCEED);\n}\n");
}
-#endif
/*-------------------------------------------------------------------------
@@ -388,14 +379,14 @@ tprint (int nbytes, int *perm, void *_a) {
*-------------------------------------------------------------------------
*/
static void
-iprint (detected_t *d, int indent) {
+iprint (detected_t *d) {
int i, j, k;
/*
* Print the byte ordering above the bit fields.
*/
- printf ("%*s * ", indent, "");
+ printf (" * ");
for (i=d->size-1; i>=0; --i) {
printf ("%4d", d->perm[i]);
if (i>0) fputs (" ", stdout);
@@ -406,7 +397,7 @@ iprint (detected_t *d, int indent) {
/*
* Print the bit fields
*/
- printf ("%*s * ", indent, "");
+ printf (" * ");
for (i=d->size-1,k=d->size*8-1; i>=0; --i) {
for (j=7; j>=0; --j) {
if (k==d->sign && d->msize) {
@@ -415,8 +406,12 @@ iprint (detected_t *d, int indent) {
putchar ('E');
} else if (k>=d->mpos && k<d->mpos+d->msize) {
putchar ('M');
- } else {
+ } else if (d->msize) {
+ putchar ('?'); /*unknown floating point bit*/
+ } else if (d->sign) {
putchar ('I');
+ } else {
+ putchar ('U');
}
--k;
}
@@ -431,7 +426,7 @@ iprint (detected_t *d, int indent) {
* Is there an implicit bit in the mantissa.
*/
if (d->msize) {
- printf ("%*s * Implicit bit? %s\n", indent, "", d->imp?"yes":"no");
+ printf (" * Implicit bit? %s\n", d->imp?"yes":"no");
}
}
@@ -439,7 +434,7 @@ iprint (detected_t *d, int indent) {
/*-------------------------------------------------------------------------
* Function: print_known_formats
*
- * Purpose: Prints archetecture names for the specified format
+ * Purpose: Prints archetecture names for the specified format
* description, if any.
*
* Return: void
@@ -453,7 +448,7 @@ iprint (detected_t *d, int indent) {
*-------------------------------------------------------------------------
*/
static void
-print_known_formats (detected_t *d, int indent) {
+print_known_formats (detected_t *d) {
int i, j, diff;
int n=sizeof(Known)/sizeof(Known[0]);
@@ -465,7 +460,7 @@ print_known_formats (detected_t *d, int indent) {
}
if (diff) continue;
- /* if (d->sign != Known[i].sign) continue;*/
+ /* if (d->sign != Known[i].sign) continue;*/
if (d->mpos != Known[i].mpos) continue;
if (d->msize != Known[i].msize) continue;
if (d->imp != Known[i].imp) continue;
@@ -473,8 +468,7 @@ print_known_formats (detected_t *d, int indent) {
if (d->esize != Known[i].esize) continue;
if (d->bias != Known[i].bias) continue;
- printf ("%*s * %s %s\n",
- indent, "", Known[i].varname, Known[i].typename);
+ printf (" * %s\n", Known[i].varname);
}
}
@@ -514,7 +508,7 @@ byte_cmp (int n, void *_a, void *_b) {
* Function: bit_cmp
*
* Purpose: Compares two bit vectors and returns the index for the
- * first bit that differs between the two vectors. The
+ * first bit that differs between the two vectors. The
* size of the vector is NBYTES. PERM is a mapping from
* actual order to little endian.
*
@@ -559,7 +553,7 @@ bit_cmp (int nbytes, int *perm, void *_a, void *_b) {
* creates a permutation vector that maps the actual order
* of a floating point number to little-endian.
*
- * This function assumes that the mantissa byte ordering
+ * This function assumes that the mantissa byte ordering
* implies the total ordering.
*
* Return: void
@@ -573,7 +567,7 @@ bit_cmp (int nbytes, int *perm, void *_a, void *_b) {
*-------------------------------------------------------------------------
*/
static void
-fix_order (int n, int first, int last, int *perm, char **mesg) {
+fix_order (int n, int first, int last, int *perm, const char **mesg) {
int i;
@@ -623,7 +617,7 @@ fix_order (int n, int first, int last, int *perm, char **mesg) {
* from the permutation, and the `padding' field is set to an
* appropriate value.
*
- * If N bytes of padding appear to the left (lower address) of
+ * If N bytes of padding appear to the left (lower address) of
* the value, then `padding=N'. If N bytes of padding appear
* to the right of the value then `padding=(-N)'.
*
@@ -681,7 +675,7 @@ fix_padding (detected_t *d) {
* floating point values stored in _A and _B then the function
* returns non-zero.
*
- * This function assumes that the exponent occupies higher
+ * This function assumes that the exponent occupies higher
* order bits than the mantissa and that the most significant
* bit of the mantissa is next to the least signficant bit
* of the exponent.
@@ -690,7 +684,7 @@ fix_padding (detected_t *d) {
* Return: Success: Non-zero if the most significant bit
* of the mantissa is discarded (ie, the
* mantissa has an implicit `one' as the
- * most significant bit). Otherwise,
+ * most significant bit). Otherwise,
* returns zero.
*
* Failure: exit(1)
@@ -701,7 +695,7 @@ fix_padding (detected_t *d) {
*
* Modifications:
*
- * Robb Matzke, 6 Nov 1996
+ * Robb Matzke, 6 Nov 1996
* Fixed a bug that occurs with non-implicit architectures.
*
*-------------------------------------------------------------------------
@@ -716,7 +710,7 @@ imp_bit (int n, int *perm, void *_a, void *_b) {
/*
* Look for the least significant bit that has changed between
- * A and B. This is the least significant bit of the exponent.
+ * A and B. This is the least significant bit of the exponent.
*/
changed = bit_cmp (n, perm, a, b);
assert (changed>=0);
@@ -750,7 +744,7 @@ imp_bit (int n, int *perm, void *_a, void *_b) {
*
* Modifications:
*
- * Robb Matzke, 6 Nov 1996
+ * Robb Matzke, 6 Nov 1996
* Fixed a bug with non-implicit architectures returning the
* wrong exponent bias.
*
@@ -803,11 +797,11 @@ print_header (void) {
char real_name[30], *comma;
char host_name[256];
int i, n;
- char *s;
- static char *month_name[] = {
+ const char *s;
+ static const char *month_name[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- static char *purpose = "\
+ static const char *purpose = "\
This machine-generated source code contains\n\
information about the various integer and\n\
floating point numeric formats found on this\n\
@@ -819,7 +813,7 @@ Each of the numeric formats listed below are\n\
printed from most significant bit to least\n\
significant bit even though the actual bytes\n\
might be stored in a different order in\n\
-memory. The integers above each binary byte\n\
+memory. The integers above each binary byte\n\
indicate the relative order of the bytes in\n\
memory; little-endian machines have\n\
decreasing numbers while big-endian machines\n\
@@ -830,11 +824,12 @@ letters with `S' for the mantissa sign bit,\n\
`M' for the mantissa magnitude, and `E' for\n\
the exponent. The exponent has an associated\n\
bias which can be subtracted to find the\n\
-true exponent. The radix point is assumed\n\
-to be before the first `M' bit. Any bit\n\
-not falling into one of these categories\n\
-is printed as a question mark, as are all\n\
-bits of integer quantities.\n\
+true exponent. The radix point is assumed\n\
+to be before the first `M' bit. Any bit\n\
+of a floating-point value not falling into one\n\
+of these categories is printed as a question\n\
+mark. Bits of fixed-point types are printed as\n\
+`I' for 2's complement and `U' for magnitude.\n\
\n\
If the most significant bit of the normalized\n\
mantissa (always a `1' except for `0.0') is\n\
@@ -842,7 +837,7 @@ not stored then an `implicit=yes' appears\n\
under the field description. In thie case,\n\
the radix point is still assumed to be\n\
before the first `M' but after the implicit\n\
-bit.";
+bit.\n";
/*
* The real name is the first item from the passwd gecos field.
@@ -869,7 +864,8 @@ bit.";
/*
* The file header: warning, copyright notice, build information.
*/
- printf ("/*\n * DO NOT EDIT THIS FILE--IT IS MACHINE GENERATED!\n */\n\n");
+ printf ("/*\n * DO NOT EDIT OR DISTRIBUTE THIS FILE -- "
+ "IT IS MACHINE GENERATED!\n */\n\n");
puts (FileHeader); /*the copyright notice--see top of this file*/
printf (" *\n * Created:\t\t%s %2d, %4d\n",
@@ -886,7 +882,7 @@ bit.";
printf (" *\n * Purpose:\t\t");
for (s=purpose; *s; s++) {
putchar (*s);
- if ('\n'==*s) printf (" *\t\t\t");
+ if ('\n'==*s && s[1]) printf (" *\t\t\t");
}
printf (" *\n * Modifications:\n *\n");
@@ -925,16 +921,16 @@ main (int argc, char *argv[]) {
print_header();
- DETECT_I (signed char, "signed char", natsc, "natsc", d[nd]); nd++;
- DETECT_I (unsigned char, "unsigned char", natuc, "natuc", d[nd]); nd++;
- DETECT_I (short, "short", nats, "natss", d[nd]); nd++;
- DETECT_I (unsigned short, "unsigned short", nats, "natus", d[nd]); nd++;
- DETECT_I (int, "int", nati, "natsi", d[nd]); nd++;
- DETECT_I (unsigned int, "unsigned int", nati, "natui", d[nd]); nd++;
- DETECT_I (long, "long", natl, "natsl", d[nd]); nd++;
- DETECT_I (unsigned long, "unsigned long", natl, "natul", d[nd]); nd++;
- DETECT_F (float, "float", natf, "natf", d[nd]); nd++;
- DETECT_F (double, "double", natd, "natd", d[nd]); nd++;
+ DETECT_I (signed char, CHAR, d[nd]); nd++;
+ DETECT_I (unsigned char, UCHAR, d[nd]); nd++;
+ DETECT_I (short, SHORT, d[nd]); nd++;
+ DETECT_I (unsigned short, USHORT, d[nd]); nd++;
+ DETECT_I (int, INT, d[nd]); nd++;
+ DETECT_I (unsigned int, UINT, d[nd]); nd++;
+ DETECT_I (long, LONG, d[nd]); nd++;
+ DETECT_I (unsigned long, ULONG, d[nd]); nd++;
+ DETECT_F (float, FLOAT, d[nd]); nd++;
+ DETECT_F (double, DOUBLE, d[nd]); nd++;
print_results (nd, d);
exit (0);
diff --git a/src/H5private.h b/src/H5private.h
index 68d5079..aaf2bf9 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -100,7 +100,7 @@
* File addresses.
*/
typedef struct {
- uint64 offset;
+ uint64 offset; /*offset within an HDF5 file */
} haddr_t;
#define NO_ADDR NULL
@@ -369,7 +369,8 @@ extern char *strdup (const char *s);
* profiling.
*
* Notes: Every file must have a file-scope variable called
- * `initialize_interface'.
+ * `initialize_interface_g' of type hbool_t which is initialized
+ * to FALSE.
*
* Don't use local variable initializers which contain
* calls to other library functions since the initializer
@@ -401,12 +402,20 @@ extern char *strdup (const char *s);
* initializing functions. Infinite recursion is no longer a
* danger.
*
+ * Robb Matzke, 3 Dec 1997
+ * The interface initialization function is no longer passed as an
+ * argument unless the `FUNC_ENTER_INIT' form is called. Instead, the
+ * function comes from the `INTERFACE_INIT' constant which must be
+ * defined in every source file.
+ *
*-------------------------------------------------------------------------
*/
extern hbool_t library_initialize_g; /*good thing C's lazy about extern!*/
extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
-#define FUNC_ENTER(func_name,interface_init_func,err) { \
+#define FUNC_ENTER(func_name,err) FUNC_ENTER_INIT(func_name,INTERFACE_INIT,err)
+
+#define FUNC_ENTER_INIT(func_name,interface_init_func,err) { \
CONSTR (FUNC, #func_name); \
PABLO_SAVE (ID_ ## func_name); \
\
diff --git a/src/H5public.h b/src/H5public.h
index 7a5ed05..277d853 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -110,6 +110,7 @@ extern "C" {
#endif
/* Functions in H5.c */
+herr_t H5init (void);
herr_t H5dont_atexit(void);
herr_t H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum);
diff --git a/src/Makefile.in b/src/Makefile.in
index a083e22..33485cd 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -17,11 +17,14 @@ PROGS=debug
LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5C.c H5D.c H5Dconv.c H5E.c H5F.c H5Fcore.c \
H5Ffamily.c H5Fistore.c H5Flow.c H5Fsec2.c H5Fsplit.c H5Fstdio.c \
H5G.c H5Gent.c H5Gnode.c H5Gshad.c H5Gstab.c H5H.c H5M.c H5MF.c \
- H5MM.c H5O.c H5Ocont.c H5Oistore.c H5Oname.c H5Onull.c H5Osdtyp.c \
- H5Osdim.c H5Ostab.c H5Ostdst.c H5P.c H5T.c H5V.c
+ H5MM.c H5O.c H5Ocont.c H5Ocstore.c H5Oefl.c H5Oistore.c H5Oname.c \
+ H5Onull.c H5Osdtyp.c H5Osdim.c H5Ostab.c H5P.c H5T.c H5Tinit.c H5V.c
LIB_OBJ=$(LIB_SRC:.c=.o)
+# Temporary files
+MOSTLYCLEAN=H5detect.o H5detect H5Tinit.o H5Tinit.c
+
# Source and object files for programs...
PROG_SRC=debug.c
PROG_OBJ=$(PROG_SRC:.c=.o)
@@ -36,7 +39,14 @@ PUB_HDR=H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5Cpublic.h \
PRIVATE_HDR=H5private.h H5Aprivate.h H5ACprivate.h H5Bprivate.h \
H5Cprivate.h H5Dprivate.h H5Eprivate.h H5Fprivate.h H5Gprivate.h \
H5Gpkg.h H5Hprivate.h H5Mprivate.h H5MFprivate.h H5MMprivate.h \
- H5Oprivate.h H5Pprivate.h H5Tprivate.h H5Vprivate.h
+ H5Oprivate.h H5Pprivate.h H5Tprivate.h H5Tpkg.h H5Vprivate.h
+
+# Number format detection
+H5Tinit.c: H5detect
+ ./H5detect >H5Tinit.c
+
+H5detect: H5detect.o
+ $(CC) $(CFLAGS) -o $@ H5detect.o
# How to build the programs...
debug: debug.o $(LIB)
diff --git a/src/debug.c b/src/debug.c
index 445ff67..2271460 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -53,20 +53,6 @@ main (int argc, char *argv[])
herr_t status = SUCCEED;
haddr_t extra;
- H5F_addr_reset (&addr);
- H5F_addr_reset (&extra);
-
- /*
- * Parse command arguments.
- */
- if (argc>2) {
- printf ("New address: %s\n", argv[2]);
- addr.offset = HDstrtol (argv[2], NULL, 0);
- }
- if (argc>3) {
- extra.offset = HDstrtol (argv[3], NULL, 0);
- }
-
/*
* Open the file and get the file descriptor.
*/
@@ -80,6 +66,19 @@ main (int argc, char *argv[])
}
/*
+ * Parse command arguments.
+ */
+ H5F_addr_reset (&addr);
+ H5F_addr_reset (&extra);
+ if (argc>2) {
+ printf ("New address: %s\n", argv[2]);
+ addr.offset = HDstrtol (argv[2], NULL, 0);
+ }
+ if (argc>3) {
+ extra.offset = HDstrtol (argv[3], NULL, 0);
+ }
+
+ /*
* Read the signature at the specified file position.
*/
printf ("Reading signature at address ");