summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL')
-rw-r--r--gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL106
1 files changed, 96 insertions, 10 deletions
diff --git a/gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL b/gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL
index 087ab79871c..1c1ce1f4dea 100644
--- a/gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL
+++ b/gnu/usr.bin/perl/dist/Time-HiRes/Makefile.PL
@@ -354,6 +354,41 @@ int main(int argc, char** argv)
EOM
}
+sub has_futimens {
+ return 1 if
+ try_compile_and_link(<<EOM);
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include <sys/time.h>
+int main(int argc, char** argv)
+{
+ int ret;
+ struct timespec ts[2];
+ ret = futimens(0, ts);
+ ret == 0 ? exit(0) : exit(errno ? errno : -1);
+}
+EOM
+}
+
+sub has_utimensat{
+ return 1 if
+ try_compile_and_link(<<EOM);
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include <sys/time.h>
+#include <fcntl.h>
+int main(int argc, char** argv)
+{
+ int ret;
+ struct timespec ts[2];
+ ret = utimensat(AT_FDCWD, 0, ts, 0);
+ ret == 0 ? exit(0) : exit(errno ? errno : -1);
+}
+EOM
+}
+
sub DEFINE {
my ($def, $val) = @_;
my $define = defined $val ? "$def=$val" : $def ;
@@ -548,7 +583,7 @@ EOD
} elsif ($^O eq 'darwin') {
$has_clock_gettime_emulation++;
$has_clock_gettime++;
- $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME';
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_EMULATION';
}
if ($has_clock_gettime) {
@@ -577,7 +612,7 @@ EOD
} elsif ($^O eq 'darwin') {
$has_clock_getres_emulation++;
$has_clock_getres++;
- $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES';
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_EMULATION';
}
if ($has_clock_getres) {
@@ -603,7 +638,7 @@ EOD
} elsif ($^O eq 'darwin') {
$has_clock_nanosleep++;
$has_clock_nanosleep_emulation++;
- $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP';
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP -DTIME_HIRES_CLOCK_NANOSLEEP_EMULATION';
}
if ($has_clock_nanosleep) {
@@ -631,6 +666,36 @@ EOD
print "NOT found.\n";
}
+ print "Looking for futimens()... ";
+ my $has_futimens;
+ if (has_futimens()) {
+ $has_futimens++;
+ $DEFINE .= ' -DHAS_FUTIMENS';
+ }
+
+ if ($has_futimens) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Looking for utimensat()... ";
+ my $has_utimensat;
+ if (has_utimensat()) {
+ $has_utimensat++;
+ $DEFINE .= ' -DHAS_UTIMENSAT';
+ }
+
+ if ($has_utimensat) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ if ($has_futimens or $has_utimensat) {
+ $DEFINE .= ' -DTIME_HIRES_UTIME';
+ }
+
print "Looking for stat() subsecond timestamps...\n";
print "Trying struct stat st_atimespec.tv_nsec...";
@@ -644,7 +709,7 @@ int main(int argc, char** argv) {
}
EOM
$has_stat_st_xtimespec++;
- DEFINE('TIME_HIRES_STAT', 1);
+ DEFINE('TIME_HIRES_STAT_ST_XTIMESPEC'); # 1
}
if ($has_stat_st_xtimespec) {
@@ -664,7 +729,7 @@ int main(int argc, char** argv) {
}
EOM
$has_stat_st_xtimensec++;
- DEFINE('TIME_HIRES_STAT', 2);
+ DEFINE('TIME_HIRES_STAT_ST_XTIMENSEC'); # 2
}
if ($has_stat_st_xtimensec) {
@@ -684,7 +749,7 @@ int main(int argc, char** argv) {
}
EOM
$has_stat_st_xtime_n++;
- DEFINE('TIME_HIRES_STAT', 3);
+ DEFINE('TIME_HIRES_STAT_ST_XTIME_N'); # 3
}
if ($has_stat_st_xtime_n) {
@@ -704,7 +769,7 @@ int main(int argc, char** argv) {
}
EOM
$has_stat_st_xtim++;
- DEFINE('TIME_HIRES_STAT', 4);
+ DEFINE('TIME_HIRES_STAT_XTIM'); # 4
}
if ($has_stat_st_xtim) {
@@ -724,7 +789,7 @@ int main(int argc, char** argv) {
}
EOM
$has_stat_st_uxtime++;
- DEFINE('TIME_HIRES_STAT', 5);
+ DEFINE('TIME_HIRES_STAT_ST_UXTIME'); # 5
}
if ($has_stat_st_uxtime) {
@@ -733,6 +798,19 @@ EOM
print "NOT found.\n";
}
+ # See HiRes.xs hrstatns()
+ if ($has_stat_st_xtimespec) {
+ DEFINE('TIME_HIRES_STAT', 1);
+ } elsif ($has_stat_st_xtimensec) {
+ DEFINE('TIME_HIRES_STAT', 2);
+ } elsif ($has_stat_st_xtime_n) {
+ DEFINE('TIME_HIRES_STAT', 3);
+ } elsif ($has_stat_st_xtim) {
+ DEFINE('TIME_HIRES_STAT', 4);
+ } elsif ($has_stat_st_uxtime) {
+ DEFINE('TIME_HIRES_STAT', 5);
+ }
+
if ($DEFINE =~ /-DTIME_HIRES_STAT=\d+/) {
print "You seem to have stat() subsecond timestamps.\n";
print "(Your struct stat has them, but the filesystems must help.)\n";
@@ -791,7 +869,7 @@ sub doMakefile {
'DynaLoader' => 0,
'Exporter' => 0,
'ExtUtils::MakeMaker' => 0,
- 'Test::More' => "0.82",
+ 'Test::More' => 0,
'strict' => 0,
},
'dist' => {
@@ -869,7 +947,8 @@ sub doConstants {
);
foreach (qw (d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
d_nanosleep d_clock_gettime d_clock_getres
- d_clock d_clock_nanosleep d_hires_stat)) {
+ d_clock d_clock_nanosleep d_hires_stat
+ d_futimens d_utimensat d_hires_utime)) {
my $macro = $_;
if ($macro =~ /^(d_nanosleep|d_clock)$/) {
$macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
@@ -879,6 +958,13 @@ sub doConstants {
push @names, {name => $_, macro => "TIME_HIRES_STAT", value => $d_hires_stat,
default => ["IV", "0"]};
next;
+ } elsif ($macro =~ /^(d_hires_utime)$/) {
+ my $d_hires_utime =
+ ($DEFINE =~ /-DHAS_FUTIMENS/ ||
+ $DEFINE =~ /-DHAS_UTIMENSAT/) ? 1 : 0;
+ push @names, {name => $_, macro => "TIME_HIRES_UTIME", value => $d_hires_utime,
+ default => ["IV", "0"]};
+ next;
} elsif ($macro =~ /^(d_clock_gettime|d_clock_getres|d_clock_nanosleep)$/) {
$macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
my $val = ($DEFINE =~ /-D$macro\b/) ? 1 : 0;