summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-07-01 05:54:58 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-07-01 05:54:58 +0000
commit046e3f33bfc965c84e96ed0ef0ba38b777cb38bf (patch)
tree04f50c23a5d649f8b78094892adceec723a07b09
parent6bdd71ef1830fa9fb85306405e4da0222df1321d (diff)
downloadperl-046e3f33bfc965c84e96ed0ef0ba38b777cb38bf.tar.gz
Rework Time::HiRes not to need HAS_NANOSLEEP from Configure.
p4raw-id: //depot/perl@19898
-rw-r--r--MANIFEST1
-rw-r--r--ext/Time/HiRes/HiRes.xs5
-rw-r--r--ext/Time/HiRes/Makefile.PL60
-rw-r--r--ext/Time/HiRes/hints/dec_osf.pl3
-rw-r--r--ext/Time/HiRes/hints/sco.pl3
5 files changed, 28 insertions, 44 deletions
diff --git a/MANIFEST b/MANIFEST
index d084d31435..190df68cca 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -733,6 +733,7 @@ ext/threads/typemap ithreads
ext/Time/HiRes/Changes Time::HiRes extension
ext/Time/HiRes/fallback/const-c.inc Time::HiRes extension
ext/Time/HiRes/fallback/const-xs.inc Time::HiRes extension
+ext/Time/HiRes/hints/dec_osf.pl Hint for Time::HiRes for named architecture
ext/Time/HiRes/hints/dynixptx.pl Hint for Time::HiRes for named architecture
ext/Time/HiRes/hints/irix.pl Hint for Time::HiRes for named architecture
ext/Time/HiRes/hints/sco.pl Hints for Time::HiRes for named architecture
diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs
index 436c6142b9..91249f0fd2 100644
--- a/ext/Time/HiRes/HiRes.xs
+++ b/ext/Time/HiRes/HiRes.xs
@@ -340,7 +340,10 @@ gettimeofday (struct timeval *tp, void *tpz)
#endif
-#if !defined(HAS_USLEEP) && defined(HAS_NANOSLEEP)
+ /* Do not use H A S _ N A N O S L E E P
+ * so that Perl Configure doesn't scan for it.
+ * The TIME_HIRES_NANOSLEEP is set by Makefile.PL. */
+#if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP)
#define HAS_USLEEP
#define usleep hrt_nanosleep /* could conflict with ncurses for static build */
diff --git a/ext/Time/HiRes/Makefile.PL b/ext/Time/HiRes/Makefile.PL
index 83433075cf..f93a5b15d2 100644
--- a/ext/Time/HiRes/Makefile.PL
+++ b/ext/Time/HiRes/Makefile.PL
@@ -11,9 +11,11 @@ use strict;
my $VERBOSE = $ENV{VERBOSE};
my $DEFINE;
-my $LIBS;
+my $LIBS = [];
my $XSOPT;
+use vars qw($self); # Used in 'sourcing' the hints.
+
my $ld_exeext = ($^O eq 'os2' and $Config{ldflags} =~ /-Zexe\b/) ? '.exe' : '';
unless($ENV{PERL_CORE}) {
@@ -212,46 +214,19 @@ EOM
return 0;
}
-sub unixinit {
- $DEFINE = '';
-
- $LIBS = [];
-
- # this might break the link, try it if it can't find some things you
- # honestly think should be in there...
- # $LIBS = ['-lucb -lbsd'];
-
- # ... but ucb is poison for Solaris, and probably Linux. honest.
- $LIBS = [] if $Config{'osname'} eq 'solaris';
- $LIBS = [] if $Config{'osname'} eq 'linux';
- $LIBS = ['-lm'] if $Config{'osname'} =~ /sco/i;
- $LIBS = ['-lc'] if $Config{'osname'} =~ /dynixptx/i;
-
- # For nanosleep
- push @$LIBS, '-lrt' unless $Config{'osname'} =~ /^(?:irix|linux)$/;
- push @$LIBS, '-lposix4';
-
- my @goodlibs;
-
- select(STDOUT);
- $| = 1;
-
- print "Checking for libraries...\n";
- my $lib;
- for $lib (@$LIBS) {
- print "Checking for $lib... ";
- $LIBS = [ $lib ];
- if ($Config{libs} =~ /\b$lib\b/ || has_x("time(0)")) {
- push @goodlibs, $lib;
- print "found.\n";
- } else {
- print "NOT found.\n";
+sub init {
+ my $hints = File::Spec->catfile("hints", "$^O.pl");
+ if (-f $hints) {
+ print "Using hints $hints...\n";
+ local $self;
+ do $hints;
+ if (exists $self->{LIBS}) {
+ $LIBS = $self->{LIBS};
+ print "Extra libraries: @$LIBS...\n";
}
}
- $LIBS = [ @goodlibs ];
- print @$LIBS ?
- "You have extra libraries: @$LIBS.\n" :
- "You have no applicable extra libraries.\n";
+
+ $DEFINE = '';
print "Looking for gettimeofday()... ";
my $has_gettimeofday;
@@ -360,9 +335,10 @@ EOD
my $has_nanosleep;
if ($Config{d_nanosleep}) {
$has_nanosleep++;
+ $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
} elsif (has_x ("nanosleep (NULL, NULL)")) {
$has_nanosleep++;
- $DEFINE .= ' -DHAS_NANOSLEEP';
+ $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
}
if ($has_nanosleep) {
@@ -452,9 +428,9 @@ sub main {
if ($^O =~ /Win32/i) {
$DEFINE = '-DSELECT_IS_BROKEN';
- $LIBS = [''];
+ $LIBS = [];
} else {
- unixinit();
+ init();
}
doMakefile;
doConstants;
diff --git a/ext/Time/HiRes/hints/dec_osf.pl b/ext/Time/HiRes/hints/dec_osf.pl
new file mode 100644
index 0000000000..b19d149e70
--- /dev/null
+++ b/ext/Time/HiRes/hints/dec_osf.pl
@@ -0,0 +1,3 @@
+# needs to explicitly link against librt to pull in nanosleep
+$self->{LIBS} = ['-lrt'];
+
diff --git a/ext/Time/HiRes/hints/sco.pl b/ext/Time/HiRes/hints/sco.pl
index 73ff149879..22f2764347 100644
--- a/ext/Time/HiRes/hints/sco.pl
+++ b/ext/Time/HiRes/hints/sco.pl
@@ -1,3 +1,4 @@
# osr5 needs to explicitly link against libc to pull in usleep
-$self->{LIBS} = ['-lc'];
+# what's the reason for -lm?
+$self->{LIBS} = ['-lm', '-lc'];