summaryrefslogtreecommitdiff
path: root/ext/Time
diff options
context:
space:
mode:
Diffstat (limited to 'ext/Time')
-rw-r--r--ext/Time/HiRes/Changes11
-rw-r--r--ext/Time/HiRes/HiRes.pm2
-rw-r--r--ext/Time/HiRes/HiRes.xs28
3 files changed, 39 insertions, 2 deletions
diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes
index c23031c360..58e5be4a52 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 cdafff5568..54fe20d198 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 4c56464065..666de93873 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