36#ifndef RTEMS_STATUS_CHECKS_H
37#define RTEMS_STATUS_CHECKS_H
61 #ifndef RTEMS_DEBUG_PRINT
62 #ifdef RTEMS_STATUS_CHECKS_USE_PRINTK
63 #define RTEMS_DEBUG_PRINT( fmt, ...) \
64 printk( "%s: " fmt, __func__, ##__VA_ARGS__)
67 #define RTEMS_DEBUG_PRINT( fmt, ...) \
68 printf( "%s: " fmt, __func__, ##__VA_ARGS__)
72 #ifdef RTEMS_DEBUG_PRINT
73 #warning RTEMS_DEBUG_PRINT was defined, but DEBUG was undefined
74 #undef RTEMS_DEBUG_PRINT
76 #define RTEMS_DEBUG_PRINT( fmt, ...)
82#define RTEMS_DEBUG_OK( msg) \
83 RTEMS_DEBUG_PRINT( "Ok: %s\n", msg)
88#ifndef RTEMS_SYSLOG_PRINT
89 #ifdef RTEMS_STATUS_CHECKS_USE_PRINTK
90 #define RTEMS_SYSLOG_PRINT( fmt, ...) \
91 printk( fmt, ##__VA_ARGS__)
94 #define RTEMS_SYSLOG_PRINT( fmt, ...) \
95 printf( fmt, ##__VA_ARGS__)
102#define RTEMS_SYSLOG( fmt, ...) \
103 RTEMS_SYSLOG_PRINT( "%s: " fmt, __func__, ##__VA_ARGS__)
108#define RTEMS_SYSLOG_WARNING( fmt, ...) \
109 RTEMS_SYSLOG( "Warning: " fmt, ##__VA_ARGS__)
115#define RTEMS_SYSLOG_WARNING_SC( sc, msg) \
116 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
117 RTEMS_SYSLOG_WARNING( "SC = %i: %s\n", (int) sc, msg); \
123#define RTEMS_SYSLOG_ERROR( fmt, ...) \
124 RTEMS_SYSLOG( "Error: " fmt, ##__VA_ARGS__)
129#define RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg) \
130 RTEMS_SYSLOG_ERROR( "SC = %i: %s\n", (int) sc, msg);
135#define RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg) \
136 RTEMS_SYSLOG_ERROR( "RV = %i: %s\n", (int) rv, msg);
142#define RTEMS_SYSLOG_ERROR_SC( sc, msg) \
143 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
144 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
151#define RTEMS_SYSLOG_ERROR_RV( rv, msg) \
152 if ((int) (rv) < 0) { \
153 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
167#define RTEMS_CHECK_SC( sc, msg) \
168 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
169 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
170 return (rtems_status_code) sc; \
172 RTEMS_DEBUG_OK( msg); \
179#define RTEMS_CHECK_SC_RV( sc, msg) \
180 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
181 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
182 return -((int) (sc)); \
184 RTEMS_DEBUG_OK( msg); \
191#define RTEMS_CHECK_SC_VOID( sc, msg) \
192 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
193 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
196 RTEMS_DEBUG_OK( msg); \
203#define RTEMS_CHECK_SC_TASK( sc, msg) \
204 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
205 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
209 RTEMS_DEBUG_OK( msg); \
216#define RTEMS_CHECK_RV( rv, msg) \
217 if ((int) (rv) < 0) { \
218 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
221 RTEMS_DEBUG_OK( msg); \
228#define RTEMS_CHECK_RV_SC( rv, msg) \
229 if ((int) (rv) < 0) { \
230 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
231 return RTEMS_IO_ERROR; \
233 RTEMS_DEBUG_OK( msg); \
240#define RTEMS_CHECK_RV_VOID( rv, msg) \
241 if ((int) (rv) < 0) { \
242 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
245 RTEMS_DEBUG_OK( msg); \
252#define RTEMS_CHECK_RV_TASK( rv, msg) \
253 if ((int) (rv) < 0) { \
254 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
258 RTEMS_DEBUG_OK( msg); \
272#define RTEMS_CLEANUP_SC( sc, label, msg) \
273 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
274 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
277 RTEMS_DEBUG_OK( msg); \
285#define RTEMS_CLEANUP_SC_RV( sc, rv, label, msg) \
286 if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
287 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
288 rv = -((int) (sc)); \
291 RTEMS_DEBUG_OK( msg); \
298#define RTEMS_CLEANUP_RV( rv, label, msg) \
299 if ((int) (rv) < 0) { \
300 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
303 RTEMS_DEBUG_OK( msg); \
311#define RTEMS_CLEANUP_RV_SC( rv, sc, label, msg) \
312 if ((int) (rv) < 0) { \
313 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
314 sc = RTEMS_IO_ERROR; \
317 RTEMS_DEBUG_OK( msg); \
323#define RTEMS_DO_CLEANUP( label, msg) \
325 RTEMS_SYSLOG_ERROR( msg); \
333#define RTEMS_DO_CLEANUP_SC( val, sc, label, msg) \
335 sc = (rtems_status_code) val; \
336 RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
344#define RTEMS_DO_CLEANUP_RV( val, rv, label, msg) \
347 RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
This header file provides the kernel character input/output support API.