mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-17 16:10:24 +08:00
[svn-r13173] Description:
Checkpoint more progress toward implementing shared message "interface" methods for message classes that can have messages shared. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
This commit is contained in:
parent
3ededdb9e2
commit
af394eaa76
@ -95,8 +95,7 @@ H5FL_EXTERN(H5S_t);
|
||||
/* Declare external the free list for H5S_extent_t's */
|
||||
H5FL_EXTERN(H5S_extent_t);
|
||||
|
||||
#ifdef NOT_YET
|
||||
/* Set up & include shared message callbacks */
|
||||
/* Set up & include shared message "interface" info */
|
||||
#define H5O_SHARED_TYPE H5O_MSG_ATTR
|
||||
#define H5O_SHARED_DECODE H5O_attr_shared_decode
|
||||
#define H5O_SHARED_DECODE_REAL H5O_attr_decode
|
||||
@ -111,7 +110,6 @@ H5FL_EXTERN(H5S_extent_t);
|
||||
#define H5O_SHARED_COPY_FILE H5O_attr_shared_copy_file
|
||||
#define H5O_SHARED_COPY_FILE_REAL H5O_attr_copy_file
|
||||
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
|
||||
#endif /* NOT_YET */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
10
src/H5Opkg.h
10
src/H5Opkg.h
@ -430,6 +430,16 @@ H5_DLL herr_t H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
|
||||
/* Shared object operators */
|
||||
H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
|
||||
const H5O_msg_class_t *type, void *mesg);
|
||||
H5_DLL herr_t H5O_shared_decode_new(H5F_t *f, const uint8_t *buf, H5O_shared_t *sh_mesg);
|
||||
H5_DLL herr_t H5O_shared_encode_new(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg);
|
||||
H5_DLL size_t H5O_shared_size_new(const H5F_t *f, const H5O_shared_t *sh_mesg);
|
||||
H5_DLL herr_t H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
|
||||
hbool_t adj_link);
|
||||
H5_DLL herr_t H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg);
|
||||
H5_DLL void *H5O_shared_copy_file_new(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
|
||||
const H5O_shared_t *shared_src, H5F_t *file_dst, hid_t dxpl_id,
|
||||
H5O_copy_t *cpy_info, void *udata);
|
||||
|
||||
|
||||
/* Attribute operations */
|
||||
H5_DLL herr_t H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr);
|
||||
|
363
src/H5Oshared.c
363
src/H5Oshared.c
@ -266,6 +266,80 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_link_adj() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_decode_new
|
||||
*
|
||||
* Purpose: Decodes a shared object message
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Monday, January 22, 2007
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5O_shared_decode_new(H5F_t *f, const uint8_t *buf, H5O_shared_t *sh_mesg)
|
||||
{
|
||||
unsigned version; /* Shared message version */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode_new)
|
||||
|
||||
/* Check args */
|
||||
HDassert(f);
|
||||
HDassert(buf);
|
||||
HDassert(sh_mesg);
|
||||
|
||||
/* Version */
|
||||
version = *buf++;
|
||||
if(version < H5O_SHARED_VERSION_1 || version > H5O_SHARED_VERSION_LATEST)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad version number for shared object message")
|
||||
|
||||
/* Get the shared information flags
|
||||
* Flags are unused before version 3.
|
||||
*/
|
||||
if(version >= H5O_SHARED_VERSION_2)
|
||||
sh_mesg->flags = *buf++;
|
||||
else {
|
||||
sh_mesg->flags = H5O_COMMITTED_FLAG;
|
||||
buf++;
|
||||
} /* end else */
|
||||
|
||||
/* Skip reserved bytes (for version 1) */
|
||||
if(version == H5O_SHARED_VERSION_1)
|
||||
buf += 6;
|
||||
|
||||
/* Body */
|
||||
if(version == H5O_SHARED_VERSION_1)
|
||||
H5G_obj_ent_decode(f, &buf, &(sh_mesg->u.oloc));
|
||||
else if (version >= H5O_SHARED_VERSION_2) {
|
||||
/* If this message is in the heap, copy a heap ID.
|
||||
* Otherwise, it is a named datatype, so copy an H5O_loc_t.
|
||||
*/
|
||||
if(sh_mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
|
||||
HDassert(version >= H5O_SHARED_VERSION_3 );
|
||||
HDmemcpy(&(sh_mesg->u.heap_id), buf, sizeof(sh_mesg->u.heap_id));
|
||||
}
|
||||
else {
|
||||
/* The H5O_COMMITTED_FLAG should be set if this message
|
||||
* is from an older version before the flag existed.
|
||||
*/
|
||||
if(version < H5O_SHARED_VERSION_3)
|
||||
sh_mesg->flags = H5O_COMMITTED_FLAG;
|
||||
|
||||
HDassert(sh_mesg->flags & H5O_COMMITTED_FLAG);
|
||||
|
||||
H5F_addr_decode(f, &buf, &(sh_mesg->u.oloc.addr));
|
||||
sh_mesg->u.oloc.file = f;
|
||||
} /* end else */
|
||||
} /* end else if */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_decode_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_decode
|
||||
@ -349,14 +423,62 @@ H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
|
||||
ret_value = mesg;
|
||||
|
||||
done:
|
||||
if(ret_value == NULL) {
|
||||
if(ret_value == NULL)
|
||||
if(mesg != NULL)
|
||||
H5MM_xfree(mesg);
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_encode_new
|
||||
*
|
||||
* Purpose: Encodes message _MESG into buffer BUF.
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, April 2, 1998
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5O_shared_encode_new(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg)
|
||||
{
|
||||
unsigned version;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode_new)
|
||||
|
||||
/* Check args */
|
||||
HDassert(f);
|
||||
HDassert(buf);
|
||||
HDassert(sh_mesg);
|
||||
|
||||
/* If this message is shared in the heap, we need to use version 3 of the
|
||||
* encoding and encode the SHARED_IN_HEAP flag.
|
||||
*/
|
||||
if(sh_mesg->flags & H5O_SHARED_IN_HEAP_FLAG || H5F_USE_LATEST_FORMAT(f))
|
||||
version = H5O_SHARED_VERSION_LATEST;
|
||||
else {
|
||||
HDassert(sh_mesg->flags & H5O_COMMITTED_FLAG);
|
||||
version = H5O_SHARED_VERSION_2; /* version 1 is no longer used */
|
||||
} /* end else */
|
||||
|
||||
*buf++ = version;
|
||||
*buf++ = (unsigned)sh_mesg->flags;
|
||||
|
||||
/* Encode either the heap ID of the message or the address of the
|
||||
* object header that holds it.
|
||||
*/
|
||||
if(sh_mesg->flags & H5O_SHARED_IN_HEAP_FLAG)
|
||||
HDmemcpy(buf, &(sh_mesg->u.heap_id), sizeof(sh_mesg->u.heap_id));
|
||||
else
|
||||
H5F_addr_encode(f, &buf, sh_mesg->u.oloc.addr);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5O_shared_encode_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_encode
|
||||
@ -459,6 +581,42 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_copy() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_size_new
|
||||
*
|
||||
* Purpose: Returns the length of a shared object message.
|
||||
*
|
||||
* Return: Success: Length
|
||||
* Failure: 0
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, April 2, 1998
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
size_t
|
||||
H5O_shared_size_new(const H5F_t *f, const H5O_shared_t *sh_mesg)
|
||||
{
|
||||
size_t ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size_new)
|
||||
|
||||
if(sh_mesg->flags & H5O_COMMITTED_FLAG) {
|
||||
ret_value = 1 + /*version */
|
||||
1 + /*the flags field */
|
||||
H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */
|
||||
} /* end if */
|
||||
else {
|
||||
HDassert(sh_mesg->flags & H5O_SHARED_IN_HEAP_FLAG);
|
||||
ret_value = 1 + /*version */
|
||||
1 + /*the flags field */
|
||||
H5O_FHEAP_ID_LEN; /* Shared in the heap */
|
||||
} /* end else */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_size_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_size
|
||||
@ -477,27 +635,67 @@ done:
|
||||
static size_t
|
||||
H5O_shared_size(const H5F_t *f, const void *_mesg)
|
||||
{
|
||||
const H5O_shared_t *shared = (const H5O_shared_t *) _mesg;
|
||||
size_t ret_value;
|
||||
const H5O_shared_t *shared = (const H5O_shared_t *)_mesg;
|
||||
size_t ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size)
|
||||
|
||||
if(shared->flags & H5O_COMMITTED_FLAG)
|
||||
{
|
||||
if(shared->flags & H5O_COMMITTED_FLAG) {
|
||||
ret_value = 1 + /*version */
|
||||
1 + /*the flags field */
|
||||
H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */
|
||||
}
|
||||
else
|
||||
{
|
||||
} /* end if */
|
||||
else {
|
||||
HDassert(shared->flags & H5O_SHARED_IN_HEAP_FLAG);
|
||||
ret_value = 1 + /*version */
|
||||
1 + /*the flags field */
|
||||
H5O_FHEAP_ID_LEN; /* Shared in the heap */
|
||||
}
|
||||
} /* end else */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value);
|
||||
}
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_size() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_delete_new
|
||||
*
|
||||
* Purpose: Free file space referenced by message
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Friday, September 26, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg, hbool_t adj_link)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_delete_new)
|
||||
|
||||
/* check args */
|
||||
HDassert(f);
|
||||
HDassert(sh_mesg);
|
||||
|
||||
/*
|
||||
* Committed datatypes increment the OH of the original message when they
|
||||
* are written (in H5O_shared_link) and decrement it here.
|
||||
* SOHMs in the heap behave differently; their refcount is incremented
|
||||
* during H5SM_share when they are going to be written (in H5O_msg_append
|
||||
* or H5O_msg_write). Their refcount in the SOHM indexes still needs to
|
||||
* be decremented when they're deleted (in H5O_shared_link_adj).
|
||||
*/
|
||||
|
||||
/* Decrement the reference count on the shared object, if requested */
|
||||
if(adj_link)
|
||||
if(H5O_shared_link_adj(f, dxpl_id, sh_mesg, -1) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_delete_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -515,8 +713,7 @@ H5O_shared_size(const H5F_t *f, const void *_mesg)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg,
|
||||
hbool_t adj_link)
|
||||
H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
|
||||
{
|
||||
const H5O_shared_t *shared = (const H5O_shared_t *) _mesg;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
@ -545,6 +742,39 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_delete() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_link_new
|
||||
*
|
||||
* Purpose: Increment reference count on any objects referenced by
|
||||
* message
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Friday, September 26, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_new)
|
||||
|
||||
/* check args */
|
||||
HDassert(f);
|
||||
HDassert(sh_mesg);
|
||||
|
||||
/* Increment the reference count on the shared object */
|
||||
if(H5O_shared_link_adj(f, dxpl_id, sh_mesg, 1) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_link_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_link
|
||||
@ -627,6 +857,91 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_shared_pre_copy_file() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_copy_file_new
|
||||
*
|
||||
* Purpose: Copies a message from _MESG to _DEST in file
|
||||
*
|
||||
* Return: Success: Ptr to _DEST
|
||||
* Failure: NULL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* November 1, 2005
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void *
|
||||
H5O_shared_copy_file_new(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
|
||||
const H5O_shared_t *shared_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
|
||||
void *udata)
|
||||
{
|
||||
H5O_shared_t *shared_dst = NULL; /* The destination message if
|
||||
* it is a shared message */
|
||||
void *dst_mesg = NULL; /* The destination message if
|
||||
* it's an unshared message */
|
||||
void *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy_file_new)
|
||||
|
||||
/* check args */
|
||||
HDassert(shared_src);
|
||||
HDassert(file_dst);
|
||||
HDassert(cpy_info);
|
||||
|
||||
HDfprintf(stderr, "%s: Copying shared messages not supported yet!\n", FUNC);
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "copying shared messages not supported yet")
|
||||
|
||||
/* Committed shared messages create a shared message at the destination
|
||||
* and also copy the committed object that they point to.
|
||||
* SOHMs actually write a non-shared message at the destination.
|
||||
*/
|
||||
if(shared_src->flags & H5O_COMMITTED_FLAG) {
|
||||
/* Allocate space for the destination message */
|
||||
if(NULL == (shared_dst = H5MM_malloc(sizeof(H5O_shared_t))))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
|
||||
/* Reset group entry for new object */
|
||||
H5O_loc_reset(&(shared_dst->u.oloc));
|
||||
shared_dst->u.oloc.file = file_dst;
|
||||
|
||||
/* Set flags for new shared object */
|
||||
shared_dst->flags = shared_src->flags;
|
||||
|
||||
/* Copy the shared object from source to destination */
|
||||
if(H5O_copy_header_map(&(shared_src->u.oloc), &(shared_dst->u.oloc), dxpl_id, cpy_info, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object")
|
||||
|
||||
/* Set return value */
|
||||
ret_value = shared_dst;
|
||||
} /* end if */
|
||||
else {
|
||||
HDassert(shared_src->flags & H5O_SHARED_IN_HEAP_FLAG);
|
||||
|
||||
/* Read the shared message to get the original message */
|
||||
if(NULL == (dst_mesg = H5O_shared_read(file_src, dxpl_id, shared_src, mesg_type, NULL)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "unable to read shared message")
|
||||
|
||||
if(mesg_type->copy_file) {
|
||||
/* Copy the original, un-shared message and return it */
|
||||
ret_value = (mesg_type->copy_file)(file_src, mesg_type, dst_mesg, file_dst, dxpl_id, cpy_info, udata);
|
||||
H5O_msg_free(mesg_type->id, dst_mesg);
|
||||
} /* end else */
|
||||
else
|
||||
ret_value = dst_mesg;
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
if(!ret_value) {
|
||||
if(shared_dst)
|
||||
H5O_msg_free(H5O_SHARED_ID, shared_dst);
|
||||
if(dst_mesg)
|
||||
H5O_msg_free(mesg_type->id, dst_mesg);
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5O_shared_copy_file_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_shared_copy_file
|
||||
@ -665,8 +980,7 @@ H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
|
||||
* and also copy the committed object that they point to.
|
||||
* SOHMs actually write a non-shared message at the destination.
|
||||
*/
|
||||
if(shared_src->flags & H5O_COMMITTED_FLAG)
|
||||
{
|
||||
if(shared_src->flags & H5O_COMMITTED_FLAG) {
|
||||
/* Allocate space for the destination message */
|
||||
if(NULL == (shared_dst = H5MM_malloc(sizeof(H5O_shared_t))))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
@ -684,9 +998,8 @@ H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
|
||||
|
||||
/* Set return value */
|
||||
ret_value = shared_dst;
|
||||
}
|
||||
else
|
||||
{
|
||||
} /* end if */
|
||||
else {
|
||||
HDassert(shared_src->flags & H5O_SHARED_IN_HEAP_FLAG);
|
||||
|
||||
/* Read the shared message to get the original message */
|
||||
@ -697,20 +1010,18 @@ H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
|
||||
/* Copy the original, un-shared message and return it */
|
||||
ret_value = (mesg_type->copy_file)(file_src, mesg_type, dst_mesg, file_dst, dxpl_id, cpy_info, udata);
|
||||
H5O_msg_free(mesg_type->id, dst_mesg);
|
||||
}
|
||||
else {
|
||||
} /* end else */
|
||||
else
|
||||
ret_value = dst_mesg;
|
||||
}
|
||||
}
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
if(!ret_value)
|
||||
{
|
||||
if(!ret_value) {
|
||||
if(shared_dst)
|
||||
H5O_msg_free(H5O_SHARED_ID, shared_dst);
|
||||
if(dst_mesg)
|
||||
H5O_msg_free(mesg_type->id, dst_mesg);
|
||||
}
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5O_shared_copy_file() */
|
||||
|
@ -13,16 +13,21 @@
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Programmer: Quincey Koziol <koziol@hdfgroup.org>
|
||||
* Friday, January 19, 2007
|
||||
* Programmer: Quincey Koziol <koziol@hdfgroup.org>
|
||||
* Friday, January 19, 2007
|
||||
*
|
||||
* Purpose: This file contains inline definitions for "generic" routines
|
||||
* supporting a "shared message interface" (ala Java) for object
|
||||
* header messages that can be shared. This interface is
|
||||
* dependent on a bunch of macros being defined which define
|
||||
* the name of the interface and "real" methods which need to
|
||||
* be implemented for each message class that supports the
|
||||
* shared message interface.
|
||||
*/
|
||||
|
||||
#ifndef H5Oshared_H
|
||||
#define H5Oshared_H
|
||||
|
||||
/* Private headers needed by this file */
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
#include "H5Eprivate.h" /* Error handling */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O_SHARED_DECODE
|
||||
@ -63,12 +68,12 @@ H5O_SHARED_DECODE(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p
|
||||
H5O_shared_t sh_mesg; /* Shared message info */
|
||||
|
||||
/* Retrieve shared message info by decoding info in buffer */
|
||||
if(H5O_shared_decode(f, p, &sh_mesg) < 0)
|
||||
if(H5O_shared_decode_new(f, p, &sh_mesg) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message")
|
||||
|
||||
/* Retrieve actual native message by reading it through shared info */
|
||||
if(NULL == (ret_value = H5O_shared_read(f, dxpl_id, &sh_mesg, H5O_SHARED_TYPE, NULL)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTREAD, NULL, "unable to retrieve native message")
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to retrieve native message")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Decode native message directly */
|
||||
@ -119,12 +124,12 @@ H5O_SHARED_ENCODE(H5F_t *f, uint8_t *p, const void *_mesg)
|
||||
/* Check for shared message */
|
||||
if(H5O_IS_SHARED(sh_mesg->flags)) {
|
||||
/* Encode shared message into buffer */
|
||||
if(H5O_shared_encode(f, p, sh_mesg) < 0)
|
||||
if(H5O_shared_encode_new(f, p, sh_mesg) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode shared message")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Encode native message directly */
|
||||
if(H5O_SHARED_ENCODE_REAL(f, p, _mesg) < )
|
||||
if(H5O_SHARED_ENCODE_REAL(f, p, _mesg) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode native message")
|
||||
} /* end else */
|
||||
|
||||
@ -171,7 +176,7 @@ H5O_SHARED_SIZE(const H5F_t *f, const void *_mesg)
|
||||
/* Check for shared message */
|
||||
if(H5O_IS_SHARED(sh_mesg->flags)) {
|
||||
/* Retrieve encoded size of shared message */
|
||||
if(0 == (ret_value = H5O_shared_size(f, sh_mesg)))
|
||||
if(0 == (ret_value = H5O_shared_size_new(f, sh_mesg)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of shared message")
|
||||
} /* end if */
|
||||
else {
|
||||
@ -204,8 +209,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5_inline herr_t
|
||||
H5O_SHARED_DELETE(const H5F_t *f, hid_t dxpl_id, const void *_mesg,
|
||||
hbool_t adj_link)
|
||||
H5O_SHARED_DELETE(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
|
||||
{
|
||||
const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
@ -225,7 +229,7 @@ H5O_SHARED_DELETE(const H5F_t *f, hid_t dxpl_id, const void *_mesg,
|
||||
/* Check for shared message */
|
||||
if(H5O_IS_SHARED(sh_mesg->flags)) {
|
||||
/* Decrement the reference count on the shared message/object */
|
||||
if(H5O_shared_delete(f, dxpl_id, sh_mesg, adj_link) < 0)
|
||||
if(H5O_shared_delete_new(f, dxpl_id, sh_mesg, adj_link) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for shared message")
|
||||
} /* end if */
|
||||
else {
|
||||
@ -258,7 +262,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5_inline herr_t
|
||||
H5O_SHARED_LINK(const H5F_t *f, hid_t dxpl_id, const void *_mesg)
|
||||
H5O_SHARED_LINK(H5F_t *f, hid_t dxpl_id, const void *_mesg)
|
||||
{
|
||||
const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
@ -278,7 +282,7 @@ H5O_SHARED_LINK(const H5F_t *f, hid_t dxpl_id, const void *_mesg)
|
||||
/* Check for shared message */
|
||||
if(H5O_IS_SHARED(sh_mesg->flags)) {
|
||||
/* Increment the reference count on the shared message/object */
|
||||
if(H5O_shared_link(f, dxpl_id, sh_mesg) < 0)
|
||||
if(H5O_shared_link_new(f, dxpl_id, sh_mesg) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for shared message")
|
||||
} /* end if */
|
||||
else {
|
||||
@ -332,13 +336,13 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
|
||||
/* Check for shared message */
|
||||
if(H5O_IS_SHARED(sh_mesg->flags)) {
|
||||
/* Copy the shared message to another file */
|
||||
if(NULL == (ret_value = H5O_shared_copy_file(file_src, mesg_type, _native_src, file_dst, dxpl_id, cpy_info, udata)))
|
||||
if(NULL == (ret_value = H5O_shared_copy_file_new(file_src, mesg_type, _native_src, file_dst, dxpl_id, cpy_info, udata)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy shared message to another file")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Decrement the reference count on the native message directly */
|
||||
/* Copy the native message directly to another file */
|
||||
if(NULL == (ret_value = H5O_SHARED_LINK_REAL(file_src, mesg_type, _native_src, file_dst, dxpl_id, cpy_info, udata)))
|
||||
if(NULL == (ret_value = H5O_SHARED_COPY_FILE_REAL(file_src, mesg_type, _native_src, file_dst, dxpl_id, cpy_info, udata)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy native message to another file")
|
||||
} /* end else */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user