Change 25379 by [EMAIL PROTECTED] on 2005/09/10 20:29:37
Integrate:
(the Time::HiRes part of)
[ 24271]
Subject: [PATCH] Symbian port of Perl
From: <[EMAIL PROTECTED]>
Date: Mon, 18 Apr 2005 13:18:30 +0300
Message-ID: <[EMAIL PROTECTED]>
[ 24472]
Upgrade to Time::HiRes 1.68
[ 24985]
Upgrade to Time::HiRes 1.69
[ 24988]
Upgrade to Time::HiRes 1.70
[ 25002]
Upgrade to Time::HiRes 1.71
[ 25044]
Upgrade to Time::HiRes 1.72
[ 25295]
Subject: Time::HiRes::nanosleep support for Solaris [PATCH]
From: Gisle Aas <[EMAIL PROTECTED]>
Date: 15 Aug 2005 21:05:22 -0700
Message-ID: <[EMAIL PROTECTED]>
[ 25298]
Upgrade to Time::HiRes 1.73
Affected files ...
... //depot/maint-5.8/perl/ext/Time/HiRes/Changes#24 integrate
... //depot/maint-5.8/perl/ext/Time/HiRes/HiRes.pm#26 integrate
... //depot/maint-5.8/perl/ext/Time/HiRes/HiRes.xs#14 integrate
... //depot/maint-5.8/perl/ext/Time/HiRes/Makefile.PL#28 integrate
... //depot/maint-5.8/perl/ext/Time/HiRes/hints/solaris.pl#3 integrate
... //depot/maint-5.8/perl/ext/Time/HiRes/t/HiRes.t#10 integrate
Differences ...
==== //depot/maint-5.8/perl/ext/Time/HiRes/Changes#24 (text) ====
Index: perl/ext/Time/HiRes/Changes
--- perl/ext/Time/HiRes/Changes#23~24144~ Sun Apr 3 08:18:11 2005
+++ perl/ext/Time/HiRes/Changes Sat Sep 10 13:29:37 2005
@@ -1,5 +1,54 @@
Revision history for Perl extension Time::HiRes.
+1.73 - Time::HiRes::nanosleep support for Solaris [PATCH]
+ (POSIX::uname() not available if building with core perl,
+ from Gisle Aas, via perl5-porters, perl change #25295)
+
+1.72 - going back to the 1.68 loader setup (using DynaLoader)
+ since too many weird things starting breaking
+ - fix a typo in José Auguste-Etienne's name
+
+1.71 - a thinko in the nanosleep() detection
+ - move more changes stuff from the README to Changes
+ - add -w to the Makefile.PL
+
+1.70 - oops in 1.69 about @ISA (not affecting anything but silly)
+ - add copyright 2005 to HiRes.pm
+ - add copyright and license to HiRes.xs
+ - add copyrights 2003, 2004, 2005 to README
+
+1.69 - actually run a test for nanosleep
+ (if there is no $Config{d_nanosleep}) since e.g. in AIX 4.2
+ it seems that one can link in nanosleep() but then calling
+ it fails instantly and sets errno to ENOSYS (Not implemented).
+ This may be fixable in the AIX case by figuring out the right
+ (realtime POSIX?) libs and whatnot, but in the general case
+ running a real test case is better. (Of course, this change
+ will no doubt run into portability problems because of the
+ execution step...) Note that because of hysterical raisins
+ most Perls do NOT have $Config{d_nanosleep} (scanning for
+ it by Configure would in many platforms require linking in
+ things like -lrt, which would in many platforms be a bad idea
+ for Perl itself).
+ (from José Auguste-Etienne)
+ - support XSLoader also since it's much faster
+ (from Alexey Tourbin)
+ - add SEE ALSO (BSD::Resource and Time::TAI64)
+
+1.68
+ - somehow 1.67 had a lot of doubled lines (a major cut-and-paste
+ error suspected), but miraculously it still worked since the
+ doubling took place below the __END__ token
+ - undef Pause() before defining it to avoid redefinition warnings
+ during compilation in case perl.h had already defined Pause()
+ (part of perl change #24271)
+ - minor doc tweaks
+
+1.67
+ - (internal) don't ignore the return value of gettimeofday()
+ - (external) return undef or an empty if the C gettimeofday() fails
+ (affects Time::HiRes gettimeofday() and the hires time())
+
1.66
- add nanosleep()
- fix the 'hierachy' typo in Makefile.PL [rt.cpan.org #8492]
@@ -237,10 +286,23 @@
the IVSIZE might not be defined)
- define NVgf if needed
- grab the typemap from 5.8.0 for the NV stuff
+
+ 1.31 and 1.32 add more backward compatibility (now all the way
+ back to Perl 5.00404), and using nanosleep() (if available) for
+ subsecond sleeps.
+
1.30
- release 1.29_02 as 1.30
+ 1.30 adds all the changes made during the Perl 5.6->5.7->5.8
+ development cycle. Most notably portability across platforms has been
+ enhanced, and the interval timers (setitimer, getitimer) have been
+ added. Note that the version of Time::HiRes that is included in Perl
+ 5.8.0 calls itself 1.20_00, but it is equivalent to this Time::HiRes
+ version. Note also that in 1.30 Wegscheid turns over the maintenance
+ to Jarkko Hietaniemi.
+
1.29_02
- fix a silly unclosed comment typo in HiRes.xs
@@ -346,6 +408,10 @@
- hopefully correct "-lc" fix for SCO.
- add PPD stuff
+ 1.20 adds a platform neutral set of C accessible routines if you are
+ running 5.005+. All other changes are packaging changes and build
+ fixes(?) for statically linked Perl, SCO, and VMS.
+
1.19 Tue Sep 29 22:30 1998
- put VMS gettimeofday() in. Patch is from Sebastian Bazley
<[EMAIL PROTECTED]>
@@ -357,6 +423,8 @@
- fix Makefile.PL (more) so that detection of gettimeofday is
more correct.
+ 1.19 has better VMS support.
+
1.18 Mon Jul 6 22:40 1998
- add usleep() for Win32.
- fix Makefile.PL to fix reported HP/UX feature where unresolved
@@ -364,6 +432,9 @@
x bit set). Thanks to David Kozinn for report and explanation.
Problems with the fix are mine :)
+ 1.18 has limited Win32 support (no ualarm). Added usleep for Win32.
+ Probably buggy. I'm sure I'll hear.
+
1.17 Wed Jul 1 20:10 1998
- fix setitimer calls so microseconds is not more than 1000000.
Hp/UX 9 doesn't like that. Provided by Roland B Robert, PhD.
@@ -374,6 +445,22 @@
1.16 Wed Nov 12 21:05 1997
- add missing EXTEND in new gettimeofday scalar code.
+
+ 1.16+ should be closer to building out of the box on Linux. Thanks
+ to Gisle Aas for patches, and the ualarm equivalent using setitimer.
+
+ If your underlying operating system doesn't implement ualarm(), then
+ a fake using setitimer() will be made. If the OS is missing usleep(),
+ a fake one using select() will be made. If a fake can't be made for
+ either ualarm() or usleep(), then the corresponding Perl function will
+ not be available. If the OS is missing gettimeofday(), you will get
+ unresolved externals, either at link- or run-time.
+
+ This is an improvement; the package used to not even build if
+ you were missing any of these bits. Roderick Schertler
+
+ <[EMAIL PROTECTED]> did all the conditional compilation stuff,
+ look at HiRes.pm and the test suites; it's good educational reading.
1.15 Mon Nov 10 21:30 1997
- HiRes.pm: update pod. Provided by Gisle Aas.
==== //depot/maint-5.8/perl/ext/Time/HiRes/HiRes.pm#26 (text) ====
Index: perl/ext/Time/HiRes/HiRes.pm
--- perl/ext/Time/HiRes/HiRes.pm#25~24144~ Sun Apr 3 08:18:11 2005
+++ perl/ext/Time/HiRes/HiRes.pm Sat Sep 10 13:29:37 2005
@@ -15,7 +15,7 @@
d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
d_nanosleep);
-$VERSION = '1.66';
+$VERSION = '1.73';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
@@ -24,7 +24,10 @@
($constname = $AUTOLOAD) =~ s/.*:://;
die "&Time::HiRes::constant not defined" if $constname eq 'constant';
my ($error, $val) = constant($constname);
- if ($error) { die $error; }
+ if ($error) {
+ my (undef,$file,$line) = caller;
+ die "$error at $file line $line.\n";
+ }
{
no strict 'refs';
*$AUTOLOAD = sub { $val };
@@ -111,9 +114,9 @@
then carefully read your C<nanosleep()> C API documentation for any
peculiarities.
-Unless using C<nanosleep> for mixing sleeping with signals, give
-some thought to whether Perl is the tool you should be using for
-work requiring nanosecond accuracies.
+If you are using C<nanosleep> for something else than mixing sleeping
+with signals, give some thought to whether Perl is the tool you should
+be using for work requiring nanosecond accuracies.
The following functions can be imported from this module.
No functions are exported by default.
@@ -151,7 +154,7 @@
Issues a C<ualarm> call; the C<$interval_useconds> is optional and
will be zero if unspecified, resulting in C<alarm>-like behaviour.
-Note that the interaction between alarms and sleeps are unspecified.
+Note that the interaction between alarms and sleeps is unspecified.
=item tv_interval
@@ -194,7 +197,7 @@
be imported, resulting in a nice drop-in replacement for the C<sleep>
provided with perl, see the L</EXAMPLES> below.
-Note that the interaction between alarms and sleeps are unspecified.
+Note that the interaction between alarms and sleeps is unspecified.
=item alarm ( $floating_seconds [, $interval_floating_seconds ] )
@@ -210,7 +213,7 @@
take the sum of the times specified for the the C<alarm()> and the
C<select()>, not just the time of the C<alarm()>.
-Note that the interaction between alarms and sleeps are unspecified.
+Note that the interaction between alarms and sleeps is unspecified.
=item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] )
@@ -235,7 +238,7 @@
and Cygwin have only C<ITIMER_REAL>, and only Solaris seems to have
C<ITIMER_REALPROF> (which is used to profile multithreaded programs).
-C<ITIMER_REAL> results in C<alarm()>-like behavior. Time is counted in
+C<ITIMER_REAL> results in C<alarm()>-like behaviour. Time is counted in
I<real time>; that is, wallclock time. C<SIGALRM> is delivered when
the timer expires.
@@ -326,12 +329,12 @@
Both functions return equivalent information (like C<gettimeofday>)
but with different representations. The names C<NVtime> and C<U2time>
were selected mainly because they are operating system independent.
-(C<gettimeofday> is Unix-centric, though some platforms like VMS have
-emulations for it.)
+(C<gettimeofday> is Unix-centric, though some platforms like Win32 and
+VMS have emulations for it.)
Here is an example of using C<NVtime> from C:
- double (*myNVtime)();
+ double (*myNVtime)(); /* Returns -1 on failure. */
SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0);
if (!svp) croak("Time::HiRes is required");
if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer");
@@ -363,6 +366,10 @@
drift off from the system clock (and the original time()) by up to 0.5
seconds. Time::HiRes will notice this eventually and recalibrate.
+=head1 SEE ALSO
+
+L<BSD::Resource>, L<Time::TAI64>.
+
=head1 AUTHORS
D. Wegscheid <[EMAIL PROTECTED]>
@@ -374,7 +381,7 @@
Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved.
-Copyright (c) 2002,2003,2004 Jarkko Hietaniemi. All rights reserved.
+Copyright (c) 2002, 2003, 2004, 2005 Jarkko Hietaniemi. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
==== //depot/maint-5.8/perl/ext/Time/HiRes/HiRes.xs#14 (text) ====
Index: perl/ext/Time/HiRes/HiRes.xs
--- perl/ext/Time/HiRes/HiRes.xs#13~24144~ Sun Apr 3 08:18:11 2005
+++ perl/ext/Time/HiRes/HiRes.xs Sat Sep 10 13:29:37 2005
@@ -1,3 +1,13 @@
+/*
+ *
+ * Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved.
+ *
+ * Copyright (c) 2002,2003,2004,2005 Jarkko Hietaniemi. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the same terms as Perl itself.
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -31,6 +41,7 @@
#ifdef HAS_PAUSE
# define Pause pause
#else
+# undef Pause /* In case perl.h did it already. */
# define Pause() sleep(~0) /* Zzz for a long time. */
#endif
@@ -810,16 +821,18 @@
PPCODE:
int status;
status = gettimeofday (&Tp, &Tz);
- Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
- if (GIMME == G_ARRAY) {
- EXTEND(sp, 2);
- /* Mac OS (Classic) has unsigned time_t */
- PUSHs(sv_2mortal(newSVuv(Tp.tv_sec)));
- PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
- } else {
- EXTEND(sp, 1);
- PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / 1000000.0))));
+ if (status == 0) {
+ Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
+ if (GIMME == G_ARRAY) {
+ EXTEND(sp, 2);
+ /* Mac OS (Classic) has unsigned time_t */
+ PUSHs(sv_2mortal(newSVuv(Tp.tv_sec)));
+ PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
+ } else {
+ EXTEND(sp, 1);
+ PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec /
1000000.0))));
+ }
}
NV
@@ -830,8 +843,12 @@
CODE:
int status;
status = gettimeofday (&Tp, &Tz);
- Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
- RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.0);
+ if (status == 0) {
+ Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
+ RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.0);
+ } else {
+ RETVAL = -1.0;
+ }
OUTPUT:
RETVAL
@@ -843,13 +860,15 @@
PPCODE:
int status;
status = gettimeofday (&Tp, NULL);
- if (GIMME == G_ARRAY) {
- EXTEND(sp, 2);
- PUSHs(sv_2mortal(newSViv(Tp.tv_sec)));
- PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
- } else {
- EXTEND(sp, 1);
- PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / 1000000.0))));
+ if (status == 0) {
+ if (GIMME == G_ARRAY) {
+ EXTEND(sp, 2);
+ PUSHs(sv_2mortal(newSViv(Tp.tv_sec)));
+ PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
+ } else {
+ EXTEND(sp, 1);
+ PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec /
1000000.0))));
+ }
}
NV
@@ -859,7 +878,11 @@
CODE:
int status;
status = gettimeofday (&Tp, NULL);
- RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.);
+ if (status == 0) {
+ RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.);
+ } else {
+ RETVAL = -1.0;
+ }
OUTPUT:
RETVAL
==== //depot/maint-5.8/perl/ext/Time/HiRes/Makefile.PL#28 (text) ====
Index: perl/ext/Time/HiRes/Makefile.PL
--- perl/ext/Time/HiRes/Makefile.PL#27~23503~ Tue Nov 16 13:28:30 2004
+++ perl/ext/Time/HiRes/Makefile.PL Sat Sep 10 13:29:37 2005
@@ -1,3 +1,10 @@
+#!/usr/bin/perl
+#
+# In general we trust %Config, but for nanosleep() this trust
+# may be misplaces (it may be linkable but not really functional).
+# Use $ENV{FORCE_NANOSLEEP_SCAN} to force rescanning whether there
+# really is hope.
+
require 5.002;
use Config;
@@ -7,7 +14,7 @@
my $VERBOSE = $ENV{VERBOSE};
my $DEFINE;
my $LIBS = [];
-my $XSOPT;
+my $XSOPT = '';
use vars qw($self); # Used in 'sourcing' the hints.
@@ -135,16 +142,30 @@
printf "cccmd = $cccmd\n" if $VERBOSE;
my $res = system($cccmd);
$ok = defined($res) && $res==0 && -s $tmp_exe && -x _;
+
+ if ( $ok && exists $args{run} && $args{run}) {
+ my $abs_tmp_exe =
+ File::Spec->
+ catfile(File::Spec->rel2abs(File::Spec->curdir),
+ $tmp_exe);
+ printf "Running $abs_tmp_exe..." if $VERBOSE;
+ if (system($abs_tmp_exe) == 0) {
+ $ok = 1;
+ } else {
+ $ok = 0;
+ print "[ system('$abs_tmp_exe') failed: status $? ] ";
+ }
+ }
unlink("$tmp.c", $tmp_exe);
}
}
- $ok;
+ return $ok;
}
sub has_gettimeofday {
# confusing but true (if condition true ==> -DHAS_GETTIMEOFDAY already)
- return 0 if $Config{d_gettimeod} eq 'define';
+ return 0 if $Config{d_gettimeod};
return 1 if try_compile_and_link(<<EOM);
#include "EXTERN.h"
#include "perl.h"
@@ -202,6 +223,32 @@
return 0;
}
+sub has_nanosleep {
+ print "Trying out nanosleep... ";
+ return 1 if
+ try_compile_and_link(<<EOM, run => 1);
+#include <time.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/* int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); */
+
+int main() {
+ struct timespec ts1, ts2;
+ int ret;
+ ts1.tv_sec = 0;
+ ts1.tv_nsec = 750000000;
+ ts2.tv_sec = 0;
+ ts2.tv_nsec = 0;
+ errno = 0;
+ ret = nanosleep(&ts1, &ts2); /* E.g. in AIX nanosleep() fail and set errno
to ENOSYS. */
+ ret == 0 ? exit(0) : exit(errno ? errno : -1);
+}
+EOM
+}
+
sub has_include {
my ($inc) = @_;
return 1 if
@@ -327,7 +374,7 @@
} else {
print "NOT found.\n";
print "Let's see if you have select()... ";
- if ($Config{'d_select'} eq 'define') {
+ if ($Config{'d_select'}) {
print "found.\n";
print "We can make a Time::HiRes::usleep().\n";
} else {
@@ -338,13 +385,14 @@
print "Looking for nanosleep()... ";
my $has_nanosleep;
- if (exists $Config{d_nanosleep}) {
+ if (exists $Config{d_nanosleep} && !$ENV{FORCE_NANOSLEEP_SCAN}) {
+ # Believe $Config{d_nanosleep}.
if ($Config{d_nanosleep}) {
$has_nanosleep++;
$DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
}
} elsif ($^O ne 'mpeix' && # MPE/iX falsely finds nanosleep.
- has_x ("nanosleep (NULL, NULL)")) {
+ has_nanosleep()) {
$has_nanosleep++;
$DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
}
==== //depot/maint-5.8/perl/ext/Time/HiRes/hints/solaris.pl#3 (text) ====
Index: perl/ext/Time/HiRes/hints/solaris.pl
--- perl/ext/Time/HiRes/hints/solaris.pl#2~23273~ Sun Sep 5 15:06:51 2004
+++ perl/ext/Time/HiRes/hints/solaris.pl Sat Sep 10 13:29:37 2005
@@ -1,6 +1,7 @@
-use POSIX qw(uname);
# 2.6 has nanosleep in -lposix4, after that it's in -lrt
-if (substr((uname())[2], 2) <= 6) {
+my $r = `/usr/bin/uname -r`;
+chomp($r);
+if (substr($r, 2) <= 6) {
$self->{LIBS} = ['-lposix4'];
} else {
$self->{LIBS} = ['-lrt'];
==== //depot/maint-5.8/perl/ext/Time/HiRes/t/HiRes.t#10 (text) ====
Index: perl/ext/Time/HiRes/t/HiRes.t
--- perl/ext/Time/HiRes/t/HiRes.t#9~24144~ Sun Apr 3 08:18:11 2005
+++ perl/ext/Time/HiRes/t/HiRes.t Sat Sep 10 13:29:37 2005
@@ -14,7 +14,7 @@
BEGIN { $| = 1; print "1..28\n"; }
-END {print "not ok 1\n" unless $loaded;}
+END { print "not ok 1\n" unless $loaded }
use Time::HiRes qw(tv_interval);
End of Patch.