amiro-blt / Target / Source / assert.h @ 470d0567
History | View | Annotate | Download (3.084 KB)
1 |
/************************************************************************************//** |
---|---|
2 |
* \file Source\assert.h
|
3 |
* \brief Bootloader assertion module header file.
|
4 |
* \ingroup Core
|
5 |
* \internal
|
6 |
*----------------------------------------------------------------------------------------
|
7 |
* C O P Y R I G H T
|
8 |
*----------------------------------------------------------------------------------------
|
9 |
* Copyright (c) 2011 by Feaser http://www.feaser.com All rights reserved
|
10 |
*
|
11 |
*----------------------------------------------------------------------------------------
|
12 |
* L I C E N S E
|
13 |
*----------------------------------------------------------------------------------------
|
14 |
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
15 |
* modify it under the terms of the GNU General Public License as published by the Free
|
16 |
* Software Foundation, either version 3 of the License, or (at your option) any later
|
17 |
* version.
|
18 |
*
|
19 |
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
20 |
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
21 |
* PURPOSE. See the GNU General Public License for more details.
|
22 |
*
|
23 |
* You should have received a copy of the GNU General Public License along with OpenBLT.
|
24 |
* If not, see <http://www.gnu.org/licenses/>.
|
25 |
*
|
26 |
* A special exception to the GPL is included to allow you to distribute a combined work
|
27 |
* that includes OpenBLT without being obliged to provide the source code for any
|
28 |
* proprietary components. The exception text is included at the bottom of the license
|
29 |
* file <license.html>.
|
30 |
*
|
31 |
* \endinternal
|
32 |
****************************************************************************************/
|
33 |
#ifndef ASSERT_H
|
34 |
#define ASSERT_H
|
35 |
|
36 |
/****************************************************************************************
|
37 |
* Macro definitions
|
38 |
****************************************************************************************/
|
39 |
/* declare assertion macro's. ASSERT_CT is for compile time assertions and ASSERT_RT is
|
40 |
* for runtime assertions.
|
41 |
*/
|
42 |
#ifdef NDEBUG
|
43 |
#define ASSERT_CT(cond) ((void)0) |
44 |
#define ASSERT_RT(cond) ((void)0) |
45 |
#else
|
46 |
#define ASSERT_CONCAT_(a, b) a##b |
47 |
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
|
48 |
/** \brief Macro for assertions that can be performed at compile time. */
|
49 |
#define ASSERT_CT(cond) enum { ASSERT_CONCAT(assert_error_on_line_, __LINE__) = 1/(!!(cond)) } |
50 |
/** \brief Macro for assertions that can only be performed at run time. */
|
51 |
#define ASSERT_RT(cond) \
|
52 |
if (cond) \
|
53 |
{ ; } \ |
54 |
else \
|
55 |
AssertFailure(__FILE__, __LINE__) |
56 |
#endif /* NDEBUG */ |
57 |
|
58 |
|
59 |
/****************************************************************************************
|
60 |
* Function prototypes
|
61 |
****************************************************************************************/
|
62 |
#ifndef NDEBUG
|
63 |
void AssertFailure(blt_char *file, blt_int32u line);
|
64 |
#endif
|
65 |
|
66 |
#endif /* ASSERT_H */ |
67 |
/*********************************** end of assert.h ***********************************/
|