This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix cases where 'do file' should be 'do ./file'.
[perl5.git] / dist / Time-HiRes / Makefile.PL
index 1c1ce1f..ca4d4dc 100644 (file)
@@ -88,7 +88,7 @@ sub try_compile_and_link {
     my $obj_ext = $Config{obj_ext} || ".o";
     unlink("$tmp.c", "$tmp$obj_ext");
 
-    if (open(TMPC, ">$tmp.c")) {
+    if (open(TMPC, '>', "$tmp.c")) {
        print TMPC $c;
        close(TMPC);
 
@@ -132,7 +132,7 @@ __EOD__
            unless defined $cccmd;
 
        if ($^O eq 'VMS') {
-           open( CMDFILE, ">$tmp.com" );
+           open( CMDFILE, '>', "$tmp.com" );
            print CMDFILE "\$ SET MESSAGE/NOFACILITY/NOSEVERITY/NOIDENT/NOTEXT\n";
            print CMDFILE "\$ $cccmd\n";
            print CMDFILE "\$ IF \$SEVERITY .NE. 1 THEN EXIT 44\n"; # escalate
@@ -290,6 +290,7 @@ sub has_clock_xxx_syscall {
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
+#include <time.h>
 #include <$SYSCALL_H>
 int main(int argc, char** argv)
 {
@@ -309,6 +310,7 @@ sub has_clock_xxx {
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
+#include <time.h>
 int main(int argc, char** argv)
 {
     struct timespec ts;
@@ -325,6 +327,7 @@ sub has_clock {
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
+#include <time.h>
 int main(int argc, char** argv)
 {
     clock_t tictoc;
@@ -348,7 +351,8 @@ int main(int argc, char** argv)
     struct timespec ts2;
     ts1.tv_sec  = 0;
     ts1.tv_nsec = 750000000;;
-    ret = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts1, &ts2);
+    /* All implementations are supposed to support CLOCK_REALTIME. */
+    ret = clock_nanosleep(CLOCK_REALTIME, 0, &ts1, &ts2);
     ret == 0 ? exit(0) : exit(errno ? errno : -1);
 }
 EOM
@@ -360,7 +364,7 @@ sub has_futimens {
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
-#include <sys/time.h>
+#include <sys/stat.h>
 int main(int argc, char** argv)
 {
     int ret;
@@ -377,7 +381,7 @@ sub has_utimensat{
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
-#include <sys/time.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 int main(int argc, char** argv)
 {
@@ -389,6 +393,21 @@ int main(int argc, char** argv)
 EOM
 }
 
+sub has_clockid_t{
+    return 1 if
+    try_compile_and_link(<<EOM);
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include <time.h>
+int main(int argc, char** argv)
+{
+    clockid_t id = CLOCK_REALTIME;
+    exit(id == CLOCK_REALTIME ? 1 : 0);
+}
+EOM
+}
+
 sub DEFINE {
     my ($def, $val) = @_;
     my $define = defined $val ? "$def=$val" : $def ;
@@ -398,7 +417,7 @@ sub DEFINE {
 }
 
 sub init {
-    my $hints = File::Spec->catfile("hints", "$^O.pl");
+    my $hints = File::Spec->catfile(".", "hints", "$^O.pl");
     if (-f $hints) {
        print "Using hints $hints...\n";
        local $self;
@@ -569,6 +588,16 @@ EOD
         print "(It would not be portable anyway.)\n";
     }
 
+    print "Looking for clockid_t... ";
+    my $has_clockid_t;
+    if (has_clockid_t()) {
+       print "found.\n";
+        $has_clockid_t++;
+       $DEFINE .= ' -DTIME_HIRES_CLOCKID_T';
+    } else {
+       print "NOT found, will use int.\n";
+    }
+
     print "Looking for clock_gettime()... ";
     my $has_clock_gettime;
     my $has_clock_gettime_emulation;
@@ -835,7 +864,7 @@ EOM
 
     if ($DEFINE) {
         $DEFINE =~ s/^\s+//;
-        if (open(XDEFINE, ">xdefine")) {
+        if (open(XDEFINE, '>', 'xdefine')) {
            print XDEFINE $DEFINE, "\n";
            close(XDEFINE);
         }
@@ -986,8 +1015,8 @@ sub doConstants {
        foreach $file ('const-c.inc', 'const-xs.inc') {
            my $fallback = File::Spec->catfile('fallback', $file);
            local $/;
-           open IN, "<$fallback" or die "Can't open $fallback: $!";
-           open OUT, ">$file" or die "Can't open $file: $!";
+           open IN, '<', $fallback or die "Can't open $fallback: $!";
+           open OUT, '>', $file or die "Can't open $file: $!";
            print OUT <IN> or die $!;
            close OUT or die "Can't close $file: $!";
            close IN or die "Can't close $fallback: $!";
@@ -1006,7 +1035,7 @@ sub main {
            DEFINE('SELECT_IS_BROKEN');
            $LIBS = [];
            print "System is $^O, skipping full configure...\n";
-           open(XDEFINE, ">xdefine") or die "$0: Cannot create xdefine: $!\n";
+           open(XDEFINE, '>', 'xdefine') or die "$0: Cannot create xdefine: $!\n";
            close(XDEFINE);
        } else {
            init();