[svn-r766] Checkpointing the reference code.

This commit is contained in:
Quincey Koziol 1998-10-19 17:25:03 -05:00
parent c1d2006c0f
commit cd4af9da24
10 changed files with 184 additions and 256 deletions

View File

@ -1938,33 +1938,14 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...)
case 'r':
if (ptr) {
if (vp) {
fprintf (out, "0x%lx", (unsigned long)vp);
} else {
fprintf(out, "NULL");
}
if (vp) {
fprintf (out, "0x%lx", (unsigned long)vp);
} else {
fprintf(out, "NULL");
}
} else {
href_t ref = va_arg (ap, href_t);
switch (ref.type) {
case H5R_BADTYPE:
fprintf (out, "H5R_BADTYPE");
break;
case H5R_OBJECT:
fprintf (out, "H5R_OBJECT");
break;
case H5R_DATASET_REGION:
fprintf (out, "H5R_DATASET_REGION");
break;
case H5R_INTERNAL:
fprintf (out, "H5R_INTERNAL");
break;
case H5R_MAXTYPE:
fprintf (out, "H5R_MAXTYPE");
break;
default:
fprintf (out, "BADTYPE(%ld)", (long)ref.type);
break;
}
href_t ref = va_arg (ap, href_t);
fprintf (out, "Reference Object=%p", &ref);
}
break;

View File

@ -1865,6 +1865,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
"unable to register types for conversion");
}
}
printf("%s: after H5T_find, tconv_func=%p\n",FUNC,tconv_func);
if (NULL==(sconv=H5S_find(mem_space, file_space))) {
HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert from memory to file data space");

View File

@ -1044,6 +1044,11 @@ 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);
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));
/* Load the object header */
if (NULL == (oh = H5AC_find(f, H5AC_OHDR, addr, NULL, NULL))) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,

105
src/H5R.c
View File

