]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
windows: Provide a cancellable usleep(), but with ms resolution only
authorMartin Willi <martin@revosec.ch>
Wed, 23 Oct 2013 13:50:10 +0000 (15:50 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:53:01 +0000 (15:53 +0200)
src/libstrongswan/utils/windows.c
src/libstrongswan/utils/windows.h

index a0ff6b84b5cefa7d58643a3548761ed60f98ce67..4a6a35eff15f1324392ba0a1d48df348b62e0ca0 100644 (file)
@@ -36,6 +36,19 @@ void windows_deinit()
        WSACleanup();
 }
 
+/**
+ * See header
+ */
+int usleep(useconds_t usec)
+{
+       if (usec > 0 && usec < 1000)
+       {       /* do not Sleep(0) for small values */
+               usec = 1000;
+       }
+       SleepEx(usec / 1000, TRUE);
+       return 0;
+}
+
 /**
  * See header
  */
index afa52424239ff358bf3f4f7f187712d9bfa207c2..8e6fd80b1dba077431d7ba15b6e23be602e05c4f 100644 (file)
@@ -85,6 +85,11 @@ static inline int sleep(unsigned int seconds)
        return 0;
 }
 
+/**
+ * Replacement of usleep(3), cancellable, ms resolution only
+ */
+int usleep(useconds_t usec);
+
 /**
  * strdup(3), the Windows variant can't free(strdup("")) and others
  */