Просмотр исходного кода

add sleep() and usleep() replacement for W32

Evgeny Grin (Karlson2k) 12 лет назад
Родитель
Сommit
8b28e693b2

+ 6 - 0
src/examples/authorization_example.c

@@ -25,6 +25,12 @@
 
 #include "platform.h"
 #include <microhttpd.h>
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
 
 #define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>"
 

+ 2 - 0
src/include/platform.h

@@ -120,6 +120,8 @@
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include <ws2tcpip.h>
+#define sleep(seconds) (SleepEx((seconds)*1000, 1)/1000)
+#define usleep(useconds) (void)SleepEx((useconds)/1000, 1)
 #endif
 
 #ifndef MHD_SOCKET_DEFINED

+ 7 - 0
src/testcurl/https/test_https_time_out.c

@@ -31,6 +31,13 @@
 #include "tls_test_common.h"
 #include <gcrypt.h>
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 extern const char srv_key_pem[];
 extern const char srv_self_signed_cert_pem[];
 

+ 5 - 2
src/testcurl/test_get.c

@@ -34,8 +34,11 @@
 #include <string.h>
 #include <time.h>
 
-#ifdef __MINGW32__
-#define usleep(usec) (Sleep ((usec) / 1000),0)
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
 #endif
 
 #ifndef WINDOWS

+ 7 - 0
src/testcurl/test_get_response_cleanup.c

@@ -41,6 +41,13 @@
 #include <unistd.h>
 #endif
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 #define TESTSTR "/* DO NOT CHANGE THIS LINE */"
 
 static int oneone;

+ 7 - 0
src/testcurl/test_iplimit.c

@@ -37,6 +37,13 @@
 #include <unistd.h>
 #endif
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 static int oneone;
 
 struct CBC

+ 7 - 0
src/testcurl/test_post.c

@@ -36,6 +36,13 @@
 #include <unistd.h>
 #endif
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 #define POST_DATA "name=daniel&project=curl"
 
 static int oneone;

+ 7 - 0
src/testcurl/test_termination.c

@@ -41,6 +41,13 @@
 #include <sys/socket.h>
 #endif
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 static int
 connection_handler (void *cls,
                     struct MHD_Connection *connection,

+ 5 - 2
src/testcurl/test_urlparse.c

@@ -32,8 +32,11 @@
 #include <string.h>
 #include <time.h>
 
-#ifdef __MINGW32__
-#define usleep(usec) (Sleep ((usec) / 1000),0)
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
 #endif
 
 #ifndef WINDOWS

+ 7 - 0
src/testspdy/test_proxies.c

@@ -34,6 +34,13 @@
 #include <sys/wait.h> /* pid_t */
 #include "common.h"
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 #define EXPECTED_BODY "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>"
 
 

+ 7 - 0
src/testzzuf/socat.c

@@ -29,6 +29,13 @@
 #include <sys/wait.h>
 #include <signal.h>
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <windows.h>
+#endif
+
 
 /**
  * A larger loop count will run more random tests --