From 7f244a5e366f6fe9070ac3e9cdf23da897e6d228 Mon Sep 17 00:00:00 2001 From: irwir Date: Sat, 23 Jun 2018 18:55:14 +0300 Subject: [PATCH] Replace Windows API threading with CRT functions --- library/timing.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/library/timing.c b/library/timing.c index d9db5d2df..28bef5579 100644 --- a/library/timing.c +++ b/library/timing.c @@ -46,6 +46,7 @@ #include #include +#include struct _hr_time { @@ -261,18 +262,16 @@ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int /* It's OK to use a global because alarm() is supposed to be global anyway */ static DWORD alarmMs; -static DWORD WINAPI TimerProc( LPVOID TimerContext ) +static void TimerProc( void *TimerContext ) { - ((void) TimerContext); + (void)TimerContext; Sleep( alarmMs ); mbedtls_timing_alarmed = 1; - return( TRUE ); + // Implicit call of _endthread() is better (see MS online docs) } void mbedtls_set_alarm( int seconds ) { - DWORD ThreadId; - if( seconds == 0 ) { /* No need to create a thread for this simple case. @@ -283,7 +282,7 @@ void mbedtls_set_alarm( int seconds ) mbedtls_timing_alarmed = 0; alarmMs = seconds * 1000; - CloseHandle( CreateThread( NULL, 0, TimerProc, NULL, 0, &ThreadId ) ); + (void)_beginthread( TimerProc, 0, NULL ); } #else /* _WIN32 && !EFIX64 && !EFI32 */