From: Jarkko Hietaniemi Date: Tue, 1 Jul 2003 05:54:58 +0000 (+0000) Subject: Rework Time::HiRes not to need HAS_NANOSLEEP from Configure. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=046e3f33bfc965c84e96ed0ef0ba38b777cb38bf;p=p5sagit%2Fp5-mst-13.2.git Rework Time::HiRes not to need HAS_NANOSLEEP from Configure. p4raw-id: //depot/perl@19898 --- diff --git a/MANIFEST b/MANIFEST index d084d31..190df68 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 436c614..91249f0 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 8343307..f93a5b1 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 0000000..b19d149 --- /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 73ff149..22f2764 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'];