From: Guus Sliepen Date: Fri, 14 Jan 2011 20:22:46 +0000 (+0100) Subject: Proper check and dropin replacement for usleep(). X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=95d8811c2cef8bcde78e1f172f6c57c25cd487aa;p=oweals%2Ftinc.git Proper check and dropin replacement for usleep(). --- diff --git a/configure.in b/configure.in index 8e718c8..d20da0c 100644 --- a/configure.in +++ b/configure.in @@ -136,7 +136,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 time 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 time unsetenv usleep vsyslog writev], [], [], [#include "have.h"] ) AC_FUNC_MALLOC diff --git a/src/dropin.c b/src/dropin.c index 52fb5b8..1bad05c 100644 --- a/src/dropin.c +++ b/src/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/src/dropin.h b/src/dropin.h index e9d1353..a4d9248 100644 --- a/src/dropin.h +++ b/src/dropin.h @@ -41,4 +41,8 @@ extern int vasprintf(char **, const char *, va_list ap); extern int gettimeofday(struct timeval *, void *); #endif +#ifndef HAVE_USLEEP +extern int usleep(long); +#endif + #endif /* __DROPIN_H__ */