source: rtems/cpukit/include/rtems/status-checks.h @ 85bca3f

4.104.114.9
Last change on this file since 85bca3f was 85bca3f, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 20, 2008 at 5:29:37 PM

2008-08-20 Sebastian Huber <sebastian.huber@…>

  • include/rtems/status-checks.h: Fixed integer conversion warning.
  • Property mode set to 100644
File size: 4.7 KB
Line 
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
23extern "C" {
24#endif /* __cplusplus */
25
26#ifdef DEBUG
27  #ifndef DEBUG_PRINT
28    #ifdef RTEMS_STATUS_CHECKS_USE_PRINTK
29      #define DEBUG_PRINT( fmt, ...) \
30        printk( "%s: " fmt, __func__, ##__VA_ARGS__)
31    #else /* RTEMS_STATUS_CHECKS_USE_PRINTK */
32      #define DEBUG_PRINT( fmt, ...) \
33        printf( "%s: " fmt, __func__, ##__VA_ARGS__)
34    #endif /* RTEMS_STATUS_CHECKS_USE_PRINTK */
35  #endif /* DEBUG_PRINT */
36#else /* DEBUG */
37  #ifdef DEBUG_PRINT
38    #warning DEBUG_PRINT was defined, but DEBUG was undefined
39    #undef DEBUG_PRINT
40  #endif /* DEBUG_PRINT */
41  #define DEBUG_PRINT( fmt, ...)
42#endif /* DEBUG */
43
44#ifndef SYSLOG_PRINT
45  #ifdef RTEMS_STATUS_CHECKS_USE_PRINTK
46    #define SYSLOG_PRINT( fmt, ...) \
47      printk( fmt, ##__VA_ARGS__)
48  #else /* RTEMS_STATUS_CHECKS_USE_PRINTK */
49    #define SYSLOG_PRINT( fmt, ...) \
50      printf( fmt, ##__VA_ARGS__)
51  #endif /* RTEMS_STATUS_CHECKS_USE_PRINTK */
52#endif /* SYSLOG_PRINT */
53
54#define SYSLOG( fmt, ...) \
55  SYSLOG_PRINT( "%s: " fmt, __func__, ##__VA_ARGS__)
56
57#define SYSLOG_WARNING( fmt, ...) \
58  SYSLOG_PRINT( "%s: Warning: " fmt, __func__, ##__VA_ARGS__)
59
60#define SYSLOG_WARNING_SC( sc, fmt, ...) \
61  if ((sc) != RTEMS_SUCCESSFUL) { \
62    SYSLOG_PRINT( "%s: Warning: SC = %i: " fmt "\n", \
63      __func__, sc, ##__VA_ARGS__); \
64  }
65
66#define SYSLOG_ERROR( fmt, ...) \
67  SYSLOG_PRINT( "%s: Error: " fmt, __func__, ##__VA_ARGS__)
68
69#define SYSLOG_ERROR_SC( sc, fmt, ...) \
70  if ((sc) != RTEMS_SUCCESSFUL) { \
71    SYSLOG_PRINT( "%s: Error: SC = %i: " fmt "\n", \
72      __func__, sc, ##__VA_ARGS__); \
73  }
74
75#define CHECK_SC( sc, hint ) \
76  if ((sc) != RTEMS_SUCCESSFUL) { \
77    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
78    return sc; \
79  } else { \
80    DEBUG_PRINT( "Ok: %s\n", hint ); \
81  }
82
83#define CHECK_SCRV( sc, hint ) \
84  if ((sc) != RTEMS_SUCCESSFUL) { \
85    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
86    return -((int) (sc)); \
87  } else { \
88    DEBUG_PRINT( "Ok: %s\n", hint ); \
89  }
90
91#define CHECK_SC_VOID( sc, hint ) \
92  if ((sc) != RTEMS_SUCCESSFUL) { \
93    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
94    return; \
95  } else { \
96    DEBUG_PRINT( "Ok: %s\n", hint ); \
97  }
98
99#define CHECK_SC_TASK( sc, hint ) \
100  if ((sc) != RTEMS_SUCCESSFUL) { \
101    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
102    rtems_task_delete( RTEMS_SELF); \
103    return; \
104  } else { \
105    DEBUG_PRINT( "Ok: %s\n", hint ); \
106  }
107
108#define CHECK_RV( rv, hint ) \
109  if ((rv) < 0) { \
110    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
111    return rv; \
112  } else { \
113    DEBUG_PRINT( "Ok: %s\n", hint ); \
114  }
115
116#define CHECK_RVSC( rv, hint ) \
117  if ((rv) < 0) { \
118    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
119    return RTEMS_IO_ERROR; \
120  } else { \
121    DEBUG_PRINT( "Ok: %s\n", hint ); \
122  }
123
124#define CHECK_RV_VOID( rv, hint ) \
125  if ((rv) < 0) { \
126    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
127    return; \
128  } else { \
129    DEBUG_PRINT( "Ok: %s\n", hint ); \
130  }
131
132#define CHECK_RV_TASK( rv, hint ) \
133  if ((rv) < 0) { \
134    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
135    rtems_task_delete( RTEMS_SELF); \
136    return; \
137  } else { \
138    DEBUG_PRINT( "Ok: %s\n", hint ); \
139  }
140
141#define CLEANUP_SC( sc, label, hint ) \
142  if ((sc) != RTEMS_SUCCESSFUL) { \
143    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
144    goto label; \
145  } else { \
146    DEBUG_PRINT( "Ok: %s\n", hint ); \
147  }
148
149#define CLEANUP_SCRV( sc, rv, label, hint ) \
150  if ((sc) != RTEMS_SUCCESSFUL) { \
151    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
152    rv = -((int) (sc)); \
153    goto label; \
154  } else { \
155    DEBUG_PRINT( "Ok: %s\n", hint ); \
156  }
157
158#define CLEANUP_RV( rv, label, hint ) \
159  if ((rv) < 0) { \
160    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
161    goto label; \
162  } else { \
163    DEBUG_PRINT( "Ok: %s\n", hint ); \
164  }
165
166#define CLEANUP_RVSC( rv, sc, label, hint ) \
167  if ((rv) < 0) { \
168    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
169    sc = RTEMS_IO_ERROR; \
170    goto label; \
171  } else { \
172    DEBUG_PRINT( "Ok: %s\n", hint ); \
173  }
174
175#define DO_CLEANUP_SC( val, sc, label, hint ) \
176  do { \
177    sc = val; \
178    SYSLOG_ERROR( "SC = %i: %s\n", sc, hint ); \
179    goto label; \
180  } while (0)
181
182#define DO_CLEANUP_RV( val, rv, label, hint ) \
183  do { \
184    rv = val; \
185    SYSLOG_ERROR( "RV = %i: %s\n", rv, hint ); \
186    goto label; \
187  } while (0)
188
189#ifdef __cplusplus
190}
191#endif /* __cplusplus */
192
193#endif /* RTEMS_STATUS_CHECKS_H */
Note: See TracBrowser for help on using the repository browser.