source: rtems/cpukit/libcsupport/include/rtems/error.h @ bab16de2

4.115
Last change on this file since bab16de2 was bab16de2, checked in by Sebastian Huber <sebastian.huber@…>, on 02/07/14 at 08:53:47

score: Change debug helper functions

Rename rtems_internal_error_description() to
rtems_internal_error_text(). Rename rtems_fatal_source_description() to
rtems_fatal_source_text(). Rename rtems_status_code_description() to
rtems_status_text(). Remove previous implementation of
rtems_status_text().

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/**
2 * @file rtems/error.h
3 *
4 * @brief RTEMS Error Reporting
5 *
6 * Defines and externs for rtems error reporting
7 *
8 * These routines provide general purpose error reporting.
9 * rtems_error reports an error to stderr and allows use of
10 * printf style formatting.  A newline is appended to all messages.
11 *
12 * error_flag can be specified as any of the following:
13 *
14 *  RTEMS_ERROR_ERRNO       -- include errno text in output
15 *  RTEMS_ERROR_PANIC       -- halts local system after output
16 *  RTEMS_ERROR_ABORT       -- abort after output
17 *
18 * It can also include a rtems_status value which can be OR'd
19 * with the above flags. *
20 *
21 * Example 1:
22 * @code
23 *  #include <rtems.h>
24 *  #include <rtems/error.h>
25 *  rtems_error(0, "stray interrupt %d", intr);
26 * @endcode
27 *
28 * Example 2:
29 * @code
30 *        if ((status = rtems_task_create(...)) != RTEMS_SUCCCESSFUL)
31 *        {
32 *            rtems_error(status | RTEMS_ERROR_ABORT,
33 *                        "could not create task");
34 *        }
35 * @endcode
36 *
37 * Example 3:
38 * @code
39 *        if ((fd = open(pathname, O_RDNLY)) < 0)
40 *        {
41 *            rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname);
42 *            goto failed;
43 *        }
44 * @endcode
45 */
46
47#ifndef _RTEMS_RTEMS_ERROR_H
48#define _RTEMS_RTEMS_ERROR_H
49
50#include <rtems/rtems/status.h>
51#include <rtems/score/interr.h>
52
53#include <stdarg.h>
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/**
60 *  @defgroup ErrorPanicSupport Error And Panic Support
61 *
62 *  @ingroup libcsupport
63 *
64 *  @brief Defines and externs for rtems error reporting
65 *
66 */
67typedef Internal_errors_t rtems_error_code_t;
68
69/*
70 * rtems_error(), rtems_verror() and rtems_panic() support
71 */
72
73#if 0
74/* not 16bit-int host clean */
75#define RTEMS_ERROR_ERRNO  (1<<((sizeof(rtems_error_code_t) * CHAR_BIT) - 2)) /* hi bit; use 'errno' */
76#define RTEMS_ERROR_PANIC  (RTEMS_ERROR_ERRNO / 2)       /* err fatal; no return */
77#define RTEMS_ERROR_ABORT  (RTEMS_ERROR_ERRNO / 4)       /* err is fatal; panic */
78#else
79#define RTEMS_ERROR_ERRNO  (0x40000000) /* hi bit; use 'errno' */
80#define RTEMS_ERROR_PANIC  (0x20000000) /* err fatal; no return */
81#define RTEMS_ERROR_ABORT  (0x10000000) /* err is fatal; panic */
82#endif
83
84#define RTEMS_ERROR_MASK \
85  (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | RTEMS_ERROR_PANIC) /* all */
86
87/**
88 *  @brief Report an Error
89 *
90 *  @param[in] error_code can be specified as any of the following:
91 *  RTEMS_ERROR_ERRNO       -- include errno text in output
92 *  RTEMS_ERROR_PANIC       -- halts local system after output
93 *  RTEMS_ERROR_ABORT       -- abort after output
94 *
95 *  @param[in] printf_format is a normal printf(3) format string,
96 *  with its concommitant arguments
97 *
98 *  @return the number of characters written.
99 */
100int   rtems_error(
101  rtems_error_code_t error_code,
102  const char *printf_format,
103  ...
104);
105
106/**
107 *  @brief Report an Error
108 *
109 *  @param[in] error_code can be specified as any of the following:
110 *  RTEMS_ERROR_ERRNO       -- include errno text in output
111 *  RTEMS_ERROR_PANIC       -- halts local system after output
112 *  RTEMS_ERROR_ABORT       -- abort after output
113 *
114 *  @param[in] printf_format is a normal printf(3) format string,
115 *  with its concommitant arguments
116 *  @param[in] @p arglist is a varargs list corresponding to
117 *  printf_format
118 *
119 *  @return the number of characters written.
120 */
121int rtems_verror(
122  rtems_error_code_t  error_code,
123  const char         *printf_format,
124  va_list             arglist
125);
126
127/**
128 * rtems_panic is shorthand for rtems_error(RTEMS_ERROR_PANIC, ...)
129 */
130void rtems_panic(
131  const char *printf_format,
132  ...
133) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
134
135extern int rtems_panic_in_progress;
136
137#ifdef __cplusplus
138}
139#endif
140
141
142#endif
143/* end of include file */
Note: See TracBrowser for help on using the repository browser.