(mbedtls) Get rid of exit function pointer
This commit is contained in:
parent
a9d29758b6
commit
35577ae15b
|
@ -243,12 +243,6 @@
|
||||||
#error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites"
|
#error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\
|
|
||||||
( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\
|
|
||||||
defined(MBEDTLS_PLATFORM_EXIT_ALT) )
|
|
||||||
#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
|
#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
|
||||||
( !defined(MBEDTLS_PLATFORM_C) ||\
|
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||||
!defined(MBEDTLS_HAVE_TIME) )
|
!defined(MBEDTLS_HAVE_TIME) )
|
||||||
|
@ -365,11 +359,6 @@
|
||||||
#error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites"
|
#error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\
|
|
||||||
!defined(MBEDTLS_PLATFORM_EXIT_ALT)
|
|
||||||
#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
|
#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
|
||||||
( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
|
( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
|
||||||
!defined(MBEDTLS_HAVE_TIME) )
|
!defined(MBEDTLS_HAVE_TIME) )
|
||||||
|
|
|
@ -351,9 +351,6 @@
|
||||||
#if defined MBEDTLS_PLATFORM_SNPRINTF_MACRO
|
#if defined MBEDTLS_PLATFORM_SNPRINTF_MACRO
|
||||||
#define POLARSSL_PLATFORM_SNPRINTF_MACRO MBEDTLS_PLATFORM_SNPRINTF_MACRO
|
#define POLARSSL_PLATFORM_SNPRINTF_MACRO MBEDTLS_PLATFORM_SNPRINTF_MACRO
|
||||||
#endif
|
#endif
|
||||||
#if defined MBEDTLS_PLATFORM_STD_EXIT
|
|
||||||
#define POLARSSL_PLATFORM_STD_EXIT MBEDTLS_PLATFORM_STD_EXIT
|
|
||||||
#endif
|
|
||||||
#if defined MBEDTLS_PLATFORM_STD_FPRINTF
|
#if defined MBEDTLS_PLATFORM_STD_FPRINTF
|
||||||
#define POLARSSL_PLATFORM_STD_FPRINTF MBEDTLS_PLATFORM_STD_FPRINTF
|
#define POLARSSL_PLATFORM_STD_FPRINTF MBEDTLS_PLATFORM_STD_FPRINTF
|
||||||
#endif
|
#endif
|
||||||
|
@ -2100,7 +2097,7 @@
|
||||||
#define platform_set_fprintf mbedtls_platform_set_fprintf
|
#define platform_set_fprintf mbedtls_platform_set_fprintf
|
||||||
#define platform_set_printf mbedtls_platform_set_printf
|
#define platform_set_printf mbedtls_platform_set_printf
|
||||||
#define platform_set_snprintf mbedtls_platform_set_snprintf
|
#define platform_set_snprintf mbedtls_platform_set_snprintf
|
||||||
#define polarssl_exit mbedtls_exit
|
#define polarssl_exit exit
|
||||||
#define polarssl_fprintf fprintf
|
#define polarssl_fprintf fprintf
|
||||||
#define polarssl_free free
|
#define polarssl_free free
|
||||||
#define polarssl_mutex_free mbedtls_mutex_free
|
#define polarssl_mutex_free mbedtls_mutex_free
|
||||||
|
|
|
@ -2283,12 +2283,9 @@
|
||||||
|
|
||||||
/* Platform options */
|
/* Platform options */
|
||||||
#if 0
|
#if 0
|
||||||
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
|
||||||
#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||||
#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||||
#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
|
#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf 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 */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */
|
/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */
|
||||||
|
|
|
@ -54,9 +54,6 @@ extern "C" {
|
||||||
#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
|
#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
|
||||||
#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
|
#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
|
|
||||||
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */
|
|
||||||
#endif
|
|
||||||
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
|
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
|
||||||
#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */
|
#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,41 +69,11 @@ extern "C" {
|
||||||
/* For size_t */
|
/* For size_t */
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* The function pointers for exit
|
|
||||||
*/
|
|
||||||
#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
|
|
||||||
extern void (*mbedtls_exit)( int status );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set your own exit function pointer
|
|
||||||
*
|
|
||||||
* \param exit_func the exit function implementation
|
|
||||||
*
|
|
||||||
* \return 0
|
|
||||||
*/
|
|
||||||
int mbedtls_platform_set_exit( void (*exit_func)( int status ) );
|
|
||||||
#else
|
|
||||||
#if defined(MBEDTLS_PLATFORM_EXIT_MACRO)
|
|
||||||
#define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO
|
|
||||||
#else
|
|
||||||
#define mbedtls_exit exit
|
|
||||||
#endif /* MBEDTLS_PLATFORM_EXIT_MACRO */
|
|
||||||
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The default exit values
|
* 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
|
#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
|
#define MBEDTLS_EXIT_FAILURE 1
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
|
#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
|
||||||
|
|
||||||
|
|
|
@ -29,28 +29,6 @@
|
||||||
|
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
|
|
||||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
|
|
||||||
/*
|
|
||||||
* Make dummy function to prevent NULL pointer dereferences
|
|
||||||
*/
|
|
||||||
static void platform_exit_uninit( int status )
|
|
||||||
{
|
|
||||||
((void) status);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MBEDTLS_PLATFORM_STD_EXIT platform_exit_uninit
|
|
||||||
#endif /* !MBEDTLS_PLATFORM_STD_EXIT */
|
|
||||||
|
|
||||||
void (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT;
|
|
||||||
|
|
||||||
int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
|
|
||||||
{
|
|
||||||
mbedtls_exit = exit_func;
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||||
|
|
Loading…
Reference in New Issue