36 #ifdef __STDC_VERSION__
37 # if __STDC_VERSION__ < 199901L
38 # if defined(__GNUC__) && __GNUC__ >= 2
39 # define OPAL_SOS_FUNCTION __FUNCTION__
41 # define OPAL_SOS_FUNCTION "<unknown>"
44 # define OPAL_SOS_FUNCTION __func__
47 # define OPAL_SOS_FUNCTION __func__
51 #define OPAL_SOS_ERR_BASE OPAL_SUCCESS
60 #define OPAL_SOS_ERR_TABLE_SIZE 512
66 #define OPAL_SOS_MAX_ERR_LEN 1024
81 #define OPAL_SOS_REPORT(severity, arg) opal_sos_reporter(__FILE__, __LINE__, \
84 opal_sos_build_error arg)
89 #define OPAL_SOS_EMERG(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_EMERG, arg)
94 #define OPAL_SOS_ALERT(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_ALERT, arg)
99 #define OPAL_SOS_CRIT(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_CRIT, arg)
105 #define OPAL_SOS_ERROR(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_ERROR, arg)
114 #define OPAL_SOS_WARN(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_WARN, arg)
119 #define OPAL_SOS_NOTICE(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_NOTICE,arg)
126 #define OPAL_SOS_INFO(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_INFO, arg)
131 #define OPAL_SOS_DEBUG(arg) OPAL_SOS_REPORT(OPAL_SOS_SEVERITY_DEBUG, arg)
138 #define OPAL_SOS_FREE(perrnum) opal_sos_free(perrnum)
148 #define OPAL_SOS_PRINT(errnum, show_history) \
149 opal_sos_print(errnum, show_history)
156 #define OPAL_SOS_ATTACH(errtgt, errnum) \
157 (errtgt = -((-errtgt & ~0xFF80000L) | \
158 ((OPAL_SOS_GET_INDEX(errnum) & 0x1FFL) * 0x80000L)))
163 #define OPAL_SOS_GET_ATTACHED_INDEX(errnum) ((int) ((-errnum & 0xFF80000L) >> 19))
169 #define OPAL_SOS_GET_ERROR_CODE(errnum) \
170 ((errnum >= 0) ? errnum : (int) -(-errnum & 0x3FFL))
178 #define OPAL_SOS_SET_ERROR_CODE(errnum, nativeerr) \
179 (errnum = -((-errnum & ~0x3FFL) | (-nativeerr & 0x3FFL)))
185 #define OPAL_SOS_IS_NATIVE(errnum) ((-errnum & ~0x3FFL) == 0)
192 #define OPAL_SOS_GET_SEVERITY(errnum) ((int)((-errnum >> 28) & 0x7L))
200 #define OPAL_SOS_SET_SEVERITY(errnum, severity) \
201 (errnum = -((-errnum & ~0x70000000L) | ((severity & 0x7L) * 0x10000000L)))
210 #define OPAL_SOS_SEVERITY2STR(severity) opal_sos_severity2str(severity)
218 #define OPAL_SOS_LOG(errnum) opal_sos_log(errnum)
227 #define OPAL_SOS_GET_INDEX(errnum) ((int)((-errnum & 0x7FC00L) >> 10))
233 #define OPAL_SOS_SET_INDEX(errnum, index) \
234 (errnum = -((-errnum & ~0x7FC00L) | ((index & 0x1FFL) * 0x400L)))
240 OPAL_DECLSPEC
extern bool opal_sos_print_low;
244 OPAL_SOS_SEVERITY_EMERG = LOG_EMERG,
245 OPAL_SOS_SEVERITY_ALERT = LOG_ALERT,
246 OPAL_SOS_SEVERITY_CRIT = LOG_CRIT,
247 OPAL_SOS_SEVERITY_ERROR = LOG_ERR,
248 OPAL_SOS_SEVERITY_WARN = LOG_WARNING,
249 OPAL_SOS_SEVERITY_NOTICE = LOG_NOTICE,
250 OPAL_SOS_SEVERITY_INFO = LOG_INFO,
251 OPAL_SOS_SEVERITY_DEBUG = LOG_DEBUG
252 } opal_sos_severity_t;
294 typedef void (*opal_sos_print_callback_fn_t) (
int errcode);
299 typedef void (*opal_sos_reporter_callback_fn_t) (opal_sos_severity_t severity,
int errcode,
300 const char *msg, ...)
301 __opal_attribute_format_funcptr__(__printf__, 3, 4);
326 void opal_sos_init(
void);
336 void opal_sos_finalize(
void);
360 opal_sos_build_error(
int errnum,
bool show_stack,
361 const char *errmsg, ...)
362 __opal_attribute_format_funcptr__(__printf__, 3, 4);
377 OPAL_DECLSPEC
int opal_sos_reporter(const
char *file,
int line, const
char *func,
378 opal_sos_severity_t severity,
388 OPAL_DECLSPEC
void opal_sos_print(
int errnum,
bool show_history);
390 OPAL_DECLSPEC
int opal_sos_prettify_error(const
char *error,
char **pretty_error);
396 OPAL_DECLSPEC
void opal_sos_print_error(opal_sos_severity_t severity,
397 int errnum, const
char *errmsg, ...)
398 __opal_attribute_format_funcptr__(__printf__, 3, 4);
403 OPAL_DECLSPEC
void opal_sos_free(
int *errnum);
408 OPAL_DECLSPEC
void opal_sos_log(
int errnum);
414 const
char *opal_sos_severity2str(opal_sos_severity_t severity);
428 opal_sos_reg_print_callback(opal_sos_print_callback_fn_t new_func,
429 opal_sos_print_callback_fn_t *prev_func);
436 opal_sos_reg_reporter_callback(opal_sos_reporter_callback_fn_t new_func,
437 opal_sos_reporter_callback_fn_t *prev_func);
Definition: opal_hash_table.h:42
char * msg
The actual error message or string for the error indicated by errnum.
Definition: opal_sos.h:279
OPAL output stream facility.
char * file
File in which the error occured.
Definition: opal_sos.h:268
char * func
This is an optional parameter that indicates the function in which the error occured.
Definition: opal_sos.h:275
Definition: opal_sos.h:254
Definition: mutex_unix.h:53
int errnum
The encoded error code for a given type of error.
Definition: opal_sos.h:265
A hash table that may be indexed with either fixed length (e.g.
Base object.
Definition: opal_object.h:182
int prev
Encoded error numbers of the previous and the next error.
Definition: opal_sos.h:285
opal_object_t super
Class parent.
Definition: opal_sos.h:256
int line
Line number on which the error was encountered.
Definition: opal_sos.h:271
Mutual exclusion functions.
A simple C-language object-oriented system with single inheritance and ownership-based memory managem...
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236