diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2008-01-01 17:35:34 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2008-01-01 17:35:34 +0000 |
commit | b2cabe67ae053fe2b734c0bbecc434246a9692d5 (patch) | |
tree | 9b8e603d6c5e619357005bb6cff1fae2676e043c /lib | |
parent | dc2bc8f02a26e970c4862a656ad32fda31aee2df (diff) | |
download | netpbm-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')
-rw-r--r-- | lib/Makefile | 7 | ||||
-rw-r--r-- | lib/util/Makefile | 2 | ||||
-rw-r--r-- | lib/util/nsleep.c | 27 | ||||
-rw-r--r-- | lib/util/nsleep.h | 7 |
4 files changed, 41 insertions, 2 deletions
diff --git a/lib/Makefile b/lib/Makefile index 34547e7a..99629d19 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -40,7 +40,12 @@ ifneq (${VMS}x,x) LIBOBJECTS += libpbmvms.o endif # Library objects to be linked but not built by Makefile.common: -LIBOBJECTS_X = util/shhopt.o util/nstring.o util/vasprintf.o util/filename.o +LIBOBJECTS_X = \ + util/shhopt.o \ + util/nstring.o \ + util/vasprintf.o \ + util/filename.o \ + util/nsleep.o \ MANUALS3 = libnetpbm MANUALS5 = pbm pgm ppm pnm pam diff --git a/lib/util/Makefile b/lib/util/Makefile index 49396010..7e4d5378 100644 --- a/lib/util/Makefile +++ b/lib/util/Makefile @@ -9,7 +9,7 @@ include $(BUILDDIR)/Makefile.config # nstring is required for asprintf(), etc. Also some systems don't have # snprintf(), e.g. Solaris 2.5.1. 2002.03.29. -UTILOBJECTS = shhopt.o nstring.o vasprintf.o filename.o +UTILOBJECTS = shhopt.o nstring.o vasprintf.o filename.o nsleep.o MERGE_OBJECTS = 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 +} diff --git a/lib/util/nsleep.h b/lib/util/nsleep.h new file mode 100644 index 00000000..372b8008 --- /dev/null +++ b/lib/util/nsleep.h @@ -0,0 +1,7 @@ +#ifndef NSLEEP_H_INCLUDED +#define NSLEEP_H_INCLUDED + +void +sleepN(unsigned int const milliseconds); + +#endif |