utils: implement my_usleep() with Sleep() on WIN32
Sleep() has only millisecond granularity, but good enough for now.
This commit is contained in:
parent
2eaeb65666
commit
7330002960
@ -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)
|
|||||||
|
|
||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user