Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef ASSERT_H |
| 8 | #define ASSERT_H |
| 9 | |
| 10 | #include <cdefs.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 12 | #include <platform_def.h> |
| 13 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 14 | #include <common/debug.h> |
| 15 | |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 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 |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 33 | void __dead2 __assert(const char *file, unsigned int line, |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 34 | const char *assertion); |
| 35 | #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 36 | void __dead2 __assert(const char *file, unsigned int line); |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 37 | #else |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 38 | void __dead2 __assert(void); |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | #endif /* ASSERT_H */ |