From 810c22c97100e13bfe73f84dc4a00ae0f9a03931 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer
Date: Sat, 25 Nov 2017 14:32:28 +0300
Subject: [PATCH 3/3] do not use sleep() for windows.
_sleep() has long been deprecated and no longer prototyped in stdlib.h,
despite the fact that msvcrt.dll still exports it. therefore, undefine
HAVE_SLEEP when targeting windows, use Sleep win32 api function instead.
---
example/cdchange.c | 3 ++-
test/driver/mmc_read.c | 9 ++++++---
test/driver/mmc_write.c | 9 ++++++---
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/example/cdchange.c b/example/cdchange.c
index 2c43b6c..37b1b1f 100644
--- a/example/cdchange.c
+++ b/example/cdchange.c
@@ -43,8 +43,9 @@
#ifdef HAVE_WINDOWS_H
#include
#endif
-#if !defined(HAVE_SLEEP) && defined(_WIN32)
+#ifdef _WIN32
#include
+#undef sleep
#define sleep(s) Sleep(1000*s)
#endif
diff --git a/test/driver/mmc_read.c b/test/driver/mmc_read.c
index 3455585..199b2e2 100644
--- a/test/driver/mmc_read.c
+++ b/test/driver/mmc_read.c
@@ -39,12 +39,15 @@
#ifdef HAVE_UNISTD_H
#include
#endif
+#ifdef _WIN32
+# undef HAVE_SLEEP
+#endif
#if !defined(HAVE_SLEEP)
-# if defined(HAVE_USLEEP)
-# define sleep(s) usleep(1000000*s)
-# elif defined(_WIN32)
+# if defined(_WIN32)
# include
# define sleep(s) Sleep(1000*s)
+# elif defined(HAVE_USLEEP)
+# define sleep(s) usleep(1000000*s)
# else
# define sleep(s) { int i; for(i=0; i<=1000*s; i++); }
# endif
diff --git a/test/driver/mmc_write.c b/test/driver/mmc_write.c
index 45884cc..82d55a4 100644
--- a/test/driver/mmc_write.c
+++ b/test/driver/mmc_write.c
@@ -39,12 +39,15 @@
#ifdef HAVE_STRING_H
#include
#endif
+#ifdef _WIN32
+# undef HAVE_SLEEP
+#endif
#if !defined(HAVE_SLEEP)
-# if defined(HAVE_USLEEP)
-# define sleep(s) usleep(1000000*s)
-# elif defined(_WIN32)
+# if defined(_WIN32)
# include
# define sleep(s) Sleep(1000*s)
+# elif defined(HAVE_USLEEP)
+# define sleep(s) usleep(1000000*s)
# else
# define sleep(s) { int i; for(i=0; i<=1000*s; i++); }
# endif
--
1.8.5.5