diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-04 07:37:15 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-04 07:37:15 (GMT) |
commit | 0a8bba91530eb333e7d3f17e18aac12db44eda63 (patch) | |
tree | 9b6cf88bc5113878ddeca5facadc1c3347ba0654 /src/H5Oefl.c | |
parent | f555ac654b71f0bcaab99775f8c2fe1dac26bfab (diff) | |
download | hdf5-0a8bba91530eb333e7d3f17e18aac12db44eda63.zip hdf5-0a8bba91530eb333e7d3f17e18aac12db44eda63.tar.gz hdf5-0a8bba91530eb333e7d3f17e18aac12db44eda63.tar.bz2 |
[svn-r13232] Description:
Remove the "scaffolding" for shared message method invocation and
simplify the way shared messages are dealt with in general.
Tested on:
FreeBSD/32 6.2 (duty)
Mac OS X/32 10.4.8 (amazon)
Diffstat (limited to 'src/H5Oefl.c')
-rw-r--r-- | src/H5Oefl.c | 142 |
1 files changed, 59 insertions, 83 deletions
diff --git a/src/H5Oefl.c b/src/H5Oefl.c index ce6a9e5..fbf3806 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -29,12 +29,12 @@ /* PRIVATE PROTOTYPES */ static void *H5O_efl_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p); -static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg); +static herr_t H5O_efl_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static void *H5O_efl_copy(const void *_mesg, void *_dest); -static size_t H5O_efl_size(const H5F_t *f, const void *_mesg); +static size_t H5O_efl_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O_efl_reset(void *_mesg); -static void *H5O_efl_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, - void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata); +static void *H5O_efl_copy_file(H5F_t *file_src, void *mesg_src, + H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata); static herr_t H5O_efl_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int indent, int fwidth); @@ -43,6 +43,7 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ H5O_EFL_ID, /*message id number */ "external file list", /*message name for debugging */ sizeof(H5O_efl_t), /*native message size */ + FALSE, /* messages are sharable? */ H5O_efl_decode, /*decode message */ H5O_efl_encode, /*encode message */ H5O_efl_copy, /*copy native value */ @@ -51,10 +52,8 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ NULL, /* free method */ NULL, /* file delete method */ NULL, /* link method */ - NULL, /*get share method */ NULL, /*set share method */ NULL, /*can share method */ - NULL, /*is shared method */ NULL, /* pre copy native value to file */ H5O_efl_copy_file, /* copy native value to file */ NULL, /* post copy native value to file */ @@ -183,29 +182,20 @@ done: * Programmer: Robb Matzke * Tuesday, November 25, 1997 * - * Modifications: - * Robb Matzke, 1998-07-20 - * Rearranged the message to add a version number near the beginning. - * - * Robb Matzke, 1999-10-14 - * Entering the name into the local heap happens when the dataset is - * created. Otherwise we could end up in infinite recursion if the heap - * happens to hash to the same cache slot as the object header. - * *------------------------------------------------------------------------- */ static herr_t -H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg) +H5O_efl_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; size_t u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_encode); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_encode) /* check args */ - assert(f); - assert(mesg); - assert(p); + HDassert(f); + HDassert(mesg); + HDassert(p); /* Version */ *p++ = H5O_EFL_VERSION; @@ -216,29 +206,29 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = 0; /* Number of slots */ - assert (mesg->nalloc>0); + HDassert(mesg->nalloc > 0); UINT16ENCODE(p, mesg->nused); /*yes, twice*/ - assert (mesg->nused>0 && mesg->nused<=mesg->nalloc); + HDassert(mesg->nused > 0 && mesg->nused <= mesg->nalloc); UINT16ENCODE(p, mesg->nused); /* Heap address */ - assert (H5F_addr_defined(mesg->heap_addr)); + HDassert(H5F_addr_defined(mesg->heap_addr)); H5F_addr_encode(f, &p, mesg->heap_addr); /* Encode file list */ - for (u=0; u<mesg->nused; u++) { + for(u = 0; u < mesg->nused; u++) { /* * The name should have been added to the heap when the dataset was * created. */ - assert(mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH (f, p, mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH (f, p, mesg->slot[u].offset); - H5F_ENCODE_LENGTH (f, p, mesg->slot[u].size); - } + HDassert(mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); + } /* end for */ - FUNC_LEAVE_NOAPI(SUCCEED); -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_efl_encode() */ /*------------------------------------------------------------------------- @@ -254,8 +244,6 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg) * Programmer: Robb Matzke * Tuesday, November 25, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * @@ -311,21 +299,19 @@ done: * Programmer: Robb Matzke * Tuesday, November 25, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static size_t -H5O_efl_size(const H5F_t *f, const void *_mesg) +H5O_efl_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; size_t ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_size); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_size) /* check args */ - assert(f); - assert(mesg); + HDassert(f); + HDassert(mesg); ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */ 2 + /*slots allocated*/ @@ -335,8 +321,8 @@ H5O_efl_size(const H5F_t *f, const void *_mesg) H5F_SIZEOF_SIZE(f) + /*file offset */ H5F_SIZEOF_SIZE(f)); /*file size */ - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_efl_size() */ /*------------------------------------------------------------------------- @@ -350,8 +336,6 @@ H5O_efl_size(const H5F_t *f, const void *_mesg) * Programmer: Robb Matzke * Tuesday, November 25, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -360,21 +344,21 @@ H5O_efl_reset(void *_mesg) H5O_efl_t *mesg = (H5O_efl_t *) _mesg; size_t u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_reset); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_reset) /* check args */ - assert(mesg); + HDassert(mesg); /* reset */ - for (u=0; u<mesg->nused; u++) - mesg->slot[u].name = H5MM_xfree (mesg->slot[u].name); + for(u = 0; u < mesg->nused; u++) + mesg->slot[u].name = H5MM_xfree(mesg->slot[u].name); mesg->heap_addr = HADDR_UNDEF; mesg->nused = mesg->nalloc = 0; if(mesg->slot) mesg->slot = H5MM_xfree(mesg->slot); - FUNC_LEAVE_NOAPI(SUCCEED); -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_efl_reset() */ /*------------------------------------------------------------------------- @@ -390,8 +374,6 @@ H5O_efl_reset(void *_mesg) * Programmer: Robb Matzke * Tuesday, March 3, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ hsize_t @@ -399,24 +381,23 @@ H5O_efl_total_size (H5O_efl_t *efl) { hsize_t ret_value = 0, tmp; - FUNC_ENTER_NOAPI_NOINIT(H5O_efl_total_size); + FUNC_ENTER_NOAPI_NOINIT(H5O_efl_total_size) - if (efl->nused>0 && - H5O_EFL_UNLIMITED==efl->slot[efl->nused-1].size) { + if(efl->nused > 0 && H5O_EFL_UNLIMITED == efl->slot[efl->nused - 1].size) ret_value = H5O_EFL_UNLIMITED; - } else { + else { size_t u; /* Local index variable */ - for (u=0; u<efl->nused; u++, ret_value=tmp) { + for(u = 0; u < efl->nused; u++, ret_value = tmp) { tmp = ret_value + efl->slot[u].size; - if (tmp<=ret_value) - HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); - } - } + if(tmp <= ret_value) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); + } /* end for */ + } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_efl_total_size() */ /*------------------------------------------------------------------------- @@ -431,14 +412,11 @@ done: * Programmer: Peter Cao * September 29, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * -H5O_efl_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *mesg_type, - void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t UNUSED *cpy_info, - void UNUSED *_udata) +H5O_efl_copy_file(H5F_t UNUSED *file_src, void *mesg_src, H5F_t *file_dst, + hid_t dxpl_id, H5O_copy_t UNUSED *cpy_info, void UNUSED *_udata) { H5O_efl_t *efl_src = (H5O_efl_t *) mesg_src; H5O_efl_t *efl_dst = NULL; @@ -479,14 +457,14 @@ H5O_efl_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *mesg_typ /* copy content from the source. Need to update later */ HDmemcpy(efl_dst->slot, efl_src->slot, size); - } + } /* end if */ /* copy the name from the source */ for(idx = 0; idx < efl_src->nused; idx++) { efl_dst->slot[idx].name = H5MM_xstrdup(efl_src->slot[idx].name); efl_dst->slot[idx].name_offset = H5HL_insert(file_dst, dxpl_id, efl_dst->heap_addr, - HDstrlen(efl_dst->slot[idx].name)+1, efl_dst->slot[idx].name); - } + HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name); + } /* end for */ /* Set return value */ ret_value = efl_dst; @@ -497,7 +475,7 @@ done: H5MM_xfree(efl_dst); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5O_efl_copy_file() */ /*------------------------------------------------------------------------- @@ -510,8 +488,6 @@ done: * Programmer: Robb Matzke * Tuesday, November 25, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -522,14 +498,14 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s char buf[64]; size_t u; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_debug); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_debug) /* check args */ - assert(f); - assert(mesg); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); + HDassert(f); + HDassert(mesg); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Heap address:", mesg->heap_addr); @@ -538,7 +514,7 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s "Slots used/allocated:", mesg->nused, mesg->nalloc); - for (u = 0; u < mesg->nused; u++) { + for(u = 0; u < mesg->nused; u++) { sprintf (buf, "File %u", (unsigned)u); HDfprintf (stream, "%*s%s:\n", indent, "", buf); @@ -557,8 +533,8 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s HDfprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Bytes reserved for data:", (unsigned long)(mesg->slot[u].size)); - } + } /* end for */ - FUNC_LEAVE_NOAPI(SUCCEED); -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_efl_debug() */ |