[svn-r15208] Description:

Add a "HDcompile_assert" macro for assertions that can/should be checked
at compile time, as opposed to run time.  (And used it for a couple of simple
cases, to begin)

Tested on:
        FreeBSD/32 6.2 (duty) in debug mode
        FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
        Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
                                in debug mode
        Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
                                in production mode
        Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
                                in production mode
        Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
                                w/szip filter, in production mode
        Mac OS X/32 10.5.3 (amazon) in debug mode
        Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
This commit is contained in:
Quincey Koziol 2008-06-12 12:51:58 -05:00
parent 5ad6d8c34c
commit 97e6dc5d87
2 changed files with 9 additions and 6 deletions

View File

@ -1036,12 +1036,12 @@ H5D_istore_idx_iterate_cb(H5F_t UNUSED *f, hid_t UNUSED dxpl_id,
FUNC_ENTER_NOAPI_NOINIT(H5D_istore_idx_iterate_cb)
/* Sanity check for memcpy() */
HDassert(offsetof(H5D_chunk_rec_t, nbytes) == offsetof(H5D_istore_key_t, nbytes));
HDassert(sizeof(chunk_rec.nbytes) == sizeof(lt_key->nbytes));
HDassert(offsetof(H5D_chunk_rec_t, offset) == offsetof(H5D_istore_key_t, offset));
HDassert(sizeof(chunk_rec.offset) == sizeof(lt_key->offset));
HDassert(offsetof(H5D_chunk_rec_t, filter_mask) == offsetof(H5D_istore_key_t, filter_mask));
HDassert(sizeof(chunk_rec.filter_mask) == sizeof(lt_key->filter_mask));
HDcompile_assert(offsetof(H5D_chunk_rec_t, nbytes) == offsetof(H5D_istore_key_t, nbytes));
HDcompile_assert(sizeof(chunk_rec.nbytes) == sizeof(lt_key->nbytes));
HDcompile_assert(offsetof(H5D_chunk_rec_t, offset) == offsetof(H5D_istore_key_t, offset));
HDcompile_assert(sizeof(chunk_rec.offset) == sizeof(lt_key->offset));
HDcompile_assert(offsetof(H5D_chunk_rec_t, filter_mask) == offsetof(H5D_istore_key_t, filter_mask));
HDcompile_assert(sizeof(chunk_rec.filter_mask) == sizeof(lt_key->filter_mask));
/* Compose generic chunk record for callback */
HDmemcpy(&chunk_rec, lt_key, sizeof(*lt_key));

View File

@ -1881,6 +1881,9 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
#define H5_GLUE(x,y) x##y
#define H5_GLUE3(x,y,z) x##y##z
/* Compile-time "assert" macro */
#define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0)
/* Private functions, not part of the publicly documented API */
H5_DLL herr_t H5_init_library(void);
H5_DLL void H5_term_library(void);