From acecb653d5f75b81476ca4703ee4b82b3b0d8033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 1 Jul 2015 11:29:31 +0200 Subject: [PATCH] Fix mbedtls_net_usleep() on Windows For some reason select() doesn't seem to work. --- library/net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/net.c b/library/net.c index 04aa0df13..57ac7cab3 100644 --- a/library/net.c +++ b/library/net.c @@ -425,15 +425,19 @@ int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ) */ void mbedtls_net_usleep( unsigned long usec ) { +#if defined(_WIN32) + Sleep( ( usec + 999 ) / 1000 ); +#else struct timeval tv; tv.tv_sec = usec / 1000000; -#if !defined(_WIN32) && ( defined(__unix__) || defined(__unix) || \ - ( defined(__APPLE__) && defined(__MACH__) ) ) +#if defined(__unix__) || defined(__unix) || \ + ( defined(__APPLE__) && defined(__MACH__) ) tv.tv_usec = (suseconds_t) usec % 1000000; #else tv.tv_usec = usec % 1000000; #endif select( 0, NULL, NULL, NULL, &tv ); +#endif } /*