1 /*
2  * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef ASSERT_H
8 #define ASSERT_H
9 
10 #include <cdefs.h>
11 
12 #include <platform_def.h>
13 
14 #include <common/debug.h>
15 
16 #ifndef PLAT_LOG_LEVEL_ASSERT
17 #define PLAT_LOG_LEVEL_ASSERT	LOG_LEVEL
18 #endif
19 
20 #if ENABLE_ASSERTIONS
21 # if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
22 #  define assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
23 # elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
24 #  define assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__))
25 # else
26 #  define assert(e)	((e) ? (void)0 : __assert())
27 # endif
28 #else
29 #define assert(e)	((void)0)
30 #endif /* ENABLE_ASSERTIONS */
31 
32 #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
33 void __dead2 __assert(const char *file, unsigned int line,
34 		      const char *assertion);
35 #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
36 void __dead2 __assert(const char *file, unsigned int line);
37 #else
38 void __dead2 __assert(void);
39 #endif
40 
41 #endif /* ASSERT_H */
42