1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Add conditional platform context creation & usage

Add another layer of abstraction before calling platform setup and teardown.
This commit is contained in:
Andrzej Kurek
2018-04-13 06:16:04 -04:00
parent aca09c7026
commit 32a675f032
2 changed files with 31 additions and 12 deletions

View File

@ -109,7 +109,9 @@ static struct
}
test_info;
#if defined(MBEDTLS_PLATFORM_C)
mbedtls_platform_context platform_ctx;
#endif
/*----------------------------------------------------------------------------*/
/* Helper flags for complex dependencies */
@ -128,6 +130,23 @@ mbedtls_platform_context platform_ctx;
/*----------------------------------------------------------------------------*/
/* Helper Functions */
static int platform_setup()
{
#if defined(MBEDTLS_PLATFORM_C)
if( mbedtls_platform_setup( &platform_ctx ) )
{
return -1;
}
#endif /* MBEDTLS_PLATFORM_C */
return 0;
}
static void platform_teardown()
{
#if defined(MBEDTLS_PLATFORM_C)
mbedtls_platform_teardown( &platform_ctx );
#endif /* MBEDTLS_PLATFORM_C */
}
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
static int redirect_output( FILE** out_stream, const char* path )