Abstracts away time()/stdlib.h into platform
Substitutes time() into a configurable platform interface to allow it to be easily substituted.
This commit is contained in:
parent
1594210a49
commit
d5800b7761
16 changed files with 159 additions and 63 deletions
|
@ -190,4 +190,27 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
|
|||
}
|
||||
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
|
||||
/*
|
||||
* Make dummy function to prevent NULL pointer dereferences
|
||||
*/
|
||||
static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer )
|
||||
{
|
||||
((void) timer);
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
#define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit
|
||||
#endif /* !MBEDTLS_PLATFORM_STD_TIME */
|
||||
|
||||
time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME;
|
||||
|
||||
int mbedtls_platform_set_exit( mbedtls_time_t (*time_func)( mbedtls_time_t timer ) )
|
||||
{
|
||||
mbedtls_time = time_func;
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
||||
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue