diff options
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 |