On Wed, Apr 23, 2014 at 08:38:07PM -0600, Eric Blake wrote: > On 04/23/2014 04:26 AM, Daniel P. Berrange wrote: > > The gnulib usleep replacement says > > > > /* This file is _intentionally_ light-weight. Rather than using > > select or nanosleep, both of which drag in external libraries on > > some platforms, this merely rounds up to the nearest second if > > usleep() does not exist. If sub-second resolution is important, > > then use a more powerful interface to begin with. */ > > Modern mingw provides usleep - it's a version that can't sleep more than > 1 second, but it at least has millisecond resolution. The fallback to > 1-second granularity only occurs for platforms that lack usleep() > altogether. > > > > > And the code confirms it > > > > int > > usleep (useconds_t micro) > > { > > unsigned int seconds = micro / 1000000; > > if (sizeof seconds < sizeof micro && micro / 1000000 != seconds) > > { > > errno = EINVAL; > > return -1; > > } > > if (!HAVE_USLEEP && micro % 1000000) > > seconds++; > > while ((seconds = sleep (seconds)) != 0); > > > > #undef usleep > > #if !HAVE_USLEEP > > Have you confirmed the value of HAVE_USLEEP in config.h for the build of > mingw that you are using? > > > # define usleep(x) 0 > > #endif > > return usleep (micro % 1000000); > > } > > > > > > The 'sleep' replacement on Win32 calls into the Win32-specific Sleep() > > function which allows milli-second granularity. Why doesn't usleep() > > call into Sleep() directly, so it gets milli-second granularity rather > > than rounding up to the nearest second ? > > As far as I can tell, mingw would be the only platform that would > benefit by calling Sleep() - but if everyone these days is already using > new enough mingw that provides usleep(), then the granularity problem is > a red herring. So at this point, I think there's nothing further worth > patching in gnulib.
Hmm, I must admit I didn't check that. I was porting libgphoto2 (which does NOT use gnulib) to mingw64 and hit build failures with lack of usleep. I just assumed it was missing since Win32 doesn't provide it, but I think in fact it must just have been wrong include files used. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|