mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-30 00:24:16 +01:00
Use Mbed TLS timing module to obtain ellapsed time in udp_proxy
This commit is contained in:
parent
211f44c928
commit
92474da0a2
@ -280,22 +280,17 @@ static const char *msg_type( unsigned char *msg, size_t len )
|
|||||||
/* Return elapsed time in milliseconds since the first call */
|
/* Return elapsed time in milliseconds since the first call */
|
||||||
static unsigned long ellapsed_time( void )
|
static unsigned long ellapsed_time( void )
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
static int initialized = 0;
|
||||||
return( 0 );
|
static struct mbedtls_timing_hr_time hires;
|
||||||
#else
|
|
||||||
static struct timeval ref = { 0, 0 };
|
|
||||||
struct timeval now;
|
|
||||||
|
|
||||||
if( ref.tv_sec == 0 && ref.tv_usec == 0 )
|
if( initialized == 0 )
|
||||||
{
|
{
|
||||||
gettimeofday( &ref, NULL );
|
(void) mbedtls_timing_get_timer( &hires, 1 );
|
||||||
|
initialized = 1;
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday( &now, NULL );
|
return( mbedtls_timing_get_timer( &hires, 0 ) );
|
||||||
return( 1000 * ( now.tv_sec - ref.tv_sec )
|
|
||||||
+ ( now.tv_usec - ref.tv_usec ) / 1000 );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
Loading…
Reference in New Issue
Block a user