From 390f1d02846803abfd46d30b3bd27894a30698c6 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 8 May 2003 15:09:07 -0500 Subject: [svn-r6837] Purpose: Code cleanup. Description: Move many package or internal function prototypes and macro definitions into tighter scope according to their current use. Added more comments where appropriate. Eliminate ancient, unused functions. Added a couple "accessor" functions to get parts of data structures which were moved out of scope. Platforms tested: h5committested --- src/H5A.c | 7 +++-- src/H5Apkg.h | 11 +++++-- src/H5Aprivate.h | 13 ++++----- src/H5D.c | 19 +++++++++--- src/H5Distore.c | 4 +-- src/H5Dpkg.h | 2 +- src/H5Dprivate.h | 2 +- src/H5F.c | 2 +- src/H5Fistore.c | 4 +-- src/H5G.c | 25 ++++++++-------- src/H5Gprivate.h | 6 ++-- src/H5Oattr.c | 16 +++++------ src/H5Odtype.c | 14 ++++----- src/H5Ofill.c | 14 ++++----- src/H5Pdcpl.c | 4 +-- src/H5S.c | 88 ++++++-------------------------------------------------- src/H5Shyper.c | 6 +++- src/H5Spkg.h | 51 +++++++++++++++++++++++++++++--- src/H5Spoint.c | 6 +++- src/H5Sprivate.h | 74 ++++++----------------------------------------- src/H5T.c | 61 ++++++++++++++++++++++++++++++++++++--- src/H5Tconv.c | 4 +-- src/H5Tpkg.h | 41 +++++++++++++++++++++++--- src/H5Tprivate.h | 64 ++++++----------------------------------- 24 files changed, 261 insertions(+), 277 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index ad4a357..7adae38 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -46,6 +46,9 @@ static int H5A_get_index(H5G_entry_t *ent, const char *name, hid_t dxpl_id); static hsize_t H5A_get_storage_size(H5A_t *attr); static herr_t H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t dxpl_id); +/* The number of reserved IDs in dataset ID group */ +#define H5A_RESERVED_ATOMS 0 + /*-------------------------------------------------------------------------- NAME @@ -631,7 +634,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(mem_type, attr->dt, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); - } else if (!H5T_IS_NOOP(tpath)) { + } else if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); @@ -784,7 +787,7 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(attr->dt, mem_type, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); - } else if (!H5T_IS_NOOP(tpath)) { + } else if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); diff --git a/src/H5Apkg.h b/src/H5Apkg.h index bcfd74e..c66cf9c 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -34,9 +34,12 @@ # undef H5A_DEBUG #endif +/* Get package's private header */ #include "H5Aprivate.h" -#include "H5HGprivate.h" -#include "H5Sprivate.h" + +/* Other private headers needed by this file */ +#include "H5HGprivate.h" /* Global heaps */ +#include "H5Sprivate.h" /* Dataspace */ struct H5A_t { unsigned initialized;/* Indicate whether the attribute has been modified */ @@ -53,6 +56,8 @@ struct H5A_t { H5F_t *sh_file; /*file pointer if this is a shared attribute */ }; -/* Function prototypes for H5T package scope */ +/* Function prototypes for H5A package scope */ +H5_DLL H5A_t *H5A_copy(const H5A_t *old_attr); +H5_DLL herr_t H5A_close(H5A_t *attr); #endif diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index 2323040..8d694bc 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -18,17 +18,16 @@ #ifndef _H5Aprivate_H #define _H5Aprivate_H +/* Include package's public header */ #include "H5Apublic.h" -#include "H5Gprivate.h" - -#define H5A_RESERVED_ATOMS 0 -typedef struct H5A_t H5A_t; /* Private headers needed by this file */ +#include "H5Gprivate.h" /* Groups */ + +/* Forward references of package typedefs */ +typedef struct H5A_t H5A_t; -/* Functions defined in H5A.c */ -H5_DLL H5A_t *H5A_copy(const H5A_t *old_attr); -H5_DLL herr_t H5A_close(H5A_t *attr); +/* Library private functions in package */ H5_DLL H5G_entry_t *H5A_entof(H5A_t *attr); #endif diff --git a/src/H5D.c b/src/H5D.c index 1713d71..49df6c3 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -20,7 +20,7 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ -#include "H5HLprivate.h" /* Name heap */ +#include "H5HLprivate.h" /* Local heaps */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace functions */ @@ -58,6 +58,17 @@ static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_close(H5D_t *dataset); +/* Internal data structure for computing variable-length dataset's total size */ +typedef struct { + hid_t dataset_id; /* ID of the dataset we are working on */ + hid_t fspace_id; /* ID of the file dataset's dataspace we are working on */ + hid_t mspace_id; /* ID of the memory dataset's dataspace we are working on */ + void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ + void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ + hid_t xfer_pid; /* ID of the dataset xfer property list */ + hsize_t size; /* Accumulated number of bytes for the selection */ +} H5D_vlen_bufsize_t; + /* Declare a free list to manage the H5D_t struct */ H5FL_DEFINE_STATIC(H5D_t); @@ -2908,7 +2919,7 @@ done: static void * H5D_vlen_get_buf_size_alloc(size_t size, void *info) { - H5T_vlen_bufsize_t *vlen_bufsize=(H5T_vlen_bufsize_t *)info; + H5D_vlen_bufsize_t *vlen_bufsize=(H5D_vlen_bufsize_t *)info; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size_alloc, NULL); @@ -2955,7 +2966,7 @@ done: static herr_t H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t *point, void *op_data) { - H5T_vlen_bufsize_t *vlen_bufsize=(H5T_vlen_bufsize_t *)op_data; + H5D_vlen_bufsize_t *vlen_bufsize=(H5D_vlen_bufsize_t *)op_data; H5T_t *dt = NULL; herr_t ret_value=0; /* The correct return value, if this function succeeds */ @@ -3015,7 +3026,7 @@ herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { - H5T_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0, 0}; + H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0, 0}; char bogus; /* bogus value to pass to H5Diterate() */ H5P_genclass_t *pclass; /* Property class */ H5P_genplist_t *plist; /* Property list */ diff --git a/src/H5Distore.c b/src/H5Distore.c index 9629963..3209814 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -44,9 +44,9 @@ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-link trees */ -#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" +#include "H5Fpkg.h" /* Files */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File space management */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 093360b..23897dd 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -31,7 +31,7 @@ #include "H5Dprivate.h" /* Other private headers needed by this file */ -#include "H5Gprivate.h" /* Group headers */ +#include "H5Gprivate.h" /* Groups */ #include "H5Oprivate.h" /* Object headers */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5Tprivate.h" /* Datatype functions */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 38c13b7..724c349 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -18,6 +18,7 @@ #ifndef _H5Dprivate_H #define _H5Dprivate_H +/* Include package's public header */ #include "H5Dpublic.h" /* Private headers needed by this file */ @@ -172,5 +173,4 @@ H5_DLL herr_t H5D_xfer_copy(hid_t new_plist_id, hid_t old_plist_id, H5_DLL herr_t H5D_xfer_close(hid_t dxpl_id, void *close_data); H5_DLL herr_t H5D_flush(H5F_t *f, hid_t dxpl_id); - #endif diff --git a/src/H5F.c b/src/H5F.c index d03440f..c186db9 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -47,7 +47,7 @@ #include "H5FLprivate.h" /*Free Lists */ #include "H5FPprivate.h" /*Flexible Parallel HDF5 */ #include "H5Iprivate.h" /*object IDs */ -#include "H5Gprivate.h" /*symbol tables */ +#include "H5Gprivate.h" /* Groups */ #include "H5MMprivate.h" /*core memory management */ #include "H5Pprivate.h" /*property lists */ #include "H5Tprivate.h" /*data types */ diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 9629963..3209814 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -44,9 +44,9 @@ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-link trees */ -#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" +#include "H5Fpkg.h" /* Files */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File space management */ diff --git a/src/H5G.c b/src/H5G.c index 6b5e9ae..d04b611 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -89,21 +89,22 @@ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ /* Packages needed by this file... */ -#include "H5private.h" -#include "H5Aprivate.h" -#include "H5Bprivate.h" -#include "H5Dprivate.h" -#include "H5Eprivate.h" -#include "H5Fpkg.h" /*file access */ -#include "H5FLprivate.h" /*Free Lists */ -#include "H5Gpkg.h" -#include "H5HLprivate.h" -#include "H5Iprivate.h" -#include "H5MMprivate.h" -#include "H5Oprivate.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Bprivate.h" /* B-trees */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ #define H5G_INIT_HEAP 8192 #define H5G_RESERVED_ATOMS 0 + #define PABLO_MASK H5G_mask /* Interface initialization */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 64b7689..46a321b 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -34,9 +34,9 @@ #include "H5Gpublic.h" /* Private headers needed by this file */ -#include "H5private.h" -#include "H5Bprivate.h" -#include "H5Fprivate.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-trees */ +#include "H5Fprivate.h" /* File access */ #include "H5RSprivate.h" /* Reference-counted strings */ /* diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 8b0326f..df6e740 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -16,14 +16,14 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ -#include "H5private.h" -#include "H5Apkg.h" -#include "H5Eprivate.h" -#include "H5FLprivate.h" /*Free Lists */ -#include "H5Gprivate.h" -#include "H5MMprivate.h" -#include "H5Opkg.h" /* Object header functions */ -#include "H5Spkg.h" /* Data spaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ #define PABLO_MASK H5O_attr_mask diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 43d2aea..5b8b479 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -15,13 +15,13 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5T_PACKAGE /*prevent warning from including H5Tpkg */ -#include "H5private.h" -#include "H5Eprivate.h" -#include "H5FLprivate.h" /*Free Lists */ -#include "H5Gprivate.h" -#include "H5MMprivate.h" -#include "H5Opkg.h" /* Object header functions */ -#include "H5Tpkg.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Tpkg.h" /* Datatypes */ #define PABLO_MASK H5O_dtype_mask diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 210b2de..8fbe390 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -21,13 +21,13 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ -#include "H5private.h" -#include "H5Eprivate.h" -#include "H5FLprivate.h" /*Free Lists */ -#include "H5Iprivate.h" -#include "H5MMprivate.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object header functions */ -#include "H5Pprivate.h" +#include "H5Pprivate.h" /* Property lists */ #define PABLO_MASK H5O_fill_mask @@ -870,7 +870,7 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type, hid_t dxpl_id) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); HDmemcpy(buf, fill->buf, H5T_get_size(fill->type)); } - if (tpath->cdata.need_bkg && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type)))) + if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); /* Do the conversion */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 4787987..d52c3cf 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1275,12 +1275,12 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/) */ if (H5T_get_size(type)>=H5T_get_size(fill.type)) { buf = value; - if (tpath->cdata.need_bkg && NULL==(bkg=H5MM_malloc(H5T_get_size(type)))) + if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } else { if (NULL==(buf=H5MM_malloc(H5T_get_size(fill.type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); - if (tpath->cdata.need_bkg) + if (H5T_path_bkg(tpath)) bkg = value; } HDmemcpy(buf, fill.buf, H5T_get_size(fill.type)); diff --git a/src/H5S.c b/src/H5S.c index 08212c4..61b2b04 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -24,6 +24,11 @@ #include "H5Spkg.h" /* Dataspace functions */ /* Local static function prototypes */ +static H5S_t * H5S_create(H5S_class_t type); +static herr_t H5S_set_extent_simple (H5S_t *space, unsigned rank, + const hsize_t *dims, const hsize_t *max); +static htri_t H5S_is_simple(const H5S_t *sdim); +static herr_t H5S_extent_release(H5S_t *ds); /* Interface initialization */ #define PABLO_MASK H5S_mask @@ -295,7 +300,7 @@ H5S_term_interface(void) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -H5S_t * +static H5S_t * H5S_create(H5S_class_t type) { H5S_t *ret_value; @@ -389,7 +394,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_extent_release(H5S_t *ds) { herr_t ret_value=SUCCEED; /* Return value */ @@ -1222,81 +1227,6 @@ done: } -/*------------------------------------------------------------------------- - * Function: H5S_cmp - * - * Purpose: Compares two data space extents. - * - * Return: Success: 0 if DS1 and DS2 are the same. - * <0 if DS1 is less than DS2. - * >0 if DS1 is greater than DS2. - * - * Failure: 0, never fails - * - * Programmer: Robb Matzke - * Wednesday, December 10, 1997 - * - * Modifications: - * 6/9/98 Changed to only compare extents - QAK - * - *------------------------------------------------------------------------- - */ -int -H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) -{ - unsigned u; - int ret_value=0; /* Return value */ - - FUNC_ENTER_NOAPI(H5S_cmp, 0); - - /* check args */ - assert(ds1); - assert(ds2); - - /* compare */ - if (ds1->extent.type < ds2->extent.type) - HGOTO_DONE(-1); - if (ds1->extent.type > ds2->extent.type) - HGOTO_DONE(1); - - switch (ds1->extent.type) { - case H5S_SIMPLE: - if (ds1->extent.u.simple.rank < ds2->extent.u.simple.rank) - HGOTO_DONE(-1); - if (ds1->extent.u.simple.rank > ds2->extent.u.simple.rank) - HGOTO_DONE(1); - - for (u = 0; u < ds1->extent.u.simple.rank; u++) { - if (ds1->extent.u.simple.size[u] < ds2->extent.u.simple.size[u]) - HGOTO_DONE(-1); - if (ds1->extent.u.simple.size[u] > ds2->extent.u.simple.size[u]) - HGOTO_DONE(1); - } - - /* don't compare max dimensions */ - -#ifdef LATER - for (u = 0; u < ds1->extent.u.simple.rank; u++) { - if ((ds1->extent.u.simple.perm ? ds1->extent.u.simple.perm[u] : u) < - (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i)) - HGOTO_DONE(-1); - if ((ds1->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : u) > - (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i)) - HGOTO_DONE(1); - } -#endif - - break; - - default: - assert("not implemented yet" && 0); - } - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - /*-------------------------------------------------------------------------- NAME H5S_is_simple @@ -1311,7 +1241,7 @@ done: This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_is_simple(const H5S_t *sdim) { htri_t ret_value; @@ -1444,7 +1374,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max) { diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 59858fe..c8b019d 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -41,6 +41,10 @@ static herr_t H5S_hyper_free_span (H5S_hyper_span_t *span); static H5S_hyper_span_info_t *H5S_hyper_copy_span (H5S_hyper_span_info_t *spans); static herr_t H5S_hyper_span_scratch (H5S_hyper_span_info_t *spans, void *scr_value); static herr_t H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t elmt_size); +/* Needed for use in hyperslab code (H5Shyper.c) */ +#ifdef NEW_HYPERSLAB_API +static herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2); +#endif /*NEW_HYPERSLAB_API*/ /* Declare a free list to manage the H5S_hyper_span_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_span_t); @@ -5518,7 +5522,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2) { H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 7844d14..61f291f 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -29,6 +29,16 @@ #include "H5Sprivate.h" +/* Number of reserved IDs in ID group */ +#define H5S_RESERVED_ATOMS 2 + +/* Flags to indicate special dataspace features are active */ +#define H5S_VALID_MAX 0x01 +#define H5S_VALID_PERM 0x02 + +/* Flags for "get_seq_list" methods */ +#define H5S_GET_SEQ_LIST_SORTED 0x0001 + /* * Dataspace extent information */ @@ -173,6 +183,10 @@ H5_DLL herr_t H5S_close_simple(H5S_simple_t *simple); H5_DLL herr_t H5S_release_simple(H5S_simple_t *simple); H5_DLL herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src); +/* Operations on selections */ +H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src); +H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); + /* Point selection iterator functions */ H5_DLL herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, size_t elmt_size); H5_DLL herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords); @@ -262,9 +276,38 @@ H5_DLL htri_t H5S_none_is_regular(const H5S_t *space); H5_DLL herr_t H5S_none_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -/* Needed for use in hyperslab code (H5Shyper.c) */ -#ifdef NEW_HYPERSLAB_API -H5_DLL herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2); -#endif /*NEW_HYPERSLAB_API*/ + +#ifdef H5_HAVE_PARALLEL +/* MPI-IO function to read directly from app buffer to file rky980813 */ +H5_DLL herr_t H5S_mpio_spaces_read(H5F_t *f, + const struct H5O_layout_t *layout, + H5P_genplist_t *dc_plist, + const H5O_efl_t *efl, + size_t elmt_size, const H5S_t *file_space, + const H5S_t *mem_space, hid_t dxpl_id, + void *buf/*out*/); + +/* MPI-IO function to write directly from app buffer to file rky980813 */ +H5_DLL herr_t H5S_mpio_spaces_write(H5F_t *f, + struct H5O_layout_t *layout, + H5P_genplist_t *dc_plist, + const H5O_efl_t *efl, + size_t elmt_size, const H5S_t *file_space, + const H5S_t *mem_space, hid_t dxpl_id, + const void *buf); + +/* MPI-IO function to check if a direct I/O transfer is possible between + * memory and the file */ +H5_DLL htri_t H5S_mpio_opt_possible(const H5S_t *mem_space, + const H5S_t *file_space, const unsigned flags); + +#ifndef _H5S_IN_H5S_C +/* Global vars whose value comes from environment variable */ +/* (Defined in H5S.c) */ +H5_DLLVAR hbool_t H5S_mpi_opt_types_g; +H5_DLLVAR hbool_t H5S_mpi_prefer_derived_types_g; +#endif /* _H5S_IN_H5S_C */ + +#endif /* H5_HAVE_PARALLEL */ #endif /*_H5Spkg_H*/ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index eefd599..9eab6bc 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -34,6 +34,10 @@ #define INTERFACE_INIT NULL static int interface_initialize_g = 0; +/* Static function prototypes */ +static herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, + size_t num_elem, const hssize_t **coord); + /* Declare a free list to manage the H5S_pnt_node_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_node_t); @@ -419,7 +423,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t **coord) { diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 6ca9802..36675ea 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -21,17 +21,12 @@ #include "H5Spublic.h" /* Private headers needed by this file */ -#include "H5private.h" -#include "H5Dpublic.h" -#include "H5Fprivate.h" -#include "H5Oprivate.h" -#include "H5Pprivate.h" - -#define H5S_RESERVED_ATOMS 2 - -/* Flags to indicate special dataspace features are active */ -#define H5S_VALID_MAX 0x01 -#define H5S_VALID_PERM 0x02 +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ /* Flags for H5S_find */ #define H5S_CONV_PAR_IO_POSSIBLE 0x0001 @@ -42,16 +37,12 @@ #define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */ #define H5S_CONV_STORAGE_MASK 0x0006 -/* Flags for "get_seq_list" methods */ -#define H5S_GET_SEQ_LIST_SORTED 0x0001 - -/* Forward references of common typedefs */ +/* Forward references of package typedefs */ typedef struct H5S_t H5S_t; typedef struct H5S_pnt_node_t H5S_pnt_node_t; typedef struct H5S_hyper_span_t H5S_hyper_span_t; typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t; typedef struct H5S_hyper_dim_t H5S_hyper_dim_t; -union H5D_storage_t; /* Point selection iteration container */ typedef struct { @@ -128,7 +119,7 @@ typedef struct H5S_conv_t { /* Read from file to application w/o intermediate scratch buffer */ herr_t (*read)(H5F_t *f, const struct H5O_layout_t *layout, - H5P_genplist_t *dc_plist, const union H5D_storage_t *store, + H5P_genplist_t *dc_plist, const H5D_storage_t *store, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, hid_t dxpl_id, void *buf/*out*/); @@ -160,9 +151,7 @@ typedef struct H5S_conv_t { #endif } H5S_conv_t; -/* We get the declaration of H5G_entry_t from the H5Oprivate.h file */ - -H5_DLL H5S_t *H5S_create(H5S_class_t type); +/* Operations on dataspaces */ H5_DLL H5S_t *H5S_copy(const H5S_t *src); H5_DLL herr_t H5S_close(H5S_t *ds); H5_DLL H5S_conv_t *H5S_find(const H5S_t *mem_space, const H5S_t *file_space, @@ -173,15 +162,10 @@ H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds); H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/, hsize_t max_dims[]/*out*/); -H5_DLL herr_t H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims, - const hsize_t *max); H5_DLL herr_t H5S_modify(struct H5G_entry_t *ent, const H5S_t *space, hbool_t update_time, hid_t dxpl_id); H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds); H5_DLL H5S_t *H5S_read(struct H5G_entry_t *ent, hid_t dxpl_id); -H5_DLL int H5S_cmp(const H5S_t *ds1, const H5S_t *ds2); -H5_DLL htri_t H5S_is_simple(const H5S_t *sdim); -H5_DLL herr_t H5S_extent_release(H5S_t *space); H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size); H5_DLL int H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], @@ -190,10 +174,8 @@ H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream int indent, int fwidth); /* Operations on selections */ -H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src); H5_DLL herr_t H5S_select_deserialize(H5S_t *space, const uint8_t *buf); H5_DLL H5S_sel_type H5S_get_select_type(const H5S_t *space); -H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); H5_DLL herr_t H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t op, void *operator_data); H5_DLL herr_t H5S_select_fill(void *fill, size_t fill_size, @@ -220,11 +202,6 @@ H5_DLL herr_t H5S_select_write(H5F_t *f, struct H5O_layout_t *layout, H5P_genplist_t *dc_plist, const union H5D_storage_t *store, size_t elmt_size, const H5S_t *file_space, const H5S_t *mem_space, hid_t dxpl_id, const void *buf/*out*/); -H5_DLL herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, - size_t num_elem, const hssize_t **coord); -#ifdef NEW_HYPERSLAB_API -H5_DLL herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2); -#endif /*NEW_HYPERSLAB_API */ H5_DLL htri_t H5S_select_valid(const H5S_t *space); H5_DLL hssize_t H5S_get_select_npoints(const H5S_t *space); H5_DLL herr_t H5S_select_all(H5S_t *space, unsigned rel_prev); @@ -243,37 +220,4 @@ H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter); H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); -#ifdef H5_HAVE_PARALLEL -/* MPI-IO function to read directly from app buffer to file rky980813 */ -H5_DLL herr_t H5S_mpio_spaces_read(H5F_t *f, - const struct H5O_layout_t *layout, - H5P_genplist_t *dc_plist, - const H5O_efl_t *efl, - size_t elmt_size, const H5S_t *file_space, - const H5S_t *mem_space, hid_t dxpl_id, - void *buf/*out*/); - -/* MPI-IO function to write directly from app buffer to file rky980813 */ -H5_DLL herr_t H5S_mpio_spaces_write(H5F_t *f, - struct H5O_layout_t *layout, - H5P_genplist_t *dc_plist, - const H5O_efl_t *efl, - size_t elmt_size, const H5S_t *file_space, - const H5S_t *mem_space, hid_t dxpl_id, - const void *buf); - -/* MPI-IO function to check if a direct I/O transfer is possible between - * memory and the file */ -H5_DLL htri_t H5S_mpio_opt_possible(const H5S_t *mem_space, - const H5S_t *file_space, const unsigned flags); - -#ifndef _H5S_IN_H5S_C -/* Global vars whose value comes from environment variable */ -/* (Defined in H5S.c) */ -H5_DLLVAR hbool_t H5S_mpi_opt_types_g; -H5_DLLVAR hbool_t H5S_mpi_prefer_derived_types_g; -#endif /* _H5S_IN_H5S_C */ - -#endif /* H5_HAVE_PARALLEL */ - #endif /* _H5Sprivate_H */ diff --git a/src/H5T.c b/src/H5T.c index 7f5f7a9..6179ff4 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -21,10 +21,10 @@ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ -#include "H5private.h" /*generic functions */ -#include "H5Dprivate.h" /*datasets (for H5Tcopy) */ -#include "H5Eprivate.h" /*error handling */ -#include "H5FLprivate.h" /*Free Lists */ +#include "H5private.h" /*generic functions */ +#include "H5Dprivate.h" /*datasets (for H5Tcopy) */ +#include "H5Eprivate.h" /*error handling */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Gprivate.h" /*groups */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ @@ -4757,6 +4757,59 @@ done: /*------------------------------------------------------------------------- + * Function: H5T_path_noop + * + * Purpose: Is the path the special no-op path? The no-op function can be + * set by the application and there might be more than one no-op + * path in a multi-threaded application if one thread is using + * the no-op path when some other thread changes its definition. + * + * Return: TRUE/FALSE (can't fail) + * + * Programmer: Quincey Koziol + * Thursday, May 8, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hbool_t +H5T_path_noop(const H5T_path_t *p) +{ + FUNC_ENTER_NOINIT(H5T_path_noop); + + assert(p); + + FUNC_LEAVE_NOAPI(p->is_hard && 0==H5T_cmp(p->src, p->dst)); +} /* end H5T_path_noop() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_path_bkg + * + * Purpose: Get the "background" flag for the conversion path. + * + * Return: Background flag (can't fail) + * + * Programmer: Quincey Koziol + * Thursday, May 8, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5T_bkg_t +H5T_path_bkg(const H5T_path_t *p) +{ + FUNC_ENTER_NOINIT(H5T_path_bkg); + + assert(p); + + FUNC_LEAVE_NOAPI(p->cdata.need_bkg); +} /* end H5T_path_bkg() */ + + +/*------------------------------------------------------------------------- * Function: H5T_convert * * Purpose: Call a conversion function to convert from source to diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 5f195d1..13a6737 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -2226,7 +2226,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* Set up conversion path for base elements */ if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes"); - } else if (!H5T_IS_NOOP(tpath)) { + } else if (!H5T_path_noop(tpath)) { if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 || (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); @@ -2475,7 +2475,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* Set up conversion path for base elements */ if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes"); - } else if (!H5T_IS_NOOP(tpath)) { + } else if (!H5T_path_noop(tpath)) { if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 || (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 23da545..6fccdba 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -34,12 +34,45 @@ # undef H5T_DEBUG #endif -#include "H5HGprivate.h" -#include "H5Dprivate.h" -#include "H5Fprivate.h" -#include "H5Rprivate.h" +/* Get package's private header */ #include "H5Tprivate.h" +#include "H5Dprivate.h" /* Datasets */ +#include "H5Fprivate.h" /* Files */ +#include "H5HGprivate.h" /* Global heaps */ + +/* Number of reserved IDs in ID group */ +#define H5T_RESERVED_ATOMS 8 + +/* Length of debugging name buffer */ +#define H5T_NAMELEN 32 + +/* Statistics about a conversion function */ +struct H5T_stats_t { + unsigned ncalls; /*num calls to conversion function */ + hsize_t nelmts; /*total data points converted */ + H5_timer_t timer; /*total time for conversion */ +}; + +/* The data type conversion database */ +struct H5T_path_t { + char name[H5T_NAMELEN]; /*name for debugging only */ + H5T_t *src; /*source data type ID */ + H5T_t *dst; /*destination data type ID */ + H5T_conv_t func; /*data conversion function */ + hbool_t is_hard; /*is it a hard function? */ + H5T_stats_t stats; /*statistics for the conversion */ + H5T_cdata_t cdata; /*data for this function */ +}; + +/* VL types */ +typedef enum { + H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ + H5T_VLEN_SEQUENCE=0, /* VL sequence */ + H5T_VLEN_STRING, /* VL string */ + H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */ +} H5T_vlen_type_t; + typedef struct H5T_atomic_t { H5T_order_t order; /*byte order */ size_t prec; /*precision in bits */ diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index ddbd42d..deccfc5 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -21,14 +21,14 @@ #include "H5Tpublic.h" /* Private headers needed by this file */ -#include "H5private.h" -#include "H5Gprivate.h" /*for H5G_entry_t */ -#include "H5Rprivate.h" /*for H5R_type_t */ - -#define H5T_RESERVED_ATOMS 8 -#define H5T_NAMELEN 32 /*length of debugging name buffer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Rprivate.h" /* References */ +/* Forward references of package typedefs */ typedef struct H5T_t H5T_t; +typedef struct H5T_stats_t H5T_stats_t; +typedef struct H5T_path_t H5T_path_t; /* How to copy a data type */ typedef enum H5T_copy_t { @@ -37,34 +37,7 @@ typedef enum H5T_copy_t { H5T_COPY_REOPEN } H5T_copy_t; -/* Statistics about a conversion function */ -typedef struct H5T_stats_t { - unsigned ncalls; /*num calls to conversion function */ - hsize_t nelmts; /*total data points converted */ - H5_timer_t timer; /*total time for conversion */ -} H5T_stats_t; - -/* The data type conversion database */ -typedef struct H5T_path_t { - char name[H5T_NAMELEN]; /*name for debugging only */ - H5T_t *src; /*source data type ID */ - H5T_t *dst; /*destination data type ID */ - H5T_conv_t func; /*data conversion function */ - hbool_t is_hard; /*is it a hard function? */ - H5T_stats_t stats; /*statistics for the conversion */ - H5T_cdata_t cdata; /*data for this function */ -} H5T_path_t; - -/* - * VL types allowed. - */ -typedef enum { - H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ - H5T_VLEN_SEQUENCE=0, /* VL sequence */ - H5T_VLEN_STRING, /* VL string */ - H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */ -} H5T_vlen_type_t; - +/* Location of VL information */ typedef enum { H5T_VLEN_BADLOC = 0, /* invalid VL Type */ H5T_VLEN_MEMORY, /* VL data stored in memory */ @@ -72,27 +45,6 @@ typedef enum { H5T_VLEN_MAXLOC /* highest type (Invalid as true type) */ } H5T_vlen_loc_t; -/* - * Internal data structure for passing information to H5T_vlen_get_buf_size - */ -typedef struct { - hid_t dataset_id; /* ID of the dataset we are working on */ - hid_t fspace_id; /* ID of the file dataset's dataspace we are working on */ - hid_t mspace_id; /* ID of the memory dataset's dataspace we are working on */ - void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ - void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ - hid_t xfer_pid; /* ID of the dataset xfer property list */ - hsize_t size; /* Accumulated number of bytes for the selection */ -} H5T_vlen_bufsize_t; - -/* - * Is the path the special no-op path? The no-op function can be set by the - * application and there might be more than one no-op path in a - * multi-threaded application if one thread is using the no-op path when some - * other thread changes its definition. - */ -#define H5T_IS_NOOP(P) ((P)->is_hard && 0==H5T_cmp((P)->src, (P)->dst)) - /* Private functions */ H5_DLL herr_t H5TN_init_interface(void); H5_DLL herr_t H5T_init(void); @@ -111,6 +63,8 @@ H5_DLL htri_t H5T_is_immutable(H5T_t *dt); H5_DLL htri_t H5T_is_named(H5T_t *dt); H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_t func, hid_t dxpl_id); +H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p); +H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p); H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -- cgit v0.12