Commit 73300029 authored by Max Kellermann's avatar Max Kellermann

utils: implement my_usleep() with Sleep() on WIN32

Sleep() has only millisecond granularity, but good enough for now.
parent 2eaeb656
...@@ -36,6 +36,10 @@ ...@@ -36,6 +36,10 @@
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef WIN32
#include <windows.h>
#endif
void stripReturnChar(char *string) void stripReturnChar(char *string)
{ {
while (string && (string = strchr(string, '\n'))) { while (string && (string = strchr(string, '\n'))) {
...@@ -45,12 +49,16 @@ void stripReturnChar(char *string) ...@@ -45,12 +49,16 @@ void stripReturnChar(char *string)
void my_usleep(long usec) void my_usleep(long usec)
{ {
#ifdef WIN32
Sleep(usec / 1000);
#else
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = usec; tv.tv_usec = usec;
select(0, NULL, NULL, NULL, &tv); select(0, NULL, NULL, NULL, &tv);
#endif
} }
int ipv6Supported(void) int ipv6Supported(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment