29 #ifdef HAVE_EXECINFO_H 31 #define BACKTRACE_LEVELMAX 0100 34 #include <lal/XLALError.h> 35 #include <lal/LALStdlib.h> 38 #define UNUSED __attribute__ ((unused)) 105 const char *fmt, va_list
ap)
119 const char *fmt, va_list
ap)
133 const char *fmt, va_list
ap)
147 const char *fmt, ...)
157 const char *fmt, ...)
167 const char *fmt, ...)
183 static const char mrk[] =
184 "+++++++++++++++++++++++++++++++++++++++++++++++++)";
185 static const char spc[] =
186 "-------------------------------------------------)";
189 floor((fraction < 0.0 ? 0.0 : fraction >
190 1.0 ? 1.0 : fraction) * l + 0.5);
192 return XLALPrintInfo(
"[%s%s %.1f%%", mrk + l - offset, spc + offset,
203 #ifndef LAL_PTHREAD_LOCK 235 pthread_key_t xlalErrnoKey;
236 pthread_once_t xlalErrnoKeyOnce = PTHREAD_ONCE_INIT;
237 pthread_key_t xlalErrorHandlerKey;
238 pthread_once_t xlalErrorHandlerKeyOnce = PTHREAD_ONCE_INIT;
241 static void XLALDestroyErrnoPtr(
void *xlalErrnoPtr)
248 static void XLALDestroyErrorHandlerPtr(
void *xlalErrorHandlerPtr)
250 free(xlalErrorHandlerPtr);
255 static void XLALCreateErrnoKey(
void)
262 static void XLALCreateErrorHandlerKey(
void)
279 xlalErrnoPtr = malloc(
sizeof(*xlalErrnoPtr));
282 (
"could not set xlal error number: malloc failed\n");
287 (
"could not set xlal error number: pthread_setspecific failed\n");
298 pthread_once(&xlalErrorHandlerKeyOnce, XLALCreateErrorHandlerKey);
302 if (!xlalErrorHandlerPtr) {
303 xlalErrorHandlerPtr = malloc(
sizeof(*xlalErrorHandlerPtr));
304 if (!xlalErrorHandlerPtr)
306 (
"could not set xlal error handler: malloc failed\n");
307 *xlalErrorHandlerPtr = NULL;
311 (
"could not set xlal error handler: pthread_setspecific failed\n");
313 return xlalErrorHandlerPtr;
418 return "Unknown return code";
424 return "Internal function call failed";
428 # define XLAL_ERROR_STRING(s) \ 429 ( ( code & XLAL_EFUNC ) ? "Internal function call failed: " s : (const char *) s ) 508 (
"Invalid floating point operation, eg sqrt(-1), 0/0");
532 return "Unknown error";
534 # undef XLAL_ERROR_STRING 570 const char UNUSED *
file,
int UNUSED line,
616 int line,
int errnum)
619 #if defined(HAVE_BACKTRACE) && defined(BACKTRACE_LEVELMAX) 620 void *callstack[BACKTRACE_LEVELMAX];
621 size_t frames = backtrace(callstack, BACKTRACE_LEVELMAX);
622 fprintf(stderr,
"backtrace:\n");
623 backtrace_symbols_fd(callstack, frames, fileno(stderr));
void XLALDefaultErrorHandler(const char *func, const char *file, int line, int errnum)
The default XLAL error handler.
int XLALPrintWarning(const char *fmt,...)
void XLALPrintWarningMessage(const char *func, const char *file, int line, const char *fmt,...)
int pthread_key_create(pthread_key_t *key, destr_function destr)
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
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.
XLALErrorHandlerType * xlalErrorHandlerGlobal
XLALErrorHandlerType * XLALSetSilentErrorHandler(void)
Sets the error handler to a silent handler and returns the old handler.
void XLALVPrintErrorMessage(const char *func, const char *file, int line, const char *fmt, va_list ap)
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 XLALVPrintWarningMessage(const char *func, const char *file, int line, const char *fmt, va_list ap)
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 xlalErrno
Modifiable lvalue containing the XLAL error number.
int XLALVPrintWarning(const char *fmt, va_list ap)
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)
Prints an info message if info printing is enabled by lalDebugLevel.
const char * XLALErrorString(int code)
Returns the error message associated with an error number.
void XLALPrintErrorMessage(const char *func, const char *file, int line, const char *fmt,...)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
Sets the error handler to a new handler and returns the old handler.
void XLALPrintInfoMessage(const char *func, const char *file, int line, const char *fmt,...)
IEEE Division by zero floating point error.
IEEE Floating point inexact error.
IEEE Invalid floating point operation, eg sqrt(-1), 0/0.
int XLALPrintInfo(const char *fmt,...)
int XLALClearErrno(void)
Clears the XLAL error number, returns the old value.
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.
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that raises SIGABRT.
Function not implemented.
IEEE Floating point underflow error.
int XLALPrintError(const char *fmt,...)
Failed to reach specified tolerance.
int XLALPrintProgressBar(double fraction)
Prints a progress bar at the "info" verbosity level.
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(* lalAbortHook)(const char *,...)
void XLALExitErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that calls exit.
void * pthread_getspecific(pthread_key_t key)
int XLALVPrintError(const char *fmt, va_list ap)
Prints an error message if error printing is enabled by lalDebugLevel.
Exceeded maximum number of iterations.
void XLALVPrintInfoMessage(const char *func, const char *file, int line, const char *fmt, va_list ap)
Print an error message with standard XLAL formatting (if error messages are enabled by lalDebugLevel)...
int pthread_setspecific(pthread_key_t key, const void *pointer)
Internal function call failed bit: "or" this with existing error number.
No such file or directory.
void XLALPerror(const char *func, const char *file, int line, int code)
Prints an error message for a particular error code in a standard format.
#define XLAL_PRINT_WARNING(...)
Macro that will print a warning message with a standard format.
Inconsistent or invalid length.
#define XLALErrorHandler
Modifiable lvalue containing the XLAL error handler.
#define XLAL_ERROR_STRING(s)
void XLALSilentErrorHandler(const char UNUSED *func, const char UNUSED *file, int UNUSED line, int UNUSED errnum)
#define XLAL_NUM_ELEM(x)
MACRO which gives the number of elements in a fixed-size array.