summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-10-22 22:49:16 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-10-22 22:49:16 (GMT)
commit671ed571239ccad6c86918dfe04580c73d1b130e (patch)
treef22698c958e5a4d497e1c7dfb69d1518915c9d2f /src
parentf571a762fd5894f551c1f906641af229d839c6a9 (diff)
downloadhdf5-671ed571239ccad6c86918dfe04580c73d1b130e.zip
hdf5-671ed571239ccad6c86918dfe04580c73d1b130e.tar.gz
hdf5-671ed571239ccad6c86918dfe04580c73d1b130e.tar.bz2
[svn-r776] Fixed references, object references should be working now.
Diffstat (limited to 'src')
-rw-r--r--src/H5.c2
-rw-r--r--src/H5D.c26
-rw-r--r--src/H5Dprivate.h1
-rw-r--r--src/H5O.c7
-rw-r--r--src/H5Odtype.c13
-rw-r--r--src/H5R.c79
-rw-r--r--src/H5Rpublic.h15
-rw-r--r--src/H5T.c59
-rw-r--r--src/H5private.h13
-rw-r--r--src/H5public.h15
10 files changed, 143 insertions, 87 deletions
diff --git a/src/H5.c b/src/H5.c
index 8e35cc9..6cbd1bb 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -1944,7 +1944,7 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...)
fprintf(out, "NULL");
}
} else {
- href_t ref = va_arg (ap, href_t);
+ hobj_ref_t ref = va_arg (ap, hobj_ref_t);
fprintf (out, "Reference Object=%p", &ref);
}
break;
diff --git a/src/H5D.c b/src/H5D.c
index dde94a2..f7bc440 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -2261,6 +2261,32 @@ H5D_typeof (H5D_t *dset)
/*-------------------------------------------------------------------------
+ * Function: H5D_get_file
+ *
+ * Purpose: Returns the dataset's file pointer.
+ *
+ * Return: Success: Ptr to the dataset's file pointer.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, October 22, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5F_t *
+H5D_get_file (const H5D_t *dset)
+{
+ FUNC_ENTER (H5D_get_file, NULL);
+ assert (dset);
+ assert (dset->ent.file);
+ FUNC_LEAVE (dset->ent.file);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5D_init_storage
*
* Purpose: Initialize the data for a new dataset. If a selection is
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index f89e9b3..6aeb421 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -83,5 +83,6 @@ H5T_t *H5D_typeof (H5D_t *dset);
H5S_t *H5D_get_space(H5D_t *dset);
H5D_t * H5D_new(const H5D_create_t *create_parms);
herr_t H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent);
+H5F_t * H5D_get_file(const H5D_t *dset);
#endif
diff --git a/src/H5O.c b/src/H5O.c
index d03d5fa..0902b1c 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1044,13 +1044,6 @@ H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
assert(addr && H5F_addr_defined(addr));
assert(type_p);
-#ifdef QAK
- printf("%s: addr=",FUNC);
- H5F_addr_print(stdout,addr);
- printf("\n%s: f=%p, addr=%p\n",FUNC,f,addr);
- printf("%s: f->shared=%p\n",FUNC,f->shared);
- printf("%s: H5AC_HASH=%lu\n",FUNC,(unsigned long)H5AC_HASH(f,addr));
-#endif /* QAK */
/* Load the object header */
if (NULL == (oh = H5AC_find(f, H5AC_OHDR, addr, NULL, NULL))) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 482725e..26d42f1 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -218,6 +218,15 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
}
break;
+ case H5T_POINTER:
+ dt->u.atomic.order = H5T_ORDER_NONE;
+ dt->u.atomic.prec = 8 * dt->size;
+ dt->u.atomic.offset = 0;
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.u.r.rtype = flags & 0x0f;
+ break;
+
default:
if (flags) {
HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
@@ -457,6 +466,10 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
}
break;
+ case H5T_POINTER:
+ flags |= (dt->u.atomic.u.r.rtype & 0x0f);
+ break;
+
default:
/*nothing */
break;
diff --git a/src/H5R.c b/src/H5R.c
index f936202..a7d79c7 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -20,6 +20,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Iprivate.h> /* ID Functions */
#include <H5Dprivate.h> /* Datasets */
#include <H5Eprivate.h> /* Error handling */
+#include <H5Fprivate.h> /* Files */
#include <H5Gprivate.h> /* Groups */
#include <H5Rprivate.h> /* References */
#include <H5Sprivate.h> /* Dataspaces */
@@ -32,10 +33,10 @@ static herr_t H5R_init_interface(void);
static void H5R_term_interface(void);
/* Static functions */
-static herr_t H5R_create(href_t *ref, H5G_entry_t *loc, const char *name,
+static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name,
H5R_type_t ref_type, H5S_t *space);
-static hid_t H5R_dereference(H5D_t *dset, href_t *ref);
-static H5S_t * H5R_get_space(href_t *ref);
+static hid_t H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref);
+static H5S_t * H5R_get_space(void *ref);
/*--------------------------------------------------------------------------
@@ -98,7 +99,7 @@ H5R_term_interface(void)
Creates a particular kind of reference for the user
USAGE
herr_t H5R_create(ref, loc, name, ref_type, space)
- href_t *ref; OUT: Reference created
+ void *ref; OUT: Reference created
H5G_entry_t *loc; IN: File location used to locate object pointed to
const char *name; IN: Name of object at location LOC_ID of object
pointed to
@@ -119,14 +120,14 @@ H5R_term_interface(void)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5R_create(href_t *ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t __unused__ *space)
+H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t __unused__ *space)
{
H5G_stat_t sb; /* Stat buffer for retrieving OID */
herr_t ret_value = FAIL;
FUNC_ENTER(H5R_create, FAIL);
- assert(ref);
+ assert(_ref);
assert(loc);
assert(name);
assert(ref_type>H5R_BADTYPE || ref_type<H5R_MAXTYPE);
@@ -134,9 +135,29 @@ H5R_create(href_t *ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
if (H5G_get_objinfo (loc, name, 0, &sb)<0)
HGOTO_ERROR (H5E_REFERENCE, H5E_NOTFOUND, FAIL, "unable to stat object");
- /* Set information for reference */
- ref->oid[0]=sb.objno[0];
- ref->oid[1]=sb.objno[1];
+ switch(ref_type) {
+ case H5R_OBJECT:
+ {
+ hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */
+ uint8 *p; /* Pointer to OID to store */
+
+ /* Set information for reference */
+ p=(uint8 *)ref->oid;
+ H5F_addr_encode(loc->file,&p,(const haddr_t *)sb.objno);
+ break;
+ }
+
+ case H5R_DATASET_REGION:
+ case H5R_INTERNAL:
+ HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
+ "Dataset region and internal references are not supported yet");
+
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ assert("unknown reference type" && 0);
+ HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
+ "internal error (unknown reference type)");
+ } /* end switch */
/* Return success */
ret_value=SUCCEED;
@@ -153,7 +174,7 @@ done:
Creates a particular kind of reference for the user
USAGE
herr_t H5Rcreate(ref, loc_id, name, ref_type, space_id)
- href_t *ref; OUT: Reference created
+ void *ref; OUT: Reference created
hid_t loc_id; IN: Location ID used to locate object pointed to
const char *name; IN: Name of object at location LOC_ID of object
pointed to
@@ -174,7 +195,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5Rcreate(href_t *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id)
+H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id)
{
H5G_entry_t *loc = NULL; /* File location */
H5S_t *space = NULL; /* Pointer to dataspace containing region */
@@ -214,7 +235,8 @@ done:
USAGE
hid_t H5R_dereference(ref)
H5D_t *dset; IN: Dataset reference object is in.
- href_t *ref; IN: Reference to open.
+ H5R_type_t ref_type; IN: Type of reference
+ void *ref; IN: Reference to open.
RETURNS
Valid ID on success, FAIL on failure
@@ -228,17 +250,19 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static hid_t
-H5R_dereference(H5D_t *dset, href_t *ref)
+H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref)
{
H5D_t *dataset; /* Pointer to dataset to open */
+ hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */
H5G_entry_t ent; /* Symbol table entry */
+ uint8 *p; /* Pointer to OID to store */
hid_t ret_value = FAIL;
FUNC_ENTER(H5R_dereference, FAIL);
assert(ref);
+ assert(ref_type==H5R_OBJECT);
-printf("%s: ref->oid=%ld-%ld\n",FUNC,(long)ref->oid[0],ref->oid[1]);
/*
* Switch on object type, when we implement that feature, always try to
* open a dataset for now
@@ -251,9 +275,10 @@ printf("%s: ref->oid=%ld-%ld\n",FUNC,(long)ref->oid[0],ref->oid[1]);
/* Initialize the symbol table entry */
HDmemset(&ent,0,sizeof(H5G_entry_t));
- HDmemcpy(&(ent.header),ref->oid,sizeof(haddr_t));
ent.type=H5G_NOTHING_CACHED;
-/* ent.file=ref->file; */
+ ent.file=H5D_get_file(dset);
+ p=(uint8 *)ref->oid;
+ H5F_addr_decode(ent.file,(const uint8 **)&p,&(ent.header));
/* Open the dataset object */
if (H5D_open_oid(dataset, &ent) < 0) {
@@ -266,7 +291,6 @@ printf("%s: ref->oid=%ld-%ld\n",FUNC,(long)ref->oid[0],ref->oid[1]);
HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
"can't register dataset");
}
-printf("%s: ret_value=%ld\n",FUNC,(long)ret_value);
done:
FUNC_LEAVE(ret_value);
@@ -281,7 +305,8 @@ done:
USAGE
hid_t H5Rdereference(ref)
hid_t dataset; IN: Dataset reference object is in.
- href_t *ref; IN: Reference to open.
+ H5R_type_t ref_type; IN: Type of reference to create
+ void *ref; IN: Reference to open.
RETURNS
Valid ID on success, FAIL on failure
@@ -294,22 +319,24 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5Rdereference(hid_t dataset, href_t *ref)
+H5Rdereference(hid_t dataset, H5R_type_t ref_type, void *_ref)
{
H5D_t *dset = NULL; /* dataset object */
hid_t ret_value = FAIL;
FUNC_ENTER(H5Rdereference, FAIL);
- H5TRACE2("i","i*r",dataset,ref);
+ H5TRACE2("i","i*r",dataset,_ref);
/* Check args */
if (H5I_DATASET != H5I_get_type(dataset) || NULL == (dset = H5I_object(dataset)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
- if(ref==NULL)
+ if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
+ if(_ref==NULL)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Create reference */
- if ((ret_value=H5R_dereference(dset, ref))<0)
+ if ((ret_value=H5R_dereference(dset, ref_type, _ref))<0)
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object");
done:
@@ -324,7 +351,7 @@ done:
Retrieves a dataspace with the region pointed to selected.
USAGE
H5S_t *H5R_get_space(ref)
- href_t *ref; IN: Reference to open.
+ void *ref; IN: Reference to open.
RETURNS
Pointer to the dataspace on success, NULL on failure
@@ -338,7 +365,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_t *
-H5R_get_space(href_t __unused__ *ref)
+H5R_get_space(void __unused__ *ref)
{
H5S_t *ret_value = NULL;
@@ -360,7 +387,7 @@ done:
Retrieves a dataspace with the region pointed to selected.
USAGE
hid_t H5Rget_space(ref)
- href_t *ref; IN: Reference to open.
+ void *ref; IN: Reference to open.
RETURNS
Valid ID on success, FAIL on failure
@@ -374,7 +401,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5Rget_space(href_t *ref)
+H5Rget_space(void *ref)
{
H5S_t *space = NULL;
hid_t ret_value = FAIL;
diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h
index 4882444..ebb7771 100644
--- a/src/H5Rpublic.h
+++ b/src/H5Rpublic.h
@@ -31,12 +31,19 @@ typedef enum {
H5R_MAXTYPE /* highest type in group (Invalid as true type)*/
} H5R_type_t;
-/* Reference structure for user's code */
+#ifdef LATER
+/* Generic reference structure for user's code */
typedef struct {
unsigned long oid[2]; /* OID of object referenced */
unsigned long region[2]; /* heap ID of region in object */
unsigned long file[2]; /* heap ID of external filename */
} href_t;
+#endif /* LATER */
+
+/* Object reference structure for user's code */
+typedef struct {
+ unsigned long oid[2]; /* OID of object referenced */
+} hobj_ref_t;
/* Publicly visible datastructures */
@@ -45,10 +52,10 @@ extern "C" {
#endif
/* Functions in H5R.c */
-herr_t H5Rcreate(href_t *ref, hid_t loc_id, const char *name,
+herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name,
H5R_type_t ref_type, hid_t space_id);
-hid_t H5Rdereference(hid_t dataset, href_t *ref);
-hid_t H5Rget_space(href_t *ref);
+hid_t H5Rdereference(hid_t dataset, H5R_type_t ref_type, void *ref);
+hid_t H5Rget_space(void *ref);
#ifdef __cplusplus
}
diff --git a/src/H5T.c b/src/H5T.c
index 575d98f..d583f3d 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -220,14 +220,6 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8*dt->size;
dt->u.atomic.offset = 0;
- /* Object pointer (i.e. object header address in file) */
- dt = H5I_object (H5T_STD_PTR_OBJ_g = H5Tcopy (H5T_NATIVE_INT_g));
- dt->type = H5T_POINTER;
- dt->state = H5T_STATE_IMMUTABLE;
- dt->size = sizeof(haddr_t);
- dt->u.atomic.u.r.rtype = H5R_OBJECT;
- dt->u.atomic.prec = 8*dt->size;
- dt->u.atomic.offset = 0;
/*------------------------------------------------------------
* IEEE Types
@@ -607,6 +599,29 @@ H5T_init_interface(void)
"can't initialize H5T layer");
}
+ /*------------------------------------------------------------
+ * Pointer types
+ *------------------------------------------------------------
+ */
+ /* Object pointer (i.e. object header address in file) */
+ if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ }
+ dt->state = H5T_STATE_IMMUTABLE;
+ H5F_addr_undef (&(dt->ent.header));
+ dt->type = H5T_POINTER;
+ dt->size = sizeof(haddr_t);
+ dt->u.atomic.order = H5T_ORDER_NONE;
+ dt->u.atomic.offset = 0;
+ dt->u.atomic.prec = 8 * dt->size;
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.u.r.rtype = H5R_OBJECT;
+ if ((H5T_STD_PTR_OBJ_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize H5T layer");
+ }
+
/*
* Register conversion functions beginning with the most general and
* ending with the most specific.
@@ -4398,36 +4413,23 @@ H5T_find(const H5T_t *src, const H5T_t *dst, H5T_bkg_t need_bkg,
FUNC_ENTER(H5T_find, NULL);
-#ifdef QAK
- printf("%s: check 1.0\n",FUNC);
-#endif /* QAK */
if (!noop_cdata.stats &&
NULL==(noop_cdata.stats = H5MM_calloc (sizeof(H5T_stats_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
-#ifdef QAK
- printf("%s: check 2.0, src->type=%d, dst->type=%d\n",
- FUNC, (int)src->type, (int)dst->type);
-#endif /* QAK */
/* No-op case */
if (need_bkg<H5T_BKG_YES && 0==H5T_cmp(src, dst)) {
*pcdata = &noop_cdata;
HRETURN(H5T_conv_noop);
}
-#ifdef QAK
- printf("%s: check 3.0\n", FUNC);
-#endif /* QAK */
/* Find it */
if (NULL == (path = H5T_path_find(NULL, src, dst, TRUE, NULL))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
"unable to create conversion path");
}
-#ifdef QAK
- printf("%s: path=%p\n", FUNC, path);
-#endif /* QAK */
if ((ret_value=path->func)) {
*pcdata = &(path->cdata);
@@ -4495,9 +4497,6 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
HRETURN(H5T_path_g[md]);
}
}
-#ifdef QAK
- printf("%s: check 2.0, create=%d, md=%d\n", FUNC, (int)create, md);
-#endif /* QAK */
/* Insert */
if (create) {
@@ -4524,18 +4523,9 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
-#ifdef QAK
- printf("%s: check 3.0, src=%p, dst=%p\n", FUNC, src, dst);
- printf("%s: check 3.0, src->type=%d, dst->type=%d\n",
- FUNC, (int)src->type, (int)dst->type);
-#endif /* QAK */
path->src = H5T_copy(src, H5T_COPY_ALL);
path->dst = H5T_copy(dst, H5T_COPY_ALL);
-#ifdef QAK
- printf("%s: check 3.5, func=%p, name=%s\n",
- FUNC, func, (name!=NULL ? name : "NULL"));
-#endif /* QAK */
/* Associate a function with the path if possible */
if (func) {
HDstrncpy (path->name, name, H5T_NAMELEN);
@@ -4601,9 +4591,6 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
}
}
}
-#ifdef QAK
- printf("%s: leaving path=%p\n", FUNC, path);
-#endif /* QAK */
FUNC_LEAVE(path);
}
diff --git a/src/H5private.h b/src/H5private.h
index 2d42902..2b976e0 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -177,19 +177,6 @@ typedef int intn;
typedef unsigned uintn;
/*
- * Status return values for the `herr_t' type.
- * Since some unix/c routines use 0 and -1 (or more precisely, non-negative
- * vs. negative) as their return code, and some assumption had been made in
- * the code about that, it is important to keep these constants the same
- * values. When checking the success or failure of an integer-valued
- * function, remember to compare against zero and not one of these two
- * values.
- */
-#define SUCCEED 0
-#define FAIL (-1)
-#define UFAIL (unsigned)(-1)
-
-/*
* File addresses.
*/
typedef struct {
diff --git a/src/H5public.h b/src/H5public.h
index 2e07a24..04550c0 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -45,6 +45,21 @@
*/
typedef int herr_t;
+
+/*
+ * Status return values for the `herr_t' type.
+ * Since some unix/c routines use 0 and -1 (or more precisely, non-negative
+ * vs. negative) as their return code, and some assumption had been made in
+ * the code about that, it is important to keep these constants the same
+ * values. When checking the success or failure of an integer-valued
+ * function, remember to compare against zero and not one of these two
+ * values.
+ */
+#define SUCCEED 0
+#define FAIL (-1)
+#define UFAIL (unsigned)(-1)
+
+
/*
* Boolean type. Successful return values are zero (false) or positive
* (true). The typical true value is 1 but don't bet on it. Boolean