From b2cabe67ae053fe2b734c0bbecc434246a9692d5 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Tue, 1 Jan 2008 17:35:34 +0000 Subject: Add sleepN() git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@540 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/Makefile | 7 ++++++- lib/util/Makefile | 2 +- lib/util/nsleep.c | 27 +++++++++++++++++++++++++++ lib/util/nsleep.h | 7 +++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 lib/util/nsleep.c create mode 100644 lib/util/nsleep.h 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 + #include +#else + #include +#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 -- cgit 1.4.1