OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

error.h
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 */
18
19 #ifndef OPAL_UTIL_ERROR_H
20 #define OPAL_UTIL_ERROR_H
21
22 #include "opal_config.h"
23
24 #include "opal/util/output.h"
25
26 BEGIN_C_DECLS
27
28 #define OPAL_ERROR_LOG(r) \
29 opal_output(0, "OPAL ERROR: %s in file %s at line %d", \
30 opal_strerror((r)), __FILE__, __LINE__);
31
32
33 /**
34 * Prints error message for errnum on stderr
35 *
36 * Print the error message corresponding to the value of \c errnum and
37 * writes it, followed by a newline, to the standard error file
38 * descriptor. If the argument \c msg is non-NULL, this string is
39 * prepended to the message string and separated from it by a colon
40 * and a space. Otherwise, only the error message string is printed.
41 *
42 * If errnum is OPAL_ERR_IN_ERRNO, the system perror is called with
43 * the argument \c msg.
44 */
45 OPAL_DECLSPEC void opal_perror(int errnum, const char *msg);
46
47 /**
48 * Return string for given error message
49 *
50 * Accepts an error number argument \c errnum and returns a pointer to
51 * the corresponding message string. The result is returned in a
52 * static buffer that should not be released with free().
53 *
54 * If errnum is \c OPAL_ERR_IN_ERRNO, the system strerror is called
55 * with an argument of the current value of \c errno and the resulting
56 * string is returned.
57 *
58 * If the errnum is not a known value, the returned value may be
59 * overwritten by subsequent calls to opal_strerror.
60 */
61 OPAL_DECLSPEC const char *opal_strerror(int errnum);
62
63 /**
64 * Return string for given error message
65 *
66 * Similar to opal_strerror, but a buffer is passed in which is filled
67 * with a string (up to buflen - 1 characters long) containing the
68 * error message corresponding to \c errnum. Unlike opal_strerror(),
69 * if an unknown value for \c errnum is passed, the returned buffer
70 * will not be overwritten by subsequent calls to opal_strerror_r().
71 */
72 OPAL_DECLSPEC int opal_strerror_r(int errnum, char *strerrbuf, size_t buflen);
73
74
75 typedef int (*opal_err2str_fn_t)(int errnum, const char **str);
76
77 /**
78 * \internal
79 *
80 * Register a handler for converting errnums to error strings
81 *
82 * Handlers will be invoked by opal_perror() , opal_strerror(), and
83 * opal_strerror_r() to return the appropriate values.
84 *
85 * \note A maximum of 5 converters can be registered. The 6th
86 * converter registration attempt will return OPAL_ERR_OUT_OF_RESOURCE
87 */
88 OPAL_DECLSPEC int opal_error_register(const char *project,
89 int err_base, int err_max,
90 opal_err2str_fn_t converter);
91
92 END_C_DECLS
93
94 #endif /* OPAL_UTIL_ERROR_H */
output.h
OPAL output stream facility.