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:
SimonB 2016-04-26 07:43:27 +01:00 committed by Simon Butcher
parent 1594210a49
commit d5800b7761
16 changed files with 159 additions and 63 deletions

View file

@ -53,10 +53,12 @@
#else
#include <stdio.h>
#include <stdlib.h>
#define mbedtls_free free
#define mbedtls_free free
#define mbedtls_calloc calloc
#define mbedtls_printf printf
#define mbedtls_snprintf snprintf
#define mbedtls_time time
#define mbedtls_time_t time_t
#define mbedtls_printf printf
#define mbedtls_snprintf snprintf
#endif
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
@ -843,7 +845,7 @@ static int x509_get_current_time( mbedtls_x509_time *now )
static int x509_get_current_time( mbedtls_x509_time *now )
{
struct tm *lt;
time_t tt;
mbedtls_time_t tt;
int ret = 0;
#if defined(MBEDTLS_THREADING_C)
@ -851,7 +853,7 @@ static int x509_get_current_time( mbedtls_x509_time *now )
return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
#endif
tt = time( NULL );
tt = mbedtls_time( NULL );
lt = gmtime( &tt );
if( lt == NULL )