about summary refs log tree commit diff
path: root/lib/util/nsleep.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-01-01 17:35:34 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-01-01 17:35:34 +0000
commitb2cabe67ae053fe2b734c0bbecc434246a9692d5 (patch)
tree9b8e603d6c5e619357005bb6cff1fae2676e043c /lib/util/nsleep.c
parentdc2bc8f02a26e970c4862a656ad32fda31aee2df (diff)
downloadnetpbm-mirror-b2cabe67ae053fe2b734c0bbecc434246a9692d5.tar.gz
netpbm-mirror-b2cabe67ae053fe2b734c0bbecc434246a9692d5.tar.xz
netpbm-mirror-b2cabe67ae053fe2b734c0bbecc434246a9692d5.zip
Add sleepN()
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@540 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util/nsleep.c')
-rw-r--r--lib/util/nsleep.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/util/nsleep.c b/lib/util/nsleep.c
new file mode 100644
index 00000000..6e61b3be
--- /dev/null
+++ b/lib/util/nsleep.c
@@ -0,0 +1,27 @@
+#ifdef WIN32
+  #include <windows.h>
+  #include <process.h>
+#else
+  #include <unistd.h>
+#endif
+
+#include "nsleep.h"
+
+
+
+void
+sleepN(unsigned int const milliseconds) {
+
+#ifdef WIN32
+    SleepEx(milliseconds, true);
+#else
+
+    /* We could use usleep() here if millisecond resolution is really
+       important, but since Netpbm has no need for it today, we don't
+       want to deal with the possibility that usleep() doesn't exist.
+       08.08.01.
+    */
+
+    sleep((milliseconds + 999)/1000);
+#endif
+}