27 #include <lal/LALAtomicDatatypes.h> 28 #include <lal/LALString.h> 30 #if defined(__cplusplus) 165 int XLALPrintInfo(const
char *fmt, ...) _LAL_GCC_PRINTF_FORMAT_(1,2);
174 int XLALVPrintInfo(const
char *fmt, va_list
ap) _LAL_GCC_VPRINTF_FORMAT_(1);
188 const
char *fmt, ...) _LAL_GCC_PRINTF_FORMAT_(4,5);
195 const
char *fmt, ...) _LAL_GCC_PRINTF_FORMAT_(4,5);
202 const
char *fmt, ...) _LAL_GCC_PRINTF_FORMAT_(4,5);
209 const
char *fmt, va_list
ap) _LAL_GCC_VPRINTF_FORMAT_(4);
216 const
char *fmt, va_list
ap) _LAL_GCC_VPRINTF_FORMAT_(4);
223 const
char *fmt, va_list
ap) _LAL_GCC_VPRINTF_FORMAT_(4);
229 #define XLAL_PRINT_DEPRECATION_WARNING(replacement) \ 231 static int _xlal_print_deprecation_warning_ = 1; \ 232 if (_xlal_print_deprecation_warning_) { \ 234 "\nDEPRECATION WARNING: program has invoked obsolete function %s(). " \ 235 "Please see %s() for information about a replacement.\n", \ 236 __func__, replacement); \ 237 _xlal_print_deprecation_warning_ = 0; \ 258 #define XLAL_PRINT_ERROR(...) \ 259 XLALPrintErrorMessage(__func__, __FILE__, __LINE__, __VA_ARGS__) 271 #define XLAL_PRINT_WARNING(...) \ 272 XLALPrintWarningMessage(__func__, __FILE__, __LINE__, __VA_ARGS__) 284 #define XLAL_PRINT_INFO(...) \ 285 XLALPrintInfoMessage(__func__, __FILE__, __LINE__, __VA_ARGS__) 313 #define XLAL_REAL4_FAIL_NAN_INT 0x7fc001a1 314 #define XLAL_REAL8_FAIL_NAN_INT LAL_INT8_C(0x7ff80000000001a1) 326 volatile const union {
338 volatile const union {
350 volatile const union {
361 for (n = 0; n <
sizeof(val); ++n)
362 if (
a.s[n] !=
b.s[n])
371 volatile const union {
382 for (n = 0; n <
sizeof(val); ++n)
383 if (
a.s[n] !=
b.s[n])
389 #define XLAL_REAL4_FAIL_NAN ( XLALREAL4FailNaN() ) 390 #define XLAL_REAL8_FAIL_NAN ( XLALREAL8FailNaN() ) 393 #define XLAL_IS_REAL4_FAIL_NAN(val) XLALIsREAL4FailNaN(val) 394 #define XLAL_IS_REAL8_FAIL_NAN(val) XLALIsREAL8FailNaN(val) 483 void XLALPerror(
const char *func,
const char *file,
int line,
int errnum);
486 #define XLAL_PERROR( ) XLALPerror(__func__, __FILE__, __LINE__, xlalErrno) 498 int line,
int errnum);
516 int line,
int errnum);
572 #define xlalErrno ( * XLALGetErrnoPtr() ) 573 #define XLALErrorHandler ( * XLALGetErrorHandlerPtr() ) 583 #define XLAL_TRY( statement, errnum ) \ 585 XLALErrorHandlerType *xlalSaveErrorHandler; \ 587 xlalSaveErrorHandler = XLALSetSilentErrorHandler(); \ 588 xlalSaveErrno = xlalErrno; \ 591 errnum = xlalErrno; \ 592 xlalErrno = xlalSaveErrno; \ 593 XLALSetErrorHandler(xlalSaveErrorHandler); \ 601 #define XLAL_TRY_SILENT( statement, errnum ) \ 603 int xlalSaveDebugLevel = lalDebugLevel; \ 604 XLALClobberDebugLevel(xlalSaveDebugLevel & ~(LALERRORBIT | LALWARNINGBIT | LALINFOBIT | LALTRACEBIT)); \ 605 XLAL_TRY(statement, errnum); \ 606 XLALClobberDebugLevel(xlalSaveDebugLevel); \ 646 #define _XLAL_ERROR_IMPL_(statement, errnum, ...) \ 648 char _XLAL_ERROR_IMPL_buf_[1024]; \ 649 XLALStringPrint(_XLAL_ERROR_IMPL_buf_, sizeof(_XLAL_ERROR_IMPL_buf_), "X" __VA_ARGS__); \ 650 if (_XLAL_ERROR_IMPL_buf_[1] != 0) { \ 651 XLAL_PRINT_ERROR("%s", &_XLAL_ERROR_IMPL_buf_[1]); \ 653 XLALError(__func__, __FILE__, __LINE__, errnum); \ 657 #define _XLAL_CHECK_IMPL_(statement, assertion, errnum, ...) \ 659 if (!(assertion)) { \ 660 char _XLAL_CHECK_IMPL_buf_[1024]; \ 661 XLALStringPrint(_XLAL_CHECK_IMPL_buf_, sizeof(_XLAL_CHECK_IMPL_buf_), "X" __VA_ARGS__); \ 662 if (_XLAL_CHECK_IMPL_buf_[1] != 0) { \ 663 XLAL_PRINT_ERROR("%s", &_XLAL_CHECK_IMPL_buf_[1]); \ 665 XLAL_PRINT_ERROR("Check failed: %s", #assertion); \ 667 XLALError(__func__, __FILE__, __LINE__, errnum); \ 688 #define XLAL_ERROR_VAL(val, ...) _XLAL_ERROR_IMPL_(return val, __VA_ARGS__) 701 #define XLAL_ERROR(...) _XLAL_ERROR_IMPL_(return (int)XLAL_FAILURE, __VA_ARGS__) 714 #define XLAL_ERROR_NULL(...) _XLAL_ERROR_IMPL_(return NULL, __VA_ARGS__) 727 #define XLAL_ERROR_VOID(...) _XLAL_ERROR_IMPL_(return, __VA_ARGS__) 740 #define XLAL_ERROR_REAL4(...) _XLAL_ERROR_IMPL_(return XLAL_REAL4_FAIL_NAN, __VA_ARGS__) 753 #define XLAL_ERROR_REAL8(...) _XLAL_ERROR_IMPL_(return XLAL_REAL8_FAIL_NAN, __VA_ARGS__) 766 #define XLAL_ERROR_MAIN(...) _XLAL_ERROR_IMPL_(return EXIT_FAILURE, __VA_ARGS__) 779 #define XLAL_ERROR_FAIL(...) _XLAL_ERROR_IMPL_(goto XLAL_FAIL, __VA_ARGS__) 796 #define XLAL_CHECK_VAL(val, assertion, ...) _XLAL_CHECK_IMPL_(return val, assertion, __VA_ARGS__) 811 #define XLAL_CHECK(assertion, ...) _XLAL_CHECK_IMPL_(return (int)XLAL_FAILURE, assertion, __VA_ARGS__) 826 #define XLAL_CHECK_NULL(assertion, ...) _XLAL_CHECK_IMPL_(return NULL, assertion, __VA_ARGS__) 841 #define XLAL_CHECK_VOID(assertion, ...) _XLAL_CHECK_IMPL_(return, assertion, __VA_ARGS__) 856 #define XLAL_CHECK_REAL4(assertion, ...) _XLAL_CHECK_IMPL_(return XLAL_REAL4_FAIL_NAN, assertion, __VA_ARGS__) 871 #define XLAL_CHECK_REAL8(assertion, ...) _XLAL_CHECK_IMPL_(return XLAL_REAL8_FAIL_NAN, assertion, __VA_ARGS__) 886 #define XLAL_CHECK_MAIN(assertion, ...) _XLAL_CHECK_IMPL_(return EXIT_FAILURE, assertion, __VA_ARGS__) 901 #define XLAL_CHECK_FAIL(assertion, ...) _XLAL_CHECK_IMPL_(goto XLAL_FAIL, assertion, __VA_ARGS__) 911 #elif defined(__cplusplus) void XLALDefaultErrorHandler(const char *func, const char *file, int line, int errnum)
The default XLAL error handler.
Failure return value (not an error number)
XLALErrorHandlerType ** XLALGetErrorHandlerPtr(void)
Function to return pointer to the XLAL error handler function pointer.
int XLALGetBaseErrno(void)
Gets the XLAL base error number ignoring the internal-function-failed flag.
IEEE Floating point overflow error.
static _LAL_INLINE_ REAL4 XLALREAL4FailNaN(void)
Returns the value of the XLAL REAL4 failure NaN.
static _LAL_INLINE_ int XLALIsREAL8FailNaN(REAL8 val)
Tests if a value is an XLAL REAL8 failure NaN.
XLALErrorHandlerType * XLALSetSilentErrorHandler(void)
Sets the error handler to a silent handler and returns the old handler.
void void void void XLALVPrintErrorMessage(const char *func, const char *file, int line, const char *fmt, va_list ap) _LAL_GCC_VPRINTF_FORMAT_(4)
Print an error message with standard XLAL formatting (if error messages are enabled by lalDebugLevel)...
void XLALErrorHandlerType(const char *func, const char *file, int line, int errnum)
The XLAL error handler type.
void XLALSilentErrorHandler(const char *func, const char *file, int line, int errnum)
A silent XLAL error handler.
void XLALVPrintWarningMessage(const char *func, const char *file, int line, const char *fmt, va_list ap) _LAL_GCC_VPRINTF_FORMAT_(4)
Print an warning message with standard XLAL formatting (if warning messages are enabled by lalDebugLe...
Apparent singularity detected.
void XLALError(const char *func, const char *file, int line, int errnum)
Routine to set the XLAL error number and invoke the XLAL error handler.
#define XLAL_REAL4_FAIL_NAN_INT
Hexadecimal representation of REAL4 NaN failure bit pattern.
XLALErrorValue
XLAL error numbers and return values.
int XLALVPrintWarning(const char *fmt, va_list ap) _LAL_GCC_VPRINTF_FORMAT_(1)
Prints a warning message if warning printing is enabled by lalDebugLevel.
int * XLALGetErrnoPtr(void)
Function to return pointer to the XLAL error number.
int XLALVPrintInfo(const char *fmt, va_list ap) _LAL_GCC_VPRINTF_FORMAT_(1)
Prints an info message if info printing is enabled by lalDebugLevel.
const char * XLALErrorString(int errnum)
Returns the error message associated with an error number.
float REAL4
Single precision real floating-point number (4 bytes).
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
Sets the error handler to a new handler and returns the old handler.
void XLALPrintErrorMessage(const char *func, const char *file, int line, const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(4
Print an error message with standard XLAL formatting (if error messages are enabled by lalDebugLevel)...
void void XLALPrintWarningMessage(const char *func, const char *file, int line, const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(4
Print an warning message with standard XLAL formatting (if warning messages are enabled by lalDebugLe...
IEEE Division by zero floating point error.
IEEE Floating point inexact error.
IEEE Invalid floating point operation, eg sqrt(-1), 0/0.
int XLALClearErrno(void)
Clears the XLAL error number, returns the old value.
#define XLAL_REAL8_FAIL_NAN_INT
Hexadecimal representation of REAL8 NaN failure bit pattern.
XLALErrorHandlerType * XLALSetDefaultErrorHandler(void)
Sets the error handler to the default handler and returns the old handler.
int XLALSetErrno(int errnum)
Sets the XLAL error number to errnum, returns the new value.
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
Prints a warning message if warning printing is enabled by lalDebugLevel.
static _LAL_INLINE_ int XLALIsREAL4FailNaN(REAL4 val)
Tests if a value is an XLAL REAL4 failure NaN.
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that raises SIGABRT.
Function not implemented.
double REAL8
Double precision real floating-point number (8 bytes).
IEEE Floating point underflow error.
void void void XLALPrintInfoMessage(const char *func, const char *file, int line, const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(4
Print an info message with standard XLAL formatting (if info messages are enabled by lalDebugLevel)...
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
Prints an error message if error printing is enabled by lalDebugLevel.
Success return value (not an error number)
Failed to reach specified tolerance.
int XLALPrintProgressBar(double)
Prints a progress bar at the "info" verbosity level.
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
Prints an info message if info printing is enabled by lalDebugLevel.
void XLALBacktraceErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that prints a function call backtrace then raises SIGABRT. ...
void XLALExitErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that calls exit.
int int int int XLALVPrintError(const char *fmt, va_list ap) _LAL_GCC_VPRINTF_FORMAT_(1)
Prints an error message if error printing is enabled by lalDebugLevel.
Exceeded maximum number of iterations.
int32_t INT4
Four-byte signed integer.
void XLALVPrintInfoMessage(const char *func, const char *file, int line, const char *fmt, va_list ap) _LAL_GCC_VPRINTF_FORMAT_(4)
Print an error message with standard XLAL formatting (if error messages are enabled by lalDebugLevel)...
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
Internal function call failed bit: "or" this with existing error number.
No such file or directory.
#define _LAL_GCC_PRINTF_FORMAT_(NFMT, NARG)
void XLALPerror(const char *func, const char *file, int line, int errnum)
Prints an error message for a particular error code in a standard format.
static _LAL_INLINE_ REAL8 XLALREAL8FailNaN(void)
Returns the value of the XLAL REAL8 failure NaN.
Inconsistent or invalid length.
#define _LAL_GCC_VPRINTF_FORMAT_(NFMT)