1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Header file for status checks. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * Copyright (c) 2008 |
---|
9 | * Embedded Brains GmbH |
---|
10 | * Obere Lagerstr. 30 |
---|
11 | * D-82178 Puchheim |
---|
12 | * Germany |
---|
13 | * rtems@embedded-brains.de |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be found in the file |
---|
16 | * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef RTEMS_STATUS_CHECKS_H |
---|
20 | #define RTEMS_STATUS_CHECKS_H |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif /* __cplusplus */ |
---|
25 | |
---|
26 | #ifdef DEBUG |
---|
27 | # ifndef DEBUG_PRINT |
---|
28 | # ifdef RTEMS_STATUS_CHECKS_USE_PRINTK |
---|
29 | # define DEBUG_PRINT( fmt, ...) printk( "%s: " fmt, __func__, ##__VA_ARGS__) |
---|
30 | # else /* RTEMS_STATUS_CHECKS_USE_PRINTK */ |
---|
31 | # define DEBUG_PRINT( fmt, ...) printf( "%s: " fmt, __func__, ##__VA_ARGS__) |
---|
32 | # endif /* RTEMS_STATUS_CHECKS_USE_PRINTK */ |
---|
33 | # endif /* DEBUG_PRINT */ |
---|
34 | #else /* DEBUG */ |
---|
35 | # define DEBUG_PRINT( fmt, ...) |
---|
36 | #endif /* DEBUG */ |
---|
37 | |
---|
38 | #ifndef SYSLOG_PRINT |
---|
39 | # ifdef RTEMS_STATUS_CHECKS_USE_PRINTK |
---|
40 | # define SYSLOG_PRINT( fmt, ...) printk( fmt, ##__VA_ARGS__) |
---|
41 | # else /* RTEMS_STATUS_CHECKS_USE_PRINTK */ |
---|
42 | # define SYSLOG_PRINT( fmt, ...) printf( fmt, ##__VA_ARGS__) |
---|
43 | # endif /* RTEMS_STATUS_CHECKS_USE_PRINTK */ |
---|
44 | #endif /* SYSLOG_PRINT */ |
---|
45 | |
---|
46 | #define SYSLOG( fmt, ...) SYSLOG_PRINT( "%s: " fmt, __func__, ##__VA_ARGS__) |
---|
47 | |
---|
48 | #define SYSLOG_WARNING( fmt, ...) SYSLOG_PRINT( "%s: Warning: " fmt, __func__, ##__VA_ARGS__) |
---|
49 | |
---|
50 | #define SYSLOG_WARNING_SC( sc, fmt, ...) \ |
---|
51 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
52 | SYSLOG_PRINT( "%s: Warning: SC = %i: " fmt "\n", __func__, sc, ##__VA_ARGS__); \ |
---|
53 | } |
---|
54 | |
---|
55 | #define SYSLOG_ERROR( fmt, ...) SYSLOG_PRINT( "%s: Error: " fmt, __func__, ##__VA_ARGS__) |
---|
56 | |
---|
57 | #define SYSLOG_ERROR_SC( sc, fmt, ...) \ |
---|
58 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
59 | SYSLOG_PRINT( "%s: Error: SC = %i: " fmt "\n", __func__, sc, ##__VA_ARGS__); \ |
---|
60 | } |
---|
61 | |
---|
62 | #define CHECK_SC( sc, hint) \ |
---|
63 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
64 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
65 | return sc; \ |
---|
66 | } else { \ |
---|
67 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
68 | } |
---|
69 | |
---|
70 | #define CHECK_SCRV( sc, hint) \ |
---|
71 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
72 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
73 | return -(sc); \ |
---|
74 | } else { \ |
---|
75 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
76 | } |
---|
77 | |
---|
78 | #define CHECK_SC_VOID( sc, hint) \ |
---|
79 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
80 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
81 | return; \ |
---|
82 | } else { \ |
---|
83 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
84 | } |
---|
85 | |
---|
86 | #define CHECK_SC_TASK( sc, hint) \ |
---|
87 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
88 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
89 | rtems_task_delete( RTEMS_SELF); \ |
---|
90 | return; \ |
---|
91 | } else { \ |
---|
92 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
93 | } |
---|
94 | |
---|
95 | #define CHECK_RV( rv, hint) \ |
---|
96 | if ((rv) < 0) { \ |
---|
97 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
98 | return rv; \ |
---|
99 | } else { \ |
---|
100 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
101 | } |
---|
102 | |
---|
103 | #define CHECK_RVSC( rv, hint) \ |
---|
104 | if ((rv) < 0) { \ |
---|
105 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
106 | return RTEMS_IO_ERROR; \ |
---|
107 | } else { \ |
---|
108 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
109 | } |
---|
110 | |
---|
111 | #define CHECK_RV_VOID( rv, hint) \ |
---|
112 | if ((rv) < 0) { \ |
---|
113 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
114 | return; \ |
---|
115 | } else { \ |
---|
116 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
117 | } |
---|
118 | |
---|
119 | #define CHECK_RV_TASK( rv, hint) \ |
---|
120 | if ((rv) < 0) { \ |
---|
121 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
122 | rtems_task_delete( RTEMS_SELF); \ |
---|
123 | return; \ |
---|
124 | } else { \ |
---|
125 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
126 | } |
---|
127 | |
---|
128 | #define CLEANUP_SC( sc, label, hint) \ |
---|
129 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
130 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
131 | goto label; \ |
---|
132 | } else { \ |
---|
133 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
134 | } |
---|
135 | |
---|
136 | #define CLEANUP_SCRV( sc, rv, label, hint) \ |
---|
137 | if ((sc) != RTEMS_SUCCESSFUL) { \ |
---|
138 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
139 | rv = -(sc); \ |
---|
140 | goto label; \ |
---|
141 | } else { \ |
---|
142 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
143 | } |
---|
144 | |
---|
145 | #define CLEANUP_RV( rv, label, hint) \ |
---|
146 | if ((rv) < 0) { \ |
---|
147 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
148 | goto label; \ |
---|
149 | } else { \ |
---|
150 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
151 | } |
---|
152 | |
---|
153 | #define CLEANUP_RVSC( rv, sc, label, hint) \ |
---|
154 | if ((rv) < 0) { \ |
---|
155 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
156 | sc = RTEMS_IO_ERROR; \ |
---|
157 | goto label; \ |
---|
158 | } else { \ |
---|
159 | DEBUG_PRINT( "Ok: %s\n", hint); \ |
---|
160 | } |
---|
161 | |
---|
162 | #define DO_CLEANUP_SC( val, sc, label, hint) \ |
---|
163 | sc = val; \ |
---|
164 | SYSLOG_ERROR( "SC = %i: %s\n", sc, hint); \ |
---|
165 | goto label; |
---|
166 | |
---|
167 | #define DO_CLEANUP_RV( val, rv, label, hint) \ |
---|
168 | rv = val; \ |
---|
169 | SYSLOG_ERROR( "RV = %i: %s\n", rv, hint); \ |
---|
170 | goto label; |
---|
171 | |
---|
172 | #ifdef __cplusplus |
---|
173 | } |
---|
174 | #endif /* __cplusplus */ |
---|
175 | |
---|
176 | #endif /* RTEMS_STATUS_CHECKS_H */ |
---|