[svn-r936] Changes since 19981119

----------------------

./src/H5.c
./src/H5A.c
./src/H5AC.c
./src/H5B.c
./src/H5D.c
./src/H5E.c
./src/H5F.c
./src/H5Farray.c
./src/H5Fcore.c
./src/H5Ffamily.c
./src/H5Fistore.c
./src/H5Flow.c
./src/H5Fmpio.c
./src/H5Fsec2.c
./src/H5Fsplit.c
./src/H5Fstdio.c
./src/H5G.c
./src/H5Gent.c
./src/H5Gnode.c
./src/H5Gstab.c
./src/H5HG.c
./src/H5HL.c
./src/H5I.c
./src/H5Iprivate.h
./src/H5MF.c
./src/H5MM.c
./src/H5O.c
./src/H5Oattr.c
./src/H5Ocomp.c
./src/H5Ocont.c
./src/H5Odtype.c
./src/H5Oefl.c
./src/H5Ofill.c
./src/H5Olayout.c
./src/H5Omtime.c
./src/H5Oname.c
./src/H5Osdspace.c
./src/H5Oshared.c
./src/H5Ostab.c
./src/H5P.c
./src/H5R.c
./src/H5RA.c
./src/H5S.c
./src/H5Sall.c
./src/H5Shyper.c
./src/H5Smpio.c
./src/H5Snone.c
./src/H5Spoint.c
./src/H5Sselect.c
./src/H5T.c
./src/H5TB.c
./src/H5Tbit.c
./src/H5Tconv.c
./src/H5V.c
./src/H5Z.c
./src/H5detect.c
./src/H5private.h
	Most of these changes are because the `interface_initialize_g'
	variable change from hbool_t to int.  It's a one line change.

	Changed the way the library is closed so we have more control
	over the order the interfaces are shut down.  Instead of
	registering an atexit() function for every interface in some
	haphazard order we just register one: H5_term_library() which
	then calls the H5*_term_interface() functions in a
	well-defined order.

	If the library is closed and then reopened repeatedly by
	calling H5close() and H5open() in a loop we only add one copy
	of the library termination functions with atexit().

	Termination is a two-step process in order to help detect
	programming errors that would cause an infinite loop caused by
	the termination of one interface waking up some other
	previously terminated interface.  The first step terminates
	the interface and *marks it as unusable*.  After all
	interfaces are terminated then we mark them all as usable
	again.  The FUNC_ENTER() macro has been modified to return
	failure or to dump core (depending on whether NDEBUG is
	defined) if we try to call an interface while it's shutting
	down.

./src/H5.c
	The H5dont_atexit() function returns failure if it's called
	more than once or if it's called too late.  However, the error
	stack is not automatically printed on failure because the
	library might not be initialized yet

./test/chunk.c
./test/flush1.c
./test/flush2.c
./test/iopipe.c
./test/overhead.c
./test/ragged.c
	Changed the extra cast for Win32 so we do floating point
	division again -- it was just confusion about precedence and
	associativity of casting and the C coercion rules. Removed
	extra carriage returns inserted by broken operating system.

./src/H5Ffamily.c
	Fixed an bug where H5F_fam_write() lowered the EOF marker for
	one of the family members causing H5F_fam_read() to read
	zeros.

./test/h5test.h		[NEW]
./test/h5test.c		[NEW]
./test/Makefile.in
./test/bittests.c
./test/cmpd_dset.c
./test/dsets.c
./test/dtypes.c
./test/extend.c
./test/external.c
	Support library for test files.  This isn't done yet but
	Katie's contractions are ~10 minutes apart so I figured I
	better back this stuff up just in case I'm not here next
	week...

	Eventually all test files will understand HDF5_DRIVER to name
	the low level file driver and parameters so we can easily test
	various drivers.  They will also understand HDF5_PREFIX to
	prepend to the beginning of file names which is necessary for
	testing ROMIO with various drivers. Also, the cleanup function
	will know how to use the file name prefix and will understand
	different file driver naming schemes like file families. I'm
	not sure they'll understand the `gsf:' type prefixes yet.

	Note, the external test is completely commented out because
	I'm in the middle of modifying it.  It will still compile and
	run but it doesn't test anything at the moment.
This commit is contained in:
Robb Matzke 1998-11-20 22:36:51 -05:00
parent 6345a417a3
commit 7488c6366e
75 changed files with 1907 additions and 1985 deletions

View File

@ -317,6 +317,8 @@
./test/flush1.c
./test/flush2.c
./test/gheap.c
./test/h5test.c
./test/h5test.h
./test/hyperslab.c
./test/iopipe.c
./test/istore.c

327
src/H5.c
View File

@ -16,26 +16,6 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
/*LINTLIBRARY */
/*+
FILE
hdf5.c
HDF library support routines
EXPORTED ROUTINES
H5dont_atexit -- Indicate that an 'atexit' routine is _not_ to be installed
H5get_libversion -- Check the version of the library
LIBRARY-SCOPED ROUTINES
H5_init_library -- initialize the HDF5 library
H5_term_library -- shut-down the HDF5 library
H5_init_thread -- initialize thread-specific information
LOCAL ROUTINES
H5_init_interface -- initialize the H5 interface
+ */
/* private headers */
#include <H5private.h> /*library */
#include <H5ACprivate.h> /*cache */
@ -44,7 +24,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Iprivate.h> /*atoms */
#include <H5MMprivate.h> /*memory management */
#include <H5Pprivate.h> /*property lists */
#include <H5Rpublic.h> /* References */
#include <H5Rpublic.h> /*references */
#include <H5Sprivate.h> /*data spaces */
#include <H5Tprivate.h> /*data types */
#include <H5Zprivate.h> /*filters */
@ -55,22 +35,13 @@ FILE *fdopen(int fd, const char *mode);
#define PABLO_MASK H5_mask
hbool_t library_initialize_g = FALSE;
hbool_t thread_initialize_g = FALSE;
hbool_t install_atexit_g = TRUE;
hbool_t dont_atexit_g = FALSE;
H5_debug_t H5_debug_g; /*debugging info */
static void H5_debug_mask(const char*);
typedef struct H5_exit {
void (*func) (void); /* Interface function to call during exit */
struct H5_exit *next; /* Pointer to next node with exit function */
} H5_exit_t;
H5_exit_t *lib_exit_head; /* Pointer to the head of the list of 'atexit' functions */
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5_init_interface
static herr_t H5_init_interface(void);
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
NAME
@ -112,13 +83,17 @@ H5_init_library(void)
H5_debug_g.pkg[H5_PKG_V].name = "v";
H5_debug_g.pkg[H5_PKG_Z].name = "z";
/* Install atexit() library cleanup routine */
if (install_atexit_g == TRUE &&
HDatexit(&H5_term_library) != 0) {
HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
"unable to register atexit function");
/*
* Install atexit() library cleanup routine unless the H5dont_atexit()
* has been called. Once we add something to the atexit() list it stays
* there permanently, so we set dont_atexit_g after we add it to prevent
* adding it again later if the library is cosed and reopened.
*/
if (!dont_atexit_g) {
atexit(H5_term_library);
dont_atexit_g = TRUE;
}
/*
* Initialize interfaces that might not be able to initialize themselves
* soon enough.
@ -135,187 +110,113 @@ H5_init_library(void)
FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
NAME
H5_add_exit
PURPOSE
Add an exit routine to the list of routines to call during 'atexit'
USAGE
herr_t H5_add_exit(func)
void (*func)(void); IN: Function pointer of routine to add to chain
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Pre-pend the new function to the list of function to call during the exit
process. These routines are responsible for free'ing static buffers, etc.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Don't make assumptions about the environment during the exit procedure...
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5_add_exit(void (*func)(void))
{
H5_exit_t *new_exit;
FUNC_ENTER_INIT(H5_add_exit, NULL, FAIL);
assert(func);
if (NULL==(new_exit = H5MM_calloc(sizeof(H5_exit_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
new_exit->func = func;
new_exit->next = lib_exit_head;
lib_exit_head = new_exit;
FUNC_LEAVE(SUCCEED);
} /* end H5_add_exit() */
/*--------------------------------------------------------------------------
NAME
H5_term_library
PURPOSE
Terminate various static buffers and shutdown the library.
USAGE
void H5_term_library()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Walk through the shutdown routines for the various interfaces and
terminate them all.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Should only ever be called by the "atexit" function, or real power-users.
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
* Function: H5_term_library
*
* Purpose: Terminate interfaces in a well-defined order due to
* dependencies among the interfaces, then terminate
* library-specific data.
*
* Return: void
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
H5_term_library(void)
{
H5_exit_t *temp;
/* Don't do anything if the library is already closed */
if (!library_initialize_g) return;
temp = lib_exit_head;
while (lib_exit_head != NULL) {
(*lib_exit_head->func) ();
lib_exit_head = lib_exit_head->next;
HDfree(temp);
temp = lib_exit_head;
} /* end while */
} /* end H5_term_library() */
/*
* Close interfaces in a well-defined order based on dependencies. The
* goal is that closing one interface doesn't reopen another that was
* just closed. In order to help us track down dependencies that we
* didn't know about, we close the interfaces in a two step process. The
* first step does the real work and makes the interface unusable. The
* second step doesn't do any work but makes it possible to reopen the
* interface later.
*/
/*--------------------------------------------------------------------------
NAME
H5_init_thread -- Initialize thread-specific information
USAGE
void H5_init_thread()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Initializes any thread-specific data or routines.
/* Function What depends on it? */
/*------------------------- ------------------------------- */
H5D_term_interface(-1); /* */
H5TB_term_interface(-1); /* */
H5Z_term_interface(-1); /* */
H5A_term_interface(-1); /* */
H5RA_term_interface(-1); /* */
H5F_term_interface(-1); /* T */
H5G_term_interface(-1); /* */
H5R_term_interface(-1); /* */
H5S_term_interface(-1); /* */
H5T_native_close(-1); /* D RA */
H5T_term_interface(-1); /* D RA */
H5P_term_interface(-1); /* D */
H5I_term_interface(-1); /* A D F G P RA S T TB Z */
/*------------------------- --------------------------------- */
--------------------------------------------------------------------------*/
herr_t
H5_init_thread(void)
{
FUNC_ENTER_INIT(H5_init_thread, NULL, FAIL);
/*
* Finalize the closing by calling all the functions again but with an
* argument of zero. This allows the interface to be reopened later.
*/
H5A_term_interface(0);
H5D_term_interface(0);
H5F_term_interface(0);
H5G_term_interface(0);
H5I_term_interface(0);
H5P_term_interface(0);
H5RA_term_interface(0);
H5R_term_interface(0);
H5S_term_interface(0);
H5TB_term_interface(0);
H5T_native_close(0);
H5T_term_interface(0);
H5Z_term_interface(0);
/* Add the "thread termination" routine to the exit chain */
if (H5_add_exit(&H5_term_thread)<0)
HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
"unable to set thread atexit function");
/* Mark library as closed */
library_initialize_g = FALSE;
}
FUNC_LEAVE(SUCCEED);
} /* H5_init_thread */
/*--------------------------------------------------------------------------
NAME
H5_term_thread
PURPOSE
Terminate various thread-specific objects
USAGE
void H5_term_thread()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Release the error stack and any other thread-specific resources allocated
on a "per thread" basis.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Can't report errors...
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
void
H5_term_thread(void)
{/*void*/}
/*--------------------------------------------------------------------------
NAME
H5_init_interface -- Initialize interface-specific information
USAGE
herr_t H5_init_interface()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
static herr_t
H5_init_interface(void)
{
FUNC_ENTER(H5_init_interface, FAIL);
FUNC_LEAVE(SUCCEED);
} /* H5_init_interface */
/*--------------------------------------------------------------------------
NAME
H5dont_atexit
PURPOSE
Indicates to the library that an 'atexit()' routine is _not_ to be installed
USAGE
herr_t H5dont_atexit(void)
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
This routine indicates to the library that an 'atexit()' cleanip routine
should not be installed. The major (only?) purpose for this is in
situations where the library is dynamically linked into an application and
is un-linked from the application before 'exit()' gets callled. In those
situations, a routine installed with 'atexit()' would jump to a routine
which was no longer in memory, causing errors.
In order to be effective, this routine _must_ be called before any other
HDF function calls, and must be called each time the library is loaded/
linked into the application. (the first time and after it's been un-loaded)
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
If this routine is used, certain memory buffers will not be de-allocated,
although in theory a user could call HPend on their own...
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
* Function: H5dont_atexit
*
* Purpose: Indicates that the library is not to clean up after itself
* when the application exits by calling exit() or returning
* from main(). This function must be called before any other
* HDF5 function or constant is used or it will have no effect.
*
* If this function is used then certain memory buffers will not
* be de-allocated nor will open files be flushed automatically.
* The application may still call H5close() explicitly to
* accomplish these things.
*
* Return: Success: non-negative
*
* Failure: negative if this function is called more than
* once or if it is called too late.
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5dont_atexit(void)
{
#ifdef DONT_DO_THIS
FUNC_ENTER_INIT(H5dont_atexit, NULL, FAIL);
#endif /* DONT_DO_THIS */
if (install_atexit_g == TRUE)
install_atexit_g = FALSE;
#ifdef DONT_DO_THIS
FUNC_LEAVE(SUCCEED);
#else /* DONT_DO_THIS */
/* FUNC_ENTER_INIT() should not be called */
H5_trace(FALSE, "H5dont_atexit", "");
if (dont_atexit_g) return FAIL;
dont_atexit_g = TRUE;
H5_trace(TRUE, NULL, "e", SUCCEED);
return(SUCCEED);
#endif /* DONT_DO_THIS */
}
@ -531,7 +432,7 @@ H5close (void)
* thing just to release it all right away. It is safe to call this
* function for an uninitialized library.
*/
H5_term_library ();
H5_term_library();
return SUCCEED;
}
@ -1138,6 +1039,12 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds)
* Note: The TYPE string is meant to be terse and is generated by a
* separate perl script.
*
* WARNING: DO NOT CALL ANY HDF5 FUNCTION THAT CALLS FUNC_ENTER(). DOING
* SO MAY CAUSE H5_trace() TO BE INVOKED RECURSIVELY OR MAY
* CAUSE LIBRARY INITIALIZATIONS THAT ARE NOT DESIRED. DO NOT
* USE THE H5T_*_* CONSTANTS SINCE THEY CALL H5_open() WHICH
* INVOKES FUNC_ENTER().
*
* Return: void
*
* Programmer: Robb Matzke
@ -1159,6 +1066,8 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...)
void *vp = NULL;
FILE *out = H5_debug_g.trace;
/* FUNC_ENTER() should not be called */
if (!out) return; /*tracing is off*/
va_start (ap, type);

View File

@ -34,12 +34,11 @@ static char RcsId[] = "$Revision$";
#define PABLO_MASK H5A_mask
/* Is the interface initialized? */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5A_init_interface
static herr_t H5A_init_interface(void);
/* PRIVATE PROTOTYPES */
static void H5A_term_interface(void);
static hid_t H5A_create(const H5G_entry_t *ent, const char *name,
const H5T_t *type, const H5S_t *space);
static hid_t H5A_open(H5G_entry_t *ent, unsigned idx);
@ -63,26 +62,18 @@ DESCRIPTION
static herr_t
H5A_init_interface(void)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER(H5A_init_interface, FAIL);
/*
* Register cleanup function.
* Create attribute group.
*/
if ((ret_value = H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE,
H5A_RESERVED_ATOMS,
(herr_t (*)(void *)) H5A_close))<0) {
if (H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS,
(herr_t (*)(void *)) H5A_close)<0) {
HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
"unable to initialize attribute group");
}
if (H5_add_exit(H5A_term_interface) < 0) {
HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
"unable to install atexit function");
"unable to initialize interface");
}
FUNC_LEAVE(ret_value);
FUNC_LEAVE(SUCCEED);
}
@ -94,7 +85,6 @@ H5A_init_interface(void)
USAGE
void H5A_term_interface()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Release any other resources allocated.
GLOBAL VARIABLES
@ -103,11 +93,13 @@ H5A_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5A_term_interface(void)
void
H5A_term_interface(intn status)
{
H5I_destroy_group(H5I_ATTR);
interface_initialize_g = FALSE;
if (interface_initialize_g>0) {
H5I_destroy_group(H5I_ATTR);
}
interface_initialize_g = status;
}

View File

@ -36,7 +36,7 @@
*/
#define PABLO_MASK H5AC_mask
#define INTERFACE_INIT NULL
static int interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#ifdef H5AC_SORT_BY_ADDR
static H5AC_t *current_cache_g = NULL; /*for sorting */

View File