@ -34,9 +34,8 @@ static void H5R_term_interface(void);
/* Static functions */
static herr_t H5R_create(href_t *ref, H5G_entry_t *loc, const char *name,
H5R_type_t ref_type, H5S_t *space);
static hid_t H5R_dereference(href_t *ref);
static hid_t H5R_dereference(H5D_t *dset, href_t *ref);
static H5S_t * H5R_get_space(href_t *ref);
static H5R_type_t H5R_get_type(href_t *ref);
/*--------------------------------------------------------------------------
@ -136,10 +135,8 @@ H5R_create(href_t *ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
HGOTO_ERROR (H5E_REFERENCE, H5E_NOTFOUND, FAIL, "unable to stat object");
/* Set information for reference */
ref->type=ref_type;
ref->objno[0]=sb.objno[0];
ref->objno[1]=sb.objno[1];
ref->file=loc->file;
ref->oid[0]=sb.objno[0];
ref->oid[1]=sb.objno[1];
/* Return success */
ret_value=SUCCEED;
@ -216,6 +213,7 @@ done:
Opens the HDF5 object referenced.
USAGE
hid_t H5R_dereference(ref)
H5D_t *dset; IN: Dataset reference object is in.
href_t *ref; IN: Reference to open.
RETURNS
@ -230,7 +228,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static hid_t
H5R_dereference(href_t *ref)
H5R_dereference(H5D_t *dset, href_t *ref)
{
H5D_t *dataset; /* Pointer to dataset to open */
H5G_entry_t ent; /* Symbol table entry */
@ -240,6 +238,7 @@ H5R_dereference(href_t *ref)
assert(ref);
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
@ -252,9 +251,9 @@ H5R_dereference(href_t *ref)
/* Initialize the symbol table entry */
HDmemset(&ent,0,sizeof(H5G_entry_t));
HDmemcpy(&(ent.header),ref->objno,sizeof(haddr_t));
HDmemcpy(&(ent.header),ref->oid,sizeof(haddr_t));
ent.type=H5G_NOTHING_CACHED;
ent.file=ref->file;
/* ent.file=ref->file; */
/* Open the dataset object */
if (H5D_open_oid(dataset, &ent) < 0) {
@ -267,6 +266,7 @@ H5R_dereference(href_t *ref)
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);
@ -280,6 +280,7 @@ done:
Opens the HDF5 object referenced.
USAGE
hid_t H5Rdereference(ref)
hid_t dataset; IN: Dataset reference object is in.
href_t *ref; IN: Reference to open.
RETURNS
@ -293,19 +294,22 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
H5Rdereference(href_t *ref)
H5Rdereference(hid_t dataset, href_t *ref)
{
H5D_t *dset = NULL; /* dataset object */
hid_t ret_value = FAIL;
FUNC_ENTER(H5Rdereference, FAIL);
H5TRACE1("i","*r",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)
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Create reference */
if ((ret_value=H5R_dereference(ref))<0)
if ((ret_value=H5R_dereference(dset, ref))<0)
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object");
done:
@ -394,80 +398,3 @@ done:
FUNC_LEAVE(ret_value);
} /* end H5Rget_space() */
/*--------------------------------------------------------------------------
NAME
H5R_get_type
PURPOSE
Retrieves the type of a reference.
USAGE
H5R_type_t H5R_get_type(ref)
href_t *ref; IN: Reference to open.
RETURNS
Reference type on success, <0 on failure
DESCRIPTION
Given a reference to some object, returns the type of reference. See
list of valid H5R_type_t in H5Rpublic.h
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static H5R_type_t
H5R_get_type(href_t *ref)
{
H5R_type_t ret_value = H5R_BADTYPE;
FUNC_ENTER(H5R_get_type, H5R_BADTYPE);
assert(ref);
ret_value=ref->type;
#ifdef LATER
done:
#endif /* LATER */
FUNC_LEAVE(ret_value);
} /* end H5R_get_type() */
/*--------------------------------------------------------------------------
NAME
H5Rget_type
PURPOSE
Retrieves the type of a reference.
USAGE
H5R_type_t H5Rget_space(ref)
href_t *ref; IN: Reference to open.
RETURNS
Valid reference type on success, <0 on failure
DESCRIPTION
Given a reference to some object, returns the type of reference. See
list of valid H5R_type_t in H5Rpublic.h
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
H5R_type_t
H5Rget_type(href_t *ref)
{
H5R_type_t ret_value = H5R_BADTYPE;
FUNC_ENTER(H5Rget_type, FAIL);
H5TRACE1("Rt","*r",ref);
/* Check args */
if(ref==NULL)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Create reference */
if ((ret_value=H5R_get_type(ref))<0)
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to check reference type");
done:
FUNC_LEAVE(ret_value);
} /* end H5Rget_type() */

View File

@ -33,17 +33,9 @@ typedef enum {
/* Reference structure for user's code */
typedef struct {
H5R_type_t type; /* Type of reference information in union */
unsigned long objno[2]; /* OID of object referenced */
struct H5F_t *file; /* Pointer to the file the reference is in */
union { /* union to hold structs */
struct {
} obj; /* Object reference structure */
struct {
} dreg; /* Dataset Region reference structure */
struct {
} intrl; /* Internal reference structure */
}u;
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;
/* Publicly visible datastructures */
@ -55,9 +47,8 @@ extern "C" {
/* Functions in H5R.c */
herr_t H5Rcreate(href_t *ref, hid_t loc_id, const char *name,
H5R_type_t ref_type, hid_t space_id);
hid_t H5Rdereference(href_t *ref);
hid_t H5Rdereference(hid_t dataset, href_t *ref);
hid_t H5Rget_space(href_t *ref);
H5R_type_t H5Rget_type(href_t *ref);
#ifdef __cplusplus
}

223
src/H5T.c
View File

@ -59,6 +59,7 @@ hid_t H5T_STD_B32BE_g = FAIL;
hid_t H5T_STD_B32LE_g = FAIL;
hid_t H5T_STD_B64BE_g = FAIL;
hid_t H5T_STD_B64LE_g = FAIL;
hid_t H5T_STD_PTR_OBJ_g = FAIL;
hid_t H5T_UNIX_D32BE_g = FAIL;
hid_t H5T_UNIX_D32LE_g = FAIL;
@ -91,7 +92,6 @@ hid_t H5T_NATIVE_HSIZE_g = FAIL;
hid_t H5T_NATIVE_HSSIZE_g = FAIL;
hid_t H5T_NATIVE_HERR_g = FAIL;
hid_t H5T_NATIVE_HBOOL_g = FAIL;
hid_t H5T_NATIVE_PTR_OBJ_g = FAIL;
/* The path database */
static intn H5T_npath_g = 0; /*num paths defined */
@ -221,9 +221,11 @@ H5T_init_interface(void)
dt->u.atomic.offset = 0;
/* Object pointer (i.e. object header address in file) */
dt = H5I_object (H5T_NATIVE_PTR_OBJ_g = H5Tcopy (H5T_NATIVE_INT_g));
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;
@ -4116,7 +4118,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
intn i, j, tmp;
hbool_t swapped;
FUNC_ENTER(H5T_equal, 0);
FUNC_ENTER(H5T_cmp, 0);
/* the easy case */
if (dt1 == dt2) HGOTO_DONE(0);
@ -4330,6 +4332,20 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
/*void */
break;
case H5T_POINTER:
if (dt1->u.atomic.u.r.rtype < dt2->u.atomic.u.r.rtype) HGOTO_DONE(-1);
if (dt1->u.atomic.u.r.rtype > dt2->u.atomic.u.r.rtype) HGOTO_DONE(1);
switch(dt1->u.atomic.u.r.rtype) {
case H5R_OBJECT:
/*void */
break;
default:
assert("not implemented yet" && 0);
} /* end switch */
break;
default:
assert("not implemented yet" && 0);
}
@ -4378,23 +4394,27 @@ H5T_find(const H5T_t *src, const H5T_t *dst, H5T_bkg_t need_bkg,
FUNC_ENTER(H5T_find, NULL);
printf("%s: check 1.0\n",FUNC);
if (!noop_cdata.stats &&
NULL==(noop_cdata.stats = H5MM_calloc (sizeof(H5T_stats_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
printf("%s: check 2.0, src->type=%d, dst->type=%d\n",FUNC,(int)src->type,(int)dst->type);
/* No-op case */
if (need_bkg<H5T_BKG_YES && 0==H5T_cmp(src, dst)) {
*pcdata = &noop_cdata;
HRETURN(H5T_conv_noop);
}
printf("%s: check 3.0\n",FUNC);
/* 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");
}
printf("%s: path=%p\n",FUNC,path);
if ((ret_value=path->func)) {
*pcdata = &(path->cdata);
@ -4448,114 +4468,119 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
/* Binary search */
while (lt < rt) {
md = (lt + rt) / 2;
assert (H5T_path_g[md]);
md = (lt + rt) / 2;
assert (H5T_path_g[md]);
cmp = H5T_cmp(src, H5T_path_g[md]->src);
if (0 == cmp) cmp = H5T_cmp(dst, H5T_path_g[md]->dst);
cmp = H5T_cmp(src, H5T_path_g[md]->src);
if (0 == cmp) cmp = H5T_cmp(dst, H5T_path_g[md]->dst);
if (cmp < 0) {
rt = md;
} else if (cmp > 0) {
lt = md + 1;
} else {
HRETURN(H5T_path_g[md]);
}
if (cmp < 0) {
rt = md;
} else if (cmp > 0) {
lt = md + 1;
} else {
HRETURN(H5T_path_g[md]);
}
}
printf("%s: check 2.0, create=%d, md=%d\n",FUNC,(int)create,md);
/* Insert */
if (create) {
if (H5T_npath_g >= H5T_apath_g) {
size_t na = MAX(64, 2 * H5T_apath_g);
H5T_path_t **x = H5MM_realloc (H5T_path_g,
na*sizeof(H5T_path_t*));
if (!x) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
H5T_apath_g = (intn)na;
H5T_path_g = x;
}
if (cmp > 0) md++;
if (H5T_npath_g >= H5T_apath_g) {
size_t na = MAX(64, 2 * H5T_apath_g);
H5T_path_t **x = H5MM_realloc (H5T_path_g,
na*sizeof(H5T_path_t*));
if (!x) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
H5T_apath_g = (intn)na;
H5T_path_g = x;
}
if (cmp > 0) md++;
/* make room */
HDmemmove(H5T_path_g + md + 1, H5T_path_g + md,
(H5T_npath_g - md) * sizeof(H5T_path_t*));
H5T_npath_g++;
/* make room */
HDmemmove(H5T_path_g + md + 1, H5T_path_g + md,
(H5T_npath_g - md) * sizeof(H5T_path_t*));
H5T_npath_g++;
/* insert */
if (NULL==(path=H5T_path_g[md]=H5MM_calloc (sizeof(H5T_path_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
path->src = H5T_copy(src, H5T_COPY_ALL);
path->dst = H5T_copy(dst, H5T_COPY_ALL);
/* insert */
if (NULL==(path=H5T_path_g[md]=H5MM_calloc (sizeof(H5T_path_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
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);
path->src = H5T_copy(src, H5T_COPY_ALL);
path->dst = H5T_copy(dst, H5T_COPY_ALL);
/* Associate a function with the path if possible */
if (func) {
HDstrncpy (path->name, name, H5T_NAMELEN);
path->name[H5T_NAMELEN-1] = '\0';
path->func = func;
path->is_hard = TRUE;
path->cdata.command = H5T_CONV_INIT;
if (NULL==(path->cdata.stats=H5MM_calloc(sizeof(H5T_stats_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
if ((src_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->src, H5T_COPY_ALL))) < 0 ||
(dst_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->dst, H5T_COPY_ALL))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
"unable to register conv types for query");
}
if ((func)(src_id, dst_id, &(path->cdata), 0, NULL, NULL)<0) {
printf("%s: check 3.5, func=%p, name=%s\n",FUNC,func,(name!=NULL ? name : "NULL"));
/* Associate a function with the path if possible */
if (func) {
HDstrncpy (path->name, name, H5T_NAMELEN);
path->name[H5T_NAMELEN-1] = '\0';
path->func = func;
path->is_hard = TRUE;
path->cdata.command = H5T_CONV_INIT;
if (NULL==(path->cdata.stats=H5MM_calloc(sizeof(H5T_stats_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
if ((src_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->src, H5T_COPY_ALL))) < 0 ||
(dst_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->dst, H5T_COPY_ALL))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
"unable to register conv types for query");
}
if ((func)(src_id, dst_id, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
if (H5DEBUG(T)) {
fprintf (H5DEBUG(T), "H5T: conversion function init "
"failed\n");
}
if (H5DEBUG(T)) {
fprintf (H5DEBUG(T), "H5T: conversion function init "
"failed\n");
}
#endif
H5E_clear(); /*ignore the failure*/
}
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
} else {
/* Locate a soft function */
for (i=H5T_nsoft_g-1; i>=0 && !path->func; --i) {
if (src->type!=H5T_soft_g[i].src ||
dst->type!=H5T_soft_g[i].dst) {
continue;
}
if ((src_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->src,
H5T_COPY_ALL))) < 0 ||
(dst_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->dst,
H5T_COPY_ALL))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
"unable to register conv types for query");
}
path->cdata.command = H5T_CONV_INIT;
path->cdata.stats = H5MM_calloc (sizeof(H5T_stats_t));
if (NULL==path->cdata.stats) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
if ((H5T_soft_g[i].func) (src_id, dst_id, &(path->cdata),
H5T_CONV_INIT, NULL, NULL) < 0) {
H5MM_xfree(path->cdata.stats);
HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
H5E_clear(); /*ignore the error*/
} else {
HDstrcpy (path->name, H5T_soft_g[i].name);
path->func = H5T_soft_g[i].func;
}
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
}
}
H5E_clear(); /*ignore the failure*/
}
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
} else {
/* Locate a soft function */
for (i=H5T_nsoft_g-1; i>=0 && !path->func; --i) {
if (src->type!=H5T_soft_g[i].src ||
dst->type!=H5T_soft_g[i].dst) {
continue;
}
if ((src_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->src,
H5T_COPY_ALL))) < 0 ||
(dst_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->dst,
H5T_COPY_ALL))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
"unable to register conv types for query");
}
path->cdata.command = H5T_CONV_INIT;
path->cdata.stats = H5MM_calloc (sizeof(H5T_stats_t));
if (NULL==path->cdata.stats) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
if ((H5T_soft_g[i].func) (src_id, dst_id, &(path->cdata),
H5T_CONV_INIT, NULL, NULL) < 0) {
H5MM_xfree(path->cdata.stats);
HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
H5E_clear(); /*ignore the error*/
} else {
HDstrcpy (path->name, H5T_soft_g[i].name);
path->func = H5T_soft_g[i].func;
}
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
}
}
}
printf("%s: leaving path=%p\n",FUNC,path);
FUNC_LEAVE(path);
}

View File

@ -24,6 +24,7 @@
#endif
#include <H5HGprivate.h>
#include <H5Rprivate.h>
#include <H5Tprivate.h>
#define H5T_NAMELEN 10 /*length of debugging name buffer */
@ -54,6 +55,10 @@ typedef struct H5T_atomic_t {
H5T_cset_t cset; /*character set */
H5T_str_t pad; /*space or null padding of extra bytes */
} s;
struct {
H5R_type_t rtype; /* Type of reference stored */
} r;
} u;
} H5T_atomic_t;

View File

@ -209,6 +209,7 @@ extern hid_t H5T_IEEE_F64LE_g;
#define H5T_STD_B32LE (H5open(), H5T_STD_B32LE_g)
#define H5T_STD_B64BE (H5open(), H5T_STD_B64BE_g)
#define H5T_STD_B64LE (H5open(), H5T_STD_B64LE_g)
#define H5T_STD_PTR_OBJ (H5open(), H5T_STD_PTR_OBJ_g)
extern hid_t H5T_STD_I8BE_g;
extern hid_t H5T_STD_I8LE_g;
extern hid_t H5T_STD_I16BE_g;
@ -233,6 +234,7 @@ extern hid_t H5T_STD_B32BE_g;
extern hid_t H5T_STD_B32LE_g;
extern hid_t H5T_STD_B64BE_g;
extern hid_t H5T_STD_B64LE_g;
extern hid_t H5T_STD_PTR_OBJ_g;
/*
* Types which are particular to Unix.
@ -347,7 +349,6 @@ extern hid_t H5T_FORTRAN_S1_g;
#define H5T_NATIVE_HSSIZE (H5open(), H5T_NATIVE_HSSIZE_g)
#define H5T_NATIVE_HERR (H5open(), H5T_NATIVE_HERR_g)
#define H5T_NATIVE_HBOOL (H5open(), H5T_NATIVE_HBOOL_g)
#define H5T_NATIVE_PTR_OBJ (H5open(), H5T_NATIVE_PTR_OBJ_g)
extern hid_t H5T_NATIVE_CHAR_g;
extern hid_t H5T_NATIVE_UCHAR_g;
extern hid_t H5T_NATIVE_SHORT_g;
@ -370,7 +371,6 @@ extern hid_t H5T_NATIVE_HSIZE_g;
extern hid_t H5T_NATIVE_HSSIZE_g;
extern hid_t H5T_NATIVE_HERR_g;
extern hid_t H5T_NATIVE_HBOOL_g;
extern hid_t H5T_NATIVE_PTR_OBJ_g;
/* Operations defined on all data types */
hid_t H5Topen (hid_t loc_id, const char *name);

View File

@ -170,7 +170,9 @@ main(int argc, char *argv[])
InitTest("h5s", test_h5s, cleanup_h5s, "Dataspaces");
InitTest("attr", test_attr, cleanup_attr, "Attributes");
InitTest("select", test_select, cleanup_select, "Selections");
#ifdef LATER
InitTest("reference", test_reference, cleanup_reference, "References");
#endif /* LATER */
Verbosity = 4; /* Default Verbosity is Low */
H5get_libversion(&major, &minor, &release);

View File

@ -45,14 +45,14 @@ static void
test_reference_obj(void)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
hid_t dataset, /* Dataset ID */
dset2; /* Dereferenced dataset ID */
hid_t group; /* Group ID */
hid_t sid1; /* Dataspace ID */
hsize_t dims1[] = {SPACE1_DIM1};
href_t *wbuf, /* buffer to write to disk */
*rbuf, /* buffer read from disk */
*tbuf; /* temp. buffer read from disk */
H5R_type_t reftype; /* Reference type created */
uint32 *tu32; /* Temporary pointer to uint32 data */
intn i; /* counting variables */
herr_t ret; /* Generic return value */
@ -105,28 +105,24 @@ test_reference_obj(void)
CHECK(ret, FAIL, "H5Dclose");
/* Create a dataset */
dataset=H5Dcreate(fid1,"Dataset3",H5T_NATIVE_PTR_OBJ,sid1,H5P_DEFAULT);
dataset=H5Dcreate(fid1,"Dataset3",H5T_STD_PTR_OBJ,sid1,H5P_DEFAULT);
CHECK(ret, FAIL, "H5Dcreate");
/* Create references */
ret = H5Rcreate(&wbuf[0],fid1,"/Dataset1",H5R_OBJECT,-1);
CHECK(ret, FAIL, "H5Rcreate");
reftype = H5Rget_type(&wbuf[0]);
VERIFY(reftype, H5R_OBJECT, "H5Rget_type");
ret = H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_OBJECT,-1);
CHECK(ret, FAIL, "H5Rcreate");
reftype = H5Rget_type(&wbuf[1]);
VERIFY(reftype, H5R_OBJECT, "H5Rget_type");
ret = H5Rcreate(&wbuf[2],fid1,"/Group1",H5R_OBJECT,-1);
CHECK(ret, FAIL, "H5Rcreate");
reftype = H5Rget_type(&wbuf[2]);
VERIFY(reftype, H5R_OBJECT, "H5Rget_type");
printf("before pointer write\n");
/* Write selection to disk */
ret=H5Dwrite(dataset,H5T_NATIVE_PTR_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf);
ret=H5Dwrite(dataset,H5T_STD_PTR_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf);
CHECK(ret, FAIL, "H5Dwrite");
printf("after pointer write\n");
/* Close disk dataspace */
ret = H5Sclose(sid1);
@ -149,36 +145,31 @@ test_reference_obj(void)
CHECK(ret, FAIL, "H5Dcreate");
/* Read selection from disk */
ret=H5Dread(dataset,H5T_NATIVE_PTR_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,rbuf);
ret=H5Dread(dataset,H5T_STD_PTR_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,rbuf);
CHECK(ret, FAIL, "H5Dread");
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
/* Check references */
reftype = H5Rget_type(&rbuf[0]);
VERIFY(reftype, H5R_OBJECT, "H5Rget_type");
reftype = H5Rget_type(&rbuf[1]);
VERIFY(reftype, H5R_OBJECT, "H5Rget_type");
reftype = H5Rget_type(&rbuf[2]);
VERIFY(reftype, H5R_OBJECT, "H5Rget_type");
/* Try to open objects */
dataset = H5Rdereference(&rbuf[0]);
dset2 = H5Rdereference(dataset,&rbuf[0]);
CHECK(dataset, FAIL, "H5Rdereference");
/* Check information in referenced dataset */
sid1 = H5Dget_space(dset2);
CHECK(sid1, FAIL, "H5Dget_space");
ret=H5Sget_simple_extent_npoints(sid1);
VERIFY(ret, 4, "H5Sget_simple_extent_npoints");
/* Read from disk */
ret=H5Dread(dataset,H5T_STD_U32LE,H5S_ALL,H5S_ALL,H5P_DEFAULT,tbuf);
ret=H5Dread(dset2,H5T_STD_U32LE,H5S_ALL,H5S_ALL,H5P_DEFAULT,tbuf);
CHECK(ret, FAIL, "H5Dread");
for(tu32=(uint32 *)tbuf,i=0; i<SPACE1_DIM1; i++,tu32++)
VERIFY(*tu32, (uint32)(i*3), "Data");
/* Close dereferenced Dataset */
ret = H5Dclose(dset2);
CHECK(ret, FAIL, "H5Dclose");
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");