RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
cpukit
include
rtems
status-checks.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
11
12
/*
13
* Copyright (c) 2008 embedded brains GmbH & Co. KG
14
* Redistribution and use in source and binary forms, with or without
15
* modification, are permitted provided that the following conditions
16
* are met:
17
* 1. Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* 2. Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in the
21
* documentation and/or other materials provided with the distribution.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#ifndef RTEMS_STATUS_CHECKS_H
37
#define RTEMS_STATUS_CHECKS_H
38
39
#include <
rtems/bspIo.h
>
40
41
#ifdef __cplusplus
42
extern
"C"
{
43
#endif
/* __cplusplus */
44
51
56
60
#ifdef DEBUG
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__)
65
#else
/* RTEMS_STATUS_CHECKS_USE_PRINTK */
66
#include <stdio.h>
67
#define RTEMS_DEBUG_PRINT( fmt, ...) \
68
printf( "%s: " fmt, __func__, ##__VA_ARGS__)
69
#endif
/* RTEMS_STATUS_CHECKS_USE_PRINTK */
70
#endif
/* RTEMS_DEBUG_PRINT */
71
#else
/* DEBUG */
72
#ifdef RTEMS_DEBUG_PRINT
73
#warning RTEMS_DEBUG_PRINT was defined, but DEBUG was undefined
74
#undef RTEMS_DEBUG_PRINT
75
#endif
/* RTEMS_DEBUG_PRINT */
76
#define RTEMS_DEBUG_PRINT( fmt, ...)
77
#endif
/* DEBUG */
78
82
#define RTEMS_DEBUG_OK( msg) \
83
RTEMS_DEBUG_PRINT( "Ok: %s\n", msg)
84
88
#ifndef RTEMS_SYSLOG_PRINT
89
#ifdef RTEMS_STATUS_CHECKS_USE_PRINTK
90
#define RTEMS_SYSLOG_PRINT( fmt, ...) \
91
printk( fmt, ##__VA_ARGS__)
92
#else
/* RTEMS_STATUS_CHECKS_USE_PRINTK */
93
#include <stdio.h>
94
#define RTEMS_SYSLOG_PRINT( fmt, ...) \
95
printf( fmt, ##__VA_ARGS__)
96
#endif
/* RTEMS_STATUS_CHECKS_USE_PRINTK */
97
#endif
/* RTEMS_SYSLOG_PRINT */
98
102
#define RTEMS_SYSLOG( fmt, ...) \
103
RTEMS_SYSLOG_PRINT( "%s: " fmt, __func__, ##__VA_ARGS__)
104
108
#define RTEMS_SYSLOG_WARNING( fmt, ...) \
109
RTEMS_SYSLOG( "Warning: " fmt, ##__VA_ARGS__)
110
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); \
118
}
119
123
#define RTEMS_SYSLOG_ERROR( fmt, ...) \
124
RTEMS_SYSLOG( "Error: " fmt, ##__VA_ARGS__)
125
129
#define RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg) \
130
RTEMS_SYSLOG_ERROR( "SC = %i: %s\n", (int) sc, msg);
131
135
#define RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg) \
136
RTEMS_SYSLOG_ERROR( "RV = %i: %s\n", (int) rv, msg);
137
142
#define RTEMS_SYSLOG_ERROR_SC( sc, msg) \
143
if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
144
RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
145
}
146
151
#define RTEMS_SYSLOG_ERROR_RV( rv, msg) \
152
if ((int) (rv) < 0) { \
153
RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
154
}
155
157
162
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; \
171
} else { \
172
RTEMS_DEBUG_OK( msg); \
173
}
174
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)); \
183
} else { \
184
RTEMS_DEBUG_OK( msg); \
185
}
186
191
#define RTEMS_CHECK_SC_VOID( sc, msg) \
192
if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
193
RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
194
return; \
195
} else { \
196
RTEMS_DEBUG_OK( msg); \
197
}
198
203
#define RTEMS_CHECK_SC_TASK( sc, msg) \
204
if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
205
RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
206
rtems_task_exit(); \
207
return; \
208
} else { \
209
RTEMS_DEBUG_OK( msg); \
210
}
211
216
#define RTEMS_CHECK_RV( rv, msg) \
217
if ((int) (rv) < 0) { \
218
RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
219
return (int) rv; \
220
} else { \
221
RTEMS_DEBUG_OK( msg); \
222
}
223
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; \
232
} else { \
233
RTEMS_DEBUG_OK( msg); \
234
}
235
240
#define RTEMS_CHECK_RV_VOID( rv, msg) \
241
if ((int) (rv) < 0) { \
242
RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
243
return; \
244
} else { \
245
RTEMS_DEBUG_OK( msg); \
246
}
247
252
#define RTEMS_CHECK_RV_TASK( rv, msg) \
253
if ((int) (rv) < 0) { \
254
RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
255
rtems_task_exit(); \
256
return; \
257
} else { \
258
RTEMS_DEBUG_OK( msg); \
259
}
260
262
267
272
#define RTEMS_CLEANUP_SC( sc, label, msg) \
273
if ((rtems_status_code) (sc) != RTEMS_SUCCESSFUL) { \
274
RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
275
goto label; \
276
} else { \
277
RTEMS_DEBUG_OK( msg); \
278
}
279
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)); \
289
goto label; \
290
} else { \
291
RTEMS_DEBUG_OK( msg); \
292
}
293
298
#define RTEMS_CLEANUP_RV( rv, label, msg) \
299
if ((int) (rv) < 0) { \
300
RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
301
goto label; \
302
} else { \
303
RTEMS_DEBUG_OK( msg); \
304
}
305
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; \
315
goto label; \
316
} else { \
317
RTEMS_DEBUG_OK( msg); \
318
}
319
323
#define RTEMS_DO_CLEANUP( label, msg) \
324
do { \
325
RTEMS_SYSLOG_ERROR( msg); \
326
goto label; \
327
} while (0)
328
333
#define RTEMS_DO_CLEANUP_SC( val, sc, label, msg) \
334
do { \
335
sc = (rtems_status_code) val; \
336
RTEMS_SYSLOG_ERROR_WITH_SC( sc, msg); \
337
goto label; \
338
} while (0)
339
344
#define RTEMS_DO_CLEANUP_RV( val, rv, label, msg) \
345
do { \
346
rv = (int) val; \
347
RTEMS_SYSLOG_ERROR_WITH_RV( rv, msg); \
348
goto label; \
349
} while (0)
350
352
354
355
#ifdef __cplusplus
356
}
357
#endif
/* __cplusplus */
358
359
#endif
/* RTEMS_STATUS_CHECKS_H */
bspIo.h
This header file provides the kernel character input/output support API.
Generated by
1.18.0