From 9299ad8c3ffdd8c3b78d33346cac355ee98462b9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 19 Aug 2010 03:47:50 +0000 Subject: [PATCH] support even older versions of mingw (as found on some Debian distros) that lack usleep/nanosleep, but have _sleep git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1828 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 6 ++++++ urjtag/configure.ac | 1 + urjtag/src/lib/usleep.c | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 3421db85..05774c50 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,9 @@ +2010-08-18 Mike Frysinger + + * configure.ac (AC_CHECK_FUNCS): Check for _sleep. + * src/lib/usleep.c: Support a fuzzy version of usleep based on old mingw + _sleep functions. + 2010-08-16 Mike Frysinger * src/tap/detect.c (urj_tap_detect_parts): Include paths to data files when diff --git a/urjtag/configure.ac b/urjtag/configure.ac index 8ed64cc4..4db4a98f 100644 --- a/urjtag/configure.ac +++ b/urjtag/configure.ac @@ -116,6 +116,7 @@ else fi AC_CHECK_FUNCS(m4_flatten([ + _sleep geteuid getuid nanosleep diff --git a/urjtag/src/lib/usleep.c b/urjtag/src/lib/usleep.c index 05a2c567..6b4d4d50 100644 --- a/urjtag/src/lib/usleep.c +++ b/urjtag/src/lib/usleep.c @@ -23,9 +23,7 @@ #ifndef HAVE_USLEEP -#ifndef HAVE_NANOSLEEP -# error Need usleep or nanosleep -#endif +#ifdef HAVE_NANOSLEEP #include @@ -42,4 +40,17 @@ int usleep (long unsigned usec) return nanosleep (&req, NULL); } +#elif defined(HAVE__SLEEP) + +/* Not exact, but close enough */ +int usleep (long unsigned usec) +{ + _sleep (usec / 1000); + return 0; +} + +#else +# error "Need sleep, usleep, or nanosleep" +#endif + #endif