From 75ac1f7b953db12d330140c7cc257a9329966bc8 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 12 Jan 2021 07:25:26 +0000 Subject: [PATCH] Add implementation for MPS assertion macros Signed-off-by: Hanno Becker --- library/mps/common.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/mps/common.h b/library/mps/common.h index 1ea33f9b1..8ea80c174 100644 --- a/library/mps/common.h +++ b/library/mps/common.h @@ -52,6 +52,24 @@ /*! This flag controls whether tracing for MPS should be enabled. */ //#define MBEDTLS_MPS_TRACE +#if defined(MBEDTLS_MPS_ENABLE_ASSERTIONS) + +#define MBEDTLS_MPS_ASSERT_RAW( cond, string ) \ + do \ + { \ + if( !(cond) ) \ + { \ + TRACE( trace_error, string ); \ + RETURN( MBEDTLS_ERR_MPS_INTERNAL_ERROR ); \ + } \ + } while( 0 ) + +#else /* MBEDTLS_MPS_ENABLE_ASSERTIONS */ + +#define MBEDTLS_MPS_ASSERT_RAW( cond, string ) do {} while( 0 ) + +#endif /* MBEDTLS_MPS_ENABLE_ASSERTIONS */ + /* \} name SECTION: MPS Configuration */ /**