diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 62 | ||||
-rw-r--r-- | src/H5A.c | 2 | ||||
-rw-r--r-- | src/H5Aprivate.h | 5 | ||||
-rw-r--r-- | src/H5Apublic.h | 5 | ||||
-rw-r--r-- | src/H5D.c | 253 | ||||
-rw-r--r-- | src/H5Dprivate.h | 11 | ||||
-rw-r--r-- | src/H5E.c | 1 | ||||
-rw-r--r-- | src/H5Epublic.h | 3 | ||||
-rw-r--r-- | src/H5F.c | 14 | ||||
-rw-r--r-- | src/H5Farray.c | 8 | ||||
-rw-r--r-- | src/H5Fprivate.h | 8 | ||||
-rw-r--r-- | src/H5Fpublic.h | 8 | ||||
-rw-r--r-- | src/H5M.c | 3 | ||||
-rw-r--r-- | src/H5Mpublic.h | 4 | ||||
-rw-r--r-- | src/H5O.c | 4 | ||||
-rw-r--r-- | src/H5Oefl.c | 322 | ||||
-rw-r--r-- | src/H5Oprivate.h | 40 | ||||
-rw-r--r-- | src/H5Osdspace.c | 2 | ||||
-rw-r--r-- | src/H5P.c | 1013 | ||||
-rw-r--r-- | src/H5Ppublic.h | 6 | ||||
-rw-r--r-- | src/H5S.c | 813 | ||||
-rw-r--r-- | src/H5Sprivate.h | 4 | ||||
-rw-r--r-- | src/H5Spublic.h | 2 | ||||
-rw-r--r-- | src/H5Ssimp.c | 4 | ||||
-rw-r--r-- | src/H5T.c | 2 | ||||
-rw-r--r-- | src/H5Tpublic.h | 2 | ||||
-rw-r--r-- | src/H5V.c | 50 | ||||
-rw-r--r-- | src/H5Vprivate.h | 16 | ||||
-rw-r--r-- | src/H5private.h | 75 | ||||
-rw-r--r-- | src/H5public.h | 85 |
30 files changed, 1674 insertions, 1153 deletions
@@ -272,45 +272,45 @@ H5dont_atexit(void) FUNC_LEAVE(SUCCEED); } /* end H5dont_atexit() */ -/*-------------------------------------------------------------------------- -NAME - H5version -- Checks the version of the library -USAGE - herr_t H5version(majnum, minnum, relnum, patnum) - uintn *majnum; OUT: The major revision number of the HDF5 library - uintn *minnum; OUT: The minor revision number of the HDF5 library - uintn *relnum; OUT: The release revision number of the HDF5 library - uintn *patnum; OUT: The patch revision number of the HDF5 library - -RETURNS - SUCCEED/FAIL -DESCRIPTION - Checks the version numbers of the library. - ---------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Function: H5version + * + * Purpose: Returns the library version numbers through arguments. MAJNUM + * will be the major revision number of the library, MINNUM the + * minor revision number, RELNUM the release revision number, + * and PATNUM the patch revision number. + * + * Note: When printing an HDF5 version number it should be printed as + * `printf ("HDF5-%d.%d.%d%c", maj, min, rel, 'a'+patch)'. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Unknown + * + * Modifications: + * Robb Matzke, 4 Mar 1998 + * Now use "normal" data types for the interface. Any of the arguments + * may be null pointers + * + *------------------------------------------------------------------------- + */ herr_t -H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum) +H5version(unsigned *majnum, unsigned *minnum, unsigned *relnum, + unsigned *patnum) { herr_t ret_value = SUCCEED; FUNC_ENTER(H5version, FAIL); - /* Check args and all the boring stuff. */ - if (majnum == NULL || minnum == NULL || relnum == NULL || patnum == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "null pointer argument"); - /* Set the version information */ - *majnum = HDF5_MAJOR_VERSION; - *minnum = HDF5_MINOR_VERSION; - *relnum = HDF5_RELEASE_VERSION; - *patnum = HDF5_PATCH_VERSION; - - done: - if (ret_value == FAIL) { /* Error condition cleanup */ + if (majnum) *majnum = HDF5_MAJOR_VERSION; + if (minnum) *minnum = HDF5_MINOR_VERSION; + if (relnum) *relnum = HDF5_RELEASE_VERSION; + if (patnum) *patnum = HDF5_PATCH_VERSION; - } /* end if */ - /* Normal function cleanup */ FUNC_LEAVE(ret_value); } @@ -671,7 +671,7 @@ H5A_dec_ref(hid_t atm) *******************************************************************************/ void * H5A_search(group_t grp, /* IN: Group to search for the object in */ - H5Asearch_func_t func, /* IN: Ptr to the comparison function */ + H5A_search_func_t func, /* IN: Ptr to the comparison function */ const void *key /* IN: pointer to key to compare against */ ) { diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index e4e654f..db7ca4d 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -89,6 +89,9 @@ typedef struct atom_group_struct_tag { atom_info_t **atom_list; /*pointer to an array of ptrs to atoms */ } atom_group_t; +/* Type of the function to compare objects & keys */ +typedef intn (*H5A_search_func_t) (const void * obj, const void * key); + /* Private Functions in H5A.c */ intn H5A_init_group (group_t grp, intn hash_size, uintn reserved, herr_t (*free_func)(void *)); @@ -97,7 +100,7 @@ hid_t H5A_register (group_t grp, void *object); void *H5A_object (hid_t atm); group_t H5A_group (hid_t atm); void *H5A_remove (hid_t atm); -void *H5A_search (group_t grp, H5Asearch_func_t func, const void *key); +void *H5A_search (group_t grp, H5A_search_func_t func, const void *key); void H5A_term_interface (void); intn H5A_dec_ref (hid_t atm); hid_t H5A_inc_ref (hid_t atm); diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 7bc14c9..648e852 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -44,10 +44,7 @@ typedef enum { } group_t; /* Type of atoms to return to users */ -typedef int32 hid_t; - -/* Type of the function to compare objects & keys */ -typedef intn (*H5Asearch_func_t) (const void * obj, const void * key); +typedef int hid_t; /* # of bits to use for Group ID in each atom (change if MAXGROUP>16) */ #define GROUP_BITS 8 @@ -16,18 +16,19 @@ static char RcsId[] = "@(#)$Revision$"; /* $Id$ */ -#include <H5private.h> /* Generic Functions */ -#include <H5Aprivate.h> /* Atoms */ -#include <H5ACprivate.h> /* Cache */ -#include <H5Pprivate.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 */ +#include <H5private.h> /* Generic Functions */ +#include <H5Aprivate.h> /* Atoms */ +#include <H5ACprivate.h> /* Cache */ +#include <H5Dprivate.h> /* Dataset functions */ +#include <H5Eprivate.h> /* Error handling */ +#include <H5Gprivate.h> /* Group headers */ +#include <H5Hprivate.h> /* Name heap */ +#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 <H5Pprivate.h> /* Property lists */ #define PABLO_MASK H5D_mask @@ -35,35 +36,37 @@ static char RcsId[] = "@(#)$Revision$"; * A dataset is the following struct. */ struct H5D_t { - H5G_entry_t ent; /*cached object header stuff */ - H5T_t *type; /*datatype of this dataset */ - H5S_t *space; /*dataspace of this dataset */ - H5D_create_t create_parms; /*creation parameters */ - H5O_layout_t layout; /*data layout */ + H5G_entry_t ent; /*cached object header stuff */ + H5T_t *type; /*datatype of this dataset */ + H5S_t *space; /*dataspace of this dataset */ + H5D_create_t *create_parms; /*creation parameters */ + H5O_layout_t layout; /*data layout */ }; -/* Default dataset creation template */ -const H5D_create_t H5D_create_dflt = -{ +/* Default dataset creation property list */ +const H5D_create_t H5D_create_dflt = { H5D_CONTIGUOUS, /* Layout */ 1, /* Chunk dimensions */ - {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values.... */ - 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks.. */ - 1, 1, 1, 1, 1, 1, 1, 1, /*...produce fewer, but larger I/O...... */ + {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values....*/ + 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks..*/ + 1, 1, 1, 1, 1, 1, 1, 1, /*...produce fewer, but larger I/O......*/ 1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */ + {H5F_ADDR_UNDEF, /* External file list heap address */ + 0, /*...slots allocated */ + 0, /*...slots used */ + NULL} /*...slot array */ }; -/* Default dataset transfer template */ -const H5D_xfer_t H5D_xfer_dflt = -{ +/* Default dataset transfer property list */ +const H5D_xfer_t H5D_xfer_dflt = { 0, /* Place holder - remove this later */ }; /* Interface initialization? */ -static hbool_t interface_initialize_g = FALSE; +static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT H5D_init_interface -static herr_t H5D_init_interface(void); -static void H5D_term_interface(void); +static herr_t H5D_init_interface(void); +static void H5D_term_interface(void); /*-------------------------------------------------------------------------- @@ -143,7 +146,7 @@ H5D_term_interface(void) * * Errors: * ARGS BADTYPE Not a data space. - * ARGS BADTYPE Not a dataset creation template. + * ARGS BADTYPE Not a dataset creation plist. * ARGS BADTYPE Not a file. * ARGS BADTYPE Not a type. * ARGS BADVALUE No name. @@ -190,7 +193,7 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id, if (H5P_DATASET_CREATE != H5Pget_class(create_parms_id) || NULL == (create_parms = H5A_object(create_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); + "not a dataset creation property list"); } } else { create_parms = &H5D_create_dflt; @@ -198,13 +201,14 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id, /* build and open the new dataset */ if (NULL == (new_dset = H5D_create(f, name, type, space, create_parms))) { - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create dataset"); + HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to create dataset"); } /* Register the new datatype and get an ID for it */ if ((ret_value = H5A_register(H5_DATASET, new_dset)) < 0) { H5D_close(new_dset); HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, - "can't register dataset"); + "unable to register dataset"); } FUNC_LEAVE(ret_value); } @@ -322,7 +326,7 @@ H5Dclose(hid_t dataset_id) * Failure: FAIL * * Programmer: Robb Matzke - * Wednesday, January 28, 1998 + * Wednesday, January 28, 1998 * * Modifications: * @@ -364,14 +368,14 @@ H5Dget_space (hid_t dataset_id) * * Purpose: Returns a copy of the file data type for a dataset. * - * Return: Success: ID for a copy of the data type. The data + * Return: Success: ID for a copy of the data type. The data * type should be released by calling * H5Tclose(). * * Failure: FAIL * * Programmer: Robb Matzke - * Tuesday, February 3, 1998 + * Tuesday, February 3, 1998 * * Modifications: * @@ -411,16 +415,16 @@ H5Dget_type (hid_t dataset_id) /*------------------------------------------------------------------------- * Function: H5Dget_create_parms * - * Purpose: Returns a copy of the dataset creation template. + * Purpose: Returns a copy of the dataset creation property list. * * Return: Success: ID for a copy of the dataset creation - * template. The template should be released by - * calling H5Pclose(). + * property list. The template should be + * released by calling H5Pclose(). * * Failure: FAIL * * Programmer: Robb Matzke - * Tuesday, February 3, 1998 + * Tuesday, February 3, 1998 * * Modifications: * @@ -441,18 +445,18 @@ H5Dget_create_parms (hid_t dataset_id) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); } - /* Copy the creation template */ + /* Copy the creation property list */ if (NULL==(copied_parms=H5P_copy (H5P_DATASET_CREATE, - &(dataset->create_parms)))) { + dataset->create_parms))) { HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to copy the creation template"); + "unable to copy the creation property list"); } /* Create an atom */ if ((ret_value=H5A_register ((group_t)(H5_TEMPLATE_0+H5P_DATASET_CREATE), copied_parms))<0) { HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to register creation template"); + "unable to register creation property list"); } FUNC_LEAVE (ret_value); @@ -653,7 +657,7 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, * Failure: FAIL * * Programmer: Robb Matzke - * Friday, January 30, 1998 + * Friday, January 30, 1998 * * Modifications: * @@ -740,9 +744,9 @@ H5D_t * H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, const H5D_create_t *create_parms) { - H5D_t *new_dset = NULL; - H5D_t *ret_value = NULL; - intn i; + H5D_t *new_dset = NULL; + H5D_t *ret_value = NULL; + intn i; FUNC_ENTER(H5D_create, NULL); @@ -758,43 +762,41 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, H5F_addr_undef(&(new_dset->ent.header)); new_dset->type = H5T_copy(type); new_dset->space = H5S_copy(space); - new_dset->create_parms = *create_parms; - - /* - * Create (open for write access) an object header. - */ - if (H5O_create(f, 0, &(new_dset->ent)) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, - "unable to create dataset object header"); - } - /* Update the type and space header messages */ - if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type) < 0 || - H5S_modify(&(new_dset->ent), new_dset->space) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, - "can't update type or space header messages"); - } + new_dset->create_parms = H5P_copy (H5P_DATASET_CREATE, create_parms); /* Total raw data size */ - new_dset->layout.type = new_dset->create_parms.layout; + new_dset->layout.type = new_dset->create_parms->layout; new_dset->layout.ndims = H5S_get_ndims(space) + 1; assert(new_dset->layout.ndims <= NELMTS(new_dset->layout.dim)); new_dset->layout.dim[new_dset->layout.ndims - 1] = H5T_get_size(type); - switch (new_dset->create_parms.layout) { + switch (new_dset->create_parms->layout) { case H5D_CONTIGUOUS: - if (H5S_get_dims(space, new_dset->layout.dim) < 0) { + if (H5S_get_dims(space, new_dset->layout.dim, NULL) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage"); } + if (new_dset->create_parms->efl.nused>0) { + size_t max_points = H5S_get_npoints_max (space); + if (max_points*H5T_get_size (type) > + H5O_efl_total_size (&(new_dset->create_parms->efl))) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "max size exceeds external storage size"); + } + } break; case H5D_CHUNKED: - if (new_dset->create_parms.chunk_ndims != H5S_get_ndims(space)) { + if (new_dset->create_parms->chunk_ndims != H5S_get_ndims(space)) { HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "dimensionality of chunks doesn't match the data space"); } + if (new_dset->create_parms->efl.nused>0) { + HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, + "external storage not supported with chunked layout"); + } for (i = 0; i < new_dset->layout.ndims - 1; i++) { - new_dset->layout.dim[i] = new_dset->create_parms.chunk_size[i]; + new_dset->layout.dim[i] = new_dset->create_parms->chunk_size[i]; } break; @@ -802,14 +804,52 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); } - /* - * Initialize storage - */ - if (H5F_arr_create(f, &(new_dset->layout)) < 0 || - H5O_modify(&(new_dset->ent), H5O_LAYOUT, 0, 0, - &(new_dset->layout)) < 0) { + /* Create (open for write access) an object header */ + if (H5O_create(f, 0, &(new_dset->ent)) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, - "unable to initialize storage"); + "unable to create dataset object header"); + } + + /* Update the type and space header messages */ + if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, H5O_FLAG_CONSTANT, + new_dset->type) < 0 || + H5S_modify(&(new_dset->ent), new_dset->space) < 0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + "can't update type or space header messages"); + } + + /* Initialize storage */ + if (0==new_dset->create_parms->efl.nused) { + if (H5F_arr_create(f, &(new_dset->layout)) < 0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + "unable to initialize storage"); + } + } else { + H5F_addr_undef (&(new_dset->layout.addr)); + } + if (H5O_modify (&(new_dset->ent), H5O_LAYOUT, 0, H5O_FLAG_CONSTANT, + &(new_dset->layout)) < 0) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unable to update layout message"); + } + if (new_dset->create_parms->efl.nused>0) { + size_t heap_size = H5H_ALIGN (1); + for (i=0; i<new_dset->create_parms->efl.nused; i++) { + size_t n = strlen (new_dset->create_parms->efl.slot[i].name)+1; + heap_size += H5H_ALIGN (n); + } + if (H5H_create (f, H5H_LOCAL, heap_size, + &(new_dset->create_parms->efl.heap_addr))<0 || + H5H_insert (f, &(new_dset->create_parms->efl.heap_addr), + 1, "")<0) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unable to create external file list name heap"); + } + if (H5O_modify (&(new_dset->ent), H5O_EFL, 0, H5O_FLAG_CONSTANT, + &(new_dset->create_parms->efl))<0) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unable to update external file list message"); + } } /* Give the dataset a name */ @@ -822,10 +862,12 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, done: if (!ret_value && new_dset) { - if (new_dset->type) - H5T_close(new_dset->type); - if (new_dset->space) - H5S_close(new_dset->space); + if (new_dset->type) H5T_close(new_dset->type); + if (new_dset->space) H5S_close(new_dset->space); + if (new_dset->create_parms) { + H5P_close (H5P_DATASET_CREATE, new_dset->create_parms); + new_dset->create_parms = NULL; + } if (H5F_addr_defined(&(new_dset->ent.header))) { H5O_close(&(new_dset->ent)); } @@ -854,7 +896,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, * *------------------------------------------------------------------------- */ -H5D_t * +H5D_t * H5D_open(H5F_t *f, const char *name) { H5D_t *dataset = NULL; /*the dataset which was found */ @@ -868,7 +910,7 @@ H5D_open(H5F_t *f, const char *name) assert(name && *name); dataset = H5MM_xcalloc(1, sizeof(H5D_t)); - dataset->create_parms = H5D_create_dflt; + dataset->create_parms = H5P_copy (H5P_DATASET_CREATE, &H5D_create_dflt); H5F_addr_undef(&(dataset->ent.header)); /* Open the dataset object */ @@ -878,16 +920,18 @@ H5D_open(H5F_t *f, const char *name) if (H5O_open(f, &(dataset->ent)) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open"); } + /* Get the type and space */ if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL)) || NULL==(dataset->space=H5S_read(f, &(dataset->ent)))) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type or space info from dataset header"); } + /* * Get the raw data layout info. It's actually stored in two locations: * the storage message of the dataset (dataset->storage) and certain - * values are copied to the dataset create template so the user can query + * values are copied to the dataset create plist so the user can query * them. */ if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout))) { @@ -896,19 +940,19 @@ H5D_open(H5F_t *f, const char *name) } switch (dataset->layout.type) { case H5D_CONTIGUOUS: - dataset->create_parms.layout = H5D_CONTIGUOUS; + dataset->create_parms->layout = H5D_CONTIGUOUS; break; case H5D_CHUNKED: /* - * Chunked storage. The creation template's dimension is one less than + * Chunked storage. The creation plist's dimension is one less than * the chunk dimension because the chunk includes a dimension for the * individual bytes of the data type. */ - dataset->create_parms.layout = H5D_CHUNKED; - dataset->create_parms.chunk_ndims = dataset->layout.ndims - 1; + dataset->create_parms->layout = H5D_CHUNKED; + dataset->create_parms->chunk_ndims = dataset->layout.ndims - 1; for (i = 0; i < dataset->layout.ndims - 1; i++) { - dataset->create_parms.chunk_size[i] = dataset->layout.dim[i]; + dataset->create_parms->chunk_size[i] = dataset->layout.dim[i]; } break; @@ -917,6 +961,14 @@ H5D_open(H5F_t *f, const char *name) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); } + /* Get the external file list message, which might not exist */ + if (!H5F_addr_defined (&(dataset->layout.addr)) && + NULL==H5O_read (&(dataset->ent), H5O_EFL, 0, + &(dataset->create_parms->efl))) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "storage address is undefined an no external file list"); + } + /* Success */ ret_value = dataset; @@ -925,10 +977,15 @@ H5D_open(H5F_t *f, const char *name) if (H5F_addr_defined(&(dataset->ent.header))) { H5O_close(&(dataset->ent)); } - if (dataset->type) + if (dataset->type) { H5T_close(dataset->type); - if (dataset->space) + } + if (dataset->space) { H5S_close(dataset->space); + } + if (dataset->create_parms) { + H5P_close (H5P_DATASET_CREATE, dataset->create_parms); + } dataset->ent.file = NULL; H5MM_xfree(dataset); } @@ -972,7 +1029,8 @@ H5D_close(H5D_t *dataset) * these fails, so we just continue. */ free_failed = (H5T_close(dataset->type) < 0 || - H5S_close(dataset->space) < 0); + H5S_close(dataset->space) < 0 || + H5P_close (H5P_DATASET_CREATE, dataset->create_parms)); /* Close the dataset object */ H5O_close(&(dataset->ent)); @@ -1070,6 +1128,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes"); } + if (dataset->create_parms->efl.nused>0) { + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "reading externally-stored data is not implemented yet"); + } /* * Compute the size of the request and allocate scratch buffers. @@ -1213,6 +1275,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes"); } + if (dataset->create_parms->efl.nused>0) { + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "writing externally-stored data is not implemente yet"); + } /* * Compute the size of the request and allocate scratch buffers. @@ -1290,7 +1356,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, * Failure: FAIL * * Programmer: Robb Matzke - * Friday, January 30, 1998 + * Friday, January 30, 1998 * * Modifications: * @@ -1307,6 +1373,11 @@ H5D_extend (H5D_t *dataset, const size_t *size) assert (dataset); assert (size); + if (dataset->create_parms->efl.nused>0) { + HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "extending externally-stored data is not implemente yet"); + } + /* This is only allowed for data spaces with chunked layout */ if (H5D_CHUNKED!=dataset->layout.type) { HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index d4360d4..fc6eeb4 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -31,14 +31,15 @@ /* Set the minimum object header size to create objects with */ #define H5D_MINHDR_SIZE 512 -/* Dataset creation template */ +/* Dataset creation property list */ typedef struct H5D_create_t { - H5D_layout_t layout; - intn chunk_ndims; - size_t chunk_size[32]; + H5D_layout_t layout; /*storage layout */ + intn chunk_ndims; /*chunk dimensionality */ + size_t chunk_size[32]; /*chunk size if chunked storage */ + H5O_efl_t efl; /*external file list */ } H5D_create_t; -/* Dataset transfer template */ +/* Dataset transfer property list */ typedef struct H5D_xfer_t { int _placeholder; /*unused--delete this later */ } H5D_xfer_t; @@ -54,6 +54,7 @@ static const H5E_major_mesg_t H5E_major_mesg_g[] = { {H5E_DATASET, "Dataset interface"}, {H5E_STORAGE, "Data storage layer"}, {H5E_TEMPLATE, "Property list interface"}, + {H5E_EFL, "External file list"}, }; static const H5E_minor_mesg_t H5E_minor_mesg_g[] = { diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 2ceb9a3..78af952 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -45,7 +45,8 @@ typedef enum H5E_major_t { H5E_DATASPACE, /*Dataspace */ H5E_DATASET, /*Dataset */ H5E_STORAGE, /*data storage */ - H5E_TEMPLATE /*Templates */ + H5E_TEMPLATE, /*Property lists */ + H5E_EFL /*External file list */ } H5E_major_t; /* Declare an enumerated type which holds all the valid minor HDF error codes */ @@ -40,11 +40,11 @@ static char RcsId[] = "@(#)$Revision$"; #include <H5private.h> /*library functions */ #include <H5Aprivate.h> /*atoms */ #include <H5ACprivate.h> /*cache */ -#include <H5Pprivate.h> /*templates */ -#include <H5Eprivate.h> /*error handling */ +#include <H5Eprivate.h> /*error handling */ #include <H5Gprivate.h> /*symbol tables */ #include <H5Mprivate.h> /*meta data */ -#include <H5MMprivate.h> /*core memory management */ +#include <H5MMprivate.h> /*core memory management */ +#include <H5Pprivate.h> /*property lists */ #include <ctype.h> #include <sys/types.h> @@ -62,7 +62,7 @@ static char RcsId[] = "@(#)$Revision$"; /*-------------------- Locally scoped variables -----------------------------*/ /* - * Define the default file creation template. + * Define the default file creation property list. */ const H5F_create_t H5F_create_dflt = { 0, /* Default user-block size */ @@ -87,8 +87,8 @@ const H5F_create_t H5F_create_dflt = { }; /* - * Define the default file access template. The template is initialized by - * H5F_init_interface(). + * Define the default file access property list. The template is initialized + * by H5F_init_interface(). */ H5F_access_t H5F_access_dflt; @@ -141,7 +141,7 @@ H5F_init_interface(void) "unable to initialize interface"); } - /* Initialize the default file access template */ + /* Initialize the default file access property list */ H5F_access_dflt.driver = H5F_LOW_DFLT; #if (H5F_LOW_DFLT == H5F_LOW_SEC2) /* Nothing to initialize */ diff --git a/src/H5Farray.c b/src/H5Farray.c index cfe79d9..7deeead 100644 --- a/src/H5Farray.c +++ b/src/H5Farray.c @@ -116,8 +116,8 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout, void *_buf/*out*/) { uint8 *buf = (uint8 *)_buf; /*cast for arithmetic */ - intn file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */ - intn mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/ + ssize_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */ + ssize_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/ size_t hslab_size[H5O_LAYOUT_NDIMS]; /*hyperslab size */ size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */ size_t mem_start, file_start; /*byte offsets to start */ @@ -250,8 +250,8 @@ H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout, const void *_buf) { const uint8 *buf = (const uint8 *)_buf; /*cast for arithmetic */ - intn file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */ - intn mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/ + ssize_t file_stride[H5O_LAYOUT_NDIMS]; /*strides through file */ + ssize_t mem_stride[H5O_LAYOUT_NDIMS]; /*strides through memory*/ size_t hslab_size[H5O_LAYOUT_NDIMS]; /*hyperslab size */ size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */ size_t mem_start, file_start; /*byte offsets to start */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 7a9e593..4700bae 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -209,7 +209,7 @@ #define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n } /* - * File-creation template. + * File-creation property list. */ typedef struct H5F_create_t { size_t userblock_size; /* Size of the file user block in bytes */ @@ -225,7 +225,7 @@ typedef struct H5F_create_t { } H5F_create_t; /* - * File-access template. + * File-access property list. */ typedef struct H5F_access_t { H5F_driver_t driver; /* Low level file driver */ @@ -391,8 +391,8 @@ 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 */ - H5F_create_t create_parms; /* File-creation template */ - H5F_access_t access_parms; /* File-access template */ + H5F_create_t create_parms; /* File-creation property list */ + H5F_access_t access_parms; /* File-access property list */ struct H5G_entry_t *root_ent; /* Root symbol table entry */ } H5F_file_t; diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 27745cd..d4a869b 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -58,6 +58,8 @@ typedef enum H5F_driver_t { H5F_LOW_FAMILY = 5 /*split addr space over many files */ } H5F_driver_t; +/* Unlimited file size for H5Pset_external() */ +#define H5F_UNLIMITED ((size_t)(-1L)) /* Parallel styles passed to H5Pset_mpi() */ #ifdef HAVE_PARALLEL @@ -71,9 +73,9 @@ extern "C" { /* Functions in H5F.c */ 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); +hid_t H5Fcreate (const char *filename, unsigned flags, hid_t create_plist, + hid_t access_plist); +hid_t H5Fopen (const char *filename, unsigned flags, hid_t access_plist); herr_t H5Fclose (hid_t fid); hid_t H5Fget_create_template (hid_t fid); hid_t H5Fget_access_template (hid_t file_id); @@ -45,13 +45,12 @@ static char RcsId[] = "@(#)$Revision$"; #include <H5private.h> /* Generic functions */ #include <H5Aprivate.h> /* Atom interface */ -#include <H5Pprivate.h> /* Template interface */ #include <H5Dprivate.h> /* Dataset interface */ #include <H5Eprivate.h> /*error handling */ #include <H5Sprivate.h> /* Dataspace functions */ #include <H5Tprivate.h> /* Datatype interface */ #include <H5Mprivate.h> /* Meta-object interface */ -#include <H5Pprivate.h> /* Template interface */ +#include <H5Pprivate.h> /* Property list interface */ #define PABLO_MASK H5M_mask diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 1f5e582..d17dedd 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -28,11 +28,11 @@ extern "C" { hid_t H5Maccess (hid_t oid); hid_t H5Mcopy (hid_t oid); hid_t H5Mfind_name (hid_t oid, group_t type, const char *name); -uint32 H5Mname_len (hid_t oid); +unsigned 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, group_t type, const char *name); -hid_t H5Mindex (hid_t oid, group_t type, uint32 idx); +hid_t H5Mindex (hid_t oid, group_t type, unsigned idx); hid_t H5Mflush (hid_t oid); herr_t H5Mdelete (hid_t oid); hid_t H5Mget_file (hid_t oid); @@ -57,9 +57,9 @@ static const H5O_class_t *const message_type_g[] = { NULL, /*0x0004 Not assigned */ NULL, /*0x0005 Not assigned */ NULL, /*0x0006 Data storage -- compact object */ - NULL, /*0x0007 Data storage -- external object */ + H5O_EFL, /*0x0007 Data storage -- external data files */ H5O_LAYOUT, /*0x0008 Data Layout */ - H5O_EFL, /*0x0009 External File List */ + NULL, /*0x0009 Not assigned */ NULL, /*0x000A Not assigned */ NULL, /*0x000B Data storage -- compressed object */ NULL, /*0x000C Attribute list */ diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 49c6c44..eb82c30 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -1,16 +1,17 @@ /* * Copyright (C) 1997 NCSA - * All rights reserved. + * All rights reserved. * * Programmer: Robb Matzke <matzke@llnl.gov> - * Tuesday, November 25, 1997 + * Tuesday, November 25, 1997 */ #include <H5private.h> #include <H5Eprivate.h> +#include <H5Hprivate.h> #include <H5MMprivate.h> #include <H5Oprivate.h> -#define PABLO_MASK H5O_efl_mask +#define PABLO_MASK H5O_efl_mask /* PRIVATE PROTOTYPES */ static void *H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p); @@ -23,34 +24,35 @@ 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 */ +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 */ - H5O_efl_decode, /*decode message */ - H5O_efl_encode, /*encode message */ - 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 */ + sizeof(H5O_efl_t), /*native message size */ + H5O_efl_decode, /*decode message */ + H5O_efl_encode, /*encode message */ + 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 +#define INTERFACE_INIT NULL + /*------------------------------------------------------------------------- - * Function: H5O_efl_decode + * Function: H5O_efl_decode * - * Purpose: Decode an external file list message and return a pointer to - * the message (and some other data). + * 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. + * Return: Success: Ptr to a new message struct. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 + * Programmer: Robb Matzke + * Tuesday, November 25, 1997 * * Modifications: * @@ -59,42 +61,61 @@ static hbool_t interface_initialize_g = FALSE; static void * H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p) { - H5O_efl_t *mesg = NULL; - int i; + H5O_efl_t *mesg = NULL; + int i; + const char *s = NULL; FUNC_ENTER(H5O_efl_decode, NULL); - /* check args */ + /* Check args */ assert(f); assert(p); - /* decode */ + /* Decode the header */ 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); +#ifndef NDEBUG + assert (H5F_addr_defined (&(mesg->heap_addr))); + s = H5H_peek (f, &(mesg->heap_addr), 0); + assert (s && !*s); +#endif + UINT16DECODE(p, mesg->nalloc); + assert(mesg->nalloc>0); + UINT16DECODE(p, mesg->nused); assert(mesg->nused <= mesg->nalloc); + p += 4; /*reserved*/ - mesg->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t)); - for (i = 0; i < mesg->nused; i++) { - UINT32DECODE(p, mesg->offset[i]); + /* Decode the file list */ + mesg->slot = H5MM_xcalloc(mesg->nalloc, sizeof(H5O_efl_entry_t)); + for (i=0; i<mesg->nused; i++) { + /* Name */ + H5F_decode_length (f, p, mesg->slot[i].name_offset); + s = H5H_peek (f, &(mesg->heap_addr), mesg->slot[i].name_offset); + assert (s && *s); + mesg->slot[i].name = H5MM_xstrdup (s); + + /* File offset */ + H5F_decode_length (f, p, mesg->slot[i].offset); + + /* Size */ + H5F_decode_length (f, p, mesg->slot[i].size); + assert (mesg->slot[i].size>0); } FUNC_LEAVE(mesg); } /*------------------------------------------------------------------------- - * Function: H5O_efl_encode + * Function: H5O_efl_encode * - * Purpose: Encodes a message + * Purpose: Encodes a message. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 + * Programmer: Robb Matzke + * Tuesday, November 25, 1997 * * Modifications: * @@ -103,8 +124,10 @@ H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p) 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; + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + int i; + size_t offset; + FUNC_ENTER(H5O_efl_encode, FAIL); @@ -114,76 +137,106 @@ H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg) assert(raw_size == H5O_ALIGN (H5O_efl_size(f, _mesg))); assert(p); - /* encode */ + /* Encode header */ + assert (H5F_addr_defined (&(mesg->heap_addr))); 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]); + assert (mesg->nalloc>0); + UINT16ENCODE(p, mesg->nused); /*yes, twice*/ + assert (mesg->nused>0 && mesg->nused<=mesg->nalloc); + UINT16ENCODE(p, mesg->nused); + *p++ = 0; + *p++ = 0; + *p++ = 0; + *p++ = 0; + + /* Encode file list */ + for (i=0; i<mesg->nused; i++) { + /* + * If the name has not been added to the heap yet then do so now. + */ + if (0==mesg->slot[i].name_offset) { + offset = H5H_insert (f, &(mesg->heap_addr), + strlen (mesg->slot[i].name)+1, + mesg->slot[i].name); + if ((size_t)(-1)==offset) { + HRETURN_ERROR (H5E_EFL, H5E_CANTINIT, FAIL, + "unable to insert URL into name heap"); + } + mesg->slot[i].name_offset = offset; + } + + /* Encode the file info */ + H5F_encode_length (f, p, mesg->slot[i].name_offset); + H5F_encode_length (f, p, mesg->slot[i].offset); + H5F_encode_length (f, p, mesg->slot[i].size); } FUNC_LEAVE(SUCCEED); } + /*------------------------------------------------------------------------- - * Function: H5O_efl_copy + * Function: H5O_efl_copy * - * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if - * necessary. + * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if + * necessary. * - * Return: Success: Ptr to _DEST + * Return: Success: Ptr to _DEST * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 + * Programmer: Robb Matzke + * Tuesday, November 25, 1997 * * Modifications: * *------------------------------------------------------------------------- */ -static void * +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; + 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 = H5MM_xcalloc(1, sizeof(H5O_efl_t)); + dest->slot = H5MM_xmalloc(mesg->nalloc * sizeof(H5O_efl_entry_t)); + } else if (NULL==dest->slot || dest->nalloc<mesg->nalloc) { + H5MM_xfree(dest->slot); + dest->slot = H5MM_xmalloc(mesg->nalloc * sizeof(H5O_efl_entry_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]; + dest->slot[i] = mesg->slot[i]; + dest->slot[i].name = H5MM_xstrdup (mesg->slot[i].name); } - FUNC_LEAVE((void *) dest); + FUNC_LEAVE((void *)dest); } + /*------------------------------------------------------------------------- - * Function: H5O_efl_size + * 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. + * 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. This + * function doesn't count unused slots. * - * Return: Success: Message data size in bytes. + * Return: Success: Message data size in bytes. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 + * Programmer: Robb Matzke + * Tuesday, November 25, 1997 * * Modifications: * @@ -192,8 +245,8 @@ H5O_efl_copy(const void *_mesg, void *_dest) 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; + const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; + size_t ret_value = FAIL; FUNC_ENTER(H5O_efl_size, FAIL); @@ -201,26 +254,30 @@ H5O_efl_size(H5F_t *f, const void *_mesg) 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 */ + ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */ + 2 + /*slots allocated*/ + 2 + /*num slots used*/ + 4 + /*reserved */ + mesg->nused * (H5F_SIZEOF_SIZE(f) + /*name offset */ + H5F_SIZEOF_SIZE(f) + /*file offset */ + H5F_SIZEOF_SIZE(f)); /*file size */ FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- - * Function: H5O_efl_reset + * Function: H5O_efl_reset * - * Purpose: Frees internal pointers and resets the message to an - * initialial state. + * Purpose: Frees internal pointers and resets the message to an + * initialial state. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 + * Programmer: Robb Matzke + * Tuesday, November 25, 1997 * * Modifications: * @@ -229,7 +286,9 @@ H5O_efl_size(H5F_t *f, const void *_mesg) static herr_t H5O_efl_reset(void *_mesg) { - H5O_efl_t *mesg = (H5O_efl_t *) _mesg; + H5O_efl_t *mesg = (H5O_efl_t *) _mesg; + int i; + FUNC_ENTER(H5O_efl_reset, FAIL); @@ -237,23 +296,70 @@ H5O_efl_reset(void *_mesg) assert(mesg); /* reset */ + for (i=0; i<mesg->nused; i++) { + mesg->slot[i].name = H5MM_xfree (mesg->slot[i].name); + } + H5F_addr_undef (&(mesg->heap_addr)); mesg->nused = mesg->nalloc = 0; - mesg->offset = H5MM_xfree(mesg->offset); + mesg->slot = H5MM_xfree(mesg->slot); FUNC_LEAVE(SUCCEED); } + + +/*------------------------------------------------------------------------- + * Function: H5O_efl_total_size + * + * Purpose: Return the total size of the external file list by summing + * the sizes of all of the files. + * + * Return: Success: Total reserved size for external data. + * + * Failure: 0 + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +size_t +H5O_efl_total_size (H5O_efl_t *efl) +{ + int i; + size_t ret_value = 0, tmp; + + FUNC_ENTER (H5O_efl_total_size, 0); + + if (efl->nused>0 && + H5O_EFL_UNLIMITED==efl->slot[efl->nused-1].size) { + ret_value = H5O_EFL_UNLIMITED; + } else { + for (i=0; i<efl->nused; i++, ret_value=tmp) { + tmp = ret_value + efl->slot[i].size; + if (tmp<=ret_value) { + HRETURN_ERROR (H5E_EFL, H5E_OVERFLOW, 0, + "total external storage size overflowed"); + } + } + } + + FUNC_LEAVE (ret_value); +} + /*------------------------------------------------------------------------- - * Function: H5O_efl_debug + * Function: H5O_efl_debug * - * Purpose: Prints debugging info for a message. + * Purpose: Prints debugging info for a message. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 + * Programmer: Robb Matzke + * Tuesday, November 25, 1997 * * Modifications: * @@ -261,11 +367,11 @@ H5O_efl_reset(void *_mesg) */ static herr_t H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent, - intn fwidth) + intn fwidth) { - const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; - char buf[64]; - intn i; + const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; + char buf[64]; + intn i; FUNC_ENTER(H5O_efl_debug, FAIL); @@ -277,19 +383,33 @@ H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent, assert(fwidth >= 0); fprintf(stream, "%*s%-*s ", indent, "", fwidth, - "Heap address:"); + "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); + "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])); + sprintf (buf, "File %d", i); + fprintf (stream, "%*s%s:\n", indent, "", buf); + + fprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX (fwidth-3, 0), + "Name:", + mesg->slot[i].name); + + fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), + "Name offset:", + (unsigned long)(mesg->slot[i].name_offset)); + + fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), + "Offset of data in file:", + (unsigned long)(mesg->slot[i].offset)); + + fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), + "Bytes reserved for data:", + (unsigned long)(mesg->slot[i].size)); } FUNC_LEAVE(SUCCEED); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 0d3b2f7..f7dafb8 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -127,6 +127,28 @@ extern const H5O_class_t H5O_DTYPE[1]; /* operates on an H5T_t struct */ /* + * External File List Message + */ +#define H5O_EFL_ID 0x0007 /*external file list id */ +#define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */ +#define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */ +extern const H5O_class_t H5O_EFL[1]; /*external file list class */ + +typedef struct H5O_efl_entry_t { + size_t name_offset; /*offset of name within heap */ + char *name; /*malloc'd name */ + size_t offset; /*offset of data within file */ + size_t size; /*size allocated within file */ +} H5O_efl_entry_t; + +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 */ + H5O_efl_entry_t *slot; /*array of external file entries */ +} H5O_efl_t; + +/* * Data Layout Message */ #define H5O_LAYOUT_ID 0x0008 @@ -141,19 +163,6 @@ typedef struct H5O_layout_t { } H5O_layout_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 @@ -191,6 +200,7 @@ typedef struct H5O_stab_t { haddr_t heap_addr; /*address of name heap */ } H5O_stab_t; +/* General message operators */ herr_t H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/); herr_t H5O_open (H5F_t *f, H5G_entry_t *ent); herr_t H5O_close (H5G_entry_t *ent); @@ -203,4 +213,8 @@ herr_t H5O_remove (H5G_entry_t *ent, const H5O_class_t *type, intn sequence); herr_t H5O_reset (const H5O_class_t *type, void *native); herr_t H5O_debug (H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, intn fwidth); + +/* EFL operators */ +size_t H5O_efl_total_size (H5O_efl_t *efl); + #endif diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 7957122..f4a690e 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -296,7 +296,7 @@ H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream, if (H5S_UNLIMITED==sdim->max[u]) { fprintf (stream, "%sINF", u?", ":""); } else { - fprintf (stream, "%s%lu\n", u?", ":"", + fprintf (stream, "%s%lu", u?", ":"", (unsigned long) (sdim->max[u])); } } @@ -1,17 +1,17 @@ /**************************************************************************** -* NCSA HDF * -* Software Development Group * -* National Center for Supercomputing Applications * -* University of Illinois at Urbana-Champaign * -* 605 E. Springfield, Champaign IL 61820 * -* * -* For conditions of distribution and use, see the accompanying * -* hdf/COPYING file. * -* * +* NCSA HDF * +* Software Development Group * +* National Center for Supercomputing Applications * +* University of Illinois at Urbana-Champaign * +* 605 E. Springfield, Champaign IL 61820 * +* * +* For conditions of distribution and use, see the accompanying * +* hdf/COPYING file. * +* * ****************************************************************************/ #ifdef RCSID -static char RcsId[] = "@(#)$Revision$"; +static char RcsId[] = "@(#)$Revision$"; #endif /* $Id$ */ @@ -19,23 +19,23 @@ static char RcsId[] = "@(#)$Revision$"; #include <stdarg.h> /* Private header files */ -#include <H5private.h> /* Generic Functions */ -#include <H5Aprivate.h> /* Atoms */ -#include <H5Bprivate.h> /* B-tree subclass names */ -#include <H5Pprivate.h> /* Template information */ -#include <H5Dprivate.h> /* Datasets */ -#include <H5Eprivate.h> /* Error handling */ -#include <H5MMprivate.h> /* Memory management */ +#include <H5private.h> /* Generic Functions */ +#include <H5Aprivate.h> /* Atoms */ +#include <H5Bprivate.h> /* B-tree subclass names */ +#include <H5Dprivate.h> /* Datasets */ +#include <H5Eprivate.h> /* Error handling */ +#include <H5MMprivate.h> /* Memory management */ +#include <H5Pprivate.h> /* Property lists */ -#define PABLO_MASK H5P_mask +#define PABLO_MASK H5P_mask /* Is the interface initialized? */ -static hbool_t interface_initialize_g = FALSE; +static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT H5P_init_interface -static herr_t H5P_init_interface(void); +static herr_t H5P_init_interface(void); /* PRIVATE PROTOTYPES */ -static void H5P_term_interface(void); +static void H5P_term_interface(void); /*-------------------------------------------------------------------------- NAME @@ -52,9 +52,9 @@ DESCRIPTION static herr_t H5P_init_interface(void) { - herr_t ret_value = SUCCEED; - intn i; - herr_t status; + herr_t ret_value = SUCCEED; + intn i; + herr_t status; FUNC_ENTER(H5P_init_interface, FAIL); @@ -76,21 +76,21 @@ H5P_init_interface(void) * atom groups aren't. */ for (i = 0; i < H5P_NCLASSES; i++) { - status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), + status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), H5A_TEMPID_HASHSIZE, 0, NULL); - if (status < 0) ret_value = FAIL; + if (status < 0) ret_value = FAIL; } if (ret_value < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, - "unable to initialize atom group"); + HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, + "unable to initialize atom group"); } /* * Register cleanup function. */ if (H5_add_exit(H5P_term_interface) < 0) { - HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, - "unable to install atexit function"); + HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, + "unable to install atexit function"); } FUNC_LEAVE(ret_value); @@ -116,10 +116,10 @@ H5P_init_interface(void) static void H5P_term_interface(void) { - intn i; + intn i; for (i = 0; i < H5P_NCLASSES; i++) { - H5A_destroy_group((group_t)(H5_TEMPLATE_0 + i)); + H5A_destroy_group((group_t)(H5_TEMPLATE_0 + i)); } } @@ -130,13 +130,13 @@ H5P_term_interface(void) Returns a copy of the default template for some class of templates. USAGE herr_t H5Pcreate (type) - H5P_class_t type; IN: Template class whose default is desired. + H5P_class_t type; IN: Template class whose default is desired. RETURNS Template ID or FAIL ERRORS - ARGS BADVALUE Unknown template class. - ATOM CANTINIT Can't register template. + ARGS BADVALUE Unknown template class. + ATOM CANTINIT Can't register template. INTERNAL UNSUPPORTED Not implemented yet. DESCRIPTION @@ -145,8 +145,8 @@ H5P_term_interface(void) hid_t H5Pcreate(H5P_class_t type) { - hid_t ret_value = FAIL; - void *tmpl = NULL; + hid_t ret_value = FAIL; + void *tmpl = NULL; FUNC_ENTER(H5Pcreate, FAIL); @@ -154,50 +154,50 @@ H5Pcreate(H5P_class_t type) switch (type) { case H5P_FILE_CREATE: tmpl = H5MM_xmalloc(sizeof(H5F_create_t)); - memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t)); - break; + memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t)); + break; case H5P_FILE_ACCESS: - tmpl = H5MM_xmalloc(sizeof(H5F_access_t)); - memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t)); - break; + tmpl = H5MM_xmalloc(sizeof(H5F_access_t)); + memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t)); + break; case H5P_DATASET_CREATE: - tmpl = H5MM_xmalloc(sizeof(H5D_create_t)); - memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t)); - break; + tmpl = H5MM_xmalloc(sizeof(H5D_create_t)); + memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t)); + break; case H5P_DATASET_XFER: - tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t)); - memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t)); - break; + tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t)); + memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t)); + break; default: - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unknown template class"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unknown template class"); } /* Atomize the new template */ if ((ret_value = H5P_create(type, tmpl)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, - "can't register template"); + HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, + "can't register template"); } FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5P_create + * Function: H5P_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 H5P_release(). + * 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 H5P_release(). * - * Return: Success: A new template ID. + * Return: Success: A new template ID. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Wednesday, December 3, 1997 + * Programmer: Robb Matzke + * Wednesday, December 3, 1997 * * Modifications: * @@ -216,8 +216,8 @@ H5P_create(H5P_class_t type, void *tmpl) /* Atomize the new template */ if ((ret_value=H5A_register((group_t)(H5_TEMPLATE_0+type), tmpl)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, - "can't register template"); + HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, + "can't register template"); } FUNC_LEAVE(ret_value); @@ -230,24 +230,24 @@ H5P_create(H5P_class_t type, void *tmpl) Release access to a template object. USAGE herr_t H5Pclose(oid) - hid_t oid; IN: Template object to release access to + hid_t oid; IN: Template object to release access to RETURNS SUCCEED/FAIL DESCRIPTION - This function releases access to a template object + This function releases access to a template object --------------------------------------------------------------------------*/ herr_t H5Pclose(hid_t tid) { H5P_class_t type; - void *tmpl = NULL; + void *tmpl = NULL; FUNC_ENTER(H5Pclose, FAIL); /* Check arguments */ if ((type=H5Pget_class (tid))<0 || NULL==(tmpl=H5A_object (tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); } /* @@ -273,7 +273,7 @@ H5Pclose(hid_t tid) * Failure: FAIL * * Programmer: Robb Matzke - * Wednesday, February 18, 1998 + * Wednesday, February 18, 1998 * * Modifications: * @@ -283,6 +283,7 @@ herr_t H5P_close (H5P_class_t type, void *tmpl) { H5F_access_t *fa_list = (H5F_access_t*)tmpl; + H5D_create_t *dc_list = (H5D_create_t*)tmpl; FUNC_ENTER (H5P_close, FAIL); @@ -323,7 +324,13 @@ H5P_close (H5P_class_t type, void *tmpl) break; case H5P_FILE_CREATE: + /*nothing to do*/ + break; + case H5P_DATASET_CREATE: + H5O_reset (H5O_EFL, &(dc_list->efl)); + break; + case H5P_DATASET_XFER: /*nothing to do*/ break; @@ -340,16 +347,16 @@ H5P_close (H5P_class_t type, void *tmpl) /*------------------------------------------------------------------------- - * Function: H5Pget_class + * Function: H5Pget_class * - * Purpose: Returns the class identifier for a template. + * Purpose: Returns the class identifier for a template. * - * Return: Success: A template class + * Return: Success: A template class * - * Failure: H5P_NO_CLASS (-1) + * Failure: H5P_NO_CLASS (-1) * - * Programmer: Robb Matzke - * Wednesday, December 3, 1997 + * Programmer: Robb Matzke + * Wednesday, December 3, 1997 * * Modifications: * @@ -358,43 +365,43 @@ H5P_close (H5P_class_t type, void *tmpl) H5P_class_t H5Pget_class(hid_t tid) { - group_t group; - H5P_class_t ret_value = H5P_NO_CLASS; + group_t group; + H5P_class_t ret_value = H5P_NO_CLASS; FUNC_ENTER(H5Pget_class, H5P_NO_CLASS); if ((group = H5A_group(tid)) < 0 || #ifndef NDEBUG - group >= H5_TEMPLATE_MAX || + group >= H5_TEMPLATE_MAX || #endif - group < H5_TEMPLATE_0) { - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5P_NO_CLASS, "not a template"); + group < H5_TEMPLATE_0) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5P_NO_CLASS, "not a template"); } ret_value = (H5P_class_t)(group - H5_TEMPLATE_0); FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5Pget_version + * Function: H5Pget_version * - * Purpose: Retrieves version information for various parts of a file. + * Purpose: Retrieves version information for various parts of a file. * - * BOOT: The file boot block. - * HEAP: The global heap. - * FREELIST: The global free list. - * STAB: The root symbol table entry. - * SHHDR: Shared object headers. + * BOOT: The file boot block. + * HEAP: The global heap. + * FREELIST: The global free list. + * STAB: The root symbol table entry. + * SHHDR: Shared object headers. * - * Any (or even all) of the output arguments can be null - * pointers. + * Any (or even all) of the output arguments can be null + * pointers. * - * Return: Success: SUCCEED, version information is returned - * through the arguments. + * Return: Success: SUCCEED, version information is returned + * through the arguments. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -402,44 +409,44 @@ H5Pget_class(hid_t tid) */ herr_t H5Pget_version(hid_t tid, int *boot /*out */ , int *heap /*out */ , - int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ ) + int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ ) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_version, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } /* Get values */ if (boot) - *boot = tmpl->bootblock_ver; + *boot = tmpl->bootblock_ver; if (heap) - *heap = tmpl->smallobject_ver; + *heap = tmpl->smallobject_ver; if (freelist) - *freelist = tmpl->freespace_ver; + *freelist = tmpl->freespace_ver; if (stab) - *stab = tmpl->objectdir_ver; + *stab = tmpl->objectdir_ver; if (shhdr) - *shhdr = tmpl->sharedheader_ver; + *shhdr = tmpl->sharedheader_ver; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pset_userblock + * Function: H5Pset_userblock * - * Purpose: Sets the userblock size field of a file creation template. + * Purpose: Sets the userblock size field of a file creation template. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 * * Modifications: * @@ -448,25 +455,25 @@ H5Pget_version(hid_t tid, int *boot /*out */ , int *heap /*out */ , herr_t H5Pset_userblock(hid_t tid, size_t size) { - intn i; - H5F_create_t *tmpl = NULL; + intn i; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_userblock, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } for (i = 8; i < 8 * sizeof(int); i++) { - uintn p2 = 8 == i ? 0 : 1 << i; - if (size == p2) - break; + uintn p2 = 8 == i ? 0 : 1 << i; + if (size == p2) + break; } if (i >= 8 * sizeof(int)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "userblock size is not valid"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "userblock size is not valid"); } /* Set value */ tmpl->userblock_size = size; @@ -475,16 +482,16 @@ H5Pset_userblock(hid_t tid, size_t size) } /*------------------------------------------------------------------------- - * Function: H5Pget_userblock + * Function: H5Pget_userblock * - * Purpose: Queries the size of a user block in a file creation template. + * Purpose: Queries the size of a user block in a file creation template. * - * Return: Success: SUCCEED, size returned through SIZE argument. + * Return: Success: SUCCEED, size returned through SIZE argument. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -493,36 +500,36 @@ H5Pset_userblock(hid_t tid, size_t size) herr_t H5Pget_userblock(hid_t tid, size_t *size) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_userblock, FAIL); /* Check args */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } /* Get value */ if (size) - *size = tmpl->userblock_size; + *size = tmpl->userblock_size; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pset_sizes + * Function: H5Pset_sizes * - * Purpose: Sets file size-of addresses and sizes. TEMPLATE - * should be a file creation template. A value of zero causes - * the property to not change. + * Purpose: Sets file size-of addresses and sizes. TEMPLATE + * should be a file creation template. A value of zero causes + * the property to not change. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 * * Modifications: * @@ -531,52 +538,52 @@ H5Pget_userblock(hid_t tid, size_t *size) herr_t H5Pset_sizes(hid_t tid, size_t sizeof_addr, size_t sizeof_size) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_sizeof_addr, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } if (sizeof_addr) { - if (sizeof_addr != 2 && sizeof_addr != 4 && - sizeof_addr != 8 && sizeof_addr != 16) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file haddr_t size is not valid"); - } + if (sizeof_addr != 2 && sizeof_addr != 4 && + sizeof_addr != 8 && sizeof_addr != 16) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file haddr_t size is not valid"); + } } if (sizeof_size) { - if (sizeof_size != 2 && sizeof_size != 4 && - sizeof_size != 8 && sizeof_size != 16) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file size_t size is not valid"); - } + if (sizeof_size != 2 && sizeof_size != 4 && + sizeof_size != 8 && sizeof_size != 16) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file size_t size is not valid"); + } } /* Set value */ if (sizeof_addr) - tmpl->sizeof_addr = sizeof_addr; + tmpl->sizeof_addr = sizeof_addr; if (sizeof_size) - tmpl->sizeof_size = sizeof_size; + tmpl->sizeof_size = sizeof_size; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pget_sizes + * Function: H5Pget_sizes * - * Purpose: Returns the size of address and size quantities stored in a - * file according to a file creation template. Either (or even - * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. + * Purpose: Returns the size of address and size quantities stored in a + * file according to a file creation template. Either (or even + * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. * - * Return: Success: SUCCEED, sizes returned through arguments. + * Return: Success: SUCCEED, sizes returned through arguments. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -584,51 +591,51 @@ H5Pset_sizes(hid_t tid, size_t sizeof_addr, size_t sizeof_size) */ herr_t H5Pget_sizes(hid_t tid, - size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) + size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_sizes, FAIL); /* Check args */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } /* Get values */ if (sizeof_addr) - *sizeof_addr = tmpl->sizeof_addr; + *sizeof_addr = tmpl->sizeof_addr; if (sizeof_size) - *sizeof_size = tmpl->sizeof_size; + *sizeof_size = tmpl->sizeof_size; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pset_sym_k + * Function: H5Pset_sym_k * - * Purpose: IK is one half the rank of a tree that stores a symbol - * table for a group. Internal nodes of the symbol table are on - * average 75% full. That is, the average rank of the tree is - * 1.5 times the value of IK. + * Purpose: IK is one half the rank of a tree that stores a symbol + * table for a group. Internal nodes of the symbol table are on + * average 75% full. That is, the average rank of the tree is + * 1.5 times the value of IK. * - * LK is one half of the number of symbols that can be stored in - * a symbol table node. A symbol table node is the leaf of a - * symbol table tree which is used to store a group. When - * symbols are inserted randomly into a group, the group's - * symbol table nodes are 75% full on average. That is, they - * contain 1.5 times the number of symbols specified by LK. + * LK is one half of the number of symbols that can be stored in + * a symbol table node. A symbol table node is the leaf of a + * symbol table tree which is used to store a group. When + * symbols are inserted randomly into a group, the group's + * symbol table nodes are 75% full on average. That is, they + * contain 1.5 times the number of symbols specified by LK. * - * Either (or even both) of IK and LK can be zero in which case - * that value is left unchanged. + * Either (or even both) of IK and LK can be zero in which case + * that value is left unchanged. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 * * Modifications: * @@ -637,40 +644,40 @@ H5Pget_sizes(hid_t tid, herr_t H5Pset_sym_k(hid_t tid, int ik, int lk) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_sym_k, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } /* Set values */ if (ik > 0) { - tmpl->btree_k[H5B_SNODE_ID] = ik; + tmpl->btree_k[H5B_SNODE_ID] = ik; } if (lk > 0) { - tmpl->sym_leaf_k = lk; + tmpl->sym_leaf_k = lk; } FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pget_sym_k + * Function: H5Pget_sym_k * - * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the - * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for - * details. Either (or even both) IK and LK may be null - * pointers. + * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the + * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for + * details. Either (or even both) IK and LK may be null + * pointers. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -679,38 +686,38 @@ H5Pset_sym_k(hid_t tid, int ik, int lk) herr_t H5Pget_sym_k(hid_t tid, int *ik /*out */ , int *lk /*out */ ) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_sym_k, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } /* Get values */ if (ik) - *ik = tmpl->btree_k[H5B_SNODE_ID]; + *ik = tmpl->btree_k[H5B_SNODE_ID]; if (lk) - *lk = tmpl->sym_leaf_k; + *lk = tmpl->sym_leaf_k; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pset_istore_k + * Function: H5Pset_istore_k * - * Purpose: IK is one half the rank of a tree that stores chunked raw - * data. On average, such a tree will be 75% full, or have an - * average rank of 1.5 times the value of IK. + * Purpose: IK is one half the rank of a tree that stores chunked raw + * data. On average, such a tree will be 75% full, or have an + * average rank of 1.5 times the value of IK. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 * * Modifications: * @@ -719,19 +726,19 @@ H5Pget_sym_k(hid_t tid, int *ik /*out */ , int *lk /*out */ ) herr_t H5Pset_istore_k(hid_t tid, int ik) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_istore_k, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } if (ik <= 0) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "istore IK value must be positive"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "istore IK value must be positive"); } /* Set value */ tmpl->btree_k[H5B_ISTORE_ID] = ik; @@ -740,18 +747,18 @@ H5Pset_istore_k(hid_t tid, int ik) } /*------------------------------------------------------------------------- - * Function: H5Pget_istore_k + * Function: H5Pget_istore_k * - * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See - * H5Pset_istore_k() for details. The argument IK may be the - * null pointer. + * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See + * H5Pset_istore_k() for details. The argument IK may be the + * null pointer. * - * Return: Success: SUCCEED, size returned through IK + * Return: Success: SUCCEED, size returned through IK * - * Failure: + * Failure: * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -760,34 +767,34 @@ H5Pset_istore_k(hid_t tid, int ik) herr_t H5Pget_istore_k(hid_t tid, int *ik /*out */ ) { - H5F_create_t *tmpl = NULL; + H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_istore_k, FAIL); /* Check arguments */ if (H5P_FILE_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } /* Get value */ if (ik) - *ik = tmpl->btree_k[H5B_ISTORE_ID]; + *ik = tmpl->btree_k[H5B_ISTORE_ID]; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pset_layout + * Function: H5Pset_layout * - * Purpose: Sets the layout of raw data in the file. + * Purpose: Sets the layout of raw data in the file. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 * * Modifications: * @@ -796,19 +803,19 @@ H5Pget_istore_k(hid_t tid, int *ik /*out */ ) herr_t H5Pset_layout(hid_t tid, H5D_layout_t layout) { - H5D_create_t *tmpl = NULL; + H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_layout, FAIL); /* Check arguments */ if (H5P_DATASET_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); } if (layout < 0 || layout >= H5D_NLAYOUTS) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "raw data layout method is not valid"); + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "raw data layout method is not valid"); } /* Set value */ tmpl->layout = layout; @@ -817,16 +824,16 @@ H5Pset_layout(hid_t tid, H5D_layout_t layout) } /*------------------------------------------------------------------------- - * Function: H5Pget_layout + * Function: H5Pget_layout * - * Purpose: Retrieves layout type of a dataset creation template. + * Purpose: Retrieves layout type of a dataset creation template. * - * Return: Success: The layout type + * Return: Success: The layout type * - * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL) + * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL) * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -835,35 +842,35 @@ H5Pset_layout(hid_t tid, H5D_layout_t layout) H5D_layout_t H5Pget_layout(hid_t tid) { - H5D_create_t *tmpl = NULL; + H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_layout, H5D_LAYOUT_ERROR); /* Check arguments */ if (H5P_DATASET_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR, - "not a dataset creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR, + "not a dataset creation template"); } FUNC_LEAVE(tmpl->layout); } /*------------------------------------------------------------------------- - * Function: H5Pset_chunk + * Function: H5Pset_chunk * - * Purpose: Sets the number of dimensions and the size of each chunk to - * the values specified. The dimensionality of the chunk should - * match the dimensionality of the data space. + * Purpose: Sets the number of dimensions and the size of each chunk to + * the values specified. The dimensionality of the chunk should + * match the dimensionality of the data space. * - * As a side effect, the layout method is changed to - * H5D_CHUNKED. + * As a side effect, the layout method is changed to + * H5D_CHUNKED. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 * * Modifications: * @@ -872,59 +879,59 @@ H5Pget_layout(hid_t tid) herr_t H5Pset_chunk(hid_t tid, int ndims, const size_t dim[]) { - int i; - H5D_create_t *tmpl = NULL; + int i; + H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_chunk, FAIL); /* Check arguments */ if (H5P_DATASET_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); } if (ndims <= 0) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "chunk dimensionality must be positive"); + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "chunk dimensionality must be positive"); } if (ndims > NELMTS(tmpl->chunk_size)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "chunk dimensionality is too large"); + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "chunk dimensionality is too large"); } if (!dim) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "no chunk dimensions specified"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "no chunk dimensions specified"); } for (i = 0; i < ndims; i++) { - if (dim[i] <= 0) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "all chunk dimensions must be positive"); - } + if (dim[i] <= 0) { + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "all chunk dimensions must be positive"); + } } /* Set value */ tmpl->layout = H5D_CHUNKED; tmpl->chunk_ndims = ndims; for (i = 0; i < ndims; i++) - tmpl->chunk_size[i] = dim[i]; + tmpl->chunk_size[i] = dim[i]; FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Pget_chunk + * Function: H5Pget_chunk * - * Purpose: Retrieves the chunk size of chunked layout. The chunk - * dimensionality is returned and the chunk size in each - * dimension is returned through the DIM argument. At most - * MAX_NDIMS elements of DIM will be initialized. + * Purpose: Retrieves the chunk size of chunked layout. The chunk + * dimensionality is returned and the chunk size in each + * dimension is returned through the DIM argument. At most + * MAX_NDIMS elements of DIM will be initialized. * - * Return: Success: Positive Chunk dimensionality. + * Return: Success: Positive Chunk dimensionality. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 * * Modifications: * @@ -933,23 +940,23 @@ H5Pset_chunk(hid_t tid, int ndims, const size_t dim[]) int H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) { - int i; - H5D_create_t *tmpl = NULL; + int i; + H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_chunk, FAIL); /* Check arguments */ if (H5P_DATASET_CREATE != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); } if (H5D_CHUNKED != tmpl->layout) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "not a chunked storage layout"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "not a chunked storage layout"); } for (i = 0; i < tmpl->chunk_ndims && i < max_ndims && dim; i++) { - dim[i] = tmpl->chunk_size[i]; + dim[i] = tmpl->chunk_size[i]; } FUNC_LEAVE(tmpl->chunk_ndims); @@ -957,6 +964,182 @@ H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) /*------------------------------------------------------------------------- + * Function: H5Pset_external + * + * Purpose: Adds an external file to the list of external files. PLIST_ID + * should be an object ID for a dataset creation property list. + * NAME is the name of an external file, OFFSET is the location + * where the data starts in that file, and SIZE is the number of + * bytes reserved in the file for the data. + * + * If a dataset is split across multiple files then the files + * should be defined in order. The total size of the dataset is + * the sum of the SIZE arguments for all the external files. If + * the total size is larger than the size of a dataset then the + * dataset can be extended (provided the data space also allows + * the extending). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_external (hid_t plist_id, const char *name, size_t offset, size_t size) +{ + int idx; + size_t total, tmp; + H5D_create_t *plist = NULL; + + FUNC_ENTER(H5Pset_external, FAIL); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(plist_id) || + NULL == (plist = H5A_object(plist_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation property list"); + } + if (!name || !*name) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "no name given"); + } + if (size<=0) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "zero size"); + } + if (plist->efl.nused>0 && + H5O_EFL_UNLIMITED==plist->efl.slot[plist->efl.nused-1].size) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "previous file size is unlimited"); + } + if (H5O_EFL_UNLIMITED!=size) { + for (idx=0, total=size; idx<plist->efl.nused; idx++, total=tmp) { + tmp = total + plist->efl.slot[idx].size; + if (tmp <= total) { + HRETURN_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, + "total external data size overflowed"); + } + } + } + + /* Add to the list */ + if (plist->efl.nused>=plist->efl.nalloc) { + plist->efl.nalloc += H5O_EFL_ALLOC; + plist->efl.slot = H5MM_xrealloc (plist->efl.slot, + (plist->efl.nalloc * + sizeof(H5O_efl_entry_t))); + } + idx = plist->efl.nused; + plist->efl.slot[idx].name_offset = 0; /*not entered into heap yet*/ + plist->efl.slot[idx].name = H5MM_xstrdup (name); + plist->efl.slot[idx].offset = offset; + plist->efl.slot[idx].size = size; + plist->efl.nused++; + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_external_count + * + * Purpose: Returns the number of external files for this dataset. + * + * Return: Success: Number of external files + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5Pget_external_count (hid_t plist_id) +{ + H5D_create_t *plist = NULL; + + FUNC_ENTER (H5Pget_external_count, FAIL); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(plist_id) || + NULL == (plist = H5A_object(plist_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation property list"); + } + + /* Return */ + FUNC_LEAVE (plist->efl.nused); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_external + * + * Purpose: Returns information about an external file. External files + * are numbered from zero to N-1 where N is the value returned + * by H5Pget_external_count(). At most NAME_SIZE characters are + * copied into the NAME array. If the external file name is + * longer than NAME_SIZE with the null terminator, then the + * return value is not null terminated (similar to strncpy()). + * + * If NAME_SIZE is zero or NAME is the null pointer then the + * external file name is not returned. If OFFSET or SIZE are + * null pointers then the corresponding information is not + * returned. + * + * See Also: H5Pset_external() + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_external (hid_t plist_id, int idx, size_t name_size, char *name/*out*/, + size_t *offset/*out*/, size_t *size/*out*/) +{ + H5D_create_t *plist = NULL; + + FUNC_ENTER (H5Pget_external, FAIL); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(plist_id) || + NULL == (plist = H5A_object(plist_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation property list"); + } + if (idx<0 || idx>=plist->efl.nused) { + HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, + "external file index is out of range"); + } + + /* Return values */ + if (name_size>0 && name) { + strncpy (name, plist->efl.slot[idx].name, name_size); + } + if (offset) *offset = plist->efl.slot[idx].offset; + if (size) *size = plist->efl.slot[idx].size; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- * Function: H5Pget_driver * * Purpose: Return the ID of the low-level file driver. TID should be a @@ -967,7 +1150,7 @@ H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) * Failure: H5F_LOW_ERROR (a negative value) * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1003,7 +1186,7 @@ H5Pget_driver (hid_t tid) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Thursday, February 19, 1998 * * Modifications: * @@ -1018,8 +1201,8 @@ H5Pset_stdio (hid_t tid) /* Check arguments */ if (H5P_FILE_ACCESS != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } @@ -1035,7 +1218,7 @@ H5Pset_stdio (hid_t tid) * * Purpose: If the file access property list is set to the stdio driver * then this function returns zero; otherwise it returns a - * negative value. In the future, additional arguments may be + * negative value. In the future, additional arguments may be * added to this function to match those added to H5Pset_stdio(). * * Return: Success: SUCCEED @@ -1043,7 +1226,7 @@ H5Pset_stdio (hid_t tid) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1083,7 +1266,7 @@ H5Pget_stdio (hid_t tid) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Thursday, February 19, 1998 * * Modifications: * @@ -1098,8 +1281,8 @@ H5Pset_sec2 (hid_t tid) /* Check arguments */ if (H5P_FILE_ACCESS != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } @@ -1115,7 +1298,7 @@ H5Pset_sec2 (hid_t tid) * * Purpose: If the file access property list is set to the sec2 driver * then this function returns zero; otherwise it returns a - * negative value. In the future, additional arguments may be + * negative value. In the future, additional arguments may be * added to this function to match those added to H5Pset_sec2(). * * Return: Success: SUCCEED @@ -1123,7 +1306,7 @@ H5Pset_sec2 (hid_t tid) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1167,7 +1350,7 @@ H5Pget_sec2 (hid_t tid) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Thursday, February 19, 1998 * * Modifications: * @@ -1182,8 +1365,8 @@ H5Pset_core (hid_t tid, size_t increment) /* Check arguments */ if (H5P_FILE_ACCESS != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } if (increment<1) { @@ -1204,7 +1387,7 @@ H5Pset_core (hid_t tid, size_t increment) * * Purpose: If the file access property list is set to the core driver * then this function returns zero; otherwise it returns a - * negative value. On success, the block size is returned + * negative value. On success, the block size is returned * through the INCREMENT argument if it isn't the null pointer. * In the future, additional arguments may be added to this * function to match those added to H5Pset_core(). @@ -1214,7 +1397,7 @@ H5Pset_core (hid_t tid, size_t increment) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1258,7 +1441,7 @@ H5Pget_core (hid_t tid, size_t *increment/*out*/) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Thursday, February 19, 1998 * * Modifications: * @@ -1276,20 +1459,20 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid, /* Check arguments */ if (H5P_FILE_ACCESS != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } if (H5P_DEFAULT!=meta_tid && (H5P_FILE_ACCESS != H5Pget_class(meta_tid) || NULL == (tmpl = H5A_object(meta_tid)))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } if (H5P_DEFAULT!=raw_tid && (H5P_FILE_ACCESS != H5Pget_class(raw_tid) || NULL == (tmpl = H5A_object(raw_tid)))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } @@ -1309,12 +1492,12 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid, * * Purpose: If the file access property list is set to the sec2 driver * then this function returns zero; otherwise it returns a - * negative value. On success, at most META_EXT_SIZE characters + * negative value. On success, at most META_EXT_SIZE characters * are copied to the META_EXT buffer if non-null and at most * RAW_EXT_SIZE characters are copied to the RAW_EXT buffer if * non-null. If the actual extension is larger than the number * of characters requested then the buffer will not be null - * terminated (that is, behavior like strncpy()). In addition, + * terminated (that is, behavior like strncpy()). In addition, * if META_PROPERTIES and/or RAW_PROPERTIES are non-null then * the file access property list of the meta file and/or raw * file is copied and its OID returned through these arguments. @@ -1329,7 +1512,7 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid, * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1403,7 +1586,7 @@ H5Pget_split (hid_t tid, size_t meta_ext_size, char *meta_ext/*out*/, * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Thursday, February 19, 1998 * * Modifications: * @@ -1420,14 +1603,14 @@ H5Pset_family (hid_t tid, hid_t memb_tid) /* Check arguments */ if (H5P_FILE_ACCESS != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } if (H5P_DEFAULT!=memb_tid && (H5P_FILE_ACCESS != H5Pget_class(memb_tid) || NULL == (tmpl = H5A_object(memb_tid)))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } @@ -1444,7 +1627,7 @@ H5Pset_family (hid_t tid, hid_t memb_tid) * * Purpose: If the file access property list is set to the family driver * then this function returns zero; otherwise it returns a - * negative value. On success, if MEMB_TID is a non-null + * negative value. On success, if MEMB_TID is a non-null * pointer it will be initialized with the OID of a copy of the * file access template used for the family members. If the * family members have no file access template (that is, they @@ -1458,7 +1641,7 @@ H5Pset_family (hid_t tid, hid_t memb_tid) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1496,50 +1679,50 @@ H5Pget_family (hid_t tid, hid_t *memb_tid) /*------------------------------------------------------------------------- - * Function: H5Pset_mpi + * Function: H5Pset_mpi * - * Signature: herr_t H5Pset_mpi(hid_t tid, MPI_Comm comm, MPI_Info info, - * uintn access_mode) + * Signature: herr_t H5Pset_mpi(hid_t tid, MPI_Comm comm, MPI_Info info, + * uintn access_mode) * - * Purpose: Store the access mode for MPIO call and the user supplied - * communicator and info in the access template which can then - * be used to open file. This function is available only in the - * parallel HDF5 library and is not a collective function. + * Purpose: Store the access mode for MPIO call and the user supplied + * communicator and info in the access template which can then + * be used to open file. This function is available only in the + * parallel HDF5 library and is not a collective function. * * Parameters: - * hid_t tid - * ID of template to modify - * MPI_Comm comm - * MPI communicator to be used for file open as defined in - * MPI_FILE_OPEN of MPI-2. This function does not make a - * duplicated communicator. Any modification to comm after - * this function call returns may have undetermined effect - * to the access template. Users should call this function - * again to setup the template. - * MPI_Info info - * MPI info object to be used for file open as defined in - * MPI_FILE_OPEN of MPI-2. This function does not make a - * duplicated info. Any modification to info after - * this function call returns may have undetermined effect - * to the access template. Users should call this function - * again to setup the template. - * uintn access_mode - * File data access modes: - * H5ACC_INDEPENDENT - * Allow independent datasets access. - * H5ACC_COLLECTIVE - * Allow only collective datasets access. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Albert Cheng - * Feb 3, 1998 + * hid_t tid + * ID of template to modify + * MPI_Comm comm + * MPI communicator to be used for file open as defined in + * MPI_FILE_OPEN of MPI-2. This function does not make a + * duplicated communicator. Any modification to comm after + * this function call returns may have undetermined effect + * to the access template. Users should call this function + * again to setup the template. + * MPI_Info info + * MPI info object to be used for file open as defined in + * MPI_FILE_OPEN of MPI-2. This function does not make a + * duplicated info. Any modification to info after + * this function call returns may have undetermined effect + * to the access template. Users should call this function + * again to setup the template. + * uintn access_mode + * File data access modes: + * H5ACC_INDEPENDENT + * Allow independent datasets access. + * H5ACC_COLLECTIVE + * Allow only collective datasets access. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Albert Cheng + * Feb 3, 1998 * * Modifications: * - * Robb Matzke, 18 Feb 1998 + * Robb Matzke, 18 Feb 1998 * Check all arguments before the template is updated so we don't leave * the template in a bad state if something goes wrong. Also, the * template data type changed to allow more generality so all the @@ -1552,7 +1735,7 @@ H5Pget_family (hid_t tid, hid_t *memb_tid) herr_t H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) { - H5F_access_t *tmpl = NULL; + H5F_access_t *tmpl = NULL; MPI_Comm lcomm; int mrc; /* MPI return code */ @@ -1560,8 +1743,8 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) /* Check arguments */ if (H5P_FILE_ACCESS != H5Pget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access template"); } @@ -1594,8 +1777,8 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) * after this call. */ if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "failure to duplicate communicator"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "failure to duplicate communicator"); } tmpl->u.mpio.comm = comm; @@ -1614,7 +1797,7 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) * * Purpose: If the file access property list is set to the mpi driver * then this function returns zero; otherwise it returns a - * negative value. In the future, additional arguments may be + * negative value. In the future, additional arguments may be * added to this function to match those added to H5Pset_mpi(). * * Return: Success: SUCCEED @@ -1622,7 +1805,7 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, February 26, 1998 + * Thursday, February 26, 1998 * * Modifications: * @@ -1664,16 +1847,16 @@ H5Pget_mpi (hid_t tid, MPI_Comm *comm, MPI_Info *info, uintn *access_mode) Copy a template USAGE hid_t H5P_copy(tid) - hid_t tid; IN: Template object to copy + 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. + 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. + yet. INTERNAL UNSUPPORTED File access properties are not implemented yet. DESCRIPTION @@ -1683,20 +1866,20 @@ H5Pget_mpi (hid_t tid, MPI_Comm *comm, MPI_Info *info, uintn *access_mode) hid_t H5Pcopy(hid_t tid) { - const void *tmpl = NULL; - void *new_tmpl = NULL; - H5P_class_t type; - hid_t ret_value = FAIL; - group_t group; + const void *tmpl = NULL; + void *new_tmpl = NULL; + H5P_class_t type; + hid_t ret_value = FAIL; + group_t group; FUNC_ENTER(H5Pcopy, FAIL); /* Check args */ if (NULL == (tmpl = H5A_object(tid)) || - (type = H5Pget_class(tid)) < 0 || - (group = H5A_group(tid)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, - "can't unatomize template"); + (type = H5Pget_class(tid)) < 0 || + (group = H5A_group(tid)) < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, + "can't unatomize template"); } /* Copy it */ @@ -1707,8 +1890,8 @@ H5Pcopy(hid_t tid) /* Register the atom for the new template */ if ((ret_value = H5A_register(group, new_tmpl)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to atomize template pointer"); + HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, + "unable to atomize template pointer"); } FUNC_LEAVE(ret_value); } @@ -1724,7 +1907,7 @@ H5Pcopy(hid_t tid) * Failure: NULL * * Programmer: Robb Matzke - * Tuesday, February 3, 1998 + * Tuesday, February 3, 1998 * * Modifications: * @@ -1733,37 +1916,71 @@ H5Pcopy(hid_t tid) void * H5P_copy (H5P_class_t type, const void *src) { - size_t size; - void *dst = NULL; + size_t size; + void *dst = NULL; + int i; + const H5D_create_t *dc_src = NULL; + H5D_create_t *dc_dst = NULL; FUNC_ENTER (H5P_copy, NULL); /* How big is the template */ switch (type) { case H5P_FILE_CREATE: - size = sizeof(H5F_create_t); - break; + size = sizeof(H5F_create_t); + break; case H5P_FILE_ACCESS: size = sizeof(H5F_access_t); break; case H5P_DATASET_CREATE: - size = sizeof(H5D_create_t); - break; + size = sizeof(H5D_create_t); + break; case H5P_DATASET_XFER: - size = sizeof(H5D_xfer_t); - break; + size = sizeof(H5D_xfer_t); + break; default: - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, - "unknown template class"); + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, + "unknown template class"); } /* Create the new template */ dst = H5MM_xmalloc(size); HDmemcpy(dst, src, size); + /* Deep-copy pointers */ + switch (type) { + case H5P_FILE_CREATE: + break; + + case H5P_FILE_ACCESS: + break; + + case H5P_DATASET_CREATE: + dc_src = (const H5D_create_t*)src; + dc_dst = (H5D_create_t*)dst; + + if (dc_src->efl.nalloc>0) { + dc_dst->efl.slot = H5MM_xmalloc (dc_dst->efl.nalloc * + sizeof(H5O_efl_entry_t)); + for (i=0; i<dc_src->efl.nused; i++) { + char *s = H5MM_xstrdup (dc_src->efl.slot[i].name); + dc_dst->efl.slot[i] = dc_src->efl.slot[i]; + dc_dst->efl.slot[i].name = s; + } + } + break; + + case H5P_DATASET_XFER: + break; + + default: + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, + "unknown template class"); + } + FUNC_LEAVE (dst); } diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index b57b8e1..c5cbef8 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -62,6 +62,12 @@ herr_t H5Pset_layout (hid_t tid, H5D_layout_t layout); H5D_layout_t H5Pget_layout (hid_t tid); herr_t H5Pset_chunk (hid_t tid, int ndims, const size_t dim[]); int H5Pget_chunk (hid_t tid, int max_ndims, size_t dim[]/*out*/); +herr_t H5Pset_external (hid_t plist_id, const char *name, size_t offset, + size_t size); +int H5Pget_external_count (hid_t plist_id); +herr_t H5Pget_external (hid_t plist_id, int idx, size_t name_size, + char *name/*out*/, size_t *offset/*out*/, + size_t *size/*out*/); H5F_driver_t H5Pget_driver (hid_t tid); herr_t H5Pset_stdio (hid_t tid); herr_t H5Pget_stdio (hid_t tid); @@ -1,34 +1,34 @@ /**************************************************************************** -* NCSA HDF * -* Software Development Group * -* National Center for Supercomputing Applications * -* University of Illinois at Urbana-Champaign * -* 605 E. Springfield, Champaign IL 61820 * -* * -* For conditions of distribution and use, see the accompanying * -* hdf/COPYING file. * -* * +* NCSA HDF * +* Software Development Group * +* National Center for Supercomputing Applications * +* University of Illinois at Urbana-Champaign * +* 605 E. Springfield, Champaign IL 61820 * +* * +* For conditions of distribution and use, see the accompanying * +* hdf/COPYING file. * +* * ****************************************************************************/ #ifdef RCSID -static char RcsId[] = "@(#)$Revision$"; +static char RcsId[] = "@(#)$Revision$"; #endif /* $Id$ */ -#include <H5private.h> /* Generic Functions */ -#include <H5Aprivate.h> /* Atom Functions */ -#include <H5Eprivate.h> /* Error handling */ -#include <H5MMprivate.h> /* Memory Management functions */ -#include <H5Oprivate.h> /*object headers */ -#include <H5Sprivate.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 <H5Sprivate.h> /* Data-space functions */ /* Interface initialization */ -#define PABLO_MASK H5S_mask -#define INTERFACE_INIT H5S_init_interface -static intn interface_initialize_g = FALSE; -static herr_t H5S_init_interface(void); -static void H5S_term_interface(void); +#define PABLO_MASK H5S_mask +#define INTERFACE_INIT H5S_init_interface +static intn interface_initialize_g = FALSE; +static herr_t H5S_init_interface(void); +static void H5S_term_interface(void); /*-------------------------------------------------------------------------- @@ -46,14 +46,14 @@ DESCRIPTION static herr_t H5S_init_interface(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER(H5S_init_interface, FAIL); /* Initialize the atom group for the file IDs */ if ((ret_value = H5A_init_group(H5_DATASPACE, H5A_DATASPACEID_HASHSIZE, H5S_RESERVED_ATOMS, (herr_t (*)(void *)) H5S_close)) != FAIL) { - ret_value = H5_add_exit(&H5S_term_interface); + ret_value = H5_add_exit(&H5S_term_interface); } FUNC_LEAVE(ret_value); } @@ -83,25 +83,25 @@ H5S_term_interface(void) } /*------------------------------------------------------------------------- - * Function: H5Screate_simple + * Function: H5Screate_simple * - * Purpose: Creates a new simple data space object and opens it for + * Purpose: Creates a new simple data space object and opens it for * access. The DIMS argument is the size of the simple dataset * and the MAXDIMS argument is the upper limit on the size of * the dataset. MAXDIMS may be the null pointer in which case * the upper limit is the same as DIMS. If an element of - * MAXDIMS is zero then the corresponding dimension is unlimited, - * otherwise no element of MAXDIMS should be smaller than the - * corresponding element of DIMS. + * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is + * unlimited, otherwise no element of MAXDIMS should be smaller + * than the corresponding element of DIMS. * - * Return: Success: The ID for the new simple data space object. + * Return: Success: The ID for the new simple data space object. * - * Failure: FAIL + * Failure: FAIL * * Errors: * - * Programmer: Quincey Koziol - * Tuesday, January 27, 1998 + * Programmer: Quincey Koziol + * Tuesday, January 27, 1998 * * Modifications: * @@ -110,8 +110,8 @@ H5S_term_interface(void) hid_t H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims) { - H5S_t *ds = NULL; - hid_t ret_value = FAIL; + H5S_t *ds = NULL; + hid_t ret_value = FAIL; int i; FUNC_ENTER(H5Screate, FAIL); @@ -127,7 +127,7 @@ H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims) } if (maxdims) { for (i=0; i<rank; i++) { - if (maxdims[i] && maxdims[i]<dims[i]) { + if (H5S_UNLIMITED!=maxdims[i] && maxdims[i]<dims[i]) { HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "maxdims is smaller than dims"); } @@ -137,56 +137,56 @@ H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims) /* Create a new data space */ ds = H5MM_xcalloc(1, sizeof(H5S_t)); #ifdef LATER /* QAK */ - if(rank>0) /* for creating simple dataspace */ + if(rank>0) /* for creating simple dataspace */ { #endif /* LATER */ - ds->type = H5S_SIMPLE; - ds->hslab_def = FALSE; /* no hyperslab defined currently */ + ds->type = H5S_SIMPLE; + ds->hslab_def = FALSE; /* no hyperslab defined currently */ - /* Initialize rank and dimensions */ - ds->u.simple.rank = rank; + /* Initialize rank and dimensions */ + ds->u.simple.rank = rank; - ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(size_t)); - HDmemcpy(ds->u.simple.size, dims, rank*sizeof(size_t)); + ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(size_t)); + HDmemcpy(ds->u.simple.size, dims, rank*sizeof(size_t)); - if (maxdims) { - ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(size_t)); - HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(size_t)); - } + if (maxdims) { + ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(size_t)); + HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(size_t)); + } #ifdef LATER /* QAK */ } /* end if */ else /* rank==0, for scalar data space */ { - ds->type = H5S_SCALAR; + ds->type = H5S_SCALAR; } /* end else */ #endif /* LATER */ /* Register the new data space and get an ID for it */ if ((ret_value = H5A_register(H5_DATASPACE, ds)) < 0) { - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to register data space for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, + "unable to register data space for ID"); } done: if (ret_value < 0) { - H5MM_xfree(ds); + H5MM_xfree(ds); } FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5Sclose + * Function: H5Sclose * - * Purpose: Release access to a data space object. + * Purpose: Release access to a data space object. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * * Errors: * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -199,27 +199,27 @@ H5Sclose(hid_t space_id) /* Check args */ if (H5_DATASPACE != H5A_group(space_id) || - NULL == H5A_object(space_id)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + NULL == H5A_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"); + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id"); } FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5S_close + * Function: H5S_close * - * Purpose: Releases all memory associated with a data space. + * Purpose: Releases all memory associated with a data space. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -234,27 +234,27 @@ H5S_close(H5S_t *ds) switch (ds->type) { case H5S_SCALAR: - /*void */ - break; + /*void */ + break; case H5S_SIMPLE: - H5MM_xfree(ds->u.simple.size); - H5MM_xfree(ds->u.simple.max); - H5MM_xfree(ds->u.simple.perm); - break; + H5MM_xfree(ds->u.simple.size); + H5MM_xfree(ds->u.simple.max); + H5MM_xfree(ds->u.simple.perm); + break; case H5S_COMPLEX: - /* nothing */ - break; + /* nothing */ + break; default: - assert("unknown data space type" && 0); - break; + assert("unknown data space type" && 0); + break; } if(ds->hslab_def==TRUE) { - H5MM_xfree(ds->h.start); - H5MM_xfree(ds->h.count); - H5MM_xfree(ds->h.stride); + H5MM_xfree(ds->h.start); + H5MM_xfree(ds->h.count); + H5MM_xfree(ds->h.stride); } /* end if */ H5MM_xfree(ds); @@ -271,7 +271,7 @@ H5S_close(H5S_t *ds) * Failure: FAIL * * Programmer: Robb Matzke - * Friday, January 30, 1998 + * Friday, January 30, 1998 * * Modifications: * @@ -309,16 +309,16 @@ H5Scopy (hid_t space_id) /*------------------------------------------------------------------------- - * Function: H5S_copy + * Function: H5S_copy * - * Purpose: Copies a data space. + * Purpose: Copies a data space. * - * Return: Success: A pointer to a new copy of SRC + * Return: Success: A pointer to a new copy of SRC * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * * Modifications: * @@ -327,8 +327,8 @@ H5Scopy (hid_t space_id) H5S_t * H5S_copy(const H5S_t *src) { - H5S_t *dst = NULL; - int i; + H5S_t *dst = NULL; + int i; FUNC_ENTER(H5S_copy, NULL); @@ -337,56 +337,56 @@ H5S_copy(const H5S_t *src) switch (dst->type) { case H5S_SCALAR: - /*void */ - break; + /*void */ + break; case H5S_SIMPLE: - if (dst->u.simple.size) { - dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank * - sizeof(dst->u.simple.size[0])); - 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(dst->u.simple.max[0])); - 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(dst->u.simple.perm[0])); - for (i = 0; i < dst->u.simple.rank; i++) { - dst->u.simple.perm[i] = src->u.simple.perm[i]; - } - } - break; + if (dst->u.simple.size) { + dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank * + sizeof(dst->u.simple.size[0])); + 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(dst->u.simple.max[0])); + 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(dst->u.simple.perm[0])); + for (i = 0; i < dst->u.simple.rank; i++) { + dst->u.simple.perm[i] = src->u.simple.perm[i]; + } + } + break; case H5S_COMPLEX: - /*void */ - break; + /*void */ + break; default: - assert("unknown data space type" && 0); - break; + assert("unknown data space type" && 0); + break; } FUNC_LEAVE(dst); } /*------------------------------------------------------------------------- - * Function: H5Sget_npoints + * Function: H5Sget_npoints * - * Purpose: Determines how many data points a data set has. + * Purpose: Determines how many data points a data set has. * - * Return: Success: Number of data points in the data set. + * Return: Success: Number of data points in the data set. * - * Failure: 0 + * Failure: 0 * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -395,32 +395,33 @@ H5S_copy(const H5S_t *src) size_t H5Sget_npoints(hid_t space_id) { - H5S_t *ds = NULL; - size_t ret_value = 0; + H5S_t *ds = NULL; + size_t ret_value = 0; FUNC_ENTER(H5Sget_npoints, 0); /* Check args */ if (H5_DATASPACE != H5A_group(space_id) || - NULL == (ds = H5A_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); + NULL == (ds = H5A_object(space_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); } ret_value = H5S_get_npoints(ds); FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- - * Function: H5S_get_npoints + * Function: H5S_get_npoints * - * Purpose: Determines how many data points a data set has. + * Purpose: Determines how many data points a data set has. * - * Return: Success: Number of data points in the data set. + * Return: Success: Number of data points in the data set. * - * Failure: 0 + * Failure: 0 * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -429,8 +430,8 @@ H5Sget_npoints(hid_t space_id) size_t H5S_get_npoints(const H5S_t *ds) { - size_t ret_value = 0; - intn i; + size_t ret_value = 0; + intn i; FUNC_ENTER(H5S_get_npoints, 0); @@ -439,8 +440,8 @@ H5S_get_npoints(const H5S_t *ds) switch (ds->type) { case H5S_SCALAR: - ret_value = 1; - break; + ret_value = 1; + break; case H5S_SIMPLE: /* @@ -455,33 +456,100 @@ H5S_get_npoints(const H5S_t *ds) for (ret_value=1, i=0; i<ds->u.simple.rank; i++) { ret_value *= ds->u.simple.size[i]; } - } - break; + } + break; case H5S_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, - "complex data spaces are not supported yet"); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, + "complex data spaces are not supported yet"); default: - assert("unknown data space class" && 0); - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, - "internal error (unknown data space class)"); + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, + "internal error (unknown data space class)"); } FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5Sget_ndims + * Function: H5S_get_npoints_max * - * Purpose: Determines the dimensionality of a data space. + * Purpose: Determines the maximum number of data points a data space may + * have. If the `max' array is null then the maximum number of + * data points is the same as the current number of data points + * without regard to the hyperslab. If any element of the `max' + * array is zero then the maximum possible size is returned. * - * Return: Success: The number of dimensions in a data space. + * Return: Success: Maximum number of data points the data space + * may have. * - * Failure: FAIL + * Failure: 0 * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +size_t +H5S_get_npoints_max(const H5S_t *ds) +{ + size_t ret_value = 0; + intn i; + + FUNC_ENTER(H5S_get_npoints_max, 0); + + /* check args */ + assert(ds); + + switch (ds->type) { + case H5S_SCALAR: + ret_value = 1; + break; + + case H5S_SIMPLE: + if (ds->u.simple.max) { + for (ret_value=1, i=0; i<ds->u.simple.rank; i++) { + if (H5S_UNLIMITED==ds->u.simple.max[i]) { + ret_value = (size_t)(-1L); + break; + } else { + ret_value *= ds->u.simple.max[i]; + } + } + } else { + for (ret_value=1, i=0; i<ds->u.simple.rank; i++) { + ret_value *= ds->u.simple.size[i]; + } + } + break; + + case H5S_COMPLEX: + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, + "complex data spaces are not supported yet"); + + default: + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, + "internal error (unknown data space class)"); + } + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5Sget_ndims + * + * Purpose: Determines the dimensionality of a data space. + * + * Return: Success: The number of dimensions in a data space. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * * Modifications: * @@ -490,15 +558,15 @@ H5S_get_npoints(const H5S_t *ds) int H5Sget_ndims(hid_t space_id) { - H5S_t *ds = NULL; - intn ret_value = 0; + H5S_t *ds = NULL; + intn ret_value = 0; FUNC_ENTER(H5Sget_ndims, FAIL); /* Check args */ if (H5_DATASPACE != H5A_group(space_id) || - NULL == (ds = H5A_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + NULL == (ds = H5A_object(space_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } ret_value = H5S_get_ndims(ds); @@ -506,17 +574,17 @@ H5Sget_ndims(hid_t space_id) } /*------------------------------------------------------------------------- - * Function: H5S_get_ndims + * Function: H5S_get_ndims * - * Purpose: Returns the number of dimensions in a data space. + * Purpose: Returns the number of dimensions in a data space. * - * Return: Success: Non-negative number of dimensions. Zero - * implies a scalar. + * Return: Success: Non-negative number of dimensions. Zero + * implies a scalar. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * * Modifications: * @@ -525,7 +593,7 @@ H5Sget_ndims(hid_t space_id) intn H5S_get_ndims(const H5S_t *ds) { - intn ret_value = FAIL; + intn ret_value = FAIL; FUNC_ENTER(H5S_get_ndims, FAIL); @@ -534,39 +602,39 @@ H5S_get_ndims(const H5S_t *ds) switch (ds->type) { case H5S_SCALAR: - ret_value = 0; - break; + ret_value = 0; + break; case H5S_SIMPLE: - ret_value = ds->u.simple.rank; - break; + ret_value = ds->u.simple.rank; + break; case H5S_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "complex data spaces are not supported yet"); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "complex data spaces are not supported yet"); default: - assert("unknown data space class" && 0); - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "internal error (unknown data space class)"); + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "internal error (unknown data space class)"); } FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5Sget_dims + * Function: H5Sget_dims * - * Purpose: Returns the size in each dimension of a data space DS through - * the DIMS argument. + * Purpose: Returns the size in each dimension of a data space DS through + * the DIMS argument. * - * Return: Success: Number of dimensions, the same value as - * returned by H5Sget_ndims(). + * Return: Success: Number of dimensions, the same value as + * returned by H5Sget_ndims(). * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * * Modifications: * @@ -576,46 +644,46 @@ int H5Sget_dims(hid_t space_id, size_t dims[]/*out*/) { - H5S_t *ds = NULL; - intn ret_value = 0; + H5S_t *ds = NULL; + intn ret_value = 0; FUNC_ENTER(H5Sget_dims, FAIL); /* Check args */ if (H5_DATASPACE != H5A_group(space_id) || - NULL == (ds = H5A_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + NULL == (ds = H5A_object(space_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } if (!dims) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); } - ret_value = H5S_get_dims(ds, dims); + ret_value = H5S_get_dims(ds, dims, NULL); FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5S_get_dims + * Function: H5S_get_dims * - * Purpose: Returns the size in each dimension of a data space. This - * function may not be meaningful for all types of data spaces. + * Purpose: Returns the size in each dimension of a data space. This + * function may not be meaningful for all types of data spaces. * - * Return: Success: Number of dimensions. Zero implies scalar. + * Return: Success: Number of dimensions. Zero implies scalar. * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ intn -H5S_get_dims(const H5S_t *ds, size_t dims[]) +H5S_get_dims(const H5S_t *ds, size_t dims[], size_t max_dims[]) { - intn ret_value = FAIL; - intn i; + intn ret_value = FAIL; + intn i; FUNC_ENTER(H5S_get_dims, FAIL); @@ -625,41 +693,48 @@ H5S_get_dims(const H5S_t *ds, size_t dims[]) switch (ds->type) { case H5S_SCALAR: - ret_value = 0; - break; + ret_value = 0; + break; case H5S_SIMPLE: - ret_value = ds->u.simple.rank; - for (i = 0; i < ret_value; i++) { - dims[i] = ds->u.simple.size[i]; - } - break; + ret_value = ds->u.simple.rank; + for (i=0; i<ret_value; i++) { + if (dims) dims[i] = ds->u.simple.size[i]; + if (max_dims) { + if (ds->u.simple.max) { + max_dims[i] = ds->u.simple.max[i]; + } else { + max_dims[i] = ds->u.simple.size[i]; + } + } + } + break; case H5S_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "complex data spaces are not supported yet"); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "complex data spaces are not supported yet"); default: - assert("unknown data space class" && 0); - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "internal error (unknown data space class)"); + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "internal error (unknown data space class)"); } FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- - * Function: H5S_modify + * Function: H5S_modify * - * Purpose: Updates a data space by writing a message to an object - * header. + * Purpose: Updates a data space by writing a message to an object + * header. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -675,39 +750,39 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds) switch (ds->type) { case H5S_SCALAR: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "scalar data spaces are not implemented yet"); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "scalar data spaces are not implemented yet"); case H5S_SIMPLE: - if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) { - HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, - "can't update simple data space message"); - } - break; + if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) { + HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "can't update simple data space message"); + } + break; case H5S_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "complex data spaces are not implemented yet"); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "complex data spaces are not implemented yet"); default: - assert("unknown data space class" && 0); - break; + assert("unknown data space class" && 0); + break; } FUNC_LEAVE(SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5S_read + * Function: H5S_read * - * Purpose: Reads the data space from an object header. + * Purpose: Reads the data space from an object header. * - * Return: Success: Pointer to a new data space. + * Return: Success: Pointer to a new data space. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -716,7 +791,7 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds) H5S_t * H5S_read(H5F_t *f, H5G_entry_t *ent) { - H5S_t *ds = NULL; + H5S_t *ds = NULL; FUNC_ENTER(H5S_read, NULL); @@ -727,28 +802,28 @@ H5S_read(H5F_t *f, H5G_entry_t *ent) ds = H5MM_xcalloc(1, sizeof(H5S_t)); if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->u.simple))) { - ds->type = H5S_SIMPLE; + ds->type = H5S_SIMPLE; } else { - ds->type = H5S_SCALAR; + ds->type = H5S_SCALAR; } FUNC_LEAVE(ds); } /*------------------------------------------------------------------------- - * Function: H5S_cmp + * Function: H5S_cmp * - * Purpose: Compares two data spaces. + * 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. + * 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 + * Failure: 0, never fails * - * Programmer: Robb Matzke - * Wednesday, December 10, 1997 + * Programmer: Robb Matzke + * Wednesday, December 10, 1997 * * Modifications: * @@ -757,7 +832,7 @@ H5S_read(H5F_t *f, H5G_entry_t *ent) intn H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) { - intn i; + intn i; FUNC_ENTER(H5S_cmp, 0); @@ -767,60 +842,60 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) /* compare */ if (ds1->type < ds2->type) - HRETURN(-1); + HRETURN(-1); if (ds1->type > ds2->type) - HRETURN(1); + HRETURN(1); switch (ds1->type) { case H5S_SIMPLE: - if (ds1->u.simple.rank < ds2->u.simple.rank) - HRETURN(-1); - if (ds1->u.simple.rank > ds2->u.simple.rank) - HRETURN(1); - - 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); - } - - /* Check if we should compare hyperslab definitions */ - if(ds1->hslab_def==TRUE && ds2->hslab_def==TRUE) { - for (i = 0; i < ds1->u.simple.rank; i++) { - if (ds1->h.start[i] < ds2->h.start[i]) - HRETURN(-1); - if (ds1->h.start[i] > ds2->h.start[i]) - HRETURN(1); - if (ds1->h.count[i] < ds2->h.count[i]) - HRETURN(-1); - if (ds1->h.count[i] > ds2->h.count[i]) - HRETURN(1); - if (ds1->h.stride[i] < ds2->h.stride[i]) - HRETURN(-1); - if (ds1->h.stride[i] > ds2->h.stride[i]) - HRETURN(1); - } + if (ds1->u.simple.rank < ds2->u.simple.rank) + HRETURN(-1); + if (ds1->u.simple.rank > ds2->u.simple.rank) + HRETURN(1); + + 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); + } + + /* Check if we should compare hyperslab definitions */ + if(ds1->hslab_def==TRUE && ds2->hslab_def==TRUE) { + for (i = 0; i < ds1->u.simple.rank; i++) { + if (ds1->h.start[i] < ds2->h.start[i]) + HRETURN(-1); + if (ds1->h.start[i] > ds2->h.start[i]) + HRETURN(1); + if (ds1->h.count[i] < ds2->h.count[i]) + HRETURN(-1); + if (ds1->h.count[i] > ds2->h.count[i]) + HRETURN(1); + if (ds1->h.stride[i] < ds2->h.stride[i]) + HRETURN(-1); + if (ds1->h.stride[i] > ds2->h.stride[i]) + HRETURN(1); + } } else { - if(ds1->hslab_def!=ds2->hslab_def) - HRETURN(ds1->hslab_def==TRUE ? 1 : -1); + if(ds1->hslab_def!=ds2->hslab_def) + HRETURN(ds1->hslab_def==TRUE ? 1 : -1); } - break; + break; default: - assert("not implemented yet" && 0); + assert("not implemented yet" && 0); } FUNC_LEAVE(0); @@ -834,17 +909,17 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) Check if a dataspace is simple (internal) USAGE hbool_t H5S_is_simple(sdim) - H5S_t *sdim; IN: Pointer to dataspace object to query + H5S_t *sdim; IN: Pointer to dataspace object to query RETURNS TRUE/FALSE/FAIL DESCRIPTION - This function determines the if a dataspace is "simple". ie. if it + This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ hbool_t H5S_is_simple(const H5S_t *sdim) { - hbool_t ret_value = FAIL; + hbool_t ret_value = FAIL; FUNC_ENTER(H5S_is_simple, FAIL); @@ -863,31 +938,31 @@ H5S_is_simple(const H5S_t *sdim) Check if a dataspace is simple USAGE hbool_t H5Sis_simple(sid) - hid_t sid; IN: ID of dataspace object to query + hid_t sid; IN: ID of dataspace object to query RETURNS TRUE/FALSE/FAIL DESCRIPTION - This function determines the if a dataspace is "simple". ie. if it + This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ hbool_t H5Sis_simple(hid_t sid) { - H5S_t *space = NULL; /* dataspace to modify */ - hbool_t ret_value = FAIL; + H5S_t *space = NULL; /* dataspace to modify */ + hbool_t ret_value = FAIL; FUNC_ENTER(H5Sis_simple, FAIL); /* Check args and all the boring stuff. */ if ((space = H5A_object(sid)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); ret_value = H5S_is_simple(space); done: if (ret_value == FAIL) { /* Error condition cleanup */ - } /* end if */ + } /* end if */ /* Normal function cleanup */ FUNC_LEAVE(ret_value); } @@ -900,14 +975,14 @@ H5Sis_simple(hid_t sid) Determine the size of a dataspace USAGE herr_t H5Sset_space(sid, rank, dims) - hid_t sid; IN: Dataspace object to query - intn rank; IN: # of dimensions for the dataspace - const size_t *dims; IN: Size of each dimension for the dataspace + hid_t sid; IN: Dataspace object to query + intn rank; IN: # of dimensions for the dataspace + const size_t *dims; IN: Size of each dimension for the dataspace RETURNS SUCCEED/FAIL DESCRIPTION - This function sets the number and size of each dimension in the - dataspace. Setting RANK to a value of zero allows scalar objects to be + This function sets the number and size of each dimension in the + dataspace. Setting RANK to a value of zero allows scalar objects to be created. Dimensions are specified from slowest to fastest changing in the DIMS array (i.e. 'C' order). Setting the size of a dimension to zero indicates that the dimension is of unlimited size and should be allowed to @@ -917,17 +992,17 @@ H5Sis_simple(hid_t sid) herr_t H5Sset_space(hid_t sid, int rank, const size_t *dims) { - H5S_t *space = NULL; /* dataspace to modify */ - intn u; /* local counting variable */ - herr_t ret_value = SUCCEED; + H5S_t *space = NULL; /* dataspace to modify */ + intn u; /* local counting variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER(H5Sset_space, FAIL); /* Check args */ if ((space = H5A_object(sid)) == NULL) - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); if (rank > 0 && dims == NULL) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); if (rank<0) HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank"); if (dims) { @@ -943,52 +1018,52 @@ H5Sset_space(hid_t sid, int rank, const size_t *dims) switch (space->type) { case H5S_SCALAR: case H5S_SIMPLE: - /* do nothing */ - break; + /* do nothing */ + break; case H5S_COMPLEX: - /* - * eventually this will destroy whatever "complex" dataspace info - * is retained, right now it's an error - */ - /* Fall through to report error */ + /* + * eventually this will destroy whatever "complex" dataspace info + * is retained, right now it's an error + */ + /* Fall through to report error */ default: - HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "unknown data space class"); } space->type = H5S_SIMPLE; /* Reset hyperslab definition, if one is defined */ if(space->hslab_def==TRUE) { - H5MM_xfree(space->h.start); - H5MM_xfree(space->h.count); - H5MM_xfree(space->h.stride); - space->hslab_def=FALSE; + H5MM_xfree(space->h.start); + H5MM_xfree(space->h.count); + H5MM_xfree(space->h.stride); + space->hslab_def=FALSE; } - if (rank == 0) { /* scalar variable */ - space->type = H5S_SCALAR; - space->u.simple.rank = 0; /* set to scalar rank */ - 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); + if (rank == 0) { /* scalar variable */ + space->type = H5S_SCALAR; + space->u.simple.rank = 0; /* set to scalar rank */ + 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); } else { - /* Free the old space for now */ - 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->u.simple.rank = rank; - space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t)); - HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank); + /* Free the old space for now */ + 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->u.simple.rank = rank; + space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t)); + HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank); } FUNC_LEAVE(ret_value); @@ -1001,14 +1076,14 @@ H5Sset_space(hid_t sid, int rank, const size_t *dims) Select a hyperslab from a simple dataspace USAGE herr_t H5Sset_hyperslab(sid, start, count, stride) - hid_t sid; IN: Dataspace object to select hyperslab from - const int *start; IN: Starting location for hyperslab to select - const size_t *count; IN: Number of elements in hyperslab - const size_t *stride; IN: Packing of elements in hyperslab + hid_t sid; IN: Dataspace object to select hyperslab from + const int *start; IN: Starting location for hyperslab to select + const size_t *count; IN: Number of elements in hyperslab + const size_t *stride; IN: Packing of elements in hyperslab RETURNS SUCCEED/FAIL DESCRIPTION - This function selects a hyperslab from a simple dataspace. The stride + This function selects a hyperslab from a simple dataspace. The stride array may be used to sub-sample the hyperslab chosen, a value of 1 in each position of the stride array selects contiguous elements in the array, a value of 2 selects every other element, etc. If the stride parameter is @@ -1019,63 +1094,63 @@ H5Sset_space(hid_t sid, int rank, const size_t *dims) herr_t H5Sset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t *stride) { - H5S_t *space = NULL; /* dataspace to modify */ - size_t *tmp_stride=NULL; /* temp. copy of stride */ - intn u; /* local counting variable */ - herr_t ret_value = SUCCEED; + H5S_t *space = NULL; /* dataspace to modify */ + size_t *tmp_stride=NULL; /* temp. copy of stride */ + intn u; /* local counting variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER(H5Sset_hyperslab, FAIL); /* Get the object */ if (H5_DATASPACE != H5A_group(sid) || (space = H5A_object(sid)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); if (start == NULL || count==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid hyperslab selected"); /* We can't modify other types of dataspaces currently, so error out */ if (space->type!=H5S_SIMPLE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "unknown dataspace type"); /* Set up stride values for later use */ tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(tmp_stride[0])); for (u=0; u<space->u.simple.rank; u++) { - tmp_stride[u] = stride ? stride[u] : 1; + tmp_stride[u] = stride ? stride[u] : 1; } /* Range check arguments */ for (u=0; u<space->u.simple.rank; u++) { - if (start[u]<0 || start[u]>=space->u.simple.size[u]) { - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + if (start[u]<0 || start[u]>=space->u.simple.size[u]) { + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "hyperslab bounds out of range"); } if (start[u]<0 || start[u]+(count[u]*tmp_stride[u])>space->u.simple.size[u]) { - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "hyperslab bounds out of range"); } } /* Allocate space for the hyperslab information */ if (NULL==space->h.start) { - space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn)); - space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); - space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); + space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn)); + space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); + space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); } /* Build hyperslab */ for(u=0; u<space->u.simple.rank; u++) { - space->h.start[u] = start[u]; - space->h.count[u] = count[u]; - space->h.stride[u] = tmp_stride[u]; + space->h.start[u] = start[u]; + space->h.count[u] = count[u]; + space->h.stride[u] = tmp_stride[u]; } space->hslab_def=TRUE; done: - if (ret_value == FAIL) { /* Error condition cleanup */ + if (ret_value == FAIL) { /* Error condition cleanup */ - } /* end if */ + } /* end if */ /* Normal function cleanup */ H5MM_xfree(tmp_stride); @@ -1086,7 +1161,7 @@ done: * Function: H5Sget_hyperslab * * Purpose: Retrieves information about the hyperslab from a simple data - * space. If no hyperslab has been defined then the hyperslab + * space. If no hyperslab has been defined then the hyperslab * is the same as the entire array. * * Return: Success: Hyperslab dimensionality. @@ -1094,7 +1169,7 @@ done: * Failure: FAIL * * Programmer: Robb Matzke - * Wednesday, January 28, 1998 + * Wednesday, January 28, 1998 * * Modifications: * @@ -1127,7 +1202,7 @@ H5Sget_hyperslab (hid_t sid, int offset[]/*out*/, size_t size[]/*out*/, * Function: H5S_get_hyperslab * * Purpose: Retrieves information about the hyperslab from a simple data - * space. If no hyperslab has been defined then the hyperslab + * space. If no hyperslab has been defined then the hyperslab * is the same as the entire array. * * Return: Success: Hyperslab dimensionality. @@ -1135,7 +1210,7 @@ H5Sget_hyperslab (hid_t sid, int offset[]/*out*/, size_t size[]/*out*/, * Failure: FAIL * * Programmer: Robb Matzke - * Wednesday, January 28, 1998 + * Wednesday, January 28, 1998 * * Modifications: * @@ -1197,7 +1272,7 @@ H5S_get_hyperslab (const H5S_t *ds, int offset[]/*out*/, * Failure: NULL * * Programmer: Robb Matzke - * Wednesday, January 21, 1998 + * Wednesday, January 21, 1998 * * Modifications: * @@ -1207,7 +1282,7 @@ const H5S_conv_t * H5S_find (const H5S_t *mem_space, const H5S_t *file_space) { static H5S_conv_t _conv; - static const H5S_conv_t *conv = NULL; + static const H5S_conv_t *conv = NULL; FUNC_ENTER (H5S_find, NULL); @@ -1251,7 +1326,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space) * Failure: FAIL * * Programmer: Robb Matzke - * Friday, January 30, 1998 + * Friday, January 30, 1998 * * Modifications: * diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 25e758e..79d7bf2 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -93,8 +93,10 @@ typedef struct H5S_tconv_t { H5S_t *H5S_copy (const H5S_t *src); herr_t H5S_close (H5S_t *ds); size_t H5S_get_npoints (const H5S_t *ds); +size_t H5S_get_npoints_max(const H5S_t *ds); intn H5S_get_ndims (const H5S_t *ds); -intn H5S_get_dims (const H5S_t *ds, size_t dims[]/*out*/); +intn H5S_get_dims (const H5S_t *ds, size_t dims[]/*out*/, + size_t max_dims[]/*out*/); herr_t H5S_modify (H5G_entry_t *ent, const H5S_t *space); H5S_t *H5S_read (H5F_t *f, H5G_entry_t *ent); intn H5S_cmp (const H5S_t *ds1, const H5S_t *ds2); diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 3fe0a31..784ca53 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -22,7 +22,7 @@ /* Define atomic datatypes */ #define H5S_ALL (-2) -#define H5S_UNLIMITED 0 +#define H5S_UNLIMITED ((size_t)(-1L)) /* Different types of dataspaces */ typedef enum H5S_class_t { diff --git a/src/H5Ssimp.c b/src/H5Ssimp.c index 99900c2..6f4dd4f 100644 --- a/src/H5Ssimp.c +++ b/src/H5Ssimp.c @@ -243,7 +243,7 @@ H5S_simp_mscat (const void *tconv_buf, size_t elmt_size, "hyperslab sampling is not implemented yet"); } } - if (H5S_get_dims (mem_space, mem_size)<0) { + if (H5S_get_dims (mem_space, mem_size, NULL)<0) { HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to retrieve data space dimensions"); } @@ -348,7 +348,7 @@ H5S_simp_mgath (const void *buf, size_t elmt_size, "hyperslab sampling is not implemented yet"); } } - if (H5S_get_dims (mem_space, mem_size)<0) { + if (H5S_get_dims (mem_space, mem_size, NULL)<0) { HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, "unable to retrieve data space dimensions"); } @@ -1774,7 +1774,7 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad) * *------------------------------------------------------------------------- */ -intn +int H5Tget_nmembers(hid_t type_id) { diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 665295a..db72bab 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -206,7 +206,7 @@ size_t H5Tget_ebias (hid_t type_id); H5T_norm_t H5Tget_norm (hid_t type_id); H5T_pad_t H5Tget_inpad (hid_t type_id); H5T_str_t H5Tget_strpad (hid_t type_id); -intn H5Tget_nmembers (hid_t type_id); +int H5Tget_nmembers (hid_t type_id); char *H5Tget_member_name (hid_t type_id, int membno); size_t H5Tget_member_offset (hid_t type_id, int membno); int H5Tget_member_dims (hid_t type_id, int membno, size_t dims[]/*out*/, @@ -41,7 +41,7 @@ static hbool_t interface_initialize_g = TRUE; */ herr_t H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, - intn *stride1) + ssize_t *stride1) { FUNC_ENTER(H5V_stride_optimize1, FAIL); @@ -54,10 +54,10 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, /* * Combine adjacent memory accesses */ - while (*np && stride1[*np - 1] == *elmt_size) { - *elmt_size *= size[*np - 1]; + while (*np && stride1[*np-1] == *elmt_size) { + *elmt_size *= size[*np-1]; if (--*np) { - stride1[*np - 1] += size[*np] * stride1[*np]; + stride1[*np-1] += size[*np] * stride1[*np]; } } @@ -88,7 +88,7 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, */ herr_t H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, - intn *stride1, intn *stride2) + ssize_t *stride1, ssize_t *stride2) { FUNC_ENTER(H5V_stride_optimize2, FAIL); @@ -101,12 +101,12 @@ H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, /* * Combine adjacent memory accesses */ - while (*np && stride1[*np - 1] == *elmt_size && - stride2[*np - 1] == *elmt_size) { - *elmt_size *= size[*np - 1]; + while (*np && stride1[*np-1] == *elmt_size && + stride2[*np-1] == *elmt_size) { + *elmt_size *= size[*np-1]; if (--*np) { - stride1[*np - 1] += size[*np] * stride1[*np]; - stride2[*np - 1] += size[*np] * stride2[*np]; + stride1[*np-1] += size[*np] * stride1[*np]; + stride2[*np-1] += size[*np] * stride2[*np]; } } @@ -145,7 +145,7 @@ H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, size_t H5V_hyper_stride(intn n, const size_t *size, const size_t *total_size, const size_t *offset, - intn *stride/*out*/) + ssize_t *stride/*out*/) { size_t skip; /*starting point byte offset */ size_t acc; /*accumulator */ @@ -165,9 +165,9 @@ H5V_hyper_stride(intn n, const size_t *size, /* others */ for (i = n - 2, acc = 1; i >= 0; --i) { size_t tmp = acc * (total_size[i+1] - size[i+1]); - assert (tmp<((size_t)1<<(8*sizeof(intn)-1))); - stride[i] = (intn)tmp; - acc *= total_size[i + 1]; + assert (tmp<((size_t)1<<(8*sizeof(ssize_t)-1))); + stride[i] = (size_t)tmp; /*overflow checked*/ + acc *= total_size[i+1]; skip += acc * (offset ? offset[i] : 0); } @@ -290,7 +290,7 @@ H5V_hyper_fill(intn n, const size_t *_size, { uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */ size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */ - intn dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */ + ssize_t dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */ size_t dst_start; /*byte offset to start of stride*/ size_t elmt_size = 1; /*bytes per element */ herr_t status; /*function return status */ @@ -373,8 +373,8 @@ H5V_hyper_copy(intn n, const size_t *_size, const uint8 *src = (const uint8 *)_src; /*cast for ptr arithmtc */ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmtc */ size_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */ - intn src_stride[H5V_HYPER_NDIMS]; /*source stride info */ - intn dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */ + ssize_t src_stride[H5V_HYPER_NDIMS]; /*source stride info */ + ssize_t dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */ size_t dst_start, src_start; /*offset to start at */ size_t elmt_size = 1; /*element size in bytes */ herr_t status; /*return status */ @@ -436,7 +436,7 @@ H5V_hyper_copy(intn n, const size_t *_size, */ herr_t H5V_stride_fill(intn n, size_t elmt_size, const size_t *size, - const intn *stride, void *_dst, uint8 fill_value) + const ssize_t *stride, void *_dst, uint8 fill_value) { uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */ @@ -457,10 +457,8 @@ H5V_stride_fill(intn n, size_t elmt_size, const size_t *size, for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) { dst += stride[j]; - if (--idx[j]) - carry = FALSE; - else - idx[j] = size[j]; + if (--idx[j]) carry = FALSE; + else idx[j] = size[j]; } } @@ -492,8 +490,8 @@ H5V_stride_fill(intn n, size_t elmt_size, const size_t *size, */ herr_t H5V_stride_copy(intn n, size_t elmt_size, const size_t *size, - const intn *dst_stride, void *_dst, - const intn *src_stride, const void *_src) + const ssize_t *dst_stride, void *_dst, + const ssize_t *src_stride, const void *_src) { uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic*/ const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmetic*/ @@ -547,11 +545,11 @@ herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, /* destination */ - intn dst_n, const size_t *dst_size, const intn *dst_stride, + intn dst_n, const size_t *dst_size, const ssize_t *dst_stride, void *_dst, /* source */ - intn src_n, const size_t *src_size, const intn *src_stride, + intn src_n, const size_t *src_size, const ssize_t *src_stride, const void *_src) { uint8 *dst = (uint8 *) _dst; diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index f0cda44..863fd2e 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -29,7 +29,7 @@ #define H5V_ZERO NULL size_t H5V_hyper_stride(intn n, const size_t *size, const size_t *total_size, - const size_t *offset, intn *stride); + const size_t *offset, ssize_t *stride); hbool_t H5V_hyper_disjointp(intn n, const size_t *offset1, const size_t *size1, const size_t *offset2, const size_t *size2); @@ -42,18 +42,18 @@ herr_t H5V_hyper_copy(intn n, const size_t *size, void *_dst, const size_t *src_total_size, const size_t *src_offset, const void *_src); herr_t H5V_stride_fill(intn n, size_t elmt_size, const size_t *size, - const intn *stride, void *_dst, uint8 fill_value); + const ssize_t *stride, void *_dst, uint8 fill_value); herr_t H5V_stride_copy(intn n, size_t elmt_size, const size_t *_size, - const intn *dst_stride, void *_dst, - const intn *src_stride, const void *_src); + const ssize_t *dst_stride, void *_dst, + const ssize_t *src_stride, const void *_src); herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, intn dst_n, - const size_t *dst_size, const intn *dst_stride, + const size_t *dst_size, const ssize_t *dst_stride, void *_dst, intn src_n, const size_t *src_size, - const intn *src_stride, const void *_src); + const ssize_t *src_stride, const void *_src); herr_t H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, - intn *stride1); + ssize_t *stride1); herr_t H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, - intn *stride1, intn *stride2); + ssize_t *stride1, ssize_t *stride2); /*------------------------------------------------------------------------- diff --git a/src/H5private.h b/src/H5private.h index 49437cc..10f5161 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -107,12 +107,87 @@ #endif /* + * Numeric data types + */ +typedef char char8; +typedef signed char int8; +typedef unsigned char uchar8, uint8; + +#if SIZEOF_SHORT==2 +typedef short int16; +typedef unsigned short uint16; +#else +typedef int int16; /*not really */ +typedef unsigned uint16; /*not really */ +#endif + +#if SIZEOF_INT==4 +typedef int int32; +typedef unsigned int uint32; +#elif SIZEOF_LONG==4 +typedef long int32; +typedef unsigned long uint32; +#else +typedef int int32; /*not really */ +typedef unsigned uint32; /*not really */ +#endif + +#if SIZEOF_INT==8 +typedef int int64; +typedef unsigned uint64; +#elif SIZEOF_LONG==8 +typedef long int64; +typedef unsigned long uint64; +#elif SIZEOF_LONG_LONG==8 +typedef long long int64; +typedef unsigned long long uint64; +#else +# error "no 64-bit integer type" +#endif + +#if SIZEOF_FLOAT==4 +typedef float float32; +#else +typedef float float32; /*not really */ +#endif + +#if SIZEOF_FLOAT==8 +typedef float float64; +#elif SIZEOF_DOUBLE==8 +typedef double float64; +#else +# error "no 64-bit floating point type" +#endif + +/* + * Define a type for generic integers. Use this instead of `int' to + * show that some thought went into the algorithm. + */ +typedef int intn; +typedef unsigned uintn; + +/* + * Status return values for the `herr_t' type. + * Since some unix/c routines use 0 and -1 (or more precisely, non-negative + * vs. negative) as their return code, and some assumption had been made in + * the code about that, it is important to keep these constants the same + * values. When checking the success or failure of an integer-valued + * function, remember to compare against zero and not one of these two + * values. + */ +#define SUCCEED 0 +#define FAIL (-1) +#define UFAIL (unsigned)(-1) + +/* * File addresses. */ typedef struct { uint64 offset; /*offset within an HDF5 file */ } haddr_t; +#define H5F_ADDR_UNDEF {((uint64)(-1L))} + /* * Some compilers have problems declaring auto variables that point * to string constants. Use the CONSTR() macro so it's easy to fix diff --git a/src/H5public.h b/src/H5public.h index ed7933f..912d935 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -24,79 +24,17 @@ #endif /* - * Data types + * Status return values. Failed integer functions in HDF5 result almost + * always in a negative value (unsigned failing functions sometimes return + * zero for failure) while successfull return is non-negative (often zero). + * The negative failure value is most commonly -1, but don't bet on it. The + * proper way to detect failure is something like: + * + * if ((dset = H5Dopen (file, name))<0) { + * fprintf (stderr, "unable to open the requested dataset\n"); + * } */ -typedef char char8; -typedef signed char int8; -typedef unsigned char uchar8, uint8; - -#if SIZEOF_SHORT==2 -typedef short int16; -typedef unsigned short uint16; -#else -typedef int int16; /*not really */ -typedef unsigned uint16; /*not really */ -#endif - -#if SIZEOF_INT==4 -typedef int int32; -typedef unsigned int uint32; -#elif SIZEOF_LONG==4 -typedef long int32; -typedef unsigned long uint32; -#else -typedef int int32; /*not really */ -typedef unsigned uint32; /*not really */ -#endif - -#if SIZEOF_INT==8 -typedef int int64; -typedef unsigned uint64; -#elif SIZEOF_LONG==8 -typedef long int64; -typedef unsigned long uint64; -#elif SIZEOF_LONG_LONG==8 -typedef long long int64; -typedef unsigned long long uint64; -#else -# error "no 64-bit integer type" -#endif - -#if SIZEOF_FLOAT==4 -typedef float float32; -#else -typedef float float32; /*not really */ -#endif - -#if SIZEOF_FLOAT==8 -typedef float float64; -#elif SIZEOF_DOUBLE==8 -typedef double float64; -#else -# error "no 64-bit floating point type" -#endif - -/* - * Define a type for generic integers. Use this instead of `int' to - * show that some thought went into the algorithm. - */ -typedef int intn; -typedef unsigned uintn; - -/* - * Status return values. - * Since some unix/c routines use 0 and -1 (or more precisely, non-negative - * vs. negative) as their return code, and some assumption had been made in - * the code about that, it is important to keep these constants the same - * values. When checking the success or failure of an integer-valued - * function, remember to compare against zero and not one of these two - * values. - */ -typedef intn herr_t; - -#define SUCCEED 0 -#define FAIL (-1) -#define UFAIL (unsigned)(-1) +typedef int herr_t; /* * Boolean type. @@ -111,7 +49,8 @@ extern "C" { herr_t H5open (void); herr_t H5close (void); herr_t H5dont_atexit (void); -herr_t H5version (uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum); +herr_t H5version (unsigned *majnum, unsigned *minnum, unsigned *relnum, + unsigned *patnum); #ifdef __cplusplus } |