Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 1 | /* |
Govindraj Raja | eee28e7 | 2023-08-01 15:52:40 -0500 | [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 | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | #include <common/debug.h> |
| 13 | |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 14 | #ifndef PLAT_LOG_LEVEL_ASSERT |
| 15 | #define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL |
| 16 | #endif |
| 17 | |
| 18 | #if ENABLE_ASSERTIONS |
Claus Pedersen | 785e66c | 2022-09-12 22:42:58 +0000 | [diff] [blame] | 19 | # if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 20 | # define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__)) |
| 21 | # else |
| 22 | # define assert(e) ((e) ? (void)0 : __assert()) |
| 23 | # endif |
| 24 | #else |
| 25 | #define assert(e) ((void)0) |
| 26 | #endif /* ENABLE_ASSERTIONS */ |
| 27 | |
Claus Pedersen | 785e66c | 2022-09-12 22:42:58 +0000 | [diff] [blame] | 28 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 29 | void __dead2 __assert(const char *file, unsigned int line); |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 30 | #else |
Masahiro Yamada | 77389b2 | 2019-07-26 20:21:39 +0900 | [diff] [blame] | 31 | void __dead2 __assert(void); |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 32 | #endif |
| 33 | |
| 34 | #endif /* ASSERT_H */ |