diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-07-07 20:13:31 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-07-07 20:13:31 (GMT) |
commit | bcf649388cb246fecf5bac670c54c7c4d654eb44 (patch) | |
tree | e73f696a48020d756c3eeda3c633047ef2465bfa | |
parent | 63be23d70dd9bb3d79d670bb94e26c829a4abc2e (diff) | |
download | hdf5-bcf649388cb246fecf5bac670c54c7c4d654eb44.zip hdf5-bcf649388cb246fecf5bac670c54c7c4d654eb44.tar.gz hdf5-bcf649388cb246fecf5bac670c54c7c4d654eb44.tar.bz2 |
[svn-r460] Changes since 19980707
----------------------
./bin/trace
./src/H5.c
./src/H5private.h
./src/H5A.c
./src/H5D.c
./src/H5F.c
./src/H5G.c
./src/H5P.c
./src/H5Pprivate.h
./src/H5S.c
./src/H5T.c
Output-only arguments have their addresses printed during
tracing and added symbolic output for the H5F_driver_t
arguments. That's another reason that we should be careful to
add `/*out*/' after arguments that are output-only and
`/*in,out*/' after arguments that are used for both input and
output values.
No internal function calls H5Pget_class() anymore.
./src/H5T.c
./src/H5Tconv.c
./src/H5Tpkg.h
./src/H5Tpublic.h
Added H5Tget_overflow() and H5Tset_overflow() so the
application can query or set a function that will be called
whenever an overflow occurs. Implemented as documented in
previous e-mail except the overflow handler gets two buffers:
one that contains the source value and one to receive the
optional destination value.
./test/dtypes.c
Tests overflow handler.
./src/H5.c
We have to declare fdopen() because I'm getting errors when
compiling on Irix64 even though we include <stdio.h> as
documented in the fdopen() man page.
-rwxr-xr-x | bin/trace | 32 | ||||
-rw-r--r-- | src/H5.c | 47 | ||||
-rw-r--r-- | src/H5A.c | 2 | ||||
-rw-r--r-- | src/H5D.c | 10 | ||||
-rw-r--r-- | src/H5E.c | 2 | ||||
-rw-r--r-- | src/H5F.c | 6 | ||||
-rw-r--r-- | src/H5G.c | 4 | ||||
-rw-r--r-- | src/H5P.c | 167 | ||||
-rw-r--r-- | src/H5Pprivate.h | 1 | ||||
-rw-r--r-- | src/H5S.c | 2 | ||||
-rw-r--r-- | src/H5T.c | 101 | ||||
-rw-r--r-- | src/H5Tconv.c | 116 | ||||
-rw-r--r-- | src/H5Tpkg.h | 3 | ||||
-rw-r--r-- | src/H5Tpublic.h | 15 | ||||
-rw-r--r-- | src/H5private.h | 71 | ||||
-rw-r--r-- | test/dtypes.c | 35 |
16 files changed, 456 insertions, 158 deletions
@@ -21,6 +21,7 @@ $Source = ""; "herr_t" => "e", "H5E_direction_t" => "Ed", "H5E_error_t*" => "Ee", + "H5F_driver_t" => "Fd", "H5G_link_t" => "Gl", "H5G_stat_t*" => "Gs", "hsize_t" => "h", @@ -47,7 +48,9 @@ $Source = ""; "H5E_auto_t" => "x", "H5E_walk_t" => "x", "H5G_iterate_t" => "x", + "H5T_cdata_t**" => "x", "H5T_conv_t" => "x", + "H5T_overflow_t" => "x", "H5Z_func_t" => "x", "size_t" => "z", "H5Z_method_t" => "Zm", @@ -76,6 +79,7 @@ sub errmesg ($$@) { sub argstring ($$$) { my ($file, $func, $atype) = @_; my ($ptr, $tstr) = (0,"!"); + my ($fq_atype); # Normalize the data type by removing redundant white space, # certain type qualifiers, and indirection. @@ -85,8 +89,12 @@ sub argstring ($$$) { $ptr = length $1 if $atype =~ s/(\*+)//; $atype =~ s/^\s+//; $atype =~ s/\s+$//; - - if ($ptr>0 && exists $TypeString{"$atype*"}) { + $fq_atype = $atype . ('*' x $ptr); + + if ($ptr>0 && exists $TypeString{$fq_atype}) { + $ptr = 0; + $tstr = $TypeString{$fq_atype}; + } elsif ($ptr>0 && exists $TypeString{"$atype*"}) { --$ptr; $tstr = $TypeString{"$atype*"}; } elsif (!exists $TypeString{$atype}) { @@ -113,23 +121,31 @@ sub rewrite_func ($$$$$) { # Parse arguments if ($args eq "void") { - $trace = "H5TRACE0(\"$rettype\", \"\");\n"; + $trace = "H5TRACE0(\"$rettype\",\"\");\n"; } else { + # Split arguments. First convert `/*in,out*/' to get rid of the + # comma, then split the arguments on commas. + $args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g; my @args = split /,[\s\n]*/, $args; + for $arg (@args) { unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**) ([a-z_A-Z]\w*)(\[\])? - (\s*\/\*\s*(in|out|in,\s*out)\s*\*\/)?\s*$/x) { + (\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) { errmesg $file, $name, "unable to parse \`$arg\'"; goto error; } else { my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6); $adir ||= "in"; - next if $adir eq "out"; $atype =~ s/\s+$//; - $atype .= "*" if $array; push @arg_name, $aname; - push @arg_str, argstring $file, $name, $atype; + + if ($adir eq "out") { + push @arg_str, "x"; + } else { + $atype .= "*" if $array; + push @arg_str, argstring $file, $name, $atype; + } } } $trace = "H5TRACE" . scalar(@arg_str) . "(\"$rettype\",\""; @@ -183,7 +199,7 @@ for $file (@ARGV) { # Make modifications my $original = $Source; - my $napi = $Source =~ s/\n([a-z]\w*(\s+[a-z]\w*)*)\s*\n #type + my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[a-z]\w*)*)\s*\n #type (H5[A-Z]{1,2}[^_A-Z]\w*) #name \s*\((.*?)\) #args (.*?\n\}[^\n]*) #body @@ -42,6 +42,9 @@ static char RcsId[] = "@(#)$Revision$"; #include <sys/time.h> #include <sys/resource.h> +/* We need this on Irix64 even though we've included stdio.h as documented */ +FILE *fdopen(int fd, const char *mode); + /* private headers */ #include <H5private.h> /*library */ #include <H5ACprivate.h> /*cache */ @@ -95,7 +98,7 @@ H5_init_library(void) const char *s = getenv ("HDF5_TRACE"); if (s && isdigit(*s)) { int fd = HDstrtol (s, NULL, 0); - H5_trace_g = fdopen (fd, "w"); + H5_trace_g = HDfdopen (fd, "w"); } } #endif @@ -1123,6 +1126,48 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) } break; + case 'F': + switch (type[1]) { + case 'd': + if (ptr) { + fprintf(out, "0x%lx", (unsigned long)vp); + } else { + H5F_driver_t driver = va_arg(ap, H5F_driver_t); + switch (driver) { + case H5F_LOW_ERROR: + fprintf(out, "H5F_LOW_ERROR"); + break; + case H5F_LOW_STDIO: + fprintf(out, "H5F_LOW_STDIO"); + break; + case H5F_LOW_SEC2: + fprintf(out, "H5F_LOW_SEC2"); + break; + case H5F_LOW_MPIO: + fprintf(out, "H5F_LOW_MPIO"); + break; + case H5F_LOW_CORE: + fprintf(out, "H5F_LOW_CORE"); + break; + case H5F_LOW_SPLIT: + fprintf(out, "H5F_LOW_SPLIT"); + break; + case H5F_LOW_FAMILY: + fprintf(out, "H5F_LOW_FAMILY"); + break; + default: + fprintf(out, "%ld", (long)driver); + break; + } + } + break; + + default: + fprintf(out, "BADTYPE(F%c)", type[1]); + goto error; + } + break; + case 'G': switch (type[1]) { case 'l': @@ -195,7 +195,7 @@ H5Acreate (hid_t loc_id, const char *name, hid_t datatype, hid_t dataspace, HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } if (H5P_DEFAULT!=create_plist && - (H5P_DATASET_CREATE != H5Pget_class(create_plist) || + (H5P_DATASET_CREATE != H5P_get_class(create_plist) || NULL == H5I_object(create_plist))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -209,7 +209,7 @@ H5Dcreate (hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } if (create_parms_id >= 0) { - if (H5P_DATASET_CREATE != H5Pget_class(create_parms_id) || + if (H5P_DATASET_CREATE != H5P_get_class(create_parms_id) || NULL == (create_parms = H5I_object(create_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -552,8 +552,8 @@ H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, const H5D_xfer_t *xfer_parms = NULL; FUNC_ENTER(H5Dread, FAIL); - H5TRACE5("e","iiiii",dataset_id,mem_type_id,mem_space_id,file_space_id, - xfer_parms_id); + H5TRACE6("e","iiiiix",dataset_id,mem_type_id,mem_space_id,file_space_id, + xfer_parms_id,buf); /* check arguments */ if (H5_DATASET != H5I_group(dataset_id) || @@ -579,7 +579,7 @@ H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, } if (H5P_DEFAULT == xfer_parms_id) { xfer_parms = &H5D_xfer_dflt; - } else if (H5P_DATASET_XFER != H5Pget_class(xfer_parms_id) || + } else if (H5P_DATASET_XFER != H5P_get_class(xfer_parms_id) || NULL == (xfer_parms = H5I_object(xfer_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); } @@ -670,7 +670,7 @@ H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, } if (H5P_DEFAULT == xfer_parms_id) { xfer_parms = &H5D_xfer_dflt; - } else if (H5P_DATASET_XFER != H5Pget_class(xfer_parms_id) || + } else if (H5P_DATASET_XFER != H5P_get_class(xfer_parms_id) || NULL == (xfer_parms = H5I_object(xfer_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); } @@ -223,7 +223,7 @@ herr_t H5Eclear (void) { FUNC_ENTER (H5Eclear, FAIL); - H5TRACE0("e", ""); + H5TRACE0("e",""); /* FUNC_ENTER() does all the work */ FUNC_LEAVE (SUCCEED); } @@ -1153,14 +1153,14 @@ H5Fcreate (const char *filename, unsigned flags, hid_t create_id, } if (H5P_DEFAULT==create_id) { create_parms = &H5F_create_dflt; - } else if (H5P_FILE_CREATE!=H5Pget_class (create_id) || + } else if (H5P_FILE_CREATE!=H5P_get_class (create_id) || NULL == (create_parms = H5I_object(create_id))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); } if (H5P_DEFAULT==access_id) { access_parms = &H5F_access_dflt; - } else if (H5P_FILE_ACCESS!=H5Pget_class (access_id) || + } else if (H5P_FILE_ACCESS!=H5P_get_class (access_id) || NULL == (access_parms = H5I_object(access_id))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1259,7 +1259,7 @@ H5Fopen (const char *filename, unsigned flags, hid_t access_id) } if (H5P_DEFAULT==access_id) { access_parms = &H5F_access_dflt; - } else if (H5P_FILE_ACCESS!=H5Pget_class (access_id) || + } else if (H5P_FILE_ACCESS!=H5P_get_class (access_id) || NULL == (access_parms = H5I_object(access_id))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -654,7 +654,7 @@ H5Gstat (hid_t loc_id, const char *name, hbool_t follow_link, H5G_t *loc = NULL; FUNC_ENTER (H5Gstat, FAIL); - H5TRACE3("e","isb",loc_id,name,follow_link); + H5TRACE4("e","isbx",loc_id,name,follow_link,statbuf); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) { @@ -697,7 +697,7 @@ H5Gget_linkval (hid_t loc_id, const char *name, size_t size, char *buf/*out*/) H5G_t *loc = NULL; FUNC_ENTER (H5Gget_linkval, FAIL); - H5TRACE3("e","isz",loc_id,name,size); + H5TRACE4("e","iszx",loc_id,name,size,buf); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) { @@ -263,7 +263,7 @@ H5Pclose (hid_t tid) H5TRACE1("e","i",tid); /* Check arguments */ - if ((type=H5Pget_class (tid))<0 || + if ((type=H5P_get_class (tid))<0 || NULL==(tmpl=H5I_object (tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); } @@ -381,12 +381,13 @@ H5P_close (H5P_class_t type, void *tmpl) *------------------------------------------------------------------------- */ H5P_class_t -H5Pget_class(hid_t tid) +H5Pget_class (hid_t tid) { H5I_group_t group; H5P_class_t ret_value = H5P_NO_CLASS; FUNC_ENTER(H5Pget_class, H5P_NO_CLASS); + H5TRACE1("p","i",tid); if ((group = H5I_group(tid)) < 0 || #ifndef NDEBUG @@ -399,6 +400,44 @@ H5Pget_class(hid_t tid) ret_value = (H5P_class_t)(group - H5_TEMPLATE_0); FUNC_LEAVE(ret_value); } + + +/*------------------------------------------------------------------------- + * Function: H5P_get_class + * + * Purpose: Internal function for getting the property list class. + * + * Return: Success: A property list class + * + * Failure: H5P_NO_CLASS (-1) + * + * Programmer: Robb Matzke + * Tuesday, July 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5P_class_t +H5P_get_class(hid_t tid) +{ + H5I_group_t group; + H5P_class_t ret_value = H5P_NO_CLASS; + + FUNC_ENTER(H5P_get_class, H5P_NO_CLASS); + + if ((group = H5I_group(tid)) < 0 || +#ifndef NDEBUG + group >= H5_TEMPLATE_MAX || +#endif + group < H5_TEMPLATE_0) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5P_NO_CLASS, + "not a property list"); + } + ret_value = (H5P_class_t)(group - H5_TEMPLATE_0); + FUNC_LEAVE(ret_value); +} + /*------------------------------------------------------------------------- * Function: H5Pget_version @@ -433,10 +472,10 @@ H5Pget_version (hid_t tid, int *boot/*out*/, int *freelist/*out*/, H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_version, FAIL); - H5TRACE1("e","i",tid); + H5TRACE5("e","ixxxx",tid,boot,freelist,stab,shhdr); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -477,7 +516,7 @@ H5Pset_userblock (hid_t tid, hsize_t size) H5TRACE2("e","ih",tid,size); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -522,7 +561,7 @@ H5Pget_userblock (hid_t tid, hsize_t *size) H5TRACE2("e","i*h",tid,size); /* Check args */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -571,7 +610,7 @@ H5Pset_alignment (hid_t fapl_id, hsize_t threshold, hsize_t alignment) H5TRACE3("e","ihh",fapl_id,threshold,alignment); /* Check args */ - if (H5P_FILE_ACCESS != H5Pget_class (fapl_id) || + if (H5P_FILE_ACCESS != H5P_get_class (fapl_id) || NULL == (fapl = H5I_object (fapl_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -614,10 +653,10 @@ H5Pget_alignment (hid_t fapl_id, hsize_t *threshold/*out*/, H5F_access_t *fapl = NULL; FUNC_ENTER (H5Pget_alignment, FAIL); - H5TRACE1("e","i",fapl_id); + H5TRACE3("e","ixx",fapl_id,threshold,alignment); /* Check args */ - if (H5P_FILE_ACCESS != H5Pget_class (fapl_id) || + if (H5P_FILE_ACCESS != H5P_get_class (fapl_id) || NULL == (fapl = H5I_object (fapl_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -658,7 +697,7 @@ H5Pset_sizes (hid_t tid, size_t sizeof_addr, size_t sizeof_size) H5TRACE3("e","izz",tid,sizeof_addr,sizeof_size); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -711,10 +750,10 @@ H5Pget_sizes (hid_t tid, H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_sizes, FAIL); - H5TRACE1("e","i",tid); + H5TRACE3("e","ixx",tid,sizeof_addr,sizeof_size); /* Check args */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -766,7 +805,7 @@ H5Pset_sym_k (hid_t tid, int ik, int lk) H5TRACE3("e","iIsIs",tid,ik,lk); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -806,10 +845,10 @@ H5Pget_sym_k (hid_t tid, int *ik /*out */ , int *lk /*out */ ) H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_sym_k, FAIL); - H5TRACE1("e","i",tid); + H5TRACE3("e","ixx",tid,ik,lk); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -850,7 +889,7 @@ H5Pset_istore_k (hid_t tid, int ik) H5TRACE2("e","iIs",tid,ik); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -889,10 +928,10 @@ H5Pget_istore_k (hid_t tid, int *ik /*out */ ) H5F_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_istore_k, FAIL); - H5TRACE1("e","i",tid); + H5TRACE2("e","ix",tid,ik); /* Check arguments */ - if (H5P_FILE_CREATE != H5Pget_class(tid) || + if (H5P_FILE_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); @@ -929,7 +968,7 @@ H5Pset_layout (hid_t tid, H5D_layout_t layout) H5TRACE2("e","iDl",tid,layout); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(tid) || + if (H5P_DATASET_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -961,14 +1000,15 @@ H5Pset_layout (hid_t tid, H5D_layout_t layout) *------------------------------------------------------------------------- */ H5D_layout_t -H5Pget_layout(hid_t tid) +H5Pget_layout (hid_t tid) { H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_layout, H5D_LAYOUT_ERROR); + H5TRACE1("Dl","i",tid); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(tid) || + if (H5P_DATASET_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR, "not a dataset creation property list"); @@ -1007,7 +1047,7 @@ H5Pset_chunk (hid_t tid, int ndims, const hsize_t dim[]) H5TRACE3("e","iIs*h",tid,ndims,dim); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(tid) || + if (H5P_DATASET_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -1067,10 +1107,10 @@ H5Pget_chunk (hid_t tid, int max_ndims, hsize_t dim[]/*out*/) H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pget_chunk, FAIL); - H5TRACE2("Is","iIs",tid,max_ndims); + H5TRACE3("Is","iIsx",tid,max_ndims,dim); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(tid) || + if (H5P_DATASET_CREATE != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -1125,7 +1165,7 @@ H5Pset_external (hid_t plist_id, const char *name, off_t offset, hsize_t size) H5TRACE4("e","isoh",plist_id,name,offset,size); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(plist_id) || + if (H5P_DATASET_CREATE != H5P_get_class(plist_id) || NULL == (plist = H5I_object(plist_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -1205,7 +1245,7 @@ H5Pget_external_count (hid_t plist_id) H5TRACE1("Is","i",plist_id); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(plist_id) || + if (H5P_DATASET_CREATE != H5P_get_class(plist_id) || NULL == (plist = H5I_object(plist_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -1251,10 +1291,10 @@ H5Pget_external (hid_t plist_id, int idx, size_t name_size, char *name/*out*/, H5D_create_t *plist = NULL; FUNC_ENTER (H5Pget_external, FAIL); - H5TRACE3("e","iIsz",plist_id,idx,name_size); + H5TRACE6("e","iIszxxx",plist_id,idx,name_size,name,offset,size); /* Check arguments */ - if (H5P_DATASET_CREATE != H5Pget_class(plist_id) || + if (H5P_DATASET_CREATE != H5P_get_class(plist_id) || NULL == (plist = H5I_object(plist_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -1298,9 +1338,10 @@ H5Pget_driver (hid_t tid) H5F_access_t *tmpl = NULL; FUNC_ENTER (H5Pget_driver, H5F_LOW_ERROR); + H5TRACE1("Fd","i",tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5F_LOW_ERROR, "not a file access property list"); @@ -1337,7 +1378,7 @@ H5Pset_stdio (hid_t tid) H5TRACE1("e","i",tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class(tid) || + if (H5P_FILE_ACCESS != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1378,7 +1419,7 @@ H5Pget_stdio (hid_t tid) H5TRACE1("e","i",tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1419,7 +1460,7 @@ H5Pset_sec2 (hid_t tid) H5TRACE1("e","i",tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class(tid) || + if (H5P_FILE_ACCESS != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1460,7 +1501,7 @@ H5Pget_sec2 (hid_t tid) H5TRACE1("e","i",tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1505,7 +1546,7 @@ H5Pset_core (hid_t tid, size_t increment) H5TRACE2("e","iz",tid,increment); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class(tid) || + if (H5P_FILE_ACCESS != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1550,10 +1591,10 @@ H5Pget_core (hid_t tid, size_t *increment/*out*/) H5F_access_t *tmpl = NULL; FUNC_ENTER (H5Pget_core, FAIL); - H5TRACE1("e","i",tid); + H5TRACE2("e","ix",tid,increment); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1601,19 +1642,19 @@ H5Pset_split (hid_t tid, const char *meta_ext, hid_t meta_tid, H5TRACE5("e","isisi",tid,meta_ext,meta_tid,raw_ext,raw_tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class(tid) || + if (H5P_FILE_ACCESS != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); } if (H5P_DEFAULT!=meta_tid && - (H5P_FILE_ACCESS != H5Pget_class(meta_tid) || + (H5P_FILE_ACCESS != H5P_get_class(meta_tid) || NULL == (meta_tmpl = H5I_object(meta_tid)))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); } if (H5P_DEFAULT!=raw_tid && - (H5P_FILE_ACCESS != H5Pget_class(raw_tid) || + (H5P_FILE_ACCESS != H5P_get_class(raw_tid) || NULL == (raw_tmpl = H5I_object(raw_tid)))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1666,10 +1707,11 @@ H5Pget_split (hid_t tid, size_t meta_ext_size, char *meta_ext/*out*/, H5F_access_t *tmpl = NULL; FUNC_ENTER (H5Pget_split, FAIL); - H5TRACE3("e","izz",tid,meta_ext_size,raw_ext_size); + H5TRACE7("e","izxxzxx",tid,meta_ext_size,meta_ext,meta_properties, + raw_ext_size,raw_ext,raw_properties); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1748,7 +1790,7 @@ H5Pset_family (hid_t tid, hsize_t memb_size, hid_t memb_tid) H5TRACE3("e","ihi",tid,memb_size,memb_tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class(tid) || + if (H5P_FILE_ACCESS != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1758,7 +1800,7 @@ H5Pset_family (hid_t tid, hsize_t memb_size, hid_t memb_tid) "family member size is too small"); } if (H5P_DEFAULT!=memb_tid && - (H5P_FILE_ACCESS != H5Pget_class(memb_tid) || + (H5P_FILE_ACCESS != H5P_get_class(memb_tid) || NULL == (tmpl = H5I_object(memb_tid)))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1802,10 +1844,10 @@ H5Pget_family (hid_t tid, hsize_t *memb_size/*out*/, hid_t *memb_tid/*out*/) H5F_access_t *tmpl = NULL; FUNC_ENTER (H5Pget_family, FAIL); - H5TRACE1("e","i",tid); + H5TRACE3("e","ixx",tid,memb_size,memb_tid); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1864,7 +1906,7 @@ H5Pset_cache (hid_t tid, int mdc_nelmts, size_t rdcc_nbytes, H5TRACE4("e","iIszd",tid,mdc_nelmts,rdcc_nbytes,rdcc_w0); /* Check arguments */ - if (H5P_FILE_ACCESS!=H5Pget_class (tid) || + if (H5P_FILE_ACCESS!=H5P_get_class (tid) || NULL==(fapl=H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1918,7 +1960,7 @@ H5Pget_cache (hid_t tid, int *mdc_nelmts, size_t *rdcc_nbytes, H5TRACE4("e","i*Is*z*d",tid,mdc_nelmts,rdcc_nbytes,rdcc_w0); /* Check arguments */ - if (H5P_FILE_ACCESS!=H5Pget_class (tid) || + if (H5P_FILE_ACCESS!=H5P_get_class (tid) || NULL==(fapl=H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1971,7 +2013,7 @@ H5Pset_buffer (hid_t plist_id, size_t size, void *tconv, void *bkg) H5TRACE4("e","izxx",plist_id,size,tconv,bkg); /* Check arguments */ - if (H5P_DATASET_XFER != H5Pget_class (plist_id) || + if (H5P_DATASET_XFER != H5P_get_class (plist_id) || NULL == (plist = H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); @@ -2012,10 +2054,10 @@ H5Pget_buffer (hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) H5D_xfer_t *plist = NULL; FUNC_ENTER (H5Pget_buffer, 0); - H5TRACE1("z","i",plist_id); + H5TRACE3("z","ixx",plist_id,tconv,bkg); /* Check arguments */ - if (H5P_DATASET_XFER != H5Pget_class (plist_id) || + if (H5P_DATASET_XFER != H5P_get_class (plist_id) || NULL == (plist = H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not a dataset transfer property list"); @@ -2058,7 +2100,7 @@ H5Pset_preserve (hid_t plist_id, hbool_t status) H5TRACE2("e","ib",plist_id,status); /* Check arguments */ - if (H5P_DATASET_XFER != H5Pget_class (plist_id) || + if (H5P_DATASET_XFER != H5P_get_class (plist_id) || NULL == (plist = H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); @@ -2096,7 +2138,7 @@ H5Pget_preserve (hid_t plist_id) H5TRACE1("Is","i",plist_id); /* Check arguments */ - if (H5P_DATASET_XFER != H5Pget_class (plist_id) || + if (H5P_DATASET_XFER != H5P_get_class (plist_id) || NULL == (plist = H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); @@ -2141,7 +2183,7 @@ H5Pset_compression (hid_t plist_id, H5Z_method_t method, unsigned int flags, H5TRACE5("e","iZmIuzx",plist_id,method,flags,cd_size,client_data); /* Check arguments */ - if (H5P_DATASET_CREATE!=H5Pget_class (plist_id) || + if (H5P_DATASET_CREATE!=H5P_get_class (plist_id) || NULL==(plist=H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -2190,14 +2232,15 @@ H5Pset_compression (hid_t plist_id, H5Z_method_t method, unsigned int flags, */ H5Z_method_t H5Pget_compression (hid_t plist_id, unsigned int *flags/*out*/, - size_t *cd_size/*in,out*/, void *client_data/*out*/) + size_t *cd_size/*in_out*/, void *client_data/*out*/) { H5D_create_t *plist = NULL; FUNC_ENTER (H5Pget_compression, FAIL); + H5TRACE4("Zm","ix*zx",plist_id,flags,cd_size,client_data); /* Check arguments */ - if (H5P_DATASET_CREATE!=H5Pget_class (plist_id) || + if (H5P_DATASET_CREATE!=H5P_get_class (plist_id) || NULL==(plist=H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -2247,7 +2290,7 @@ H5Pset_deflate (hid_t plist_id, int level) H5TRACE2("e","iIs",plist_id,level); /* Check arguments */ - if (H5P_DATASET_CREATE!=H5Pget_class (plist_id) || + if (H5P_DATASET_CREATE!=H5P_get_class (plist_id) || NULL==(plist=H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -2295,7 +2338,7 @@ H5Pget_deflate (hid_t plist_id) H5TRACE1("Is","i",plist_id); /* Check arguments */ - if (H5P_DATASET_CREATE!=H5Pget_class (plist_id) || + if (H5P_DATASET_CREATE!=H5P_get_class (plist_id) || NULL==(plist=H5I_object (plist_id))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); @@ -2371,7 +2414,7 @@ H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info) H5TRACE3("e","iMcMi",tid,comm,info); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class(tid) || + if (H5P_FILE_ACCESS != H5P_get_class(tid) || NULL == (tmpl = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -2426,7 +2469,7 @@ H5Pget_mpi (hid_t tid, MPI_Comm *comm, MPI_Info *info) H5TRACE3("e","i*Mc*Mi",tid,comm,info); /* Check arguments */ - if (H5P_FILE_ACCESS != H5Pget_class (tid) || + if (H5P_FILE_ACCESS != H5P_get_class (tid) || NULL == (tmpl = H5I_object (tid))) { HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -2488,7 +2531,7 @@ H5Pset_xfer (hid_t tid, H5D_transfer_t data_xfer_mode) H5TRACE2("e","iDt",tid,data_xfer_mode); /* Check arguments */ - if (H5P_DATASET_XFER != H5Pget_class(tid) || + if (H5P_DATASET_XFER != H5P_get_class(tid) || NULL == (plist = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); @@ -2538,7 +2581,7 @@ H5Pget_xfer (hid_t tid, H5D_transfer_t *data_xfer_mode) H5TRACE2("e","i*Dt",tid,data_xfer_mode); /* Check arguments */ - if (H5P_DATASET_XFER != H5Pget_class(tid) || + if (H5P_DATASET_XFER != H5P_get_class(tid) || NULL == (plist = H5I_object(tid))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); @@ -2588,7 +2631,7 @@ H5Pcopy (hid_t tid) /* Check args */ if (NULL == (tmpl = H5I_object(tid)) || - (type = H5Pget_class(tid)) < 0 || + (type = H5P_get_class(tid)) < 0 || (group = H5I_group(tid)) < 0) { HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to unatomize property list"); diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index d1b877b..36c8652 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -25,5 +25,6 @@ hid_t H5P_create (H5P_class_t type, void *tmpl); void *H5P_copy (H5P_class_t type, const void *src); herr_t H5P_close (H5P_class_t type, void *tmpl); +H5P_class_t H5P_get_class(hid_t tid); #endif @@ -694,7 +694,7 @@ H5Sget_dims (hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims[]/*out*/) intn ret_value = 0; FUNC_ENTER(H5Sget_dims, FAIL); - H5TRACE1("Is","i",space_id); + H5TRACE3("Is","ixx",space_id,dims,maxdims); /* Check args */ if (H5_DATASPACE != H5I_group(space_id) || NULL == (ds = H5I_object(space_id))) { @@ -99,6 +99,9 @@ static intn H5T_nsoft_g = 0; /*num soft funcs defined */ static intn H5T_asoft_g = 0; /*num slots allocated */ static H5T_soft_t *H5T_soft_g = NULL; /*master soft list */ +/* The overflow handler */ +H5T_overflow_t H5T_overflow_g = NULL; + /*-------------------------------------------------------------------------- NAME H5T_init_interface -- Initialize interface-specific information @@ -1201,11 +1204,12 @@ H5Tlock (hid_t type_id) *------------------------------------------------------------------------- */ H5T_class_t -H5Tget_class(hid_t type_id) +H5Tget_class (hid_t type_id) { H5T_t *dt = NULL; FUNC_ENTER(H5Tget_class, H5T_NO_CLASS); + H5TRACE1("Tt","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -1384,12 +1388,13 @@ H5Tset_size (hid_t type_id, size_t size) *------------------------------------------------------------------------- */ H5T_order_t -H5Tget_order(hid_t type_id) +H5Tget_order (hid_t type_id) { H5T_t *dt = NULL; H5T_order_t order; FUNC_ENTER(H5Tget_order, H5T_ORDER_ERROR); + H5TRACE1("To","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -1751,7 +1756,7 @@ H5Tget_pad (hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) H5T_t *dt = NULL; FUNC_ENTER(H5Tget_pad, FAIL); - H5TRACE1("e","i",type_id); + H5TRACE3("e","ixx",type_id,lsb,msb); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -1830,12 +1835,13 @@ H5Tset_pad (hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) *------------------------------------------------------------------------- */ H5T_sign_t -H5Tget_sign(hid_t type_id) +H5Tget_sign (hid_t type_id) { H5T_t *dt = NULL; H5T_sign_t sign; FUNC_ENTER(H5Tget_sign, H5T_SGN_ERROR); + H5TRACE1("Ts","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -1925,7 +1931,7 @@ H5Tget_fields (hid_t type_id, size_t *spos/*out*/, H5T_t *dt = NULL; FUNC_ENTER(H5Tget_fields, FAIL); - H5TRACE1("e","i",type_id); + H5TRACE6("e","ixxxxx",type_id,spos,epos,esize,mpos,msize); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -2126,12 +2132,13 @@ H5Tset_ebias (hid_t type_id, size_t ebias) *------------------------------------------------------------------------- */ H5T_norm_t -H5Tget_norm(hid_t type_id) +H5Tget_norm (hid_t type_id) { H5T_t *dt = NULL; H5T_norm_t norm; FUNC_ENTER(H5Tget_norm, H5T_NORM_ERROR); + H5TRACE1("Tn","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -2213,12 +2220,13 @@ H5Tset_norm (hid_t type_id, H5T_norm_t norm) *------------------------------------------------------------------------- */ H5T_pad_t -H5Tget_inpad(hid_t type_id) +H5Tget_inpad (hid_t type_id) { H5T_t *dt = NULL; H5T_pad_t pad; FUNC_ENTER(H5Tget_inpad, H5T_PAD_ERROR); + H5TRACE1("Tp","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -2302,12 +2310,13 @@ H5Tset_inpad (hid_t type_id, H5T_pad_t pad) *------------------------------------------------------------------------- */ H5T_cset_t -H5Tget_cset(hid_t type_id) +H5Tget_cset (hid_t type_id) { H5T_t *dt = NULL; H5T_cset_t cset; FUNC_ENTER(H5Tget_cset, H5T_CSET_ERROR); + H5TRACE1("Tc","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -2390,12 +2399,13 @@ H5Tset_cset (hid_t type_id, H5T_cset_t cset) *------------------------------------------------------------------------- */ H5T_str_t -H5Tget_strpad(hid_t type_id) +H5Tget_strpad (hid_t type_id) { H5T_t *dt = NULL; H5T_str_t strpad; FUNC_ENTER(H5Tget_strpad, H5T_STR_ERROR); + H5TRACE1("Tz","i",type_id); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -2614,7 +2624,7 @@ H5Tget_member_dims (hid_t type_id, int membno, intn ndims, i; FUNC_ENTER(H5Tget_member_dims, FAIL); - H5TRACE2("Is","iIs",type_id,membno); + H5TRACE4("Is","iIsxx",type_id,membno,dims,perm); /* Check args */ if (H5_DATATYPE != H5I_group(type_id) || @@ -2831,7 +2841,8 @@ H5Tpack (hid_t type_id) *------------------------------------------------------------------------- */ herr_t -H5Tregister_hard (const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) +H5Tregister_hard (const char *name, hid_t src_id, hid_t dst_id, + H5T_conv_t func) { H5T_t *src = NULL; H5T_t *dst = NULL; @@ -3139,12 +3150,13 @@ H5Tunregister (H5T_conv_t func) *------------------------------------------------------------------------- */ H5T_conv_t -H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) +H5Tfind (hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) { H5T_conv_t ret_value = NULL; H5T_t *src = NULL, *dst = NULL; FUNC_ENTER(H5Tfind, NULL); + H5TRACE3("x","iix",src_id,dst_id,pcdata); /* Check args */ if (H5_DATATYPE != H5I_group(src_id) || @@ -3228,6 +3240,71 @@ H5Tconvert (hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, FUNC_LEAVE (SUCCEED); } + +/*------------------------------------------------------------------------- + * Function: H5Tget_overflow + * + * Purpose: Returns a pointer to the current global overflow function. + * This is an application-defined function that is called + * whenever a data type conversion causes an overflow. + * + * Return: Success: Ptr to an application-defined function. + * + * Failure: NULL (this can happen if no overflow handling + * function is registered). + * + * Programmer: Robb Matzke + * Tuesday, July 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5T_overflow_t +H5Tget_overflow (void) +{ + FUNC_ENTER(H5Tget_overflow, NULL); + H5TRACE0("x",""); + + if (NULL==H5T_overflow_g) { + HRETURN_ERROR(H5E_DATATYPE, H5E_UNINITIALIZED, NULL, + "no overflow handling function is registered"); + } + + FUNC_LEAVE(H5T_overflow_g); +} + + +/*------------------------------------------------------------------------- + * Function: H5Tset_overflow + * + * Purpose: Sets the overflow handler to be the specified function. FUNC + * will be called for all data type conversions that result in + * an overflow. See the definition of `H5T_overflow_t' for + * documentation of arguments and return values. The NULL + * pointer may be passed to remove the overflow handler. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, July 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Tset_overflow (H5T_overflow_t func) +{ + FUNC_ENTER(H5Tset_overflow, FAIL); + H5TRACE1("e","x",func); + H5T_overflow_g = func; + FUNC_LEAVE(SUCCEED); +} + + /*------------------------------------------------------------------------- * API functions are above; library-private functions are below... *------------------------------------------------------------------------- diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 930b330..211caf7 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -14,6 +14,7 @@ #include <H5MMprivate.h> #include <H5Tpkg.h> #include <math.h> /*for ceil() */ +#include <float.h> /*for FLT_MAX and HUGE_VAL */ /* Conversion data for H5T_conv_struct() */ typedef struct H5T_conv_struct_t { @@ -551,6 +552,9 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * * Modifications: * + * Robb Matzke, 7 Jul 1998 + * Added overflow handling. + * *------------------------------------------------------------------------- */ herr_t @@ -701,8 +705,11 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, dst->u.atomic.prec-src->u.atomic.prec, FALSE); } else if (first>=dst->u.atomic.prec) { /*overflow*/ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, - TRUE); + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, + dst->u.atomic.prec, TRUE); + } } else { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, @@ -715,13 +722,16 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * If the source is signed and the destination isn't then we * can have overflow if the source contains more bits than * the destination (destination is set to the maximum - * possible value) or underflow if the source is negative + * possible value) or overflow if the source is negative * (destination is set to zero). */ if (first+1 == src->u.atomic.prec) { - /*underflow*/ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, - FALSE); + /*overflow*/ + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, + dst->u.atomic.prec, FALSE); + } } else if (src->u.atomic.prec < dst->u.atomic.prec) { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, @@ -731,8 +741,11 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FALSE); } else if (first>=dst->u.atomic.prec) { /*overflow*/ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, - TRUE); + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, + dst->u.atomic.prec, TRUE); + } } else { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, @@ -748,10 +761,13 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ if (first+1 >= dst->u.atomic.prec) { /*overflow*/ - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec-1, TRUE); - H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec-1, - 1, FALSE); + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, + dst->u.atomic.prec-1, TRUE); + H5T_bit_set (d, (dst->u.atomic.offset + + dst->u.atomic.prec-1), 1, FALSE); + } } else if (src->u.atomic.prec<dst->u.atomic.prec) { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, @@ -767,7 +783,7 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, } else if (first+1 == src->u.atomic.prec) { /* * Both the source and the destination are signed and the - * source value is negative. We could experience underflow + * source value is negative. We could experience overflow * if the destination isn't wide enough in which case the * destination is set to a negative number with the largest * possible magnitude. @@ -778,11 +794,14 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t fz = (size_t)sfz; if (sfz>=0 && fz+1>=dst->u.atomic.prec) { - /*underflow*/ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, - FALSE); - H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec-1, - 1, TRUE); + /*overflow*/ + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, + dst->u.atomic.prec-1, FALSE); + H5T_bit_set (d, (dst->u.atomic.offset + + dst->u.atomic.prec-1), 1, TRUE); + } } else if (src->u.atomic.prec<dst->u.atomic.prec) { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, @@ -804,10 +823,13 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ if (first+1>=dst->u.atomic.prec) { /*overflow*/ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, - TRUE); - H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec-1, - 1, FALSE); + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, + dst->u.atomic.prec-1, TRUE); + H5T_bit_set (d, (dst->u.atomic.offset + + dst->u.atomic.prec-1), 1, FALSE); + } } else if (src->u.atomic.prec<dst->u.atomic.prec) { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, @@ -888,6 +910,9 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Modifications: * + * Robb Matzke, 7 Jul 1998 + * Added overflow handling. + * *------------------------------------------------------------------------- */ herr_t @@ -1143,12 +1168,30 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* * The exponent is too large to fit in the available region * or it results in the maximum possible value. Use positive - * or negative infinity instead. + * or negative infinity instead unless the application + * specifies something else. Before calling the overflow + * handler make sure the source buffer we hand it is in the + * original byte order. */ + if (H5T_overflow_g) { + uint8 over_src[256]; + assert(src_p->size<=sizeof over_src); + if (H5T_ORDER_BE==src.order) { + for (i=0; i<src_p->size; i++) { + over_src[src_p->size-(i+1)] = s[i]; + } + } else { + for (i=0; i<src_p->size; i++) { + over_src[i] = s[i]; + } + } + if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) { + goto next; + } + } expo = expo_max; H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; - } /* @@ -1239,6 +1282,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ + next: if (d==dbuf) HDmemcpy (dp, d, dst_p->size); sp += direction * src_p->size; dp += direction * dst_p->size; @@ -1324,12 +1368,14 @@ H5T_conv_float_double (hid_t __unused__ src_id, hid_t __unused__ dst_id, * * Modifications: * + * Robb Matzke, 7 Jul 1998 + * Added overflow handling. + * *------------------------------------------------------------------------- */ herr_t -H5T_conv_double_float (hid_t __unused__ src_id, hid_t __unused__ dst_id, - H5T_cdata_t *cdata, size_t nelmts, void *buf, - void __unused__ *bkg) +H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, + size_t nelmts, void *buf, void __unused__ *bkg) { size_t elmtno; /*element number */ double *s; /*source buffer */ @@ -1349,8 +1395,20 @@ H5T_conv_double_float (hid_t __unused__ src_id, hid_t __unused__ dst_id, s = (double*)buf; d = (float*)buf; - for (elmtno=0; elmtno<nelmts; elmtno++) { - *d++ = *s++; + for (elmtno=0; elmtno<nelmts; elmtno++, d++, s++) { + if (*s > FLT_MAX) { + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + *d = HUGE_VAL; + } + } else if (*s < -FLT_MAX) { + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + *d = -HUGE_VAL; + } + } else { + *d = *s; + } } break; diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index a411916..e53a5e0 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -116,6 +116,9 @@ typedef enum H5T_sdir_t { H5T_BIT_MSB /*search msb toward lsb */ } H5T_sdir_t; +/* The overflow handler */ +extern H5T_overflow_t H5T_overflow_g; + /* Function prototypes for H5T package scope */ H5T_path_t *H5T_path_find (const char *name, const H5T_t *src, const H5T_t *dst, hbool_t create, H5T_conv_t func); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 56ad7c3..89491fc 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -118,6 +118,19 @@ typedef struct H5T_cdata_t { typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, void *buf, void *bkg); +/* + * If an error occurs during a data type conversion then the function + * registered with H5Tset_overflow() is called. It's arguments are the + * source and destination data types, a buffer which has the source value, + * and a buffer to receive an optional result for the overflow conversion. + * If the overflow handler chooses a value for the result it should return + * non-negative; otherwise the hdf5 library will choose an appropriate + * result. + */ +typedef herr_t (*H5T_overflow_t)(hid_t src_id, hid_t dst_id, + void *src_buf, void *dst_buf); + + #ifdef __cplusplus extern "C" { #endif @@ -379,6 +392,8 @@ herr_t H5Tunregister (H5T_conv_t func); H5T_conv_t H5Tfind (hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); herr_t H5Tconvert (hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background); +H5T_overflow_t H5Tget_overflow(void); +herr_t H5Tset_overflow(H5T_overflow_t func); #ifdef __cplusplus } diff --git a/src/H5private.h b/src/H5private.h index 82f0add..2dac272 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -481,40 +481,45 @@ extern char *strdup(const char *s); *------------------------------------------------------------------------- */ #ifdef H5_DEBUG_API -#define H5TRACE_DECL const char *RTYPE=NULL -#define H5TRACE0(R,T) RTYPE=R; \ - H5_trace(0,FUNC,T) -#define H5TRACE1(R,T,A0) RTYPE=R; \ - H5_trace(0,FUNC,T,#A0,A0) -#define H5TRACE2(R,T,A0,A1) RTYPE=R; \ - H5_trace(0,FUNC,T,#A0,A0,#A1,A1) -#define H5TRACE3(R,T,A0,A1,A2) RTYPE=R; \ - H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ - #A2,A2) -#define H5TRACE4(R,T,A0,A1,A2,A3) RTYPE=R; \ - H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ - #A2,A2,#A3,A3) -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) RTYPE=R; \ - H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ - #A2,A2,#A3,A3,#A4,A4) -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) RTYPE=R; \ - H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ - #A2,A2,#A3,A3,#A4,A4, \ - #A5,A5) -#define H5TRACE_RETURN(V) if (RTYPE) { \ - H5_trace(1,NULL,RTYPE,NULL,V); \ - RTYPE=NULL; \ - } +#define H5TRACE_DECL const char *RTYPE=NULL +#define H5TRACE0(R,T) RTYPE=R; \ + H5_trace(0,FUNC,T) +#define H5TRACE1(R,T,A0) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0) +#define H5TRACE2(R,T,A0,A1) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0,#A1,A1) +#define H5TRACE3(R,T,A0,A1,A2) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ + #A2,A2) +#define H5TRACE4(R,T,A0,A1,A2,A3) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ + #A2,A2,#A3,A3) +#define H5TRACE5(R,T,A0,A1,A2,A3,A4) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ + #A2,A2,#A3,A3,#A4,A4) +#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ + #A2,A2,#A3,A3,#A4,A4, \ + #A5,A5) +#define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) RTYPE=R; \ + H5_trace(0,FUNC,T,#A0,A0,#A1,A1, \ + #A2,A2,#A3,A3,#A4,A4, \ + #A5,A5,#A6,A6) +#define H5TRACE_RETURN(V) if (RTYPE) { \ + H5_trace(1,NULL,RTYPE,NULL,V); \ + RTYPE=NULL; \ + } #else -#define H5TRACE_DECL /*void*/ -#define H5TRACE0(R,T) /*void*/ -#define H5TRACE1(R,T,A0) /*void*/ -#define H5TRACE2(R,T,A0,A1) /*void*/ -#define H5TRACE3(R,T,A0,A1,A2) /*void*/ -#define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ -#define H5TRACE_RETURN(V) /*void*/ +#define H5TRACE_DECL /*void*/ +#define H5TRACE0(R,T) /*void*/ +#define H5TRACE1(R,T,A0) /*void*/ +#define H5TRACE2(R,T,A0,A1) /*void*/ +#define H5TRACE3(R,T,A0,A1,A2) /*void*/ +#define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ +#define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ +#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ +#define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) /*void*/ +#define H5TRACE_RETURN(V) /*void*/ #endif void H5_trace (hbool_t returning, const char *func, const char *type, ...); diff --git a/test/dtypes.c b/test/dtypes.c index e9e8f06..9bd8747 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -53,6 +53,9 @@ typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; +/* Count the number of overflows */ +static int noverflows_g = 0; + /* * Some machines generate SIGFPE on floating point overflows. According to * the Posix standard, we cannot assume that we can continue from such a @@ -88,6 +91,31 @@ fpe_handler(int __unused__ signo) /*------------------------------------------------------------------------- + * Function: overflow_handler + * + * Purpose: Gets called for all data type conversion overflows. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Tuesday, July 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +overflow_handler(hid_t __unused__ src_id, hid_t __unused__ dst_id, + void __unused__ *src_buf, void __unused__ *dst_buf) +{ + noverflows_g++; + return -1; +} + + +/*------------------------------------------------------------------------- * Function: cleanup * * Purpose: Removes test files @@ -895,6 +923,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) dst_size = H5Tget_size(dst); buf = malloc(nelmts*MAX(src_size, dst_size)); saved = malloc(nelmts*MAX(src_size, dst_size)); + noverflows_g = 0; for (i=0; i<ntests; i++) { @@ -1074,6 +1103,9 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } puts(" PASSED"); } + if (noverflows_g>0) { + printf(" %d overflow%s\n", noverflows_g, 1==noverflows_g?"":"s"); + } done: if (buf) free (buf); @@ -1119,6 +1151,9 @@ main(void) /* Set the error handler */ H5Eset_auto (display_error_cb, NULL); + /* Set the overflow handler */ + H5Tset_overflow(overflow_handler); + /* Do the tests */ nerrors += test_classes()<0 ? 1 : 0; nerrors += test_copy()<0 ? 1 : 0; |