2005-08-22 07:05:39 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-23 04:29:35 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-08-22 07:05:39 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPAL_UTIL_ERROR_H
|
|
|
|
#define OPAL_UTIL_ERROR_H
|
|
|
|
|
2009-03-17 04:45:19 +03:00
|
|
|
#include "opal_config.h"
|
|
|
|
|
2011-05-08 18:45:16 +04:00
|
|
|
#include "opal/util/output.h"
|
|
|
|
|
2009-08-20 15:42:18 +04:00
|
|
|
BEGIN_C_DECLS
|
2006-08-23 04:29:35 +04:00
|
|
|
|
2011-05-08 18:45:16 +04:00
|
|
|
#define OPAL_ERROR_LOG(r) \
|
|
|
|
opal_output(0, "OPAL ERROR: %s in file %s at line %d", \
|
|
|
|
opal_strerror((r)), __FILE__, __LINE__);
|
|
|
|
|
|
|
|
|
2005-08-22 07:05:39 +04:00
|
|
|
/**
|
|
|
|
* Prints error message for errnum on stderr
|
|
|
|
*
|
|
|
|
* Print the error message corresponding to the value of \c errnum and
|
|
|
|
* writes it, followed by a newline, to the standard error file
|
|
|
|
* descriptor. If the argument \c msg is non-NULL, this string is
|
|
|
|
* prepended to the message string and separated from it by a colon
|
|
|
|
* and a space. Otherwise, only the error message string is printed.
|
|
|
|
*
|
|
|
|
* If errnum is OPAL_ERR_IN_ERRNO, the system perror is called with
|
|
|
|
* the argument \c msg.
|
|
|
|
*/
|
2006-08-20 19:54:04 +04:00
|
|
|
OPAL_DECLSPEC void opal_perror(int errnum, const char *msg);
|
2005-08-22 07:05:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return string for given error message
|
|
|
|
*
|
|
|
|
* Accepts an error number argument \c errnum and returns a pointer to
|
|
|
|
* the corresponding message string. The result is returned in a
|
|
|
|
* static buffer that should not be released with free().
|
|
|
|
*
|
|
|
|
* If errnum is \c OPAL_ERR_IN_ERRNO, the system strerror is called
|
|
|
|
* with an argument of the current value of \c errno and the resulting
|
|
|
|
* string is returned.
|
|
|
|
*
|
|
|
|
* If the errnum is not a known value, the returned value may be
|
|
|
|
* overwritten by subsequent calls to opal_strerror.
|
|
|
|
*/
|
2006-08-20 19:54:04 +04:00
|
|
|
OPAL_DECLSPEC const char *opal_strerror(int errnum);
|
2005-08-22 07:05:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return string for given error message
|
|
|
|
*
|
|
|
|
* Similar to opal_strerror, but a buffer is passed in which is filled
|
|
|
|
* with a string (up to buflen - 1 characters long) containing the
|
|
|
|
* error message corresponding to \c errnum. Unlike opal_strerror(),
|
|
|
|
* if an unknown value for \c errnum is passed, the returned buffer
|
|
|
|
* will not be overwritten by subsequent calls to opal_strerror_r().
|
|
|
|
*/
|
2006-08-20 19:54:04 +04:00
|
|
|
OPAL_DECLSPEC int opal_strerror_r(int errnum, char *strerrbuf, size_t buflen);
|
2005-08-22 07:05:39 +04:00
|
|
|
|
|
|
|
|
2011-02-13 19:09:17 +03:00
|
|
|
typedef int (*opal_err2str_fn_t)(int errnum, const char **str);
|
2005-08-22 07:05:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
*
|
|
|
|
* Register a handler for converting errnums to error strings
|
|
|
|
*
|
|
|
|
* Handlers will be invoked by opal_perror() , opal_strerror(), and
|
|
|
|
* opal_strerror_r() to return the appropriate values.
|
|
|
|
*
|
|
|
|
* \note A maximum of 5 converters can be registered. The 6th
|
|
|
|
* converter registration attempt will return OPAL_ERR_OUT_OF_RESOURCE
|
|
|
|
*/
|
2006-08-20 19:54:04 +04:00
|
|
|
OPAL_DECLSPEC int opal_error_register(const char *project,
|
2005-08-30 03:36:53 +04:00
|
|
|
int err_base, int err_max,
|
|
|
|
opal_err2str_fn_t converter);
|
2005-08-22 07:05:39 +04:00
|
|
|
|
2009-08-20 15:42:18 +04:00
|
|
|
END_C_DECLS
|
2005-08-22 07:05:39 +04:00
|
|
|
|
|
|
|
#endif /* OPAL_UTIL_ERROR_H */
|