From: Steve Peters <steve@fisharerojo.org>
Date: Fri, 4 Nov 2005 00:10:21 +0000 (+0000)
Subject: Upgrade to Time-HiRes 1.79
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5433ad89831be48f30ff00a45f97ceccc5dde26;p=p5sagit%2Fp5-mst-13.2.git

Upgrade to Time-HiRes 1.79

p4raw-id: //depot/perl@25981
---

diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes
index c23031c..58e5be4 100644
--- a/ext/Time/HiRes/Changes
+++ b/ext/Time/HiRes/Changes
@@ -1,8 +1,17 @@
 Revision history for Perl extension Time::HiRes.
 
+1.79	[2005-10-03]
+	- try nanosleep for emulating usleep -- may help in some weird
+	  embedded realtime places which have nanosleep but neither usleep
+	  nor select nor poll (doesn't have to be weird embedded realtime
+	  place, though -- in many places usleep is nanosleep anyway)
+	- try poll for emulating usleep -- this may help some obscure/old
+	  SVR4 places that have neither usleep nor select
+	- a redundant test guard in HiRes.t
+
 1.78	[2005-10-03]
 	- ITIMER_VIRTUAL detection in HiRes.t had problems (that we cannot
-	  in the general case fail already at 'use' is suboptimal)
+	  in the general case fail already at 'use' phase is suboptimal)
 	- fixes to the documentation of clock_gettime() and clock_getres()
 
 1.77	[2005-10-03]
diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm
index cdafff5..54fe20d 100644
--- a/ext/Time/HiRes/HiRes.pm
+++ b/ext/Time/HiRes/HiRes.pm
@@ -17,7 +17,7 @@ require DynaLoader;
 		 d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
 		 d_nanosleep d_clock_gettime d_clock_getres);
 	
-$VERSION = '1.78';
+$VERSION = '1.79';
 $XS_VERSION = $VERSION;
 $VERSION = eval $VERSION;
 
diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs
index 4c56464..666de93 100644
--- a/ext/Time/HiRes/HiRes.xs
+++ b/ext/Time/HiRes/HiRes.xs
@@ -362,6 +362,7 @@ gettimeofday (struct timeval *tp, void *tpz)
 
  /* Do not use H A S _ N A N O S L E E P
   * so that Perl Configure doesn't scan for it.
+  * (We are part of the core perl now.)
   * The TIME_HIRES_NANOSLEEP is set by Makefile.PL. */
 #if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP)
 #define HAS_USLEEP
@@ -408,6 +409,33 @@ hrt_usleep(unsigned long usec)
 }
 #endif /* #if !defined(HAS_USLEEP) && defined(WIN32) */
 
+#if !defined(HAS_USLEEP) && defined(HAS_NANOSLEEP)
+#define HAS_USLEEP
+#define usleep hrt_usleep  /* could conflict with ncurses for static build */
+
+void
+hrt_usleep(unsigned long usec)
+{
+	struct timespec tsa;
+	tsa.tv_sec  = usec * 1000; /* Ignoring wraparound. */
+	tsa.tv_nsec = 0;
+	nanosleep(&tsa, NULL);
+}
+
+#endif /* #if !defined(HAS_USLEEP) && defined(HAS_POLL) */
+
+#if !defined(HAS_USLEEP) && defined(HAS_POLL)
+#define HAS_USLEEP
+#define usleep hrt_usleep  /* could conflict with ncurses for static build */
+
+void
+hrt_usleep(unsigned long usec)
+{
+    int msec = usec / 1000;
+    poll(0, 0, msec);
+}
+
+#endif /* #if !defined(HAS_USLEEP) && defined(HAS_POLL) */
 
 #if !defined(HAS_UALARM) && defined(HAS_SETITIMER)
 #define HAS_UALARM