1 /* 2 * Copyright 2021 The Hafnium Authors. 3 * 4 * Use of this source code is governed by a BSD-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/BSD-3-Clause. 7 */ 8 9 #pragma once 10 11 #if !defined(__cplusplus) 12 13 #include "hf/panic.h" 14 15 #ifndef PLAT_LOG_LEVEL_ASSERT 16 #define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL 17 #endif 18 19 #if ENABLE_ASSERTIONS 20 #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE 21 #define assert(e) \ 22 ((e) ? (void)0 : panic("ASSERT: %s:%d:%s\n", __FILE__, __LINE__, #e)) 23 #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO 24 #define assert(e) ((e) ? (void)0 : panic("ASSERT: %s:%d\n", __FILE__, __LINE__)) 25 #else 26 #define assert(e) ((e) ? (void)0 : panic("ASSERT\n")) 27 #endif 28 #else 29 #define assert(e) ((void)0) 30 #endif /* ENABLE_ASSERTIONS */ 31 32 #endif /* !defined(__cplusplus) */ 33