From 91947445956817f10b29fc888feaaa9ca74a4823 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Fri, 18 Mar 2016 13:49:27 +0000 Subject: [PATCH] Add exit value macros to platform abstraction layer. --- ChangeLog | 1 + include/mbedtls/config.h | 4 +++- include/mbedtls/platform.h | 22 +++++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 007f60418..cdbac2e8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ Changes don't use the optimized assembly for bignum multiplication. This removes the need to pass -fomit-frame-pointer to avoid a build error with -O0. * Disabled SSLv3 in the default configuration. + * Add exit value macros to the platform abstraction layer. = mbed TLS 2.2.1 released 2016-01-05 diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index d9b37e0ce..c9332e113 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -131,7 +131,7 @@ //#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS /** - * \def MBEDTLS_PLATFORM_EXIT_ALT + * \def MBEDTLS_PLATFORM_XXX_ALT * * MBEDTLS_PLATFORM_XXX_ALT: Uncomment a macro to let mbed TLS support the * function in the platform abstraction layer. @@ -2469,6 +2469,8 @@ //#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ /* Note: your snprintf must correclty zero-terminate the buffer! */ //#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */ /* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ /* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ diff --git a/include/mbedtls/platform.h b/include/mbedtls/platform.h index f71f1b649..1371ff1c6 100644 --- a/include/mbedtls/platform.h +++ b/include/mbedtls/platform.h @@ -64,7 +64,13 @@ extern "C" { #define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use */ #endif #if !defined(MBEDTLS_PLATFORM_STD_EXIT) -#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default free to use */ +#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) +#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */ +#endif +#if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) +#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< Default exit value to use */ #endif #else /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) @@ -207,6 +213,20 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); #endif /* MBEDTLS_PLATFORM_EXIT_MACRO */ #endif /* MBEDTLS_PLATFORM_EXIT_ALT */ +/* + * The default exit values + */ +#if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) +#define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS +#else +#define MBEDTLS_EXIT_SUCCESS 0 +#endif +#if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) +#define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE +#else +#define MBEDTLS_EXIT_FAILURE 1 +#endif + #ifdef __cplusplus } #endif