blob: d04f9dc043066c39a7a41839d8a0ad5a598b921c [file] [log] [blame]
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +01001/*
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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010012#include <platform_def.h>
13
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014#include <common/debug.h>
15
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010016#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__dead2 void __assert(const char *file, unsigned int line,
34 const char *assertion);
35#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
36__dead2 void __assert(const char *file, unsigned int line);
37#else
38__dead2 void __assert(void);
39#endif
40
41#endif /* ASSERT_H */