]> sjero.net Git - wget/blobdiff - src/mswindows.c
[svn] New function xsleep that resumes sleeps interrupted by signals
[wget] / src / mswindows.c
index 3f36d2c5ac8118b7dccc0580ce501aeafb8f1a87..36aef00f8317fb33b12554f65bcf58ecfcb82d63 100644 (file)
@@ -74,35 +74,23 @@ static DWORD set_sleep_mode (DWORD mode);
 static DWORD pwr_mode = 0;
 static int windows_nt_p;
 
-#ifndef HAVE_SLEEP
+/* Windows version of xsleep in utils.c.  */
 
-/* Emulation of Unix sleep.  */
-
-unsigned int
-sleep (unsigned seconds)
-{
-  return SleepEx (1000 * seconds, TRUE) ? 0U : 1000 * seconds;
-}
-#endif
-
-#ifndef HAVE_USLEEP
-/* Emulation of Unix usleep().  This has a granularity of
-   milliseconds, but that's ok because:
-
-   a) Wget is only using it with milliseconds [not anymore, but b)
-      still applies];
-
-   b) You can't rely on usleep's granularity anyway.  If a caller
-   expects usleep to respect every microsecond, he's in for a
-   surprise.  */
-
-int
-usleep (unsigned long usec)
+void
+xsleep (double seconds)
 {
-  SleepEx (usec / 1000, TRUE);
-  return 0;
+#ifdef HAVE_USLEEP
+  if (seconds > 1000)
+    {
+      /* Explained in utils.c. */
+      sleep (seconds);
+      seconds -= (long) seconds;
+    }
+  usleep (seconds * 1000000L);
+#else  /* not HAVE_USLEEP */
+  SleepEx (seconds * 1000, FALSE);
+#endif /* not HAVE_USLEEP */
 }
-#endif  /* HAVE_USLEEP */
 
 void
 windows_main_junk (int *argc, char **argv, char **exec_name)