From b3731c04097e66a6b8908bb893c5da831d89c04d Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 12 Jan 2011 20:57:14 +0100 Subject: [PATCH] Proper check and dropin replacement for usleep(). --- configure.in | 2 +- lib/dropin.c | 5 +++-- lib/dropin.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 8e1ae87e..078a7f1d 100644 --- a/configure.in +++ b/configure.in @@ -128,7 +128,7 @@ dnl Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_ALLOCA AC_TYPE_SIGNAL -AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system unsetenv vsyslog writev], +AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system unsetenv usleep vsyslog writev], [], [], [#include "have.h"] ) AC_FUNC_MALLOC diff --git a/lib/dropin.c b/lib/dropin.c index 52fb5b86..1bad05cd 100644 --- a/lib/dropin.c +++ b/lib/dropin.c @@ -164,9 +164,10 @@ int gettimeofday(struct timeval *tv, void *tz) { } #endif -#ifdef HAVE_MINGW +#ifndef HAVE_USLEEP int usleep(long usec) { - Sleep(usec / 1000); + struct timeval tv = {usec / 1000000, (usec / 1000) % 1000}; + select(0, NULL, NULL, NULL, &tv); return 0; } #endif diff --git a/lib/dropin.h b/lib/dropin.h index d5cf6d2c..a4d92480 100644 --- a/lib/dropin.h +++ b/lib/dropin.h @@ -41,7 +41,7 @@ extern int vasprintf(char **, const char *, va_list ap); extern int gettimeofday(struct timeval *, void *); #endif -#ifdef HAVE_MINGW +#ifndef HAVE_USLEEP extern int usleep(long); #endif -- 2.39.5