@ -139,7 +139,7 @@ static const H5AC_class_t H5AC_BT[1] = {{
/* Interface initialization? */
#define INTERFACE_INIT NULL
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
/*-------------------------------------------------------------------------

View File

@ -91,10 +91,9 @@ const H5D_xfer_t H5D_xfer_dflt = {
};
/* Interface initialization? */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5D_init_interface
static herr_t H5D_init_interface(void);
static void H5D_term_interface(void);
static herr_t H5D_init_storage(H5D_t *dataset, const H5S_t *space);
H5D_t * H5D_new(const H5D_create_t *create_parms);
@ -114,42 +113,42 @@ DESCRIPTION
static herr_t
H5D_init_interface(void)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER(H5D_init_interface, FAIL);
/* Initialize the atom group for the dataset IDs */
if ((ret_value = H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE,
H5D_RESERVED_ATOMS,
(herr_t (*)(void *)) H5D_close)) >=0) {
ret_value = H5_add_exit(H5D_term_interface);
if (H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS,
(herr_t (*)(void *)) H5D_close)<0) {
HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
FUNC_LEAVE(ret_value);
FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
NAME
H5D_term_interface
PURPOSE
Terminate various H5D objects
USAGE
void H5D_term_interface()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Release the atom group and any other resources allocated.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Can't report errors...
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5D_term_interface(void)
/*-------------------------------------------------------------------------
* Function: H5D_term_interface
*
* Purpose: Terminate this interface.
*
* Return: void
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
H5D_term_interface(intn status)
{
H5I_destroy_group(H5I_DATASET);
interface_initialize_g = FALSE;
if (interface_initialize_g>0) {
H5I_destroy_group(H5I_DATASET);
}
interface_initialize_g = status;
}
/*-------------------------------------------------------------------------
* Function: H5Dcreate

View File

@ -65,7 +65,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_istore_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*

View File

@ -110,7 +110,7 @@ static const H5E_minor_mesg_t H5E_minor_mesg_g[] = {
};
/* Interface initialization? */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
const hbool_t H5E_clearable_g = TRUE; /* DO NOT CHANGE */

View File

@ -98,9 +98,8 @@ const H5F_mprop_t H5F_mount_dflt = {
};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5F_init_interface
static void H5F_term_interface(void);
/* PRIVATE PROTOTYPES */
static H5F_t *H5F_new(H5F_file_t *shared, const H5F_create_t *fcpl,
@ -112,28 +111,27 @@ static herr_t H5F_locate_signature(H5F_low_t *f_handle,
haddr_t *addr/*out*/);
/*--------------------------------------------------------------------------
NAME
H5F_init_interface -- Initialize interface-specific information
USAGE
herr_t H5F_init_interface()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Initializes any interface-specific data or routines.
ERRORS
Modifications:
Robb Matzke, 4 Aug 1997
Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call.
It was already H5F_mask for the PABLO_TRACE_ON call.
rky 980816
Added .disp, .btype, .ftype to H5F_access_t.
--------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
* Function: H5F_init_interface
*
* Purpose: Initialize interface-specific information.
*
* Return: Success: non-negative
*
* Failure: negative
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
* Robb Matzke, 4 Aug 1997
* Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call.
* It was already H5F_mask for the PABLO_TRACE_ON call.
*
* rky 980816
* Added .disp, .btype, .ftype to H5F_access_t.
*-------------------------------------------------------------------------
*/
herr_t
H5F_init_interface(void)
{
@ -154,9 +152,8 @@ H5F_init_interface(void)
/* Initialize the atom group for the file IDs */
if (H5I_init_group(H5I_FILE, H5I_FILEID_HASHSIZE, 0,
(herr_t (*)(void*))H5F_close)<0 ||
H5_add_exit(H5F_term_interface)<0) {
HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL,
(herr_t (*)(void*))H5F_close)<0) {
HRETURN_ERROR (H5E_FILE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
@ -211,11 +208,13 @@ H5F_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5F_term_interface(void)
void
H5F_term_interface(intn status)
{
H5I_destroy_group(H5I_FILE);
interface_initialize_g = FALSE;
if (interface_initialize_g>0) {
H5I_destroy_group(H5I_FILE);
}
interface_initialize_g = status;
}

View File

@ -22,7 +22,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_arr_mask
#define INTERFACE_INIT NULL
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;

View File

@ -22,7 +22,7 @@
#define H5F_CORE_DEV 0xffff /*pseudo dev for core until we fix things */
#define PABLO_MASK H5F_core
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static htri_t H5F_core_access(const char *name,

View File

@ -27,7 +27,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_family
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
#define H5F_FAM_OFFSET(LF,ADDR) ((off_t)((ADDR)->offset % \
@ -454,11 +454,14 @@ H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms,
/*
* Make sure the logical eof is large enough to handle the request.
* Do not decrease the EOF
*/
max_addr = cur_addr;
H5F_addr_inc(&max_addr, (hsize_t)nbytes);
H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
if (H5F_addr_gt(&max_addr, &(lf->u.fam.memb[membno]->eof))) {
H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
}
/* Write the data to the member */
if (H5F_low_write(lf->u.fam.memb[membno],
access_parms->u.fam.memb_access, xfer_mode,

View File

@ -65,7 +65,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_istore_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*

View File

@ -18,7 +18,7 @@
#define addr_defined(X) (((uint64_t)(-1)!=(X)->offset) ? TRUE : FALSE)
#define PABLO_MASK H5F_low
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -63,7 +63,7 @@
#include <mpio.h>
#define PABLO_MASK H5F_mpio
static hbool_t interface_initialize_g = FALSE; /* rky??? */
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/* Global var to allow elimination of redundant metadata writes

View File

@ -20,7 +20,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_sec2
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static H5F_low_t *H5F_sec2_open(const char *name,

View File

@ -22,7 +22,7 @@
#define H5F_SPLIT_RAW_EXT ".raw"
#define PABLO_MASK H5F_split
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static htri_t H5F_split_access(const char *name,

View File

@ -14,7 +14,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_stdio
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static H5F_low_t *H5F_stdio_open(const char *name,

View File

@ -91,10 +91,9 @@
#define PABLO_MASK H5G_mask
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5G_init_interface
static herr_t H5G_init_interface(void);
static void H5G_term_interface(void);
static H5G_typeinfo_t *H5G_type_g = NULL; /*object typing info */
static size_t H5G_ntypes_g = 0; /*entries in type table */
static size_t H5G_atypes_g = 0; /*entries allocated */
@ -683,8 +682,7 @@ H5G_init_interface(void)
/* Initialize the atom group for the group IDs */
if (H5I_init_group(H5I_GROUP, H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
(herr_t (*)(void *)) H5G_close) < 0 ||
H5_add_exit(H5G_term_interface) < 0) {
(herr_t (*)(void *)) H5G_close) < 0) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
@ -717,21 +715,24 @@ H5G_init_interface(void)
*
*-------------------------------------------------------------------------
*/
static void
H5G_term_interface(void)
void
H5G_term_interface(intn status)
{
size_t i;
if (interface_initialize_g>0) {
/* Empty the object type table */
for (i=0; i<H5G_ntypes_g; i++) {
H5MM_xfree(H5G_type_g[i].desc);
}
H5G_ntypes_g = H5G_atypes_g = 0;
H5G_type_g = H5MM_xfree(H5G_type_g);
/* Empty the object type table */
for (i=0; i<H5G_ntypes_g; i++) {
H5MM_xfree(H5G_type_g[i].desc);
/* Destroy the group object id group */
H5I_destroy_group(H5I_GROUP);
}
H5G_ntypes_g = H5G_atypes_g = 0;
H5G_type_g = H5MM_xfree(H5G_type_g);
/* Destroy the group object id group */
H5I_destroy_group(H5I_GROUP);
interface_initialize_g = FALSE;
interface_initialize_g = status;
}

View File

@ -14,7 +14,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5G_ent_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -91,7 +91,7 @@ H5B_class_t H5B_SNODE[1] = {{
}};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -17,7 +17,7 @@
#include <H5Oprivate.h>
#define PABLO_MASK H5G_stab_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------

View File

@ -64,7 +64,7 @@ static const H5AC_class_t H5AC_GHEAP[1] = {{
}};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -61,7 +61,7 @@ static const H5AC_class_t H5AC_LHEAP[1] = {{
}};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -65,7 +65,7 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialialization? */
#define PABLO_MASK H5I_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5I_init_interface
static herr_t H5I_init_interface(void);
@ -161,9 +161,6 @@ H5I_init_interface(void)
*/
assert(H5I_MAXID<=(1<<GROUP_BITS));
/* Registers the cleanup routine with the exit chain */
ret_value = H5_add_exit(&H5I_term_interface);
FUNC_LEAVE(ret_value);
}
@ -920,28 +917,28 @@ H5I_release_id_node(H5I_id_info_t *id)
REVISION LOG
--------------------------------------------------------------------------*/
void
H5I_term_interface(void)
H5I_term_interface(intn status)
{
H5I_id_info_t *curr;
intn i;
H5I_id_info_t *curr;
intn i;
/* Release the free-list if it exists */
if (id_free_list != NULL) {
while (id_free_list != NULL) {
if (interface_initialize_g>0) {
/* Release the free-list */
while (id_free_list) {
curr = id_free_list;
id_free_list = id_free_list->next;
HDfree(curr);
}
}
/* Release all groups */
for (i = 0; i < (intn) H5I_MAXID; i++) {
if (id_group_list[i] != NULL) {
HDfree(id_group_list[i]);
id_group_list[i] = NULL;
/* Release all groups */
for (i = 0; i < (intn) H5I_MAXID; i++) {
if (id_group_list[i] != NULL) {
HDfree(id_group_list[i]);
id_group_list[i] = NULL;
}
}
}
/* Indicate interface closed */
interface_initialize_g = FALSE;
/* Indicate interface status */
interface_initialize_g = status;
}

View File

@ -70,7 +70,6 @@ void *H5I_object (hid_t id);
H5I_type_t H5I_get_type (hid_t id);
void *H5I_remove (hid_t id);
void *H5I_search (H5I_type_t grp, H5I_search_func_t func, const void *key);
void H5I_term_interface (void);
intn H5I_dec_ref (hid_t id);
hid_t H5I_inc_ref (hid_t id);

View File

@ -28,7 +28,7 @@
#define PABLO_MASK H5MF_mask
/* Is the interface initialized? */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -20,7 +20,7 @@
/* Interface initialization? */
#define PABLO_MASK H5MM_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -45,7 +45,7 @@ static const H5AC_class_t H5AC_OHDR[1] = {{
}};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5O_init_interface
static herr_t H5O_init_interface(void);

View File

@ -54,7 +54,7 @@ const H5O_class_t H5O_ATTR[1] = {{
#define H5O_ATTR_VERSION 1
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------

View File

@ -14,7 +14,7 @@
/* Interface initialization */
#define PABLO_MASK H5O_pline_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
#define H5O_PLINE_VERSION 1

View File

@ -46,7 +46,7 @@ const H5O_class_t H5O_CONT[1] = {{
}};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------

View File

@ -58,7 +58,7 @@ const H5O_class_t H5O_DTYPE[1] = {{
#define H5O_DTYPE_VERSION 1
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------

View File

@ -40,7 +40,7 @@ const H5O_class_t H5O_EFL[1] = {{
#define H5O_EFL_VERSION 1
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -40,7 +40,7 @@ const H5O_class_t H5O_FILL[1] = {{
}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -40,7 +40,7 @@ const H5O_class_t H5O_LAYOUT[1] = {{
/* Interface initialization */
#define PABLO_MASK H5O_layout_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -37,7 +37,7 @@ const H5O_class_t H5O_MTIME[1] = {{
}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -46,7 +46,7 @@ const H5O_class_t H5O_NAME[1] = {{
}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -51,7 +51,7 @@ const H5O_class_t H5O_SDSPACE[1] = {{
#define H5O_SDSPACE_VERSION 1
/* Is the interface initialized? */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------

View File

@ -42,7 +42,7 @@ const H5O_class_t H5O_SHARED[1] = {{
/* Interface initialization */
#define PABLO_MASK H5O_shared_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -46,7 +46,7 @@ const H5O_class_t H5O_STAB[1] = {{
}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------

View File

@ -28,13 +28,10 @@ static char RcsId[] = "@(#)$Revision$";
#define PABLO_MASK H5P_mask
/* Is the interface initialized? */
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5P_init_interface
static herr_t H5P_init_interface(void);
/* PRIVATE PROTOTYPES */
static void H5P_term_interface(void);
/*--------------------------------------------------------------------------
NAME
H5P_init_interface -- Initialize interface-specific information
@ -83,14 +80,6 @@ H5P_init_interface(void)
"unable to initialize atom group");
}
/*
* Register cleanup function.
*/
if (H5_add_exit(H5P_term_interface) < 0) {
HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
"unable to install atexit function");
}
FUNC_LEAVE(ret_value);
}
@ -111,15 +100,18 @@ H5P_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5P_term_interface(void)
void
H5P_term_interface(intn status)
{
intn i;
for (i = 0; i < H5P_NCLASSES; i++) {
H5I_destroy_group((H5I_type_t)(H5I_TEMPLATE_0 + i));
if (interface_initialize_g>0) {
for (i = 0; i < H5P_NCLASSES; i++) {
H5I_destroy_group((H5I_type_t)(H5I_TEMPLATE_0 + i));
}
}
interface_initialize_g = FALSE;
interface_initialize_g = status;
}
/*--------------------------------------------------------------------------

View File

@ -29,9 +29,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialization */
#define PABLO_MASK H5R_mask
#define INTERFACE_INIT H5R_init_interface
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t H5R_init_interface(void);
static void H5R_term_interface(void);
/* Static functions */
static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name,
@ -55,17 +54,17 @@ DESCRIPTION
static herr_t
H5R_init_interface(void)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER(H5R_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if ((ret_value = H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE,
H5R_RESERVED_ATOMS, (herr_t (*)(void *)) NULL)) >= 0) {
ret_value = H5_add_exit(&H5R_term_interface);
if (H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE, H5R_RESERVED_ATOMS,
(herr_t (*)(void *)) NULL)<0) {
HRETURN_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
FUNC_LEAVE(ret_value);
} /* end H5R_init_interface() */
FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@ -85,13 +84,16 @@ H5R_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5R_term_interface(void)
void
H5R_term_interface(intn status)
{
/* Free ID group */
H5I_destroy_group(H5I_REFERENCE);
interface_initialize_g = FALSE;
} /* end H5R_term_interface() */
if (interface_initialize_g>0) {
/* Free ID group */
H5I_destroy_group(H5I_REFERENCE);
}
interface_initialize_g = status;
}
/*--------------------------------------------------------------------------

View File

@ -47,10 +47,9 @@ struct H5RA_t {
};
#define PABLO_MASK H5RA_mask
static hbool_t interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5RA_init_interface
static herr_t H5RA_init_interface(void);
static void H5RA_term_interface(void);
static H5T_t *H5RA_meta_type_g = NULL;
static herr_t H5RA_fix_overflow(H5RA_t *ra, H5T_t *type, H5RA_meta_t *meta,
@ -74,15 +73,15 @@ static herr_t H5RA_fix_overflow(H5RA_t *ra, H5T_t *type, H5RA_meta_t *meta,
static herr_t
H5RA_init_interface(void)
{
herr_t ret_value = SUCCEED;
H5T_t *type = NULL;
FUNC_ENTER(H5RA_init_interface, FAIL);
/* The atom group */
if ((ret_value=H5I_init_group(H5I_RAGGED, H5I_RAGGED_HASHSIZE, 0,
(herr_t(*)(void*))H5RA_close))>=0) {
ret_value = H5_add_exit(H5RA_term_interface);
if (H5I_init_group(H5I_RAGGED, H5I_RAGGED_HASHSIZE, 0,
(herr_t(*)(void*))H5RA_close)<0) {
HRETURN_ERROR (H5E_RAGGED, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
/* The meta dataset type */
@ -98,7 +97,7 @@ H5RA_init_interface(void)
}
H5RA_meta_type_g = type;
FUNC_LEAVE(ret_value);
FUNC_LEAVE(SUCCEED);
}
@ -116,13 +115,16 @@ H5RA_init_interface(void)
*
*-------------------------------------------------------------------------
*/
static void
H5RA_term_interface(void)
void
H5RA_term_interface(intn status)
{
H5I_destroy_group(H5I_RAGGED);
H5T_close(H5RA_meta_type_g);
H5RA_meta_type_g = NULL;
interface_initialize_g = FALSE;
if (interface_initialize_g>0) {
H5I_destroy_group(H5I_RAGGED);
H5T_close(H5RA_meta_type_g);
H5RA_meta_type_g = NULL;
}
interface_initialize_g = status;
}

182
src/H5S.c
View File

@ -27,9 +27,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialization */
#define PABLO_MASK H5S_mask
#define INTERFACE_INIT H5S_init_interface
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t H5S_init_interface(void);
static void H5S_term_interface(void);
/* Tables of file and memory conversion information */
static const H5S_fconv_t *H5S_fconv_g[H5S_SEL_N];
@ -61,13 +60,13 @@ DESCRIPTION
static herr_t
H5S_init_interface(void)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER(H5S_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if ((ret_value = H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
H5S_RESERVED_ATOMS, (herr_t (*)(void *)) H5S_close)) >= 0) {
ret_value = H5_add_exit(&H5S_term_interface);
if (H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
H5S_RESERVED_ATOMS, (herr_t (*)(void *))H5S_close)<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
/* Register space conversion functions */
@ -88,7 +87,7 @@ H5S_init_interface(void)
}
#endif
FUNC_LEAVE(ret_value);
FUNC_LEAVE(SUCCEED);
}
@ -109,8 +108,8 @@ H5S_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5S_term_interface(void)
void
H5S_term_interface(intn status)
{
size_t i;
@ -118,96 +117,101 @@ H5S_term_interface(void)
int j, nprints=0;
H5S_conv_t *path=NULL;
char buf[256];
/*
* Print statistics about each conversion path.
*/
if (H5DEBUG(S)) {
for (i=0; i<H5S_nconv_g; i++) {
path = H5S_conv_g[i];
for (j=0; j<2; j++) {
if (0==path->stats[j].gath_ncalls &&
0==path->stats[j].scat_ncalls &&
0==path->stats[j].bkg_ncalls) {
continue;
}
if (0==nprints++) {
fprintf(H5DEBUG(S), "H5S: data space conversion "
"statistics accumulated over life of library:\n");
fprintf(H5DEBUG(S),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"Memory <> File", "Bytes", "Calls",
"User", "System", "Elapsed", "Bandwidth");
fprintf(H5DEBUG(S),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"--------------", "-----", "-----",
"----", "------", "-------", "---------");
}
#endif
/* Summary */
sprintf(buf, "%s %c %s",
path->m->name, 0==j?'>':'<', path->f->name);
fprintf(H5DEBUG(S), " %-16s\n", buf);
if (interface_initialize_g>0) {
#ifdef H5S_DEBUG
/*
* Print statistics about each conversion path.
*/
if (H5DEBUG(S)) {
for (i=0; i<H5S_nconv_g; i++) {
path = H5S_conv_g[i];
for (j=0; j<2; j++) {
if (0==path->stats[j].gath_ncalls &&
0==path->stats[j].scat_ncalls &&
0==path->stats[j].bkg_ncalls) {
continue;
}
if (0==nprints++) {
fprintf(H5DEBUG(S), "H5S: data space conversion "
"statistics:\n");
fprintf(H5DEBUG(S),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"Memory <> File", "Bytes", "Calls",
"User", "System", "Elapsed", "Bandwidth");
fprintf(H5DEBUG(S),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"--------------", "-----", "-----",
"----", "------", "-------", "---------");
}
/* Gather */
if (path->stats[j].gath_ncalls) {
H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes),
path->stats[j].gath_timer.etime);
HDfprintf(H5DEBUG(S),
" %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
"gather",
path->stats[j].gath_nbytes,
path->stats[j].gath_ncalls,
path->stats[j].gath_timer.utime,
path->stats[j].gath_timer.stime,
path->stats[j].gath_timer.etime,
buf);
}
/* Summary */
sprintf(buf, "%s %c %s",
path->m->name, 0==j?'>':'<', path->f->name);
fprintf(H5DEBUG(S), " %-16s\n", buf);
/* Scatter */
if (path->stats[j].scat_ncalls) {
H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes),
path->stats[j].scat_timer.etime);
HDfprintf(H5DEBUG(S),
" %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
"scatter",
path->stats[j].scat_nbytes,
path->stats[j].scat_ncalls,
path->stats[j].scat_timer.utime,
path->stats[j].scat_timer.stime,
path->stats[j].scat_timer.etime,
buf);
}
/* Gather */
if (path->stats[j].gath_ncalls) {
H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes),
path->stats[j].gath_timer.etime);
HDfprintf(H5DEBUG(S),
" %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
"%10s\n", "gather",
path->stats[j].gath_nbytes,
path->stats[j].gath_ncalls,
path->stats[j].gath_timer.utime,
path->stats[j].gath_timer.stime,
path->stats[j].gath_timer.etime,
buf);
}
/* Background */
if (path->stats[j].bkg_ncalls) {
H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes),
path->stats[j].bkg_timer.etime);
HDfprintf(H5DEBUG(S),
" %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
"background",
path->stats[j].bkg_nbytes,
path->stats[j].bkg_ncalls,
path->stats[j].bkg_timer.utime,
path->stats[j].bkg_timer.stime,
path->stats[j].bkg_timer.etime,
buf);
/* Scatter */
if (path->stats[j].scat_ncalls) {
H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes),
path->stats[j].scat_timer.etime);
HDfprintf(H5DEBUG(S),
" %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
"%10s\n", "scatter",
path->stats[j].scat_nbytes,
path->stats[j].scat_ncalls,
path->stats[j].scat_timer.utime,
path->stats[j].scat_timer.stime,
path->stats[j].scat_timer.etime,
buf);
}
/* Background */
if (path->stats[j].bkg_ncalls) {
H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes),
path->stats[j].bkg_timer.etime);
HDfprintf(H5DEBUG(S),
" %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
"%10s\n", "background",
path->stats[j].bkg_nbytes,
path->stats[j].bkg_ncalls,
path->stats[j].bkg_timer.utime,
path->stats[j].bkg_timer.stime,
path->stats[j].bkg_timer.etime,
buf);
}
}
}
}
}
#endif
/* Free data types */
H5I_destroy_group(H5I_DATASPACE);
/* Free data types */
H5I_destroy_group(H5I_DATASPACE);
/* Clear/free conversion table */
HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
H5S_conv_g = H5MM_xfree(H5S_conv_g);
H5S_nconv_g = H5S_aconv_g = 0;
interface_initialize_g = FALSE;
/* Clear/free conversion table */
HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
H5S_conv_g = H5MM_xfree(H5S_conv_g);
H5S_nconv_g = H5S_aconv_g = 0;
}
interface_initialize_g = status;
}

View File

@ -16,7 +16,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_all_mask
#define INTERFACE_INIT NULL
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t H5S_all_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter);

View File

@ -18,7 +18,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_hyper_mask
#define INTERFACE_INIT NULL
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
/* Local datatypes */
/* Parameter block for H5S_hyper_fread & H5S_hyper_fwrite */

View File

@ -29,7 +29,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_all_mask
#define INTERFACE_INIT NULL
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t
H5S_mpio_all_type( const H5S_t *space, const size_t elmt_size,

View File

@ -16,7 +16,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_none_mask
#define INTERFACE_INIT NULL
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
/*--------------------------------------------------------------------------

View File

@ -17,7 +17,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_point_mask
#define INTERFACE_INIT NULL
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t H5S_point_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter);

View File

@ -18,59 +18,9 @@
/* Interface initialization */
#define PABLO_MASK H5S_select_mask
#define INTERFACE_INIT H5S_select_init
static intn interface_initialize_g = FALSE;
static herr_t H5S_select_init(void);
static void H5S_select_term(void);
#define INTERFACE_INIT NULL
static intn interface_initialize_g = 0;
/*--------------------------------------------------------------------------
NAME
H5S_select_init
PURPOSE
Initialize selection interface
USAGE
herr_t H5S_select_init(void)
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_select_init (void)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER (H5S_select_init, FAIL);
/* Register the atexit function for this (sub)interface */
ret_value = H5_add_exit(&H5S_select_term);
FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
NAME
H5S_select_term
PURPOSE
Terminate various H5S selection objects and free lists
USAGE
void H5S_select_term()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Release the selection resources allocated.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Can't report errors...
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5S_select_term(void)
{
}
/*--------------------------------------------------------------------------
NAME

228
src/H5T.c
View File

@ -26,9 +26,8 @@ static char RcsId[] = "@(#)$Revision$";
#define H5T_COMPND_INC 64 /*typical max numb of members per struct */
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5T_init_interface
static void H5T_term_interface(void);
hid_t H5T_IEEE_F32BE_g = FAIL;
hid_t H5T_IEEE_F32LE_g = FAIL;
@ -123,23 +122,25 @@ herr_t
H5T_init_interface(void)
{
H5T_t *dt = NULL;
herr_t ret_value = SUCCEED;
interface_initialize_g = TRUE;
FUNC_ENTER(H5T_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if ((ret_value = H5I_init_group(H5I_DATATYPE, H5I_DATATYPEID_HASHSIZE,
H5T_RESERVED_ATOMS,
(herr_t (*)(void *)) H5T_close)) >= 0) {
ret_value = H5_add_exit(&H5T_term_interface);
if (H5I_init_group(H5I_DATATYPE, H5I_DATATYPEID_HASHSIZE,
H5T_RESERVED_ATOMS, (herr_t (*)(void *))H5T_close)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
/*
* Initialize pre-defined native data types from code generated during
* the library configuration by H5detect.
*/
ret_value = H5T_native_open();
if (H5T_native_open()<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
/*------------------------------------------------------------
* Native types
@ -1163,7 +1164,7 @@ H5T_init_interface(void)
"unable to register conversion function");
}
FUNC_LEAVE(ret_value);
FUNC_LEAVE(SUCCEED);
}
@ -1196,29 +1197,25 @@ H5T_unlock_cb (void *_dt, const void __unused__ *key)
FUNC_LEAVE (0);
}
/*--------------------------------------------------------------------------
NAME
H5T_term_interface
PURPOSE
Terminate various H5T objects
USAGE
void H5T_term_interface()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
Release the atom group and any other resources allocated.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Can't report errors...
EXAMPLES
REVISION LOG
/*-------------------------------------------------------------------------
* Function: H5T_term_interface
*
* Purpose: Close this interface.
*
* Return: void
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
* Robb Matzke, 1998-06-11
* Statistics are only printed for conversion functions that were
* called.
*
--------------------------------------------------------------------------*/
static void
H5T_term_interface(void)
*-------------------------------------------------------------------------
*/
void
H5T_term_interface(intn status)
{
intn i;
H5T_path_t *path = NULL;
@ -1230,110 +1227,115 @@ H5T_term_interface(void)
H5T_cdata_t *cdata;
char bandwidth[32];
#endif
/* Unregister all conversion functions */
for (i=0; i<H5T_npath_g; i++) {
path = H5T_path_g[i];
assert (path);
if (path->func) {
path->cdata.command = H5T_CONV_FREE;
if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
if (interface_initialize_g>0) {
/* Unregister all conversion functions */
for (i=0; i<H5T_npath_g; i++) {
path = H5T_path_g[i];
assert (path);
if (path->func) {
path->cdata.command = H5T_CONV_FREE;
if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL,
NULL)<0) {
#ifdef H5T_DEBUG
if (H5DEBUG(T)) {
fprintf (H5DEBUG(T), "H5T: conversion function failed "
"to free private data for %s\n", path->name);
if (H5DEBUG(T)) {
fprintf (H5DEBUG(T), "H5T: conversion function failed "
"to free private data for %s\n", path->name);
}
#endif
H5E_clear(); /*ignore the error*/
}
#ifdef H5T_DEBUG
if (H5DEBUG(T) && path->cdata.stats->ncalls>0) {
if (0==nprint++) {
HDfprintf (H5DEBUG(T),
"H5T: type conversion statistics:\n");
HDfprintf (H5DEBUG(T),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"Conversion", "Elmts", "Calls", "User",
"System", "Elapsed", "Bandwidth");
HDfprintf (H5DEBUG(T),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"----------", "-----", "-----", "----",
"------", "-------", "---------");
}
nbytes = MAX (H5T_get_size (path->src),
H5T_get_size (path->dst));
nbytes *= path->cdata.stats->nelmts;
H5_bandwidth(bandwidth, (double)nbytes,
path->cdata.stats->timer.etime);
HDfprintf (H5DEBUG(T),
" %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
path->name,
path->cdata.stats->nelmts,
path->cdata.stats->ncalls,
path->cdata.stats->timer.utime,
path->cdata.stats->timer.stime,
path->cdata.stats->timer.etime,
bandwidth);
}
#endif
H5E_clear(); /*ignore the error*/
H5T_close (path->src);
H5T_close (path->dst);
H5MM_xfree (path->cdata.stats);
}
H5MM_xfree (path);
H5T_path_g[i] = NULL;
}
#ifdef H5T_DEBUG
if (H5DEBUG(T) && path->cdata.stats->ncalls>0) {
/* Print debugging infor for the `noop' conversion */
if (H5DEBUG(T) &&
H5T_conv_noop==H5T_find(NULL, NULL, H5T_BKG_NO, &cdata)) {
if (cdata->stats->ncalls>0) {
if (0==nprint++) {
HDfprintf (H5DEBUG(T), "H5T: type conversion statistics "
"accumulated over life of function:\n");
HDfprintf (H5DEBUG(T),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"Conversion", "Elmts", "Calls", "User",
"System", "Elapsed", "Bandwidth");
HDfprintf (H5DEBUG(T),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"----------", "-----", "-----", "----",
"------", "-------", "---------");
"H5T: type conversion statistics\n");
HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s "
"%10s\n", "Conversion", "Elmts", "Calls",
"User", "System", "Elapsed", "Bandwidth");
HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s "
"%10s\n", "----------", "-----", "-----",
"----", "------", "-------", "---------");
}
nbytes = MAX (H5T_get_size (path->src),
H5T_get_size (path->dst));
nbytes *= path->cdata.stats->nelmts;
nbytes = cdata->stats->nelmts;
H5_bandwidth(bandwidth, (double)nbytes,
path->cdata.stats->timer.etime);
cdata->stats->timer.etime);
HDfprintf (H5DEBUG(T),
" %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
path->name,
path->cdata.stats->nelmts,
path->cdata.stats->ncalls,
path->cdata.stats->timer.utime,
path->cdata.stats->timer.stime,
path->cdata.stats->timer.etime,
"no-op",
cdata->stats->nelmts,
cdata->stats->ncalls,
cdata->stats->timer.utime,
cdata->stats->timer.stime,
cdata->stats->timer.etime,
bandwidth);
}
#endif
H5T_close (path->src);
H5T_close (path->dst);
H5MM_xfree (path->cdata.stats);
}
H5MM_xfree (path);
H5T_path_g[i] = NULL;
}
#ifdef H5T_DEBUG
/* Print debugging infor for the `noop' conversion */
if (H5DEBUG(T) &&
H5T_conv_noop==H5T_find(NULL, NULL, H5T_BKG_NO, &cdata)) {
if (cdata->stats->ncalls>0) {
if (0==nprint++) {
HDfprintf (H5DEBUG(T), "H5T: type conversion statistics "
"accumulated over life of library:\n");
HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
"Conversion", "Elmts", "Calls", "User",
"System", "Elapsed", "Bandwidth");
HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
"----------", "-----", "-----", "----",
"------", "-------", "---------");
}
nbytes = cdata->stats->nelmts;
H5_bandwidth(bandwidth, (double)nbytes, cdata->stats->timer.etime);
HDfprintf (H5DEBUG(T),
" %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
"no-op",
cdata->stats->nelmts,
cdata->stats->ncalls,
cdata->stats->timer.utime,
cdata->stats->timer.stime,
cdata->stats->timer.etime,
bandwidth);
}
}
#endif
/* Clear conversion tables */
H5T_apath_g = 0;
H5T_npath_g = 0;
H5T_path_g = H5MM_xfree (H5T_path_g);
/* Clear conversion tables */
H5T_apath_g = 0;
H5T_npath_g = 0;
H5T_path_g = H5MM_xfree (H5T_path_g);
H5T_asoft_g = 0;
H5T_nsoft_g = 0;
H5T_soft_g = H5MM_xfree (H5T_soft_g);
H5T_asoft_g = 0;
H5T_nsoft_g = 0;
H5T_soft_g = H5MM_xfree (H5T_soft_g);
/* Clear noop function */
if ((cfunc=H5T_find (NULL, NULL, H5T_BKG_NO, &pcdata))) {
pcdata->command = H5T_CONV_FREE;
(cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
/* Clear noop function */
if ((cfunc=H5T_find (NULL, NULL, H5T_BKG_NO, &pcdata))) {
pcdata->command = H5T_CONV_FREE;
(cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
}
/* Unlock all datatypes, then free them */
H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL);
H5I_destroy_group(H5I_DATATYPE);
}
/* Unlock all datatypes, then free them */
H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL);
H5I_destroy_group(H5I_DATATYPE);
interface_initialize_g = FALSE;
interface_initialize_g = status;
}

View File

@ -43,9 +43,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface init/term information */
#define PABLO_MASK H5TB_mask
#define INTERFACE_INIT H5TB_init_interface
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t H5TB_init_interface(void);
static void H5TB_term_interface(void);
/* Local information for managing buffers */
#define H5TB_RESERVED_ATOMS 0
@ -80,15 +79,15 @@ DESCRIPTION
static herr_t
H5TB_init_interface(void)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER(H5TB_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if ((ret_value = H5I_init_group(H5I_TEMPBUF, H5I_TEMPBUFID_HASHSIZE,
H5TB_RESERVED_ATOMS, NULL)) >= 0) {
ret_value = H5_add_exit(&H5TB_term_interface);
if (H5I_init_group(H5I_TEMPBUF, H5I_TEMPBUFID_HASHSIZE,
H5TB_RESERVED_ATOMS, NULL)<0) {
HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
FUNC_LEAVE(ret_value);
FUNC_LEAVE(SUCCEED);
}
@ -109,29 +108,32 @@ H5TB_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5TB_term_interface(void)
void
H5TB_term_interface(intn status)
{
H5TB_t *curr=H5TB_list_head, /* pointer to current temp. buffer */
*next; /* pointer to next temp. buffer */
/* Destroy the atom group */
H5I_destroy_group(H5I_TEMPBUF);
if (interface_initialize_g>0) {
/* Destroy the atom group */
H5I_destroy_group(H5I_TEMPBUF);
/* Step through the list and free the buffers */
while(curr!=NULL) {
next=curr->next;
/* Step through the list and free the buffers */
while(curr!=NULL) {
next=curr->next;
if(curr->buf!=NULL)
H5MM_xfree(curr->buf);
H5MM_xfree(curr);
if(curr->buf!=NULL)
H5MM_xfree(curr->buf);
H5MM_xfree(curr);
curr=next;
} /* end while */
curr=next;
} /* end while */
/* Reset head & tail pointers */
H5TB_list_head=H5TB_list_tail=NULL;
interface_initialize_g = FALSE;
/* Reset head & tail pointers */
H5TB_list_head=H5TB_list_tail=NULL;
}
interface_initialize_g = status;
}
/*-------------------------------------------------------------------------

View File

@ -17,7 +17,7 @@
/* Interface initialization */
#define PABLO_MASK H5Tbit_mask
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

View File

@ -26,7 +26,7 @@ typedef struct H5T_conv_struct_t {
} H5T_conv_struct_t;
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*

View File

@ -13,7 +13,7 @@
#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
#define PABLO_MASK H5V_mask
static hbool_t interface_initialize_g = TRUE;
static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL

121
src/H5Z.c
View File

@ -20,9 +20,8 @@
/* Interface initialization */
#define PABLO_MASK H5Z_mask
#define INTERFACE_INIT H5Z_init_interface
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = 0;
static herr_t H5Z_init_interface (void);
static void H5Z_term_interface (void);
static size_t H5Z_table_alloc_g = 0;
static size_t H5Z_table_used_g = 0;
@ -52,10 +51,8 @@ static herr_t
H5Z_init_interface (void)
{
FUNC_ENTER (H5Z_init_interface, FAIL);
H5_add_exit (H5Z_term_interface);
H5Z_register (H5Z_FILTER_DEFLATE, "deflate",
H5Z_filter_deflate);
H5Z_register (H5Z_FILTER_DEFLATE, "deflate", H5Z_filter_deflate);
FUNC_LEAVE (SUCCEED);
}
@ -75,69 +72,73 @@ H5Z_init_interface (void)
*
*-------------------------------------------------------------------------
*/
static void
H5Z_term_interface (void)
void
H5Z_term_interface (intn status)
{
size_t i;
#ifdef H5Z_DEBUG
int dir, nprint=0;
char comment[16], bandwidth[32];
if (H5DEBUG(Z)) {
for (i=0; i<H5Z_table_used_g; i++) {
for (dir=0; dir<2; dir++) {
if (0==H5Z_table_g[i].stats[dir].total) continue;
if (0==nprint++) {
/* Print column headers */
HDfprintf (H5DEBUG(Z), "H5Z: filter statistics "
"accumulated over life of library:\n");
HDfprintf (H5DEBUG(Z),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"Filter", "Total", "Errors", "User",
"System", "Elapsed", "Bandwidth");
HDfprintf (H5DEBUG(Z),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"------", "-----", "------", "----",
"------", "-------", "---------");
}
/* Truncate the comment to fit in the field */
HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment);
comment[sizeof(comment)-1] = '\0';
/*
* Format bandwidth to have four significant digits and units
* of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or the word
* `Inf' if the elapsed time is zero.
*/
H5_bandwidth(bandwidth,
(double)(H5Z_table_g[i].stats[dir].total),
H5Z_table_g[i].stats[dir].timer.etime);
/* Print the statistics */
HDfprintf (H5DEBUG(Z),
" %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f "
"%10s\n", dir?"<":">", comment,
H5Z_table_g[i].stats[dir].total,
H5Z_table_g[i].stats[dir].errors,
H5Z_table_g[i].stats[dir].timer.utime,
H5Z_table_g[i].stats[dir].timer.stime,
H5Z_table_g[i].stats[dir].timer.etime,
bandwidth);
}
}
}
#endif
/* Free the table */
for (i=0; i<H5Z_table_used_g; i++) {
H5MM_xfree(H5Z_table_g[i].name);
if (interface_initialize_g>0) {
#ifdef H5Z_DEBUG
if (H5DEBUG(Z)) {
for (i=0; i<H5Z_table_used_g; i++) {
for (dir=0; dir<2; dir++) {
if (0==H5Z_table_g[i].stats[dir].total) continue;
if (0==nprint++) {
/* Print column headers */
HDfprintf (H5DEBUG(Z), "H5Z: filter statistics "
"accumulated over life of library:\n");
HDfprintf (H5DEBUG(Z),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"Filter", "Total", "Errors", "User",
"System", "Elapsed", "Bandwidth");
HDfprintf (H5DEBUG(Z),
" %-16s %10s %10s %8s %8s %8s %10s\n",
"------", "-----", "------", "----",
"------", "-------", "---------");
}
/* Truncate the comment to fit in the field */
HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment);
comment[sizeof(comment)-1] = '\0';
/*
* Format bandwidth to have four significant digits and
* units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or
* the word `Inf' if the elapsed time is zero.
*/
H5_bandwidth(bandwidth,
(double)(H5Z_table_g[i].stats[dir].total),
H5Z_table_g[i].stats[dir].timer.etime);
/* Print the statistics */
HDfprintf (H5DEBUG(Z),
" %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f "
"%10s\n", dir?"<":">", comment,
H5Z_table_g[i].stats[dir].total,
H5Z_table_g[i].stats[dir].errors,
H5Z_table_g[i].stats[dir].timer.utime,
H5Z_table_g[i].stats[dir].timer.stime,
H5Z_table_g[i].stats[dir].timer.etime,
bandwidth);
}
}
}
#endif
/* Free the table */
for (i=0; i<H5Z_table_used_g; i++) {
H5MM_xfree(H5Z_table_g[i].name);
}
H5Z_table_g = H5MM_xfree(H5Z_table_g);
H5Z_table_used_g = H5Z_table_alloc_g = 0;
}
H5Z_table_g = H5MM_xfree(H5Z_table_g);
H5Z_table_used_g = H5Z_table_alloc_g = 0;
interface_initialize_g = FALSE;
interface_initialize_g = status;
}

View File

@ -321,16 +321,16 @@ print_results(int nd, detected_t *d)
#include <H5MMprivate.h>\n\
#include <H5Tpkg.h>\n\
\n\
static hbool_t interface_initialize_g = FALSE;\n\
static intn interface_initialize_g = 0;\n\
#define INTERFACE_INIT NULL\n\
\n");
/* The interface termination function */
printf("\n\
static void\n\
H5T_native_close(void)\n\
void\n\
H5T_native_close(intn status)\n\
{\n\
interface_initialize_g = FALSE;\n\
interface_initialize_g = status;\n\
}\n");
/* The interface initialization function */
@ -340,8 +340,7 @@ H5T_native_open (void)\n\
{\n\
H5T_t *dt = NULL;\n\
\n\
FUNC_ENTER (H5T_init, FAIL);\n\
H5_add_exit(&H5T_native_close);\n");
FUNC_ENTER (H5T_init, FAIL);\n");
for (i = 0; i < nd; i++) {

View File

@ -818,7 +818,6 @@ void H5_trace (hbool_t returning, const char *func, const char *type, ...);
*-------------------------------------------------------------------------
*/
extern hbool_t library_initialize_g; /*good thing C's lazy about extern! */
extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
/* Is `S' the name of an API function? */
#define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4]))
@ -839,18 +838,9 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"library initialization failed"); \
} \
} \
} \
\
/* Initialize this thread */ \
if (!thread_initialize_g) { \
thread_initialize_g = TRUE; \
if (H5_init_thread()<0) { \
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"thread initialization failed"); \
} \
} \
\
/* Initialize this interface */ \
/* Initialize this interface or bust */ \
if (!interface_initialize_g) { \
interface_initialize_g = TRUE; \
if (interface_init_func && \
@ -858,10 +848,14 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"interface initialization failed"); \
} \
} else if (interface_initialize_g<0) { \
HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, err, \
"interface is closing"); \
assert("interface is closing" && 0); \
} \
\
/* Clear thread error stack entering public functions */ \
if (H5E_clearable_g && H5_IS_API (FUNC)) { \
if (H5E_clearable_g && H5_IS_API (FUNC)) { \
H5E_clear (); \
} \
{
@ -901,8 +895,21 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
/* Private functions, not part of the publicly documented API */
herr_t H5_init_library(void);
void H5_term_library(void);
herr_t H5_add_exit(void (*func) (void));
herr_t H5_init_thread(void);
void H5_term_thread(void);
/* Functions to terminate interfaces */
void H5A_term_interface(intn status);
void H5D_term_interface(intn status);
void H5F_term_interface(intn status);
void H5G_term_interface(intn status);
void H5I_term_interface(intn status);
void H5P_term_interface(intn status);
void H5RA_term_interface(intn status);
void H5R_term_interface(intn status);
void H5S_term_interface(intn status);
void H5TB_term_interface(intn status);
void H5T_native_close(intn status);
void H5T_term_interface(intn status);
void H5Z_term_interface(intn status);
#endif

View File

@ -1,11 +1,41 @@
h5test.o: \
h5test.c \
h5test.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5Rprivate.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
testhdf5.o: \
testhdf5.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h
../src/H5config.h
tattr.o: \
tattr.c \
testhdf5.h \
@ -29,8 +59,7 @@ tattr.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5Rpublic.h
tfile.o: \
tfile.c \
testhdf5.h \
@ -45,8 +74,7 @@ tfile.o: \
../src/H5Fprivate.h \
../src/H5Fpublic.h \
../src/H5Dpublic.h \
../src/H5Pprivate.h \
../src/H5Ppublic.h
../src/H5Pprivate.h
theap.o: \
theap.c \
testhdf5.h \
@ -64,8 +92,7 @@ theap.o: \
../src/H5Dpublic.h \
../src/H5Pprivate.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5HLprivate.h
../src/H5Zpublic.h
tmeta.o: \
tmeta.c \
testhdf5.h \
@ -74,8 +101,7 @@ tmeta.o: \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
../src/H5Fprivate.h
../src/H5Ipublic.h
tohdr.o: \
tohdr.c \
testhdf5.h \
@ -105,8 +131,7 @@ tohdr.o: \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h \
../src/H5Zprivate.h
../src/H5Spublic.h
trefer.o: \
trefer.c \
testhdf5.h \
@ -130,8 +155,7 @@ trefer.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5Rpublic.h
tselect.o: \
tselect.c \
testhdf5.h \
@ -155,8 +179,7 @@ tselect.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5Rpublic.h
tstab.o: \
tstab.c \
testhdf5.h \
@ -186,8 +209,7 @@ tstab.o: \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h \
../src/H5Zprivate.h
../src/H5Spublic.h
th5s.o: \
th5s.c \
testhdf5.h \
@ -212,12 +234,15 @@ th5s.o: \
../src/H5HGpublic.h \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Zprivate.h
../src/H5Zprivate.h \
../src/H5Zpublic.h \
../src/H5Pprivate.h
dtypes.o: \
dtypes.c \
../src/H5config.h \
h5test.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -237,17 +262,18 @@ dtypes.o: \
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5private.h \
../src/H5Rprivate.h
../src/H5Rprivate.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
hyperslab.o: \
hyperslab.c \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
../src/H5MMprivate.h
../src/H5config.h
istore.o: \
istore.c \
../src/H5private.h \
@ -274,12 +300,15 @@ istore.o: \
../src/H5Zpublic.h \
../src/H5Iprivate.h \
../src/H5Pprivate.h \
../src/H5Ppublic.h
../src/H5Ppublic.h \
../src/H5MMprivate.h \
../src/H5MMpublic.h
dsets.o: \
dsets.c \
../src/H5config.h \
h5test.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -296,12 +325,22 @@ dsets.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5Rprivate.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
cmpd_dset.o: \
cmpd_dset.c \
../src/H5config.h \
h5test.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -317,12 +356,23 @@ cmpd_dset.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h
../src/H5Rpublic.h \
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5Rprivate.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
extend.o: \
extend.c \
../src/H5config.h \
h5test.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -339,33 +389,22 @@ extend.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
external.o: \
external.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5Rprivate.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
iopipe.o: \
iopipe.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -382,7 +421,9 @@ iopipe.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
gheap.o: \
gheap.c \
../src/H5private.h \
@ -399,13 +440,12 @@ gheap.o: \
../src/H5Bprivate.h \
../src/H5Bpublic.h \
../src/H5HGprivate.h \
../src/H5HGpublic.h \
../src/H5Pprivate.h
../src/H5HGpublic.h
shtype.o: \
shtype.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -422,12 +462,14 @@ shtype.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
big.o: \
big.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -450,9 +492,9 @@ big.o: \
../src/H5private.h
links.o: \
links.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -469,12 +511,14 @@ links.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
chunk.o: \
chunk.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -490,30 +534,47 @@ chunk.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h
../src/H5Rpublic.h \
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
bittests.o: \
bittests.c \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5HGpublic.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Fprivate.h \
../src/H5Fpublic.h \
../src/H5Ipublic.h \
../src/H5private.h \
../src/H5Dpublic.h \
../src/H5Rprivate.h \
../src/H5Rpublic.h \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Gprivate.h \
../src/H5Gpublic.h
mtime.o: \
mtime.c \
../src/H5config.h \
h5test.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5Rprivate.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
mtime.o: \
mtime.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -536,9 +597,9 @@ mtime.o: \
../src/H5private.h
ragged.o: \
ragged.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -561,9 +622,9 @@ ragged.o: \
../src/H5private.h
unlink.o: \
unlink.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -579,12 +640,13 @@ unlink.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h
../src/H5Rpublic.h \
../src/H5RApublic.h
overhead.o: \
overhead.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -602,12 +664,13 @@ overhead.o: \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h \
../src/H5Spublic.h
../src/H5Spublic.h \
../src/H5Tpublic.h
fillval.o: \
fillval.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -625,12 +688,13 @@ fillval.o: \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h \
../src/H5Spublic.h
../src/H5Spublic.h \
../src/H5Tpublic.h
mount.o: \
mount.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -646,12 +710,13 @@ mount.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h
../src/H5Rpublic.h \
../src/H5RApublic.h
flush1.o: \
flush1.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -668,12 +733,14 @@ flush1.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
flush2.o: \
flush2.c \
../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@ -690,4 +757,6 @@ flush2.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h

View File

@ -9,7 +9,7 @@
# Add include directory to the C preprocessor flags and the hdf5
# library to the library list.
CPPFLAGS=-I. -I../src @CPPFLAGS@
LIBS=../src/libhdf5.a @LIBS@
LIBS=libh5test.a ../src/libhdf5.a @LIBS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
@ -18,6 +18,11 @@ TEST_PROGS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset \
flush2
TIMINGS=iopipe chunk ragged overhead
# The libh5test.a library provides common support code for the tests.
LIB=libh5test.a
LIB_SRC=h5test.c
LIB_OBJ=$(LIB_SRC:.c=.o)
# Temporary files
MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
tfile3.h5 th5s1.h5 theap.h5 tohdr.h5 tstab1.h5 tstab2.h5 \
@ -55,8 +60,8 @@ timings _timings: $(TIMINGS)
fi; \
done;
# How to build the tests... They all depend on the hdf5 library.
$(TEST_PROGS): ../src/libhdf5.a
# How to build the tests... They all depend on the test and hdf5 libraries.
$(TEST_PROGS): libh5test.a ../src/libhdf5.a
TESTHDF5_OBJ=testhdf5.o tattr.o tfile.o theap.o tmeta.o tohdr.o trefer.o tselect.o tstab.o th5s.o
testhdf5: $(TESTHDF5_OBJ)
$(CC) $(CFLAGS) -o $@ $(TESTHDF5_OBJ) $(LDFLAGS) $(LIBS)

View File

@ -7,6 +7,8 @@
*
* Purpose: Tests functions in H5Tbit.c
*/
#include <h5test.h>
#define H5T_PACKAGE
#include <H5Tpkg.h>
@ -38,21 +40,20 @@ test_find (void)
intn i;
ssize_t n;
printf ("%-70s", "Testing bit search operations");
fflush (stdout);
TESTING("bit search operations");
/* The zero length buffer */
memset (v1, 0xaa, sizeof v1);
n = H5T_bit_find (v1, 0, 0, H5T_BIT_LSB, TRUE);
if (-1!=n) {
puts ("*FAILED*");
puts (" Zero length test failed (lsb)!");
FAILED();
puts (" Zero length test failed (lsb)!");
goto failed;
}
n = H5T_bit_find (v1, 0, 0, H5T_BIT_MSB, TRUE);
if (-1!=n) {
puts ("*FAILED*");
puts (" Zero length test failed (msb)!");
FAILED();
puts (" Zero length test failed (msb)!");
goto failed;
}
@ -61,14 +62,14 @@ test_find (void)
memset (v1, 0, sizeof v1);
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE);
if (-1!=n) {
puts ("*FAILED*");
puts (" Zero buffer test failed (lsb)!");
FAILED();
puts (" Zero buffer test failed (lsb)!");
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE);
if (-1!=n) {
puts ("*FAILED*");
puts (" Zero buffer test failed (msb)!");
FAILED();
puts (" Zero buffer test failed (msb)!");
goto failed;
}
@ -78,14 +79,14 @@ test_find (void)
v1[i/8] = 1<<(i%8);
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE);
if ((ssize_t)i!=n) {
puts ("*FAILED*");
printf (" Test for set bit %d failed (lsb)!\n", i);
FAILED();
printf (" Test for set bit %d failed (lsb)!\n", i);
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE);
if ((ssize_t)i!=n) {
puts ("*FAILED*");
printf (" Test for set bit %d failed (msb)!\n", i);
FAILED();
printf (" Test for set bit %d failed (msb)!\n", i);
goto failed;
}
}
@ -94,14 +95,14 @@ test_find (void)
memset (v1, 0xff, sizeof v1);
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE);
if (-1!=n) {
puts ("*FAILED*");
puts (" One buffer test failed (lsb)!");
FAILED();
puts (" One buffer test failed (lsb)!");
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE);
if (-1!=n) {
puts ("*FAILED*");
puts (" One buffer test failed (msb)!");
FAILED();
puts (" One buffer test failed (msb)!");
goto failed;
}
@ -111,24 +112,24 @@ test_find (void)
v1[i/8] &= ~(1<<(i%8));
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE);
if ((ssize_t)i!=n) {
puts ("*FAILED*");
printf (" Test for clear bit %d failed (lsb)!\n", i);
FAILED();
printf (" Test for clear bit %d failed (lsb)!\n", i);
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE);
if ((ssize_t)i!=n) {
puts ("*FAILED*");
printf (" Test for clear bit %d failed (lsb)!\n", i);
FAILED();
printf (" Test for clear bit %d failed (lsb)!\n", i);
goto failed;
}
}
puts (" PASSED");
PASSED();
return 0;
failed:
printf (" v = 0x");
printf (" v = 0x");
for (i=0; i<(int)sizeof(v1); i++) printf ("%02x", v1[i]);
printf ("\n");
return -1;
@ -159,8 +160,7 @@ test_copy (void)
intn i, j;
ssize_t n;
printf ("%-70s", "Testing bit copy operations");
fflush (stdout);
TESTING("bit copy operations");
for (i=0; i<NTESTS; i++) {
s_offset = rand() % (8*sizeof v1);
@ -174,13 +174,13 @@ test_copy (void)
H5T_bit_copy (v2, d_offset, v1, s_offset, size);
for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break;
if (size>0 && j>=(intn)sizeof(v2)) {
puts ("*FAILED*");
puts (" Unabled to find copied region in destination");
FAILED();
puts (" Unabled to find copied region in destination");
goto failed;
}
if (0==size && j<(intn)sizeof(v2)) {
puts ("*FAILED*");
puts (" Found copied bits when we shouldn't have");
FAILED();
puts (" Found copied bits when we shouldn't have");
goto failed;
}
@ -188,26 +188,26 @@ test_copy (void)
/* Look for the zeros and ones */
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1);
if (size>0 && n!=(ssize_t)d_offset) {
puts ("*FAILED*");
printf (" Unable to find first copied bit in destination "
FAILED();
printf (" Unable to find first copied bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
puts ("*FAILED*");
puts (" Found copied bits and shouldn't have!");
FAILED();
puts (" Found copied bits and shouldn't have!");
goto failed;
}
n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0);
if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
puts ("*FAILED*");
printf (" Unable to find last copied bit in destination "
FAILED();
printf (" Unable to find last copied bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (d_offset+size==8*sizeof(v2) && n>=0) {
puts ("*FAILED*");
puts (" High-order zeros are present and shouldn't be!");
FAILED();
puts (" High-order zeros are present and shouldn't be!");
goto failed;
}
@ -217,41 +217,41 @@ test_copy (void)
*/
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1);
if (size>0 && (size_t)(n+1)!=d_offset+size) {
puts ("*FAILED*");
printf (" Unable to find last copied bit in destination "
FAILED();
printf (" Unable to find last copied bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
puts ("*FAILED*");
puts (" Found copied bits but shouldn't have (reverse)!");
FAILED();
puts (" Found copied bits but shouldn't have (reverse)!");
goto failed;
}
n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0);
if (d_offset>0 && n+1!=(ssize_t)d_offset) {
puts ("*FAILED*");
printf (" Unable to find beginning of copied data "
FAILED();
printf (" Unable to find beginning of copied data "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==d_offset && n>=0) {
puts ("*FAILED*");
puts (" Found leading original data but shouldn't have!");
FAILED();
puts (" Found leading original data but shouldn't have!");
goto failed;
}
}
puts (" PASSED");
PASSED();
return 0;
failed:
printf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n",
printf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n",
i, (unsigned long)s_offset, (unsigned long)d_offset,
(unsigned long)size);
printf (" s = 0x");
printf (" s = 0x");
for (j=sizeof(v1)-1; j>=0; --j) printf ("%02x", v1[j]);
printf ("\n d = 0x");
printf ("\n d = 0x");
for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
printf ("\n");
return -1;
@ -282,8 +282,7 @@ test_set (void)
intn i, j;
ssize_t n;
printf ("%-70s", "Testing bit set operations");
fflush (stdout);
TESTING("bit set operations");
for (i=0; i<NTESTS; i++) {
d_offset = rand() % (8*sizeof v2);
@ -295,13 +294,13 @@ test_set (void)
H5T_bit_set (v2, d_offset, size, TRUE);
for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break;
if (size>0 && j>=(intn)sizeof(v2)) {
puts ("*FAILED*");
puts (" Unabled to find set region in buffer");
FAILED();
puts (" Unabled to find set region in buffer");
goto failed;
}
if (0==size && j<(intn)sizeof(v2)) {
puts ("*FAILED*");
puts (" Found set bits when we shouldn't have");
FAILED();
puts (" Found set bits when we shouldn't have");
goto failed;
}
@ -309,26 +308,26 @@ test_set (void)
/* Look for the zeros and ones */
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1);
if (size>0 && n!=(ssize_t)d_offset) {
puts ("*FAILED*");
printf (" Unable to find first set bit in destination "
FAILED();
printf (" Unable to find first set bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
puts ("*FAILED*");
puts (" Found set bits and shouldn't have!");
FAILED();
puts (" Found set bits and shouldn't have!");
goto failed;
}
n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0);
if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
puts ("*FAILED*");
printf (" Unable to find last set bit in destination "
FAILED();
printf (" Unable to find last set bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (d_offset+size==8*sizeof(v2) && n>=0) {
puts ("*FAILED*");
puts (" High-order zeros are present and shouldn't be!");
FAILED();
puts (" High-order zeros are present and shouldn't be!");
goto failed;
}
@ -338,38 +337,38 @@ test_set (void)
*/
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1);
if (size>0 && (size_t)(n+1)!=d_offset+size) {
puts ("*FAILED*");
printf (" Unable to find last set bit in destination "
FAILED();
printf (" Unable to find last set bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
puts ("*FAILED*");
puts (" Found set bits but shouldn't have (reverse)!");
FAILED();
puts (" Found set bits but shouldn't have (reverse)!");
goto failed;
}
n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0);
if (d_offset>0 && n+1!=(ssize_t)d_offset) {
puts ("*FAILED*");
printf (" Unable to find beginning of set bit region "
FAILED();
printf (" Unable to find beginning of set bit region "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==d_offset && n>=0) {
puts ("*FAILED*");
puts (" Found leading zeros but shouldn't have!");
FAILED();
puts (" Found leading zeros but shouldn't have!");
goto failed;
}
}
puts (" PASSED");
PASSED();
return 0;
failed:
printf (" i=%d, d_offset=%lu, size=%lu\n",
printf (" i=%d, d_offset=%lu, size=%lu\n",
i, (unsigned long)d_offset, (unsigned long)size);
printf (" d = 0x");
printf (" d = 0x");
for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
printf ("\n");
return -1;
@ -400,8 +399,7 @@ test_clear (void)
intn i, j;
ssize_t n;
printf ("%-70s", "Testing bit clear operations");
fflush (stdout);
TESTING("bit clear operations");
for (i=0; i<NTESTS; i++) {
d_offset = rand() % (8*sizeof v2);
@ -413,13 +411,13 @@ test_clear (void)
H5T_bit_set (v2, d_offset, size, FALSE);
for (j=0; j<(intn)sizeof(v2); j++) if (0xff!=v2[j]) break;
if (size>0 && j>=(intn)sizeof(v2)) {
puts ("*FAILED*");
puts (" Unabled to find cleared region in buffer");
FAILED();
puts (" Unabled to find cleared region in buffer");
goto failed;
}
if (0==size && j<(intn)sizeof(v2)) {
puts ("*FAILED*");
puts (" Found cleared bits when we shouldn't have");
FAILED();
puts (" Found cleared bits when we shouldn't have");
goto failed;
}
@ -427,26 +425,26 @@ test_clear (void)
/* Look for the zeros and ones */
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 0);
if (size>0 && n!=(ssize_t)d_offset) {
puts ("*FAILED*");
printf (" Unable to find first cleared bit in destination "
FAILED();
printf (" Unable to find first cleared bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
puts ("*FAILED*");
puts (" Found cleared bits and shouldn't have!");
FAILED();
puts (" Found cleared bits and shouldn't have!");
goto failed;
}
n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1);
if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
puts ("*FAILED*");
printf (" Unable to find last cleared bit in destination "
FAILED();
printf (" Unable to find last cleared bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (d_offset+size==8*sizeof(v2) && n>=0) {
puts ("*FAILED*");
puts (" High-order ones are present and shouldn't be!");
FAILED();
puts (" High-order ones are present and shouldn't be!");
goto failed;
}
@ -456,38 +454,38 @@ test_clear (void)
*/
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 0);
if (size>0 && (size_t)(n+1)!=d_offset+size) {
puts ("*FAILED*");
printf (" Unable to find last cleared bit in destination "
FAILED();
printf (" Unable to find last cleared bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
puts ("*FAILED*");
puts (" Found cleared bits but shouldn't have (reverse)!");
FAILED();
puts (" Found cleared bits but shouldn't have (reverse)!");
goto failed;
}
n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 1);
if (d_offset>0 && n+1!=(ssize_t)d_offset) {
puts ("*FAILED*");
printf (" Unable to find beginning of cleared bit region "
FAILED();
printf (" Unable to find beginning of cleared bit region "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==d_offset && n>=0) {
puts ("*FAILED*");
puts (" Found leading ones but shouldn't have!");
FAILED();
puts (" Found leading ones but shouldn't have!");
goto failed;
}
}
puts (" PASSED");
PASSED();
return 0;
failed:
printf (" i=%d, d_offset=%lu, size=%lu\n",
printf (" i=%d, d_offset=%lu, size=%lu\n",
i, (unsigned long)d_offset, (unsigned long)size);
printf (" d = 0x");
printf (" d = 0x");
for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
printf ("\n");
return -1;

View File

@ -289,7 +289,7 @@ test_diag (int op, hsize_t cache_size, hsize_t io_size, hsize_t offset)
* Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
return (double)((hssize_t)(nio/nio_g));
return (double)(hssize_t)nio/(hssize_t)nio_g;
}

View File

@ -8,24 +8,12 @@
/* See H5private.h for how to include headers */
#undef NDEBUG
#include <hdf5.h>
#include <h5test.h>
#ifdef STDC_HEADERS
# include <assert.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif
#ifndef HAVE_ATTRIBUTE
# undef __attribute__
# define __attribute__(X) /*void*/
# define __unused__ /*void*/
#else
# define __unused__ __attribute__((unused))
#endif
#define TEST_FILE_NAME "cmpd_dset.h5"
const char *FILENAME[] = {
"cmpd_dset",
NULL
};
/* The first dataset */
typedef struct s1_t {
@ -76,54 +64,6 @@ typedef struct s5_t {
# define NY 9u
#endif
/*-------------------------------------------------------------------------
* Function: cleanup
*
* Purpose: Cleanup temporary test files
*
* Return: none
*
* Programmer: Albert Cheng
* May 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
cleanup(void)
{
if (!getenv ("HDF5_NOCLEANUP")) {
remove(TEST_FILE_NAME);
}
}
/*-------------------------------------------------------------------------
* Function: display_error_cb
*
* Purpose: Displays the error stack after printing "*FAILED*".
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
display_error_cb (void __unused__ *client_data)
{
puts ("*FAILED*");
H5Eprint (stdout);
return 0;
}
/*-------------------------------------------------------------------------
* Function: main
@ -186,18 +126,20 @@ main (void)
/* Other variables */
unsigned int i, j;
hid_t file, dataset, space, PRESERVE;
hid_t file, dataset, space, PRESERVE, fapl;
static hsize_t dim[] = {NX, NY};
hssize_t f_offset[2]; /*offset of hyperslab in file */
hsize_t h_size[2]; /*size of hyperslab */
size_t memb_size[1] = {4};
char filename[256];
/* Set up error handling */
H5Eset_auto(display_error_cb, NULL);
h5_reset();
/* Create the file */
if ((file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, fapl))<0) goto error;
/* Create the data space */
if ((space = H5Screate_simple (2, dim, NULL))<0) goto error;
@ -210,8 +152,7 @@ main (void)
*######################################################################
* STEP 1: Save the original dataset natively.
*/
printf("%-70s", "Testing basic compound write");
fflush(stdout);
TESTING("basic compound write");
/* Initialize the dataset */
for (i=0; i<NX*NY; i++) {
@ -245,7 +186,7 @@ main (void)
if (H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1)<0) {
goto error;
}
puts(" PASSED");
PASSED();
/*
*######################################################################
@ -253,8 +194,7 @@ main (void)
* it's the same as the first just to test things better, but
* in fact, we could have used s1_tid.
*/
printf("%-70s", "Testing basic compound read");
fflush(stdout);
TESTING("basic compound read");
/* Create a data type for s2 */
if ((s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)))<0) goto error;
@ -282,12 +222,12 @@ main (void)
s1[i].c[3]!=s2[i].c[3] ||
s1[i].d!=s2[i].d ||
s1[i].e!=s2[i].e) {
puts("*FAILED*");
puts(" Incorrect values read from the file");
FAILED();
puts(" Incorrect values read from the file");
goto error;
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
@ -295,8 +235,7 @@ main (void)
* has the same data space but the data type is different: the
* data type is a struct whose members are in the opposite order.
*/
printf("%-70s", "Testing reversal of struct members");
fflush (stdout);
TESTING("reversal of struct members");
/* Create a data type for s3 */
if ((s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)))<0) goto error;
@ -324,20 +263,19 @@ main (void)
s1[i].c[3]!=s3[i].c[3] ||
s1[i].d!=s3[i].d ||
s1[i].e!=s3[i].e) {
puts("*FAILED*");
puts(" Incorrect values read from the file");
FAILED();
puts(" Incorrect values read from the file");
goto error;
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
* STEP 4: Read a subset of the members. Of the <a,b,c,d,e> members
* stored on disk we'll read <b,d>.
*/
printf("%-70s", "Testing subset struct read");
fflush (stdout);
TESTING("subset struct read");
/* Create a datatype for s4 */
if ((s4_tid = H5Tcreate (H5T_COMPOUND, sizeof(s4_t)))<0) goto error;
@ -353,20 +291,19 @@ main (void)
for (i=0; i<NX*NY; i++) {
if (s1[i].b!=s4[i].b ||
s1[i].d!=s4[i].d) {
puts("*FAILED*");
puts(" Incorrect values read from the file");
FAILED();
puts(" Incorrect values read from the file");
goto error;
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
* STEP 5: Read all the members into a struct which has other members
* which have already been initialized.
*/
printf("%-70s", "Testing partially initialized superset read");
fflush(stdout);
TESTING("partially initialized superset read");
/* Initialize some members */
for (i=0; i<NX*NY; i++) {
@ -402,8 +339,8 @@ main (void)
s1[i].c[3]!=s5[i].c[3] ||
s1[i].d!=s5[i].d ||
s1[i].e!=s5[i].e) {
puts("*FAILED*");
puts(" Incorrect values read from the file");
FAILED();
puts(" Incorrect values read from the file");
goto error;
}
}
@ -414,12 +351,12 @@ main (void)
s5[i].mid1 != 1001+4*i ||
s5[i].mid2 != 1002+4*i ||
s5[i].post != 1003+4*i) {
puts("*FAILED*");
puts(" Memory values were clobbered");
FAILED();
puts(" Memory values were clobbered");
goto error;
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
@ -427,8 +364,7 @@ main (void)
* fields unchanged. This tests member alignment and background
* buffers.
*/
printf("%-70s", "Testing partially initialized superset write");
fflush (stdout);
TESTING("partially initialized superset write");
/* Initialize `s4' with new values */
for (i=0; i<NX*NY; i++) {
@ -456,12 +392,17 @@ main (void)
s1[i].c[3] != 8*i+5 ||
s1[i].d != 8*i+6 ||
s1[i].e != 8*i+7) {
puts("*FAILED*");
puts(" File values were clobbered");
FAILED();
printf(" i==%u, row=%u, col=%u\n", i, i/NY, i%NY);
printf(" got: {%7d,%7d,[%7d,%7d,%7d,%7d],%7d,%7d}\n",
s1[i].a, s1[i].b, s1[i].c[0], s1[i].c[1], s1[i].c[2],
s1[i].c[3], s1[i].d, s1[i].e);
printf(" ans: {%7d,%7d,[%7d,%7d,%7d,%7d],%7d,%7d}\n",
8*i+0, 8*i+1, 8*i+2, 8*i+3, 8*i+4, 8*i+5, 8*i+6, 8*i+7);
goto error;
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
@ -469,8 +410,7 @@ main (void)
* though these data spaces are equal it tests a different part of the
* library.
*/
printf("%-70s", "Testing explicit data space");
fflush (stdout);
TESTING("explicit data space");
/* Create the data space */
if ((s7_sid = H5Screate_simple (2, dim, NULL))<0) goto error;
@ -490,12 +430,12 @@ main (void)
s2[i].c[3] != s1[i].c[3] ||
s2[i].d != s1[i].d ||
s2[i].e != s1[i].e) {
puts("*FAILED*");
puts(" Incorrect values read from file");
FAILED();
puts(" Incorrect values read from file");
goto error;
}
}
puts(" PASSED");
PASSED();
/*
@ -503,8 +443,7 @@ main (void)
* STEP 8. Read a hyperslab of the file into a complete array in memory.
* The hyperslab is the middle third of the array.
*/
printf("%-70s", "Testing hyperslab partial read to array");
fflush (stdout);
TESTING("hyperslab partial read to array");
/* Create the file data space */
if ((s8_f_sid = H5Dget_space (dataset))<0) goto error;
@ -539,8 +478,8 @@ main (void)
ps8->c[3] != ps1->c[3] ||
ps8->d != ps1->d ||
ps8->e != ps1->e) {
puts("*FAILED*");
puts(" Incorrect values read from file");
FAILED();
puts(" Incorrect values read from file");
goto error;
}
}
@ -548,7 +487,7 @@ main (void)
free (s8);
s8 = NULL;
puts(" PASSED");
PASSED();
/*
@ -556,8 +495,7 @@ main (void)
* STEP 9. Read a hyperslab of the file into a hyperslab of memory. The
* part of memory not read is already initialized and must not change.
*/
printf("%-70s", "Testing hyperslab partial read to another hyperslab");
fflush (stdout);
TESTING("hyperslab partial read to another hyperslab");
/* Initialize */
for (i=0; i<NX*NY; i++) {
@ -587,8 +525,8 @@ main (void)
ps2->c[3] != ps1->c[3] ||
ps2->d != ps1->d ||
ps2->e != ps1->e) {
puts("*FAILED*");
puts(" Memory values clobbered");
FAILED();
puts(" Memory values clobbered");
goto error;
}
} else {
@ -600,22 +538,21 @@ main (void)
ps2->c[3] != (unsigned)(-1) ||
ps2->d != (unsigned)(-1) ||
ps2->e != (unsigned)(-1)) {
puts("*FAILED*");
puts(" Incorrect values read from file");
FAILED();
puts(" Incorrect values read from file");
goto error;
}
}
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
* STEP 10. Same as step 9 except the memory array contains some members
* which are already initialized, like step 5.
*/
printf("%-70s", "Testing hyperslab to hyperslab part initialized read");
fflush (stdout);
TESTING("hyperslab to hyperslab part initialized read");
/* Initialize */
for (i=0; i<NX*NY; i++) {
@ -650,8 +587,8 @@ main (void)
ps5->d != ps1->d ||
ps5->e != ps1->e ||
ps5->post != (unsigned)(-1)) {
puts("*FAILED*");
puts(" Memory values clobbered");
FAILED();
puts(" Memory values clobbered");
goto error;
}
} else {
@ -667,22 +604,21 @@ main (void)
ps5->d != (unsigned)(-1) ||
ps5->e != (unsigned)(-1) ||
ps5->post != (unsigned)(-1)) {
puts("*FAILED*");
puts(" Incorrect values read from file");
FAILED();
puts(" Incorrect values read from file");
goto error;
}
}
}
}
puts(" PASSED");
PASSED();
/*
*######################################################################
* Step 11: Write an array into the middle third of the dataset
* initializeing only members `b' and `d' to -1.
*/
printf("%-70s", "Testing hyperslab part initialized write");
fflush (stdout);
TESTING("hyperslab part initialized write");
/* Create the memory array and initialize all fields to zero */
ndims = 2;
@ -721,8 +657,8 @@ main (void)
ps1->c[2] != 8*(i*NY+j)+4 ||
ps1->c[3] != 8*(i*NY+j)+5 ||
ps1->e != 8*(i*NY+j)+7) {
puts("*FAILED*");
puts(" Write clobbered values");
FAILED();
puts(" Write clobbered values");
goto error;
}
@ -732,21 +668,21 @@ main (void)
(hsize_t)j<f_offset[1]+h_size[1]) {
if (ps1->b != (unsigned)(-1) ||
ps1->d != (unsigned)(-1)) {
puts("*FAILED*");
puts(" Wrong values written or read");
FAILED();
puts(" Wrong values written or read");
goto error;
}
} else {
if (ps1->b != 8*(i*NY+j)+1 ||
ps1->d != 8*(i*NY+j)+6) {
puts("*FAILED*");
puts(" Write clobbered values");
FAILED();
puts(" Write clobbered values");
goto error;
}
}
}
}
puts(" PASSED");
PASSED();
/*
@ -756,12 +692,11 @@ main (void)
H5Dclose (dataset);
H5Fclose (file);
cleanup();
h5_cleanup(fapl);
puts("All compound dataset tests passed.");
return 0;
error:
cleanup();
puts("Remaining tests have been skipped.");
puts("*** DATASET TESTS FAILED ***");
return 1;

View File

@ -8,40 +8,13 @@
* Purpose: Tests the dataset interface (H5D)
*/
/* See H5private.h for how to include files */
#undef NDEBUG
#include <hdf5.h>
#include <h5test.h>
#ifdef STDC_HEADERS
# include <assert.h>
# include <math.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif
const char *FILENAME[] = {
"dataset",
NULL
};
#ifdef HAVE_UNISTD_H
# include <sys/types.h>
# include <unistd.h>
#endif
#ifndef HAVE_ATTRIBUTE
# undef __attribute__
# define __attribute__(X) /*void*/
# define __unused__ /*void*/
#else
# define __unused__ __attribute__((unused))
#endif
#ifndef HAVE_FUNCTION
# undef __FUNCTION__
# define __FUNCTION__ ""
#endif
#define AT() printf (" at %s:%d in %s()...\n", \
__FILE__, __LINE__, __FUNCTION__);
#define TEST_FILE_NAME "dataset.h5"
#define DSET_DEFAULT_NAME "default"
#define DSET_CHUNKED_NAME "chunked"
#define DSET_SIMPLE_IO_NAME "simple_io"
@ -51,31 +24,6 @@
#define H5Z_BOGUS 305
/*-------------------------------------------------------------------------
* Function: display_error_cb
*
* Purpose: Displays the error stack after printing "*FAILED*".
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
display_error_cb (void __unused__ *client_data)
{
puts ("*FAILED*");
H5Eprint (stdout);
return 0;
}
/*-------------------------------------------------------------------------
* Function: test_create
@ -100,11 +48,8 @@ test_create(hid_t file)
hsize_t dims[2];
herr_t status;
hsize_t csize[2];
herr_t (*func)(void*) = NULL;
void *client_data = NULL;
printf("%-70s", "Testing create/open/close");
fflush (stdout);
TESTING("create, open, close");
/* Create the data space */
dims[0] = 256;
@ -132,14 +77,13 @@ test_create(hid_t file)
* dataset can only be created once. Temporarily turn off error
* reporting.
*/
H5Eget_auto (&func, &client_data);
H5Eset_auto (NULL, NULL);
dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
H5P_DEFAULT);
H5Eset_auto (func, client_data);
H5E_BEGIN_TRY {
dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
H5P_DEFAULT);
} H5E_END_TRY;
if (dataset >= 0) {
puts("*FAILED*");
printf(" Library allowed overwrite of existing dataset.\n");
FAILED();
puts(" Library allowed overwrite of existing dataset.");
goto error;
}
@ -155,13 +99,12 @@ test_create(hid_t file)
* cannot be created with this function. Temporarily turn off error
* reporting.
*/
H5Eget_auto (&func, &client_data);
H5Eset_auto (NULL, NULL);
dataset = H5Dopen(file, "does_not_exist");
H5Eset_auto (func, client_data);
H5E_BEGIN_TRY {
dataset = H5Dopen(file, "does_not_exist");
} H5E_END_TRY;
if (dataset >= 0) {
puts("*FAILED*");
printf(" Opened a non-existent dataset.\n");
FAILED();
puts(" Opened a non-existent dataset.");
goto error;
}
@ -186,7 +129,7 @@ test_create(hid_t file)
*/
if (H5Dclose(dataset) < 0) goto error;
puts(" PASSED");
PASSED();
return 0;
error:
@ -222,8 +165,7 @@ test_simple_io(hid_t file)
hsize_t dims[2];
void *tconv_buf = NULL;
printf("%-70s", "Testing simple I/O");
fflush (stdout);
TESTING("simple I/O");
/* Initialize the dataset */
for (i = n = 0; i < 100; i++) {
@ -235,38 +177,33 @@ test_simple_io(hid_t file)
/* Create the data space */
dims[0] = 100;
dims[1] = 200;
space = H5Screate_simple(2, dims, NULL);
assert(space>=0);
if ((space = H5Screate_simple(2, dims, NULL))<0) goto error;
/* Create a small conversion buffer to test strip mining */
tconv_buf = malloc (1000);
xfer = H5Pcreate (H5P_DATASET_XFER);
assert (xfer>=0);
status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL);
assert (status>=0);
if ((status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL))<0) goto error;
/* Create the dataset */
dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
H5P_DEFAULT);
assert(dataset >= 0);
if ((dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
H5P_DEFAULT))<0) goto error;
/* Write the data to the dataset */
status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, points);
if (status<0) goto error;
if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
goto error;
/* Read the dataset back */
status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, check);
if (status<0) goto error;
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
goto error;
/* Check that the values read are the same as the values written */
for (i = 0; i < 100; i++) {
for (j = 0; j < 200; j++) {
if (points[i][j] != check[i][j]) {
puts("*FAILED*");
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
}
}
@ -275,7 +212,7 @@ test_simple_io(hid_t file)
H5Pclose (xfer);
H5Dclose(dataset);
free (tconv_buf);
puts(" PASSED");
PASSED();
return 0;
error:
@ -305,15 +242,13 @@ test_tconv(hid_t file)
int i;
hsize_t dims[1];
hid_t space, dataset;
herr_t status;
out = malloc (4*1000000);
assert (out);
in = malloc (4*1000000);
assert (in);
printf("%-70s", "Testing data type conversion");
fflush (stdout);
TESTING("data type conversion");
/* Initialize the dataset */
for (i = 0; i < 1000000; i++) {
@ -325,38 +260,40 @@ test_tconv(hid_t file)
/* Create the data space */
dims[0] = 1000000;
space = H5Screate_simple (1, dims, NULL);
assert(space >= 0);
if ((space = H5Screate_simple (1, dims, NULL))<0) goto error;
/* Create the data set */
dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_STD_I32LE, space,
H5P_DEFAULT);
assert(dataset >= 0);
if ((dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_STD_I32LE, space,
H5P_DEFAULT))<0) goto error;
/* Write the data to the dataset */
status = H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL,
H5P_DEFAULT, out);
assert(status >= 0);
if (H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
out)<0) goto error;
/* Read data with byte order conversion */
status = H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL,
H5P_DEFAULT, in);
assert(status >= 0);
if (H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in)<0)
goto error;
/* Check */
for (i = 0; i < 1000000; i++) {
assert(in[4 * i + 0] == out[4 * i + 3]);
assert(in[4 * i + 1] == out[4 * i + 2]);
assert(in[4 * i + 2] == out[4 * i + 1]);
assert(in[4 * i + 3] == out[4 * i + 0]);
if (in[4*i+0]!=out[4*i+3] ||
in[4*i+1]!=out[4*i+2] ||
in[4*i+2]!=out[4*i+1] ||
in[4*i+3]!=out[4*i+0]) {
FAILED();
puts(" Read with byte order conversion failed.");
goto error;
}
}
H5Dclose(dataset);
if (H5Dclose(dataset)<0) goto error;
free (out);
free (in);
puts(" PASSED");
return 0;
error:
return -1;
}
@ -381,9 +318,6 @@ bogus(unsigned int __unused__ flags, size_t __unused__ cd_nelmts,
const unsigned int __unused__ cd_values[], size_t nbytes,
size_t __unused__ *buf_size, void __unused__ **buf)
{
#if 0
abort();
#endif
return nbytes;
}
@ -408,7 +342,6 @@ static herr_t
test_compression(hid_t file)
{
hid_t dataset, space, xfer, dc;
herr_t status;
int points[100][200], check[100][200];
const hsize_t size[2] = {100, 200};
const hsize_t chunk_size[2] = {2, 25};
@ -418,64 +351,57 @@ test_compression(hid_t file)
hsize_t i, j, n;
void *tconv_buf = NULL;
printf ("%-70s", "Testing compression (setup)");
fflush (stderr);
TESTING("compression (setup)");
/* Create the data space */
space = H5Screate_simple(2, size, NULL);
assert(space>=0);
if ((space = H5Screate_simple(2, size, NULL))<0) goto error;
/*
* Create a small conversion buffer to test strip mining. We
* might as well test all we can!
*/
xfer = H5Pcreate (H5P_DATASET_XFER);
assert (xfer>=0);
if ((xfer = H5Pcreate (H5P_DATASET_XFER))<0) goto error;
tconv_buf = malloc (1000);
status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL);
assert (status>=0);
if (H5Pset_buffer (xfer, 1000, tconv_buf, NULL)<0) goto error;
/* Use chunked storage with compression */
dc = H5Pcreate (H5P_DATASET_CREATE);
H5Pset_chunk (dc, 2, chunk_size);
H5Pset_deflate (dc, 6);
if ((dc = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error;
if (H5Pset_deflate (dc, 6)<0) goto error;
/* Create the dataset */
dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space, dc);
assert(dataset >= 0);
puts (" PASSED");
if ((dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space,
dc))<0) goto error;
PASSED();
/*----------------------------------------------------------------------
* STEP 1: Read uninitialized data. It should be zero.
*----------------------------------------------------------------------
*/
printf ("%-70s", "Testing compression (uninitialized read)");
fflush (stdout);
TESTING("compression (uninitialized read)");
status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, check);
if (status<0) goto error;
if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
goto error;
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (0!=check[i][j]) {
puts("*FAILED*");
printf(" Read a non-zero value.\n");
printf(" At index %lu,%lu\n",
FAILED();
printf(" Read a non-zero value.\n");
printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
puts (" PASSED");
PASSED();
/*----------------------------------------------------------------------
* STEP 2: Test compression by setting up a chunked dataset and writing
* to it.
*----------------------------------------------------------------------
*/
printf("%-70s", "Testing compression (write)");
fflush (stdout);
TESTING("compression (write)");
for (i=n=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
@ -483,36 +409,33 @@ test_compression(hid_t file)
}
}
status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, points);
if (status<0) goto error;
puts (" PASSED");
if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
goto error;
PASSED();
/*----------------------------------------------------------------------
* STEP 3: Try to read the data we just wrote.
*----------------------------------------------------------------------
*/
printf ("%-70s", "Testing compression (read)");
fflush (stdout);
TESTING("compression (read)");
/* Read the dataset back */
status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, check);
if (status<0) goto error;
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
goto error;
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (points[i][j] != check[i][j]) {
puts("*FAILED*");
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
puts (" PASSED");
PASSED();
/*----------------------------------------------------------------------
* STEP 4: Write new data over the top of the old data. The new data is
@ -521,37 +444,33 @@ test_compression(hid_t file)
* dataset although we rewrite the whole thing.
*----------------------------------------------------------------------
*/
printf ("%-70s", "Testing compression (modify)");
fflush (stdout);
TESTING("compression (modify)");
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]/2; j++) {
points[i][j] = rand ();
}
}
status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, points);
if (status<0) goto error;
if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
goto error;
/* Read the dataset back and check it */
status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, check);
if (status<0) goto error;
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
goto error;
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (points[i][j] != check[i][j]) {
puts("*FAILED*");
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
puts (" PASSED");
PASSED();
/*----------------------------------------------------------------------
* STEP 5: Close the dataset and then open it and read it again. This
@ -559,29 +478,26 @@ test_compression(hid_t file)
* object header.
*----------------------------------------------------------------------
*/
printf ("%-70s", "Testing compression (re-open)");
fflush (stdout);
TESTING("compression (re-open)");
H5Dclose (dataset);
dataset = H5Dopen (file, DSET_COMPRESS_NAME);
status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, check);
if (status<0) goto error;
if (H5Dclose (dataset)<0) goto error;
if ((dataset = H5Dopen (file, DSET_COMPRESS_NAME))<0) goto error;
if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
goto error;
/* Check that the values read are the same as the values written */
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (points[i][j] != check[i][j]) {
puts("*FAILED*");
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
puts (" PASSED");
PASSED();
/*----------------------------------------------------------------------
* STEP 6: Test partial I/O by writing to and then reading from a
@ -589,76 +505,72 @@ test_compression(hid_t file)
* boundaries (we know that case already works from above tests).
*----------------------------------------------------------------------
*/
printf ("%-70s", "Testing compression (partial I/O)");
fflush (stderr);
TESTING("compression (partial I/O)");
for (i=0; i<hs_size[0]; i++) {
for (j=0; j<hs_size[1]; j++) {
points[hs_offset[0]+i][hs_offset[1]+j] = rand ();
}
}
H5Sselect_hyperslab(space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL);
status = H5Dwrite (dataset, H5T_NATIVE_INT, space, space, xfer, points);
if (status<0) goto error;
status = H5Dread (dataset, H5T_NATIVE_INT, space, space, xfer, check);
if (status<0) goto error;
if (H5Sselect_hyperslab(space, H5S_SELECT_SET, hs_offset, NULL, hs_size,
NULL)<0) goto error;
if (H5Dwrite (dataset, H5T_NATIVE_INT, space, space, xfer, points)<0)
goto error;
if (H5Dread (dataset, H5T_NATIVE_INT, space, space, xfer, check)<0)
goto error;
/* Check that the values read are the same as the values written */
for (i=0; i<hs_size[0]; i++) {
for (j=0; j<hs_size[1]; j++) {
if (points[hs_offset[0]+i][hs_offset[1]+j] !=
check[hs_offset[0]+i][hs_offset[1]+j]) {
puts("*FAILED*");
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
(unsigned long)(hs_offset[0]+i),
(unsigned long)(hs_offset[1]+j));
printf(" At original: %d\n",
printf(" At original: %d\n",
(int)points[hs_offset[0]+i][hs_offset[1]+j]);
printf(" At returned: %d\n",
printf(" At returned: %d\n",
(int)check[hs_offset[0]+i][hs_offset[1]+j]);
goto error;
}
}
}
puts (" PASSED");
PASSED();
/*----------------------------------------------------------------------
* STEP 7: Register an application-defined compression method and use it
* to write and then read the dataset.
*----------------------------------------------------------------------
*/
printf ("%-70s", "Testing compression (app-defined method)");
fflush (stdout);
TESTING("compression (app-defined method)");
if (H5Zregister (H5Z_BOGUS, "bogus", bogus)<0) goto error;
if (H5Pset_filter (dc, H5Z_BOGUS, 0, 0, NULL)<0) goto error;
if (H5Dclose (dataset)<0) goto error;
if (H5Sclose (space)<0) goto error;
if ((space = H5Screate_simple (2, size, NULL))<0) goto error;
dataset = H5Dcreate (file, DSET_BOGUS_NAME, H5T_NATIVE_INT, space, dc);
assert (dataset>=0);
if ((dataset=H5Dcreate (file, DSET_BOGUS_NAME, H5T_NATIVE_INT, space,
dc))<0) goto error;
status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, points);
if (status<0) goto error;
status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
xfer, check);
if (status<0) goto error;
if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
goto error;
if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
goto error;
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (points[i][j] != check[i][j]) {
puts("*FAILED*");
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
FAILED();
printf(" Read different values than written.\n");
printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
puts (" PASSED");
PASSED();
@ -666,9 +578,9 @@ test_compression(hid_t file)
* Cleanup
*----------------------------------------------------------------------
*/
H5Pclose (xfer);
H5Pclose (dc);
H5Dclose(dataset);
if (H5Pclose (xfer)<0) goto error;
if (H5Pclose (dc)<0) goto error;
if (H5Dclose(dataset)<0) goto error;
free (tconv_buf);
return 0;
@ -704,7 +616,7 @@ test_multiopen (hid_t file)
static hsize_t max_size[1] = {H5S_UNLIMITED};
hsize_t tmp_size[1];
printf ("%-70s", "Testing multi-open with extending");
TESTING("multi-open with extending");
/* Create the dataset and open it twice */
if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
@ -723,8 +635,8 @@ test_multiopen (hid_t file)
if ((space = H5Dget_space (dset2))<0) goto error;
if (H5Sget_simple_extent_dims (space, tmp_size, NULL)<0) goto error;
if (cur_size[0]!=tmp_size[0]) {
puts ("*FAILED*");
printf (" Got %d instead of %d!\n",
FAILED();
printf (" Got %d instead of %d!\n",
(int)tmp_size[0], (int)cur_size[0]);
goto error;
}
@ -733,7 +645,7 @@ test_multiopen (hid_t file)
if (H5Dclose (dset2)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
puts (" PASSED");
PASSED();
return 0;
error:
@ -746,29 +658,6 @@ test_multiopen (hid_t file)
return -1;
}
/*-------------------------------------------------------------------------
* Function: cleanup
*
* Purpose: Cleanup temporary test files
*
* Return: none
*
* Programmer: Albert Cheng
* May 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
cleanup(void)
{
if (!getenv ("HDF5_NOCLEANUP")) {
remove(TEST_FILE_NAME);
}
}
/*-------------------------------------------------------------------------
* Function: main
@ -790,64 +679,43 @@ int
main(void)
{
hid_t file, grp, fapl;
herr_t status;
int nerrors=0, mdc_nelmts;
char filename[1024];
status = H5open ();
assert (status>=0);
/* Automatic error reporting to standard output */
H5Eset_auto (display_error_cb, NULL);
/* Create the file */
fapl = H5Pcreate(H5P_FILE_ACCESS);
assert(fapl>=0);
h5_reset();
fapl = h5_fileaccess();
#if 1
/* Turn off raw data cache */
status = H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL);
assert(status>=0);
status = H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0);
assert(status>=0);
if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL)<0) goto error;
if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0)<0) goto error;
#endif
file = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, fapl);
assert(file >= 0);
H5Pclose(fapl);
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, fapl))<0) goto error;
/* Cause the library to emit initial messages */
grp = H5Gcreate (file, "emit diagnostics", 0);
H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted");
H5Gclose (grp);
if ((grp = H5Gcreate (file, "emit diagnostics", 0))<0) goto error;
if (H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted")<0)
goto error;
if (H5Gclose (grp)<0) goto error;
status = test_create(file);
nerrors += status < 0 ? 1 : 0;
nerrors += test_create(file)<0 ?1:0;
nerrors += test_simple_io(file)<0 ?1:0;
nerrors += test_tconv(file)<0 ?1:0;
nerrors += test_compression(file)<0 ?1:0;
nerrors += test_multiopen (file)<0 ?1:0;
status = test_simple_io(file);
nerrors += status < 0 ? 1 : 0;
status = test_tconv(file);
nerrors += status < 0 ? 1 : 0;
status = test_compression(file);
nerrors += status < 0 ? 1 : 0;
status = test_multiopen (file);
nerrors += status < 0 ? 1 : 0;
status = H5Fclose(file);
if (nerrors) {
printf("***** %d DATASET TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
exit(1);
}
if (H5Fclose(file)<0) goto error;
if (nerrors) goto error;
printf("All dataset tests passed.\n");
status = H5close ();
assert (status>=0);
cleanup();
h5_cleanup(fapl);
return 0;
error:
nerrors = MAX(1, nerrors);
printf("***** %d DATASET TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -8,42 +8,16 @@
* Purpose: Tests extendible datasets.
*/
/* See H5private.h for how to include headers */
#undef NDEBUG
#include <hdf5.h>
#include <h5test.h>
#ifdef STDC_HEADERS
# include <assert.h>
# include <stdlib.h>
#endif
const char *FILENAME[] = {
"extend",
NULL
};
#define TEST_FILE_NAME "extend.h5"
#define NX 100 /* USE AN EVEN NUMBER!*/
#define NY 100 /* USE AN EVEN NUMBER!*/
/*-------------------------------------------------------------------------
* Function: cleanup
*
* Purpose: Cleanup temporary test files
*
* Return: none
*
* Programmer: Albert Cheng
* May 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
cleanup(void)
{
if (!getenv ("HDF5_NOCLEANUP")) {
remove(TEST_FILE_NAME);
}
}
/*-------------------------------------------------------------------------
* Function: main
@ -65,6 +39,7 @@ int
main (void)
{
hid_t file, dataset, mem_space, file_space, cparms;
hid_t fapl;
herr_t status;
int i, j, k, m;
static int buf1[NY][NX], buf2[NX/2][NY/2];
@ -74,6 +49,11 @@ main (void)
static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
static hsize_t size[2];
hssize_t offset[2];
char filename[1024];
TESTING("dataset extend");
h5_reset();
fapl = h5_fileaccess();
/* Initialize buffer and space */
for (i=0; i<NX; i++) {
@ -81,22 +61,19 @@ main (void)
buf1[i][j] = i*NY+j;
}
}
mem_space = H5Screate_simple (2, dims, maxdims);
assert (mem_space>=0);
if ((mem_space = H5Screate_simple (2, dims, maxdims))<0) goto error;
/* Create the file */
file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, H5P_DEFAULT);
assert (file>=0);
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, fapl))<0) goto error;
/* Create the dataset which is originally NX by NY */
cparms = H5Pcreate (H5P_DATASET_CREATE);
assert (cparms>=0);
status = H5Pset_chunk (cparms, 2, chunk_dims);
assert (status>=0);
dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space, cparms);
assert (dataset>=0);
H5Pclose (cparms);
if ((cparms = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_chunk (cparms, 2, chunk_dims)<0) goto error;
if ((dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space,
cparms))<0) goto error;
if (H5Pclose (cparms)<0) goto error;
/* Write the data */
for (i=0; i<5; i++) {
@ -107,57 +84,60 @@ main (void)
offset[1] = j * NY;
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
status = H5Dextend (dataset, size);
assert (status>=0);
if (H5Dextend (dataset, size)<0) goto error;
/* Select a hyperslab */
file_space = H5Dget_space (dataset);
assert (file_space>=0);
status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset, NULL, dims, NULL);
assert (status>=0);
if ((file_space = H5Dget_space (dataset))<0) goto error;
if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
NULL, dims, NULL)<0) goto error;
/* Write to the hyperslab */
status = H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf1);
assert (status>=0);
H5Sclose (file_space);
if (H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf1)<0) goto error;
if (H5Sclose (file_space)<0) goto error;
}
}
H5Sclose (mem_space);
if (H5Sclose (mem_space)<0) goto error;
/* Read the data */
mem_space = H5Screate_simple (2, half_dims, NULL);
file_space = H5Dget_space (dataset);
if ((mem_space = H5Screate_simple (2, half_dims, NULL))<0) goto error;
if ((file_space = H5Dget_space (dataset))<0) goto error;
for (i=0; i<10; i++) {
for (j=0; j<10; j++) {
/* Select a hyperslab */
offset[0] = i * NX/2;
offset[1] = j * NY/2;
assert (file_space>=0);
status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL);
assert (status>=0);
if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
NULL, half_dims, NULL)<0) goto error;
/* Read */
status = H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf2);
assert (status>=0);
if (H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf2)<0) goto error;
/* Compare */
for (k=0; k<NX/2; k++) {
for (m=0; m<NY/2; m++) {
assert (buf2[k][m]==buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]);
if (buf2[k][m]!=buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]) {
FAILED();
printf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m);
goto error;
}
}
}
}
}
H5Dclose (dataset);
H5Fclose (file);
if (H5Dclose (dataset)<0) goto error;
if (H5Fclose (file)<0) goto error;
PASSED();
printf("All extend tests passed.\n");
cleanup();
h5_cleanup(fapl);
return 0;
error:
printf("*** One or more extend tests failed ***\n");
return 1;
}

View File

@ -7,70 +7,21 @@
*
* Purpose: Tests datasets stored in external raw files.
*/
/* See H5private.h for how to include headers */
#undef NDEBUG
#include <H5config.h>
#ifdef STDC_HEADERS
# include <assert.h>
# include <fcntl.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif
#ifdef HAVE_IO_H
# include <io.h>
#endif
#ifdef HAVE_UNISTD_H
# include <sys/types.h>
# include <unistd.h>
#endif
#include <hdf5.h>
#ifndef HAVE_ATTRIBUTE
# undef __attribute__
# define __attribute__(X) /*void*/
# define __unused__ /*void*/
#if 1 /* have to go, and this is only half baked.... 19981120 rpm*/
int main(void) {return 0;}
#else
# define __unused__ __attribute__((unused))
#endif
#define TEST_FILE_NAME1 "extern_1.h5"
#define TEST_FILE_NAME2 "extern_2.h5"
#define TEST_FILE_NAME3 "extern_3.h5"
#include <h5test.h>
const char *FILENAME[] = {
"extern_1",
"extern_2",
"extern_3",
NULL
};
static int nerrors_g = 0;
/*-------------------------------------------------------------------------
* Function: display_error_cb
*
* Purpose: Displays the error stack after printing "*FAILED*".
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
display_error_cb (void __unused__ *client_data)
{
puts ("*FAILED*");
H5Eprint (stdout);
nerrors_g++;
return 0;
}
/*-------------------------------------------------------------------------
* Function: same_contents
@ -135,7 +86,7 @@ same_contents (const char *name1, const char *name2)
*-------------------------------------------------------------------------
*/
static void
test_1 (void)
test_1 (hid_t fapl)
{
hid_t file, plist, space, dset, grp;
herr_t status;
@ -143,42 +94,37 @@ test_1 (void)
herr_t (*func)(void*) = NULL;
void *client_data = NULL;
int n;
char filename[1024];
/*
* Create the file and an initial group. This causes messages about
* debugging to be emitted before we start playing games with what the
* output looks like.
*/
file = H5Fcreate (TEST_FILE_NAME1, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, H5P_DEFAULT);
assert (file>=0);
grp = H5Gcreate (file, "emit-diagnostics", 8);
H5Gclose (grp);
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, fapl))<0) goto error;
if ((grp = H5Gcreate (file, "emit-diagnostics", 8))<0) goto error;
if (H5Gclose (grp)<0) goto error;
/*
* A single external file for a non-extendible dataset.
*/
do {
printf ("%-70s", "...fixed-size data space, exact storage");
fflush (stdout);
plist = H5Pcreate (H5P_DATASET_CREATE);
assert (plist>=0);
status = H5Pset_external (plist, "ext1.data", 0, (hsize_t)400);
assert (status>=0);
TESTING("fixed-size data space, exact storage");
if ((plist = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_external (plist, "ext1.data", 0, (hsize_t)400)<0) goto error;
size[0] = max_size[0] = 100;
space = H5Screate_simple (1, size, max_size);
assert (space>=0);
size[0] = max_size[0] = 100;
if ((space = H5Screate_simple (1, size, max_size))<0) goto error;
/* Create the dataset, the `dset1' name is used later too */
if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist))<0)
goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Pclose (plist)<0) goto error;
PASSED();
/* Create the dataset, the `dset1' name is used later too */
dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist);
if (dset<0) break;
H5Dclose (dset);
puts (" PASSED");
} while (0);
H5Sclose (space);
H5Pclose (plist);
/*
* A single external file which is too small to represent all the data.
@ -490,6 +436,8 @@ test_1 (void)
/* END OF TESTS */
H5Fclose (file);
error:
}
@ -586,7 +534,7 @@ test_2 (void)
puts (" Failed to read dataset");
break;
}
for (i=0; i<100; i++) {
if (whole[i]!=(signed)i) {
puts ("*FAILED*");
@ -856,3 +804,4 @@ main (void)
return (nerrors_g?1:0);
}
#endif

View File

@ -107,13 +107,13 @@ main(void)
/* Write some data */
for (i=0; i<ds_size[0]; i++) {
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
for (j=0; j<ds_size[1]; j++) {
the_data[i][j] = (double)((hssize_t)(i/(j+1)));
the_data[i][j] = (double)(hssize_t)i/((hssize_t)(j+1));
}
}
if (H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT,

View File

@ -131,7 +131,7 @@ main(void)
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
error = fabs(the_data[i][j]-(double)((hssize_t)(i/(j+1))));
error = fabs(the_data[i][j]-(double)(hssize_t)i/((hssize_t)j+1));
assert(error<0.0001);
}
}

366
test/h5test.c Normal file
View File

@ -0,0 +1,366 @@
/*
* Copyright © 1998 NCSA
* All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
* Thursday, November 19, 1998
*
* Purpose: Provides support functions for most of the hdf5 tests cases.
*
*/
#undef NDEBUG /*override -DNDEBUG */
#include <h5test.h>
/*
* Define these environment variables or constants to influence functions in
* this test support library. The environment variable is used in preference
* to the cpp constant. If neither is defined then use some default value.
*
* HDF5_PREFIX: A string to add to the beginning of all file names.
* This can be used to tell MPIO what driver to use
* (e.g., "gfs:", "ufs:", or "nfs:") or to use a
* different file system (e.g., "/tmp" or "/usr/tmp").
* The prefix will be separated from the base file name
* by a slash. See h5_fixname() for details.
*
* HDF5_DRIVER: This string describes what low level file driver to
* use for HDF5 file access. The first word in the
* value is the name of the driver and subsequent data
* is interpreted according to the driver. See
* h5_fileaccess() for details.
*
*/
/*-------------------------------------------------------------------------
* Function: h5_errors
*
* Purpose: Displays the error stack after printing "*FAILED*".
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
h5_errors(void __unused__ *client_data)
{
FAILED();
H5Eprint (stdout);
return 0;
}
/*-------------------------------------------------------------------------
* Function: h5_cleanup
*
* Purpose: Cleanup temporary test files. The list of test files is in
* `extern const char *FILENAMES[]' -- these are only the base
* names. The file access property list is also closed.
*
* Return: none
*
* Programmer: Albert Cheng
* May 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
h5_cleanup(hid_t fapl)
{
char filename[1024];
char temp[2048];
int i, j;
if (!getenv("HDF5_NOCLEANUP")) {
for (i=0; FILENAME[i]; i++) {
if (NULL==h5_fixname(FILENAME[i], fapl, filename,
sizeof filename)) {
continue;
}
switch (H5Pget_driver(fapl)) {
case H5F_LOW_CORE:
break; /*nothing to remove*/
case H5F_LOW_SPLIT:
snprintf(temp, sizeof temp, "%s.raw", filename);
remove(temp);
snprintf(temp, sizeof temp, "%s.meta", filename);
remove(temp);
break;
case H5F_LOW_FAMILY:
for (j=0; /*void*/; j++) {
snprintf(temp, sizeof temp, filename, j);
if (access(temp, F_OK)<0) break;
remove(temp);
}
break;
default:
remove(filename);
break;
}
}
}
H5Pclose(fapl);
}
/*-------------------------------------------------------------------------
* Function: h5_reset
*
* Purpose: Reset the library by closing it.
*
* Return: void
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
h5_reset(void)
{
fflush(stdout);
fflush(stderr);
H5close();
H5Eset_auto (h5_errors, NULL);}
/*-------------------------------------------------------------------------
* Function: h5_fixname
*
* Purpose: Create a file name from a file base name like `test' and
* return it through the FULLNAME (at most SIZE characters
* counting the null terminator). The full name is created by
* prepending the contents of HDF5_PREFIX (separated from the
* base name by a slash) and appending a file extension based on
* the driver supplied.
*
* Return: Success: The FULLNAME pointer.
*
* Failure: NULL if BASENAME or FULLNAME is the null
* pointer or if FULLNAME isn't large enough for
* the result.
*
* Programmer: Robb Matzke
* Thursday, November 19, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
char *
h5_fixname(const char *basename, hid_t fapl, char *fullname, size_t size)
{
const char *prefix=NULL, *suffix=NULL;
H5F_driver_t driver;
if (!basename || !fullname || size<1) return NULL;
/* First use the environment variable, then try the constant */
prefix = getenv("HDF5_PREFIX");
#ifdef HDF5_PREFIX
if (!prefix) prefix = HDF5_PREFIX;
#endif
/* Prepend the prefix value to the base name */
if (prefix && *prefix) {
if (snprintf(fullname, size, "%s/%s", prefix, basename)==(int)size) {
return NULL; /*buffer is too small*/
}
} else if (strlen(basename)>=size) {
return NULL; /*buffer is too small*/
} else {
strcpy(fullname, basename);
}
/* Append a suffix */
if ((driver=H5Pget_driver(fapl))<0) return NULL;
switch (driver) {
case H5F_LOW_SPLIT:
case H5F_LOW_CORE:
suffix = NULL;
break;
case H5F_LOW_FAMILY:
suffix = "%05d.h5";
break;
default:
suffix = ".h5";
break;
}
if (suffix) {
if (strlen(fullname)+strlen(suffix)>=size) return NULL;
strcat(fullname, suffix);
}
return fullname;
}
/*-------------------------------------------------------------------------
* Function: h5_fileaccess
*
* Purpose: Returns a file access template which is the default template
* but with a file driver set according to the constant or
* environment variable HDF5_DRIVER
*
* Return: Success: A file access property list
*
* Failure: -1
*
* Programmer: Robb Matzke
* Thursday, November 19, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
h5_fileaccess(void)
{
const char *val = NULL;
const char *name;
char s[1024];
hid_t fapl = -1;
hsize_t fam_size = 1024*1024;
/* First use the environment variable, then the constant */
val = getenv("HDF5_DRIVER");
#ifdef HDF5_DRIVER
if (!val) val = HDF5_DRIVER;
#endif
if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
if (!val || !*val) return fapl; /*use default*/
strncpy(s, val, sizeof s);
s[sizeof(s)-1] = '\0';
if (NULL==(name=strtok(s, " \t\n\r"))) return fapl;
if (!strcmp(name, "sec2")) {
/* Unix read() and write() system calls */
if (H5Pset_sec2(fapl)<0) return -1;
} else if (!strcmp(name, "stdio")) {
/* C standard I/O library */
if (H5Pset_stdio(fapl)<0) return -1;
} else if (!strcmp(name, "core")) {
/* In-core temporary file with 1MB increment */
if (H5Pset_core(fapl, 1024*1024)<0) return -1;
} else if (!strcmp(name, "split")) {
/* Split meta data and raw data each using default driver */
if (H5Pset_split(fapl, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT)<0)
return -1;
} else if (!strcmp(name, "family")) {
/* Family of files, each 1MB and using the default driver */
if ((val=strtok(NULL, " \t\n\r"))) {
fam_size = strtod(val, NULL) * 1024*1024;
}
if (H5Pset_family(fapl, fam_size, H5P_DEFAULT)<0) return -1;
} else {
/* Unknown driver */
return -1;
}
return fapl;
}
/*-------------------------------------------------------------------------
* Function: h5_no_hwconv
*
* Purpose: Turn off hardware data type conversions.
*
* Return: void
*
* Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
h5_no_hwconv(void)
{
H5Tunregister(H5T_conv_char_uchar);
H5Tunregister(H5T_conv_char_short);
H5Tunregister(H5T_conv_char_ushort);
H5Tunregister(H5T_conv_char_int);
H5Tunregister(H5T_conv_char_uint);
H5Tunregister(H5T_conv_char_long);
H5Tunregister(H5T_conv_char_ulong);
H5Tunregister(H5T_conv_uchar_char);
H5Tunregister(H5T_conv_uchar_short);
H5Tunregister(H5T_conv_uchar_ushort);
H5Tunregister(H5T_conv_uchar_int);
H5Tunregister(H5T_conv_uchar_uint);
H5Tunregister(H5T_conv_uchar_long);
H5Tunregister(H5T_conv_uchar_ulong);
H5Tunregister(H5T_conv_short_char);
H5Tunregister(H5T_conv_short_uchar);
H5Tunregister(H5T_conv_short_ushort);
H5Tunregister(H5T_conv_short_int);
H5Tunregister(H5T_conv_short_uint);
H5Tunregister(H5T_conv_short_long);
H5Tunregister(H5T_conv_short_ulong);
H5Tunregister(H5T_conv_ushort_char);
H5Tunregister(H5T_conv_ushort_uchar);
H5Tunregister(H5T_conv_ushort_short);
H5Tunregister(H5T_conv_ushort_int);
H5Tunregister(H5T_conv_ushort_uint);
H5Tunregister(H5T_conv_ushort_long);
H5Tunregister(H5T_conv_ushort_ulong);
H5Tunregister(H5T_conv_int_char);
H5Tunregister(H5T_conv_int_uchar);
H5Tunregister(H5T_conv_int_short);
H5Tunregister(H5T_conv_int_ushort);
H5Tunregister(H5T_conv_int_uint);
H5Tunregister(H5T_conv_int_long);
H5Tunregister(H5T_conv_int_ulong);
H5Tunregister(H5T_conv_uint_char);
H5Tunregister(H5T_conv_uint_uchar);
H5Tunregister(H5T_conv_uint_short);
H5Tunregister(H5T_conv_uint_ushort);
H5Tunregister(H5T_conv_uint_int);
H5Tunregister(H5T_conv_uint_long);
H5Tunregister(H5T_conv_uint_ulong);
H5Tunregister(H5T_conv_long_char);
H5Tunregister(H5T_conv_long_uchar);
H5Tunregister(H5T_conv_long_short);
H5Tunregister(H5T_conv_long_ushort);
H5Tunregister(H5T_conv_long_int);
H5Tunregister(H5T_conv_long_uint);
H5Tunregister(H5T_conv_long_ulong);
H5Tunregister(H5T_conv_ulong_char);
H5Tunregister(H5T_conv_ulong_uchar);
H5Tunregister(H5T_conv_ulong_short);
H5Tunregister(H5T_conv_ulong_ushort);
H5Tunregister(H5T_conv_ulong_int);
H5Tunregister(H5T_conv_ulong_uint);
H5Tunregister(H5T_conv_ulong_long);
H5Tunregister(H5T_conv_float_double);
H5Tunregister(H5T_conv_double_float);
}

69
test/h5test.h Normal file
View File

@ -0,0 +1,69 @@
/*
* Copyright © 1998 NCSA
* All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
* Friday, November 20, 1998
*
* Purpose: Test support stuff.
*/
#ifndef _H5TEST_H
#define _H5TEST_H
#undef NDEBUG
#include <hdf5.h>
#include <H5private.h>
#ifdef STDC_HEADERS
# include <signal.h>
#endif
#define H5T_PACKAGE
#include <H5Tpkg.h> /*to turn off hardware conversions*/
/*
* This array should contain a list of file base names created by the test.
* The base name is a word like `test' which will have a prefix and suffix
* added to result in something like `ufs:/u/matzke/test.h5'
*/
extern const char *FILENAME[];
/*
* The name of the test is printed by saying TESTING("something") which will
* result in the string `Testing something' being flushed to standard output.
* If a test passes, fails, or is skipped then the PASSED(), FAILED(), or
* SKIPPED() macro should be called. After FAILED() or SKIPPED() the caller
* should print additional information to stdout indented by at least four
* spaces. If the h5_errors() is used for automatic error handling then
* the FAILED() macro is invoked automatically when an API function fails.
*/
#define TESTING(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
#define PASSED() puts(" PASSED")
#define FAILED() puts("*FAILED*")
#define SKIPPED() puts(" -SKIP-")
/*
* Print the current location on the standard output stream.
*/
#define AT() printf (" at %s:%d in %s()...\n", \
__FILE__, __LINE__, __FUNCTION__);
#ifdef __cplusplus
extern "C" {
#endif
void h5_cleanup(hid_t fapl);
void h5_cleanup(hid_t fapl);
herr_t h5_errors(void __unused__ *client_data);
char *h5_fixname(const char *basename, hid_t fapl, char *fullname,
size_t size);
hid_t h5_fileaccess(void);
void h5_no_hwconv(void);
void h5_reset(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -188,7 +188,7 @@ main (void)
* 1998-11-06 ptl
*/
printf ("I/O request size is %1.1fMB\n",
((double)((hssize_t)(size[0]*size[1])))/(1024.0*1024));
(double)(hssize_t)(size[0]*size[1])/1024.0*1024);
/* Open the files */
file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

View File

@ -10,7 +10,7 @@
/* See H5private.h for how to include headers */
#undef NDEBUG
#include <H5config.h>
#include <hdf5.h>
#ifdef STDC_HEADERS
# include <ctype.h>
@ -29,7 +29,9 @@
# include <unistd.h>
#endif
#include <hdf5.h>
#ifdef HAVE_IO_H
# include <io.h>
#endif
#ifndef HAVE_ATTRIBUTE
# undef __attribute__
@ -244,14 +246,14 @@ test(fill_t fill_style, const double splits[],
if (verbose) {
if (H5Fflush(file, H5F_SCOPE_LOCAL)<0) goto error;
if (fstat(fd, &sb)<0) goto error;
/*
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
printf("%4lu %8.3f\n",
printf("%4lu %8.3f ***\n",
(unsigned long)i,
(double)((hssize_t)((sb.st_size-i*sizeof(int))/i)));
(double)(hssize_t)(sb.st_size-i*sizeof(int))/(hssize_t)i);
}
}
@ -282,14 +284,14 @@ test(fill_t fill_style, const double splits[],
abort();
}
if (fstat(fd, &sb)<0) goto error;
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
printf("%-7s %8.3f\n", sname,
(double)((hssize_t)((sb.st_size-cur_size[0]*sizeof(int))/cur_size[0])));
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
printf("%-7s %8.3f\n", sname,
(double)(hssize_t)(sb.st_size-cur_size[0]*sizeof(int))/
(hssize_t)cur_size[0]);
}
close(fd);
return 0;

View File

@ -8,8 +8,13 @@
/* See H5private.h for how to include headers */
#undef NDEBUG
#include <hdf5.h>
#include <H5private.h> /*for performance monitoring*/
#ifdef STDC_HEADERS
# include <signal.h>
#endif
#define NOTIFY_INTERVAL 2 /*seconds*/
#define TIME_LIMIT 60 /*seconds*/
#define CH_SIZE 8192*8 /*approx chunk size in bytes*/
@ -242,7 +247,7 @@ ragged_write_all(hid_t ra, hsize_t rows_at_once)
* 1998-11-06 ptl
*/
H5_bandwidth(s,
(double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
(double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s%s\n",
(unsigned long)(row+i), (unsigned long)total_nelmts,
@ -261,7 +266,7 @@ ragged_write_all(hid_t ra, hsize_t rows_at_once)
* the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
H5_bandwidth(s, (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s\n",
(unsigned long)row, (unsigned long)total_nelmts,
@ -375,8 +380,7 @@ ragged_read_all(hid_t ra, hsize_t rows_at_once)
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
H5_bandwidth(s,
(double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s%s\n",
(unsigned long)(row+i), (unsigned long)total_nelmts,
@ -403,7 +407,7 @@ ragged_read_all(hid_t ra, hsize_t rows_at_once)
* the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
H5_bandwidth(s, (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s\n",
(unsigned long)row, (unsigned long)total_nelmts,
@ -540,7 +544,7 @@ ragged_read_short(hid_t ra, hsize_t rows_at_once, hsize_t width)
* 1998-11-06 ptl
*/
H5_bandwidth(s,
(double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
(double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s%s\n",
(unsigned long)(row+i), (unsigned long)read_nelmts,
@ -567,7 +571,7 @@ ragged_read_short(hid_t ra, hsize_t rows_at_once, hsize_t width)
* the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
H5_bandwidth(s, (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s\n",
(unsigned long)row, (unsigned long)read_nelmts,
@ -579,7 +583,7 @@ ragged_read_short(hid_t ra, hsize_t rows_at_once, hsize_t width)
* Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
H5_bandwidth(s, (double)((hssize_t)read_nelmts)*sizeof(C_MTYPE),
H5_bandwidth(s, (double)(hssize_t)read_nelmts*sizeof(C_MTYPE),
timer_total.etime);
printf(" %27s%10s\n", "", s);