blob: 462bb43faa7cba9edcae07214b21eb8f0587acf3 [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 Diaze0f90632018-12-14 00:18:21 +000012#include <common/debug.h>
13
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010014#ifndef PLAT_LOG_LEVEL_ASSERT
15#define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL
16#endif
17
18#if ENABLE_ASSERTIONS
Claus Pedersen785e66c2022-09-12 22:42:58 +000019# if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010020# 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 Pedersen785e66c2022-09-12 22:42:58 +000028#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
Masahiro Yamada77389b22019-07-26 20:21:39 +090029void __dead2 __assert(const char *file, unsigned int line);
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010030#else
Masahiro Yamada77389b22019-07-26 20:21:39 +090031void __dead2 __assert(void);
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010032#endif
33
34#endif /* ASSERT_H */