RKH
rkhassert.h
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH web site: http://sourceforge.net/projects/rkh-reactivesys/
28  * e-mail: francuccilea@gmail.com
29  * ---------------------------------------------------------------------------
30  */
31 
58 /* -------------------------- Development history -------------------------- */
59 /*
60  * 2015.10.24 LeFr v2.4.05 Initial version
61  */
62 
63 /* -------------------------------- Authors -------------------------------- */
64 /*
65  * LeFr Leandro Francucci francuccilea@gmail.com
66  */
67 
68 /* --------------------------------- Notes --------------------------------- */
69 /* --------------------------------- Module -------------------------------- */
70 #ifndef __RKHASSERT_H__
71 #define __RKHASSERT_H__
72 
73 /* ----------------------------- Include files ----------------------------- */
74 #include "rkhcfg.h"
75 #include "rkhfwk_module.h"
76 
77 /* ---------------------- External C language linkage ---------------------- */
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 /* --------------------------------- Macros -------------------------------- */
83 #if RKH_CFG_FWK_ASSERT_EN == RKH_ENABLED
84 
127  #define RKH_ASSERT(exp) \
128  if ((exp)) \
129  { \
130  } \
131  else \
132  { \
133  rkh_assert(m_name, __LINE__); \
134  }
135 
149  #define RKH_ALLEGE(exp) RKH_ASSERT(exp)
150 
161  #define RKH_ERROR() rkh_assert(m_name, __LINE__)
162 
163 #else
164  #define RKH_ASSERT(exp) ((void)0)
165  #define RKH_ALLEGE(exp) ((void)(exp))
166  #define RKH_ERROR() ((void)0)
167 #endif
168 
178 #define RKH_REQUIRE(exp) RKH_ASSERT(exp)
179 
189 #define RKH_ENSURE(exp) RKH_ASSERT(exp)
190 
200 #define RKH_INVARIANT(exp) RKH_ASSERT(exp)
201 
202 /* -------------------------------- Constants ------------------------------ */
203 /* ------------------------------- Data types ------------------------------ */
204 /* -------------------------- External variables --------------------------- */
205 /* -------------------------- Function prototypes -------------------------- */
206 #if RKH_CFG_FWK_ASSERT_EN == RKH_ENABLED
207 
261 void rkh_assert(const char *const file, int line);
262 #endif
263 
264 /* -------------------- External C language linkage end -------------------- */
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 /* ------------------------------ Module end ------------------------------- */
270 #endif
271 
272 /* ------------------------------ End of file ------------------------------ */
Specifies the macros to identify file modules.
RKH user configurations.
void rkh_assert(const char *const file, int line)
Callback invoked in case the condition passed to RKH_ASSERT(), RKH_REQUIRE(), RKH_ENSURE(), RKH_ERROR(), or RKH_ALLEGE() evaluates to FALSE.