* Normalization with develop * Removes checks and work-arounds for strtoll and strtoull (#769) * Removes checks for (v)snprintf, which are C99 (#772) * Update missing release note info. (#776) * Replaces the H5_OVERRIDE macro with override (#773) The macro is no longer necessary now that we require C++11. * Cleans up some POSIX header bits in H5private.h (#783) * Removes outdated checks for ways inline might be defined (#781) These are obsolete now that we require C99. * Removes checks for system(), which is C89/90 (#782) * Removes C++ dependency on H5private.h (#774) * Removes C++ dependency on H5private.h Most C API calls have been removed, aside from a few uses of free, where we just dropped the 'HD'. A couple of H5_ATTR_UNUSED macros were also replaced with (void) statements. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Further simplifies Autotools type size checks (#789) Also fixes an issue where clock_gettime and difftime are not detected due to earlier simplifications of this code. * Release Note (#784) * Normalization of CMake H5pubconf.h with Autotools (#791) Mostly just moving things around and changing the comments to keep the delta small. The only symbol change is that for curl/curl.h which I changed to H5_HAVE_CURL_CURL_H to match the Autotools. This symbol is not used in the library and is just an artifact of the checks. * Fix tools test (#794) * Removes ancient Autotools cruft (#790) * Reorganization of C and POSIX headers in H5public.h & H5private.h (#793) * Reorganization of C and POSIX headers in H5public.h & H5private.h Consolidated and removed duplicates * It turns out Windows has sys/types.h Co-authored-by: Larry Knox <lrknox@hdfgroup.org> * Removes checks for signal and set/longjmp, which are C89 (#798) Also removes checks for setjmp.h and stddef.h * Assume frexpl/f and fabsl/f, which are C99 (#799) * Assume the library has C99 types in C++ type code (#806) * Assume the library has C99 types in C++ type code * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes obsolete equivalents of C99's __func__ (#800) * Cleans up POSIX/C bits in H5private.h (#804) * Cleans up POSIX/C bits in H5private.h * Assume difftime exists (C89) * Reorg AC_CHECK_HEADERS so headers are in alphabetical order * Split off networking-related AC_CHECK_HEADERS * Remove unused UNAME_CYGWIN from configure.ac * Remove checks for unused sys/timeb.h * Tidying pass over H5private.h HD prefix macros * Tidy H5win32defs.h * Add HD prefix to various scanf calls * Committing clang-format changes * Fixes to the alarm(2) code used in the tests to make Windows happy Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Brings the tools getopt(3) replacement into the main library (#803) * Moves get_option from the tools library to the C library * Adds H5 prefix to get_option call and variables * Renames the H5_get_option long options struct and enum * Removes type guesses when C99 types are missing (#807) * Assume C99 types exist in H5detect.c (#808) * Fixes parallel issues from recent C99 changes * Adds MPE FUNC --> __func__ changes missed in earlier PRs * Fix typo * Fixes parallel issues from recent C99 changes (#809) * Fixes parallel issues from recent C99 changes * Adds MPE FUNC --> __func__ changes missed in earlier PRs * Even more missed FUNC --> __func__ macros * Removes remaining H5_TIME_WITH_SYS_TIME cruft (#810) Mostly from CMake Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
246 lines
17 KiB
C
246 lines
17 KiB
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* Copyright by The HDF Group. *
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
* All rights reserved. *
|
|
* *
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
* the COPYING file, which can be found at the root of the source code *
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
|
* If you do not have access to either file, you may request a copy from *
|
|
* help@hdfgroup.org. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
/*
|
|
* Header file for error values, etc.
|
|
*/
|
|
#ifndef H5TOOLS_ERROR_H
|
|
#define H5TOOLS_ERROR_H
|
|
|
|
#include "H5Epublic.h"
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
|
|
/* tools-HDF5 Error variables */
|
|
H5TOOLS_DLLVAR int H5tools_INDENT_g;
|
|
H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g;
|
|
H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g;
|
|
H5TOOLS_DLLVAR hid_t H5E_tools_g;
|
|
H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
|
|
H5TOOLS_DLLVAR hid_t H5E_tools_min_info_id_g;
|
|
H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
|
|
|
|
/*
|
|
* H5TOOLS_INIT_ERROR macro, used to initialize error reporting.
|
|
*/
|
|
#define H5TOOLS_INIT_ERROR() \
|
|
do { \
|
|
char lib_str[256]; \
|
|
\
|
|
/* Initialize library version string for error class */ \
|
|
HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); \
|
|
\
|
|
/* Create new HDF5 error stack for the tools to use */ \
|
|
if ((H5tools_ERR_STACK_g = H5Ecreate_stack()) < 0) \
|
|
HDfprintf(stderr, "Failed to create HDF5 tools error stack\n"); \
|
|
\
|
|
/* Register errors from the HDF5 tools as a new error class */ \
|
|
if ((H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str)) < 0) \
|
|
HDfprintf(stderr, "Failed to register HDF5 tools error class\n"); \
|
|
\
|
|
/* Create a new HDF5 major error message for errors from the tools library */ \
|
|
if ((H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library")) < 0) \
|
|
HDfprintf(stderr, "Failed to register major error message for tools library errors\n"); \
|
|
\
|
|
/* Create a new HDF5 minor error message for errors from the tools library */ \
|
|
if ((H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function")) < 0) \
|
|
HDfprintf(stderr, "Failed to register minor error message for tools library errors\n"); \
|
|
\
|
|
/* Create a new HDF5 minor error message for info messages from the tools library */ \
|
|
if ((H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info")) < 0) \
|
|
HDfprintf(stderr, "Failed to register minor error message for tools library info messages\n"); \
|
|
\
|
|
/* Create a new HDF5 minor error message for debug messages from the tools library */ \
|
|
if ((H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug")) < 0) \
|
|
HDfprintf(stderr, "Failed to register minor error message for tools library debug messages\n"); \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_CLOSE_ERROR macro, used to terminate error reporting.
|
|
*/
|
|
#define H5TOOLS_CLOSE_ERROR() \
|
|
do { \
|
|
/* Close all error messages created by H5TOOLS_INIT_ERROR() */ \
|
|
if (H5Eclose_msg(H5E_tools_min_dbg_id_g) < 0) \
|
|
HDfprintf(stderr, "Failed to close minor error message for tools library debug messages\n"); \
|
|
if (H5Eclose_msg(H5E_tools_min_info_id_g) < 0) \
|
|
HDfprintf(stderr, "Failed to close minor error message for tools library info messages\n"); \
|
|
if (H5Eclose_msg(H5E_tools_min_id_g) < 0) \
|
|
HDfprintf(stderr, "Failed to close minor error message for tools library errors\n"); \
|
|
if (H5Eclose_msg(H5E_tools_g) < 0) \
|
|
HDfprintf(stderr, "Failed to close major error message for tools library errors\n"); \
|
|
\
|
|
/* Unregister the HDF5 tools error class */ \
|
|
if (H5Eunregister_class(H5tools_ERR_CLS_g) < 0) \
|
|
HDfprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \
|
|
\
|
|
/* Close the tools error stack */ \
|
|
if (H5Eclose_stack(H5tools_ERR_STACK_g) < 0) \
|
|
HDfprintf(stderr, "Failed to close HDF5 tools error stack\n"); \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_PUSH_ERROR macro, used to push an error to an error stack. Not meant to
|
|
* be called directly.
|
|
*/
|
|
#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \
|
|
do { \
|
|
if (enable_error_stack > 0) { \
|
|
if (estack_id >= 0 && err_cls >= 0) \
|
|
H5Epush2(estack_id, __FILE__, __func__, __LINE__, err_cls, maj_err_id, min_err_id, \
|
|
__VA_ARGS__); \
|
|
else { \
|
|
HDfprintf(stderr, __VA_ARGS__); \
|
|
HDfprintf(stderr, "\n"); \
|
|
} \
|
|
} \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_ERROR macro, used to facilitate error reporting within a function body.
|
|
* The arguments are the return value and an error string. The return value is assigned
|
|
* to a variable `ret_value'. This macro is meant to be used for reporting an error without
|
|
* having control branch to the `done' label. This is often used when an error occurs
|
|
* after the `done' label, in which case an infinite loop would ensue if control branched
|
|
* backwards.
|
|
*/
|
|
#define H5TOOLS_ERROR(ret_val, ...) \
|
|
do { \
|
|
H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
|
|
__VA_ARGS__); \
|
|
ret_value = ret_val; \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_GOTO_ERROR macro, used to facilitate error reporting within a function body.
|
|
* The arguments are the return value and an error string. The return value is assigned
|
|
* to a variable `ret_value' and control branches to the `done' label.
|
|
*/
|
|
#define H5TOOLS_GOTO_ERROR(ret_val, ...) \
|
|
do { \
|
|
H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
|
|
__VA_ARGS__); \
|
|
H5TOOLS_GOTO_DONE(ret_val); \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_GOTO_DONE macro, used to facilitate normal return within a function body.
|
|
* The argument is the return value which is assigned to the `ret_value'
|
|
* variable. Control branches to the `done' label.
|
|
*/
|
|
#define H5TOOLS_GOTO_DONE(ret_val) \
|
|
do { \
|
|
ret_value = ret_val; \
|
|
goto done; \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_GOTO_DONE_NO_RET macro, used to facilitate normal return within a function body.
|
|
* Control simply branches to the `done' label without setting any return value.
|
|
*/
|
|
#define H5TOOLS_GOTO_DONE_NO_RET() \
|
|
do { \
|
|
goto done; \
|
|
} while (0)
|
|
|
|
/*
|
|
* H5TOOLS_INFO macro, used to facilitate error reporting. The arguments are
|
|
* a description of the error.
|
|
*/
|
|
#define H5TOOLS_INFO(...) \
|
|
do { \
|
|
H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_info_id_g, \
|
|
__VA_ARGS__); \
|
|
} while (0)
|
|
|
|
#ifdef H5_TOOLS_DEBUG
|
|
|
|
#define H5TOOLS_START_DEBUG(...) \
|
|
do { \
|
|
H5tools_INDENT_g += 2; \
|
|
HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
|
|
HDfprintf(stderr, __VA_ARGS__); \
|
|
HDfprintf(stderr, "\n"); \
|
|
HDfflush(stderr); \
|
|
} while (0)
|
|
|
|
#define H5TOOLS_DEBUG(...) \
|
|
do { \
|
|
HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
|
|
HDfprintf(stderr, __VA_ARGS__); \
|
|
HDfprintf(stderr, "\n"); \
|
|
HDfflush(stderr); \
|
|
} while (0)
|
|
|
|
#define H5TOOLS_ENDDEBUG(...) \
|
|
do { \
|
|
HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
|
|
HDfprintf(stderr, __VA_ARGS__); \
|
|
HDfprintf(stderr, "\n"); \
|
|
H5tools_INDENT_g -= 2; \
|
|
HDfflush(stderr); \
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define H5TOOLS_START_DEBUG(...) \
|
|
do { \
|
|
; \
|
|
} while (0)
|
|
|
|
#define H5TOOLS_DEBUG(...) \
|
|
do { \
|
|
; \
|
|
} while (0)
|
|
|
|
#define H5TOOLS_ENDDEBUG(...) \
|
|
do { \
|
|
; \
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
/* Macro for "catching" flow of control when an error occurs. Note that the
|
|
* H5_LEAVE macro won't jump back here once it's past this point.
|
|
*/
|
|
#define CATCH \
|
|
catch_except:; \
|
|
past_catch = TRUE;
|
|
|
|
/*
|
|
* H5_LEAVE macro, used to facilitate control flow in a function. The argument
|
|
* is the return value. The return value is assigned to a variable `ret_value'
|
|
* and control branches to the `catch_except' label, if we're not already past
|
|
* it.
|
|
*/
|
|
#define H5_LEAVE(v) \
|
|
{ \
|
|
ret_value = v; \
|
|
if (!past_catch) \
|
|
goto catch_except; \
|
|
}
|
|
|
|
/*
|
|
* H5TOOLS_THROW macro, used to facilitate error reporting within a function body.
|
|
* The arguments are the minor error number, and an error string.
|
|
* The return value is assigned to a variable `ret_value' and control branches
|
|
* to the `catch_except' label, if we're not already past it.
|
|
*/
|
|
#define H5TOOLS_THROW(ret_val, ...) \
|
|
do { \
|
|
H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
|
|
__VA_ARGS__); \
|
|
H5_LEAVE(ret_val) \
|
|
} while (0)
|
|
|
|
#endif /* H5TOOLS_ERROR_H */
|