diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-19 17:31:41 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-19 17:31:41 (GMT) |
commit | d4909147e16628c04ce64e272503f96030f1df30 (patch) | |
tree | dcffc28e2f1155bc99345ef390a6999821aa94c5 /src | |
parent | 46598f35cafc38ff166783e57d5622f4a1a3153e (diff) | |
download | hdf5-d4909147e16628c04ce64e272503f96030f1df30.zip hdf5-d4909147e16628c04ce64e272503f96030f1df30.tar.gz hdf5-d4909147e16628c04ce64e272503f96030f1df30.tar.bz2 |
[svn-r13156] Description:
Begin refactoring code to straighten out the contorted code that handles
shared messages.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Apkg.h | 3 | ||||
-rw-r--r-- | src/H5Oattr.c | 8 | ||||
-rw-r--r-- | src/H5Oprivate.h | 6 | ||||
-rw-r--r-- | src/H5Oshared.c | 15 | ||||
-rw-r--r-- | src/H5Oshared.h | 350 | ||||
-rw-r--r-- | src/H5Spkg.h | 13 | ||||
-rw-r--r-- | src/H5Tpkg.h | 7 |
7 files changed, 382 insertions, 20 deletions
diff --git a/src/H5Apkg.h b/src/H5Apkg.h index a3910a9..6fa92e8 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -57,6 +57,8 @@ /* Define the main attribute structure */ struct H5A_t { + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + hbool_t initialized;/* Indicate whether the attribute has been modified */ hbool_t obj_opened; /* Object header entry opened? */ H5O_loc_t oloc; /* Object location for object attribute is on */ @@ -69,7 +71,6 @@ struct H5A_t { size_t ds_size; /* Size of dataspace on disk */ void *data; /* Attribute data (on a temporary basis) */ size_t data_size; /* Size of data on disk */ - H5O_shared_t sh_loc; /* Location of shared message */ H5O_crt_idx_t crt_idx; /* Attribute's creation index in the object header */ }; diff --git a/src/H5Oattr.c b/src/H5Oattr.c index a2c6654..a50d9f3 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -186,7 +186,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) H5O_shared_t *shared; /* Shared information */ /* Get the shared information */ - if (NULL == (shared = (H5O_shared_t *)(H5O_MSG_SHARED->decode)(f, dxpl_id, p))) + if(NULL == (shared = (H5O_shared_t *)(H5O_MSG_SHARED->decode)(f, dxpl_id, p))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message") /* Get the actual datatype information */ @@ -215,11 +215,11 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) H5O_shared_t *shared; /* Shared information */ /* Get the shared information */ - if (NULL == (shared = (H5O_shared_t *)(H5O_MSG_SHARED->decode)(f, dxpl_id, p))) + if(NULL == (shared = (H5O_shared_t *)(H5O_MSG_SHARED->decode)(f, dxpl_id, p))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message") /* Get the actual datatype information */ - if((extent= (H5S_extent_t *)H5O_shared_read(f, dxpl_id, shared, H5O_MSG_SDSPACE, NULL))==NULL) + if((extent = (H5S_extent_t *)H5O_shared_read(f, dxpl_id, shared, H5O_MSG_SDSPACE, NULL))==NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace") /* Free the shared information */ @@ -272,7 +272,7 @@ done: PURPOSE Encode a simple attribute message USAGE - herr_t H5O_attr_encode(f, raw_size, p, mesg) + herr_t H5O_attr_encode(f, p, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the simple datatype struct diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 1076441..c978b8c 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -198,13 +198,14 @@ typedef struct H5O_fill_t { */ typedef struct H5O_fill_new_t { + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5T_t *type; /*type. Null implies same as dataset */ ssize_t size; /*number of bytes in the fill value */ void *buf; /*the fill value */ H5D_alloc_time_t alloc_time; /* time to allocate space */ H5D_fill_time_t fill_time; /* time to write fill value */ hbool_t fill_defined; /* whether fill value is defined */ - H5O_shared_t sh_loc; /*location of shared message */ } H5O_fill_new_t; /* @@ -336,10 +337,11 @@ typedef struct H5O_ginfo_t { * (Data structure in memory) */ typedef struct H5O_pline_t { + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + size_t nalloc; /*num elements in `filter' array */ size_t nused; /*num filters defined */ H5Z_filter_info_t *filter; /*array of filters */ - H5O_shared_t sh_loc; /*location of shared message */ } H5O_pline_t; /* diff --git a/src/H5Oshared.c b/src/H5Oshared.c index c06871e..9b2de74 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -169,9 +169,17 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, if(NULL == (native_mesg = H5O_msg_decode(f, dxpl_id, type->id, buf))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode shared message.") - /* Copy this message to the user's buffer */ - if(NULL == (ret_value = (type->copy)(native_mesg, mesg))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space") + /* Check if there is a user buffer to fill */ + if(mesg) { + /* Copy this message to the user's buffer */ + if(NULL == (ret_value = (type->copy)(native_mesg, mesg))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space") + } /* end if */ + else { + /* Otherwise, take ownership of the decoded native message */ + ret_value = native_mesg; + native_mesg = NULL; + } /* end else */ } /* end if */ else { HDassert(shared->flags & H5O_COMMITTED_FLAG); @@ -653,7 +661,6 @@ H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, HDassert(file_dst); HDassert(cpy_info); - /* 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. diff --git a/src/H5Oshared.h b/src/H5Oshared.h new file mode 100644 index 0000000..2a20a0d --- /dev/null +++ b/src/H5Oshared.h @@ -0,0 +1,350 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Friday, January 19, 2007 + */ +#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 + * + * Purpose: Decode an object header message that may be shared. + * + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. + * + * Return: Success: Pointer to the new message in native form + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, January 19, 2007 + * + *------------------------------------------------------------------------- + */ +static H5_inline void * +H5O_SHARED_DECODE(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_DECODE) + +#ifndef H5O_SHARED_TYPE +#error "Need to define H5O_SHARED_TYPE macro!" +#endif /* H5O_SHARED_TYPE */ +#ifndef H5O_SHARED_DECODE +#error "Need to define H5O_SHARED_DECODE macro!" +#endif /* H5O_SHARED_DECODE */ +#ifndef H5O_SHARED_DECODE_REAL +#error "Need to define H5O_SHARED_DECODE_REAL macro!" +#endif /* H5O_SHARED_DECODE_REAL */ + + /* Check for shared message */ + if(mesg_flags & H5O_MSG_FLAG_SHARED) { + 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) + 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") + } /* end if */ + else { + /* Decode native message directly */ + if(NULL == (ret_value = H5O_SHARED_DECODE_REAL(f, dxpl_id, p))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode native message") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_SHARED_DECODE() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_SHARED_ENCODE + * + * Purpose: Encode an object header message that may be shared. + * + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, January 19, 2007 + * + *------------------------------------------------------------------------- + */ +static H5_inline herr_t +H5O_SHARED_ENCODE(H5F_t *f, uint8_t *p, 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 */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_ENCODE) + +#ifndef H5O_SHARED_TYPE +#error "Need to define H5O_SHARED_TYPE macro!" +#endif /* H5O_SHARED_TYPE */ +#ifndef H5O_SHARED_ENCODE +#error "Need to define H5O_SHARED_ENCODE macro!" +#endif /* H5O_SHARED_ENCODE */ +#ifndef H5O_SHARED_ENCODE_REAL +#error "Need to define H5O_SHARED_ENCODE_REAL macro!" +#endif /* H5O_SHARED_ENCODE_REAL */ + + /* 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) + 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) < ) + HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode native message") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_SHARED_ENCODE() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_SHARED_SIZE + * + * Purpose: Returns the length of an encoded message. + * + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. + * + * Return: Success: Length + * Failure: 0 + * + * Programmer: Quincey Koziol + * Friday, January 19, 2007 + * + *------------------------------------------------------------------------- + */ +static H5_inline size_t +H5O_SHARED_SIZE(const H5F_t *f, const void *_mesg) +{ + const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + size_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_SIZE) + +#ifndef H5O_SHARED_TYPE +#error "Need to define H5O_SHARED_TYPE macro!" +#endif /* H5O_SHARED_TYPE */ +#ifndef H5O_SHARED_SIZE +#error "Need to define H5O_SHARED_SIZE macro!" +#endif /* H5O_SHARED_SIZE */ +#ifndef H5O_SHARED_SIZE_REAL +#error "Need to define H5O_SHARED_SIZE_REAL macro!" +#endif /* H5O_SHARED_SIZE_REAL */ + + /* 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))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of shared message") + } /* end if */ + else { + /* Retrieve size of native message directly */ + if(0 == (ret_value = H5O_SHARED_SIZE_REAL(f, _mesg))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of native message") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_SHARED_SIZE() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_SHARED_DELETE + * + * Purpose: Decrement reference count on any objects referenced by + * message + * + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, January 19, 2007 + * + *------------------------------------------------------------------------- + */ +static H5_inline herr_t +H5O_SHARED_DELETE(const 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 */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_DELETE) + +#ifndef H5O_SHARED_TYPE +#error "Need to define H5O_SHARED_TYPE macro!" +#endif /* H5O_SHARED_TYPE */ +#ifndef H5O_SHARED_DELETE +#error "Need to define H5O_SHARED_DELETE macro!" +#endif /* H5O_SHARED_DELETE */ +#ifndef H5O_SHARED_DELETE_REAL +#error "Need to define H5O_SHARED_DELETE_REAL macro!" +#endif /* H5O_SHARED_DELETE_REAL */ + + /* 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) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for shared message") + } /* end if */ + else { + /* Decrement the reference count on the native message directly */ + if(H5O_SHARED_DELETE_REAL(f, dxpl_id, _mesg, adj_link) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for native message") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_SHARED_DELETE() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_SHARED_LINK + * + * Purpose: Increment reference count on any objects referenced by + * message + * + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, January 19, 2007 + * + *------------------------------------------------------------------------- + */ +static H5_inline herr_t +H5O_SHARED_LINK(const 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 */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_LINK) + +#ifndef H5O_SHARED_TYPE +#error "Need to define H5O_SHARED_TYPE macro!" +#endif /* H5O_SHARED_TYPE */ +#ifndef H5O_SHARED_LINK +#error "Need to define H5O_SHARED_LINK macro!" +#endif /* H5O_SHARED_LINK */ +#ifndef H5O_SHARED_LINK_REAL +#error "Need to define H5O_SHARED_LINK_REAL macro!" +#endif /* H5O_SHARED_LINK_REAL */ + + /* 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) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for shared message") + } /* end if */ + else { + /* Increment the reference count on the native message directly */ + if(H5O_SHARED_LINK_REAL(f, dxpl_id, _mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for native message") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_SHARED_LINK() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_SHARED_COPY_FILE + * + * Purpose: Copies a message from _SRC to _DEST in file + * + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, January 19, 2007 + * + *------------------------------------------------------------------------- + */ +static H5_inline void * +H5O_SHARED_COPY_FILE(H5F_t *file_src, const H5O_msg_class_t *mesg_type, + void *_native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, + void *udata) +{ + const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_native_src; /* Pointer to shared message portion of actual message */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_COPY_FILE) + +#ifndef H5O_SHARED_TYPE +#error "Need to define H5O_SHARED_TYPE macro!" +#endif /* H5O_SHARED_TYPE */ +#ifndef H5O_SHARED_COPY_FILE +#error "Need to define H5O_SHARED_COPY_FILE macro!" +#endif /* H5O_SHARED_COPY_FILE */ +#ifndef H5O_SHARED_COPY_FILE_REAL +#error "Need to define H5O_SHARED_COPY_FILE_REAL macro!" +#endif /* H5O_SHARED_COPY_FILE_REAL */ + + /* 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))) + 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))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy native message to another file") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_SHARED_COPY_FILE() */ + +#endif /* H5Oshared_H */ + diff --git a/src/H5Spkg.h b/src/H5Spkg.h index c9b413e..4c225dc 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -38,13 +38,14 @@ */ /* Extent container */ struct H5S_extent_t { - H5S_class_t type; /* Type of extent */ - hsize_t nelem; /* Number of elements in extent */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - unsigned rank; /* Number of dimensions */ - hsize_t *size; /* Current size of the dimensions */ - hsize_t *max; /* Maximum size of the dimensions */ - H5O_shared_t sh_loc; /* location of this message if shared */ + H5S_class_t type; /* Type of extent */ + hsize_t nelem; /* Number of elements in extent */ + + unsigned rank; /* Number of dimensions */ + hsize_t *size; /* Current size of the dimensions */ + hsize_t *max; /* Maximum size of the dimensions */ }; /* diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 14f77cf..9232196 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -326,9 +326,10 @@ typedef struct H5T_shared_t { } H5T_shared_t; struct H5T_t { - H5T_shared_t *shared; /* all other information */ - H5G_name_t path; /* group hier. path if the type is a named type */ - H5O_shared_t sh_loc; /* shared object message if this is a shared type*/ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + + H5T_shared_t *shared; /* all other information */ + H5G_name_t path; /* group hier. path if the type is a named type */ }; /* A compound datatype member */ |