Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, 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 | #include <debug.h> |
| 12 | #include <platform_def.h> |
| 13 | |
| 14 | #ifndef PLAT_LOG_LEVEL_ASSERT |
| 15 | #define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL |
| 16 | #endif |
| 17 | |
| 18 | #if ENABLE_ASSERTIONS |
| 19 | # if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE |
| 20 | # define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) |
| 21 | # elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
| 22 | # define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__)) |
| 23 | # else |
| 24 | # define assert(e) ((e) ? (void)0 : __assert()) |
| 25 | # endif |
| 26 | #else |
| 27 | #define assert(e) ((void)0) |
| 28 | #endif /* ENABLE_ASSERTIONS */ |
| 29 | |
| 30 | #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE |
| 31 | __dead2 void __assert(const char *file, unsigned int line, |
| 32 | const char *assertion); |
| 33 | #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO |
| 34 | __dead2 void __assert(const char *file, unsigned int line); |
| 35 | #else |
| 36 | __dead2 void __assert(void); |
| 37 | #endif |
| 38 | |
| 39 | #endif /* ASSERT_H */ |