blob: 486bbc29041b45a72d01422b2715048c7337fc70 [file] [log] [blame]
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +01001/*
Masahiro Yamada77389b22019-07-26 20:21:39 +09002 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +01003 *
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
Masahiro Yamada77389b22019-07-26 20:21:39 +090033void __dead2 __assert(const char *file, unsigned int line,
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010034 const char *assertion);
35#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
Masahiro Yamada77389b22019-07-26 20:21:39 +090036void __dead2 __assert(const char *file, unsigned int line);
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010037#else
Masahiro Yamada77389b22019-07-26 20:21:39 +090038void __dead2 __assert(void);
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010039#endif
40
41#endif /* ASSERT_H */