+ print "Looking for clock_gettime()... ";
+ my $has_clock_gettime;
+ if (exists $Config{d_clock_gettime}) {
+ $has_clock_gettime++ if $Config{d_clock_gettime}; # Unlikely...
+ } elsif (has_clock_xxx('gettime')) {
+ $has_clock_gettime++;
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME';
+ } elsif (defined $SYSCALL_H && has_clock_xxx_syscall('gettime')) {
+ $has_clock_gettime++;
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_SYSCALL';
+ }
+
+ if ($has_clock_gettime) {
+ if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETTIME_SYSCALL/) {
+ print "found (via syscall).\n";
+ } else {
+ print "found.\n";
+ }
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Looking for clock_getres()... ";
+ my $has_clock_getres;
+ if (exists $Config{d_clock_getres}) {
+ $has_clock_getres++ if $Config{d_clock_getres}; # Unlikely...
+ } elsif (has_clock_xxx('getres')) {
+ $has_clock_getres++;
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES';
+ } elsif (defined $SYSCALL_H && has_clock_xxx_syscall('getres')) {
+ $has_clock_getres++;
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_SYSCALL';
+ }
+
+ if ($has_clock_getres) {
+ if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETRES_SYSCALL/) {
+ print "found (via syscall).\n";
+ } else {
+ print "found.\n";
+ }
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Looking for clock_nanosleep()... ";
+ my $has_clock_nanosleep;
+ if (exists $Config{d_clock_nanosleep}) {
+ $has_clock_nanosleep++ if $Config{d_clock_nanosleep}; # Unlikely...
+ } elsif (has_clock_nanosleep()) {
+ $has_clock_nanosleep++;
+ $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP';
+ }
+
+ if ($has_clock_nanosleep) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Looking for clock()... ";
+ my $has_clock;
+ if (exists $Config{d_clock}) {
+ $has_clock++ if $Config{d_clock}; # Unlikely...
+ } elsif (has_clock()) {
+ $has_clock++;
+ $DEFINE .= ' -DTIME_HIRES_CLOCK';
+ }
+
+ if ($has_clock) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Looking for stat() subsecond timestamps...\n";
+
+ print "Trying struct stat st_atimespec.tv_nsec...";
+ my $has_stat_st_xtimespec;
+ if (try_compile_and_link(<<EOM)) {
+$TIME_HEADERS
+#include <sys/stat.h>
+int main(int argc, char** argv) {
+ struct stat st;
+ st.st_atimespec.tv_nsec = 0;
+}
+EOM
+ $has_stat_st_xtimespec++;
+ DEFINE('TIME_HIRES_STAT', 1);
+ }
+
+ if ($has_stat_st_xtimespec) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Trying struct stat st_atimensec...";
+ my $has_stat_st_xtimensec;
+ if (try_compile_and_link(<<EOM)) {
+$TIME_HEADERS
+#include <sys/stat.h>
+int main(int argc, char** argv) {
+ struct stat st;
+ st.st_atimensec = 0;
+}
+EOM
+ $has_stat_st_xtimensec++;
+ DEFINE('TIME_HIRES_STAT', 2);
+ }
+
+ if ($has_stat_st_xtimensec) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Trying struct stat st_atime_n...";
+ my $has_stat_st_xtime_n;
+ if (try_compile_and_link(<<EOM)) {
+$TIME_HEADERS
+#include <sys/stat.h>
+int main(int argc, char** argv) {
+ struct stat st;
+ st.st_atime_n = 0;
+}
+EOM
+ $has_stat_st_xtime_n++;
+ DEFINE('TIME_HIRES_STAT', 3);
+ }
+
+ if ($has_stat_st_xtime_n) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Trying struct stat st_atim.tv_nsec...";
+ my $has_stat_st_xtim;
+ if (try_compile_and_link(<<EOM)) {
+$TIME_HEADERS
+#include <sys/stat.h>
+int main(int argc, char** argv) {
+ struct stat st;
+ st.st_atim.tv_nsec = 0;
+}
+EOM
+ $has_stat_st_xtim++;
+ DEFINE('TIME_HIRES_STAT', 4);
+ }
+
+ if ($has_stat_st_xtim) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ print "Trying struct stat st_uatime...";
+ my $has_stat_st_uxtime;
+ if (try_compile_and_link(<<EOM)) {
+$TIME_HEADERS
+#include <sys/stat.h>
+int main(int argc, char** argv) {
+ struct stat st;
+ st.st_uatime = 0;
+}
+EOM
+ $has_stat_st_uxtime++;
+ DEFINE('TIME_HIRES_STAT', 5);
+ }
+
+ if ($has_stat_st_uxtime) {
+ print "found.\n";
+ } else {
+ print "NOT found.\n";
+ }
+
+ 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";
+ } else {
+ print "You do not seem to have stat subsecond timestamps.\n";
+ }
+