summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-04-03 21:11:05 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-04-03 21:11:05 (GMT)
commit92571bbe1d77c74ddefeeba6ac0b2097593c058d (patch)
tree610c3a65c2d3fa5dabfda39635770029bb734646 /src/H5T.c
parenta780cdd178f849afbc8cbb24e416eef733cbc9f2 (diff)
downloadhdf5-92571bbe1d77c74ddefeeba6ac0b2097593c058d.zip
hdf5-92571bbe1d77c74ddefeeba6ac0b2097593c058d.tar.gz
hdf5-92571bbe1d77c74ddefeeba6ac0b2097593c058d.tar.bz2
[svn-r336] Changes since 19980402
---------------------- ./MANIFEST ./test/Makefile.in ./test/shtype.c [NEW] Added some tests for shared data types. ./configure.in Removed MF and HL from the default debug list since. MF because it hasn't been implemented yet and HL because it produces lots of annoying messages about adjusting the size of local heaps. ./src/H5F.c ./src/H5T.c ./src/H5Tprivate.h Fixed a bug with opening the same file twice. The first close on the file_id incorrectly closed shared data structs. Closing a file now correctly unshares data types that might be pointing into that file. ./src/H5T.c ./src/H5Tpublic.h Added an H5Tis_shared(). The caller supplies a file and a data type and the function returns true if the data type is currently marked for sharing in that file. ./src/H5AC.c ./src/H5F.c ./src/H5HL.c ./src/H5HG.c ./src/H5MF.c ./src/H5O.c We now detect errors sooner when writing to a read-only file. In the past, the error might not show up until the cached item was flushed, and it was sometimes possible to not even get an error! ./src/H5I.c ./src/H5Iprivate.h If the search function fails then H5I_search() returns failure. Also, the first argument for the search function isn't const anymore because we might want the search to have side effects (like calling H5T_unshare() for all shared data types whose file just closed).
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c92
1 files changed, 90 insertions, 2 deletions
diff --git a/src/H5T.c b/src/H5T.c
index be72fa6..c45003d 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -12,8 +12,9 @@ static char RcsId[] = "@(#)$Revision$";
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
#include <H5private.h> /*generic functions */
-#include <H5Iprivate.h> /*ID functions */
-#include <H5Eprivate.h> /*error handling */
+#include <H5Iprivate.h> /*ID functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Gprivate.h> /*groups */
#include <H5HGprivate.h> /*global heap */
#include <H5MMprivate.h> /*memory management */
#include <H5Sprivate.h> /*data space */
@@ -2206,6 +2207,50 @@ H5Tshare (hid_t loc_id, hid_t type_id)
/*-------------------------------------------------------------------------
+ * Function: H5Tis_shared
+ *
+ * Purpose: Determines if a data type is shared in the specified file.
+ * The TYPE_ID is the type in question and LOC_ID is a file id
+ * or group id (a group id is used only to identify the file).
+ *
+ * Return: Success: TRUE or FALSE
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Friday, April 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5Tis_shared (hid_t loc_id, hid_t type_id)
+{
+ H5G_t *loc = NULL;
+ H5T_t *dt = NULL;
+ hbool_t ret_value = FAIL;
+
+ FUNC_ENTER (H5Tis_shared, FAIL);
+
+ /* Check arguments */
+ if (NULL==(loc=H5G_loc (loc_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ }
+ if (H5_DATATYPE!=H5I_group (type_id) ||
+ NULL==(dt=H5I_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+
+ /* Is it sharable */
+ ret_value = (H5HG_defined (&(dt->sh_heap)) &&
+ dt->sh_file->shared==H5G_fileof(loc)->shared) ? TRUE : FALSE;
+
+ FUNC_LEAVE (ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5Tregister_hard
*
* Purpose: Register a hard conversion function for a data type
@@ -2771,6 +2816,49 @@ H5T_unshare (H5T_t *dt)
/*-------------------------------------------------------------------------
+ * Function: H5T_invalidate_cb
+ *
+ * Purpose: This is a callback function for H5I_search(). When a file is
+ * closed we scan through the data type list and invalidate
+ * shared info for all types that have sharing enabled for the
+ * specified file. This insures that we don't having dangling
+ * pointers from data types to files. We have to do this with
+ * data types but not datasets because a dataset_id always
+ * corresponds to an open object header which prevents the file
+ * from closing in the first place, but a data type can exist
+ * independent of a file and doesn't have an object header.
+ *
+ * Return: Success: 0, this function never returns a non-zero
+ * value because that would terminate
+ * H5I_search().
+ *
+ * Failure: 0
+ *
+ * Programmer: Robb Matzke
+ * Friday, April 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+intn
+H5T_invalidate_cb (void *obj, const void *call_data)
+{
+ H5T_t *dt = (H5T_t *)obj;
+ const H5F_t *f = (const H5F_t*)call_data; /*used only for comparison*/
+
+ FUNC_ENTER (H5T_invalidate, 0);
+
+ if (H5HG_defined (&(dt->sh_heap)) && dt->sh_file->shared==f->shared) {
+ H5T_unshare (dt);
+ H5E_clear ();
+ }
+
+ FUNC_LEAVE (0);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5T_is_atomic
*
* Purpose: Determines if a data type is an atomic type.