3 # In general we trust %Config, but for nanosleep() this trust
4 # may be misplaced (it may be linkable but not really functional).
5 # Use $ENV{FORCE_NANOSLEEP_SCAN} to force rescanning whether there
11 use ExtUtils::MakeMaker;
14 my $VERBOSE = $ENV{VERBOSE};
20 our $self; # Used in 'sourcing' the hints.
22 # TBD: Can we just use $Config(exe_ext) here instead of this complex
24 my $ld_exeext = ($^O eq 'cygwin' ||
25 $^O eq 'os2' && $Config{ldflags} =~ /-Zexe\b/) ? '.exe' :
26 (($^O eq 'vos') ? $Config{exe_ext} : '');
28 unless($ENV{PERL_CORE}) {
29 $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
32 # Perls 5.002 and 5.003 did not have File::Spec, fake what we need.
36 $^O =~ /mswin32|netware|djgpp/i ? '\\' :
43 my $catdir = join(my_dirsep, @_);
44 $^O eq 'VMS' ? "[$catdir]" : $catdir;
49 return join(my_dirsep, @_) unless $^O eq 'VMS';
51 return my_catdir (undef, @_) . $file;
56 $^O eq 'VMS' ? "-" : "..";
60 eval { require File::Spec };
62 *File::Spec::catdir = \&my_catdir;
63 *File::Spec::updir = \&my_updir;
64 *File::Spec::catfile = \&my_catfile;
68 # Avoid 'used only once' warnings.
69 my $nop1 = *File::Spec::catdir;
70 my $nop2 = *File::Spec::updir;
71 my $nop3 = *File::Spec::catfile;
73 # if you have 5.004_03 (and some slightly older versions?), xsubpp
74 # tries to generate line numbers in the C code generated from the .xs.
75 # unfortunately, it is a little buggy around #ifdef'd code.
76 # my choice is leave it in and have people with old perls complain
77 # about the "Usage" bug, or leave it out and be unable to compile myself
78 # without changing it, and then I'd always forget to change it before a
79 # release. Sorry, Edward :)
81 sub try_compile_and_link {
88 my $obj_ext = $Config{obj_ext} || ".o";
89 unlink("$tmp.c", "$tmp$obj_ext");
91 if (open(TMPC, '>', "$tmp.c")) {
95 my $cccmd = $args{cccmd};
101 if ($ENV{PERL_CORE}) {
102 my $updir = File::Spec->updir;
103 $COREincdir = File::Spec->catdir(($updir) x 2);
105 $COREincdir = File::Spec->catdir($Config{'archlibexp'}, 'CORE');
108 if ($ENV{PERL_CORE}) {
109 unless (-f File::Spec->catfile($COREincdir, "EXTERN.h")) {
111 Your environment variable PERL_CORE is '$ENV{PERL_CORE}' but there
112 is no EXTERN.h in $COREincdir.
113 Cannot continue, aborting.
118 my $ccflags = $Config{'ccflags'} . ' ' . "-I$COREincdir"
119 . ' -DPERL_NO_INLINE_FUNCTIONS';
122 $cccmd = "$Config{'cc'} /include=($COREincdir) $tmp.c";
125 if ($args{silent} || !$VERBOSE) {
126 $errornull = "2>/dev/null" unless defined $errornull;
131 $cccmd = "$Config{'cc'} -o $tmp $ccflags $tmp.c @$LIBS $errornull"
132 unless defined $cccmd;
135 open( CMDFILE, '>', "$tmp.com" );
136 print CMDFILE "\$ SET MESSAGE/NOFACILITY/NOSEVERITY/NOIDENT/NOTEXT\n";
137 print CMDFILE "\$ $cccmd\n";
138 print CMDFILE "\$ IF \$SEVERITY .NE. 1 THEN EXIT 44\n"; # escalate
140 system("\@ $tmp.com");
142 for ("$tmp.c", "$tmp$obj_ext", "$tmp.com", "$tmp$Config{exe_ext}") {
148 my $tmp_exe = "$tmp$ld_exeext";
149 printf "cccmd = $cccmd\n" if $VERBOSE;
150 my $res = system($cccmd);
151 $ok = defined($res) && $res == 0 && -s $tmp_exe && -x _;
153 if ( $ok && exists $args{run} && $args{run} && !$ENV{TIME_HIRES_DONT_RUN_PROBES} ) {
155 File::Spec->catfile(File::Spec->curdir, $tmp_exe);
157 unshift @run, $Config{run} if $Config{run} && -e $Config{run};
158 printf "Running $tmp_exe..." if $VERBOSE;
159 if (system(@run) == 0) {
167 *** The test run of '$tmp_exe' failed: status $?
168 *** (the status means: errno = $errno or '$!')
169 *** DO NOT PANIC: this just means that *some* functionality will be missing.
173 unlink("$tmp.c", $tmp_exe);
180 my $TIME_HEADERS = <<EOH;
185 # include <sys/types.h>
188 # include <sys/time.h>
191 # include <sys/select.h> /* struct timeval might be hidden in here */
195 sub has_gettimeofday {
196 # confusing but true (if condition true ==> -DHAS_GETTIMEOFDAY already)
197 return 0 if $Config{d_gettimeod};
198 return 1 if try_compile_and_link(<<EOM);
203 gettimeofday(&tv, 0);
205 int main(int argc, char** argv)
217 try_compile_and_link(<<EOM, %args);
227 # include <sys/types.h>
231 # include <sys/time.h>
234 int main(int argc, char** argv)
245 try_compile_and_link(<<EOM, run => 1);
247 #include <sys/time.h>
252 /* int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); */
254 int main(int argc, char** argv) {
255 struct timespec ts1, ts2;
258 ts1.tv_nsec = 750000000;
262 ret = nanosleep(&ts1, &ts2); /* E.g. in AIX nanosleep() fails and sets errno to ENOSYS. */
263 ret == 0 ? exit(0) : exit(errno ? errno : -1);
271 try_compile_and_link(<<EOM);
277 int main(int argc, char** argv)
285 sub has_clock_xxx_syscall {
287 return 0 unless defined $SYSCALL_H;
289 try_compile_and_link(<<EOM, run => 1);
294 #include <$SYSCALL_H>
295 int main(int argc, char** argv)
298 /* Many Linuxes get ENOSYS even though the syscall exists. */
299 /* All implementations are supposed to support CLOCK_REALTIME. */
300 int ret = syscall(SYS_clock_$x, CLOCK_REALTIME, &ts);
301 ret == 0 ? exit(0) : exit(errno ? errno : -1);
309 try_compile_and_link(<<EOM, run => 1);
314 int main(int argc, char** argv)
317 int ret = clock_$xxx(CLOCK_REALTIME, &ts); /* Many Linuxes get ENOSYS. */
318 /* All implementations are supposed to support CLOCK_REALTIME. */
319 ret == 0 ? exit(0) : exit(errno ? errno : -1);
326 try_compile_and_link(<<EOM, run => 1);
331 int main(int argc, char** argv)
334 clock_t ret = clock();
335 ret == (clock_t)-1 ? exit(errno ? errno : -1) : exit(0);
340 sub has_clock_nanosleep {
342 try_compile_and_link(<<EOM, run => 1);
347 int main(int argc, char** argv)
353 ts1.tv_nsec = 750000000;;
354 /* All implementations are supposed to support CLOCK_REALTIME. */
355 ret = clock_nanosleep(CLOCK_REALTIME, 0, &ts1, &ts2);
356 ret == 0 ? exit(0) : exit(errno ? errno : -1);
363 try_compile_and_link(<<EOM);
367 #include <sys/stat.h>
368 int main(int argc, char** argv)
371 struct timespec ts1[2], ts2[2];
372 ret1 = futimens(0, ts1);
374 read(0, buf, 0); /* Assuming reading nothing updates atime (the [0]) */
375 ret2 = futimens(0, ts2);
376 ret1 == 0 && ret2 == 0 && (ts1[0].tv_nsec != 0 || ts2[0].tv_nsec != 0) ?
377 exit(0) : exit(errno ? errno : -1);
384 try_compile_and_link(<<EOM);
388 #include <sys/stat.h>
390 int main(int argc, char** argv)
393 struct timespec ts1[2], ts2[2];
394 /* We make the brave but probably foolish assumption that systems
395 * modern enough to have utimensat also have the /dev/stdin. */
396 ret1 = utimensat(AT_FDCWD, "/dev/stdin", ts1, 0);
398 read(0, buf, 0); /* Assuming reading nothing updates atime (the [0]) */
399 ret2 = utimensat(AT_FDCWD, "/dev/stdin", ts2, 0);
400 ret1 == 0 && ret2 == 0 && (ts1[0].tv_nsec != 0 || ts2[0].tv_nsec != 0) ?
401 exit(0) : exit(errno ? errno : -1);
408 try_compile_and_link(<<EOM);
413 int main(int argc, char** argv)
415 clockid_t id = CLOCK_REALTIME;
416 exit(id == CLOCK_REALTIME ? 1 : 0);
422 my ($def, $val) = @_;
423 my $define = defined $val ? "$def=$val" : $def ;
424 unless ($DEFINE =~ /(?:^| )-D\Q$define\E(?: |$)/) {
425 $DEFINE .= " -D$define";
430 my $hints = File::Spec->catfile("hints", "$^O.pl");
432 print "Using hints $hints...\n";
435 if (exists $self->{LIBS}) {
436 $LIBS = $self->{LIBS};
437 print "Extra libraries: @$LIBS...\n";
443 if ($Config{d_syscall}) {
444 print "Have syscall()... looking for syscall.h... ";
445 if (has_include('syscall.h')) {
446 $SYSCALL_H = 'syscall.h';
447 } elsif (has_include('sys/syscall.h')) {
448 $SYSCALL_H = 'sys/syscall.h';
451 print "No syscall()...\n";
454 if ($Config{d_syscall}) {
455 if (defined $SYSCALL_H) {
456 print "found <$SYSCALL_H>.\n";
458 print "NOT found.\n";
462 print "Looking for gettimeofday()... ";
463 my $has_gettimeofday;
464 if (exists $Config{d_gettimeod}) {
465 $has_gettimeofday++ if $Config{d_gettimeod};
466 } elsif (has_gettimeofday()) {
467 $DEFINE .= ' -DHAS_GETTIMEOFDAY';
471 if ($has_gettimeofday) {
475 Your operating system does not seem to have the gettimeofday() function.
476 (or, at least, I cannot find it)
478 There is no way Time::HiRes is going to work.
480 I am awfully sorry but I cannot go further.
482 Aborting configuration.
487 print "Looking for setitimer()... ";
489 if (exists $Config{d_setitimer}) {
490 $has_setitimer++ if $Config{d_setitimer};
491 } elsif (has_x("setitimer(ITIMER_REAL, 0, 0)")) {
493 $DEFINE .= ' -DHAS_SETITIMER';
496 if ($has_setitimer) {
499 print "NOT found.\n";
502 print "Looking for getitimer()... ";
504 if (exists $Config{'d_getitimer'}) {
505 $has_getitimer++ if $Config{'d_getitimer'};
506 } elsif (has_x("getitimer(ITIMER_REAL, 0)")) {
508 $DEFINE .= ' -DHAS_GETITIMER';
511 if ($has_getitimer) {
514 print "NOT found.\n";
517 if ($has_setitimer && $has_getitimer) {
518 print "You have interval timers (both setitimer and getitimer).\n";
520 print "You do NOT have interval timers.\n";
523 print "Looking for ualarm()... ";
525 if (exists $Config{d_ualarm}) {
526 $has_ualarm++ if $Config{d_ualarm};
527 } elsif (has_x ("ualarm (0, 0)")) {
529 $DEFINE .= ' -DHAS_UALARM';
535 print "NOT found.\n";
536 if ($has_setitimer) {
537 print "But you have setitimer().\n";
538 print "We can make a Time::HiRes::ualarm().\n";
542 print "Looking for usleep()... ";
544 if (exists $Config{d_usleep}) {
545 $has_usleep++ if $Config{d_usleep};
546 } elsif (has_x ("usleep (0)")) {
548 $DEFINE .= ' -DHAS_USLEEP';
554 print "NOT found.\n";
555 print "Let's see if you have select()... ";
556 if ($Config{'d_select'}) {
558 print "We can make a Time::HiRes::usleep().\n";
560 print "NOT found.\n";
561 print "You won't have a Time::HiRes::usleep().\n";
565 print "Looking for nanosleep()... ";
567 if ($ENV{FORCE_NANOSLEEP_SCAN}) {
568 print "forced scan... ";
569 if (has_nanosleep()) {
571 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
574 elsif (exists $Config{d_nanosleep}) {
575 print "believing \$Config{d_nanosleep}... ";
576 if ($Config{d_nanosleep}) {
578 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
580 } elsif ($^O =~ /^(mpeix)$/) {
581 # MPE/iX falsely finds nanosleep from its libc equivalent.
582 print "skipping because in $^O... ";
584 if (has_nanosleep()) {
586 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
590 if ($has_nanosleep) {
592 print "You can mix subsecond sleeps with signals, if you want to.\n";
593 print "(It's still not portable, though.)\n";
595 print "NOT found.\n";
596 my $nt = ($^O eq 'os2' ? '' : 'not');
597 print "You can$nt mix subsecond sleeps with signals.\n";
598 print "(It would not be portable anyway.)\n";
601 print "Looking for clockid_t... ";
603 if (has_clockid_t()) {
606 $DEFINE .= ' -DTIME_HIRES_CLOCKID_T';
608 print "NOT found, will use int.\n";
611 print "Looking for clock_gettime()... ";
612 my $has_clock_gettime;
613 my $has_clock_gettime_emulation;
614 if (exists $Config{d_clock_gettime}) {
615 $has_clock_gettime++ if $Config{d_clock_gettime}; # Unlikely...
616 } elsif (has_clock_xxx('gettime')) {
617 $has_clock_gettime++;
618 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME';
619 } elsif (defined $SYSCALL_H && has_clock_xxx_syscall('gettime')) {
620 $has_clock_gettime++;
621 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_SYSCALL';
622 } elsif ($^O eq 'darwin') {
623 $has_clock_gettime_emulation++;
624 $has_clock_gettime++;
625 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_EMULATION';
628 if ($has_clock_gettime) {
629 if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETTIME_SYSCALL/) {
630 print "found (via syscall).\n";
631 } elsif ($has_clock_gettime_emulation) {
632 print "found (via emulation).\n";
637 print "NOT found.\n";
640 print "Looking for clock_getres()... ";
641 my $has_clock_getres;
642 my $has_clock_getres_emulation;
643 if (exists $Config{d_clock_getres}) {
644 $has_clock_getres++ if $Config{d_clock_getres}; # Unlikely...
645 } elsif (has_clock_xxx('getres')) {
647 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES';
648 } elsif (defined $SYSCALL_H && has_clock_xxx_syscall('getres')) {
650 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_SYSCALL';
651 } elsif ($^O eq 'darwin') {
652 $has_clock_getres_emulation++;
654 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_EMULATION';
657 if ($has_clock_getres) {
658 if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETRES_SYSCALL/) {
659 print "found (via syscall).\n";
660 } elsif ($has_clock_getres_emulation) {
661 print "found (via emulation).\n";
666 print "NOT found.\n";
669 print "Looking for clock_nanosleep()... ";
670 my $has_clock_nanosleep;
671 my $has_clock_nanosleep_emulation;
672 if (exists $Config{d_clock_nanosleep}) {
673 $has_clock_nanosleep++ if $Config{d_clock_nanosleep}; # Unlikely...
674 } elsif (has_clock_nanosleep()) {
675 $has_clock_nanosleep++;
676 $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP';
677 } elsif ($^O eq 'darwin') {
678 $has_clock_nanosleep++;
679 $has_clock_nanosleep_emulation++;
680 $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP -DTIME_HIRES_CLOCK_NANOSLEEP_EMULATION';
683 if ($has_clock_nanosleep) {
684 if ($has_clock_nanosleep_emulation) {
685 print "found (via emulation).\n";
690 print "NOT found.\n";
693 print "Looking for clock()... ";
695 if (exists $Config{d_clock}) {
696 $has_clock++ if $Config{d_clock}; # Unlikely...
697 } elsif (has_clock()) {
699 $DEFINE .= ' -DTIME_HIRES_CLOCK';
705 print "NOT found.\n";
708 print "Looking for working futimens()... ";
710 if (has_futimens()) {
712 $DEFINE .= ' -DHAS_FUTIMENS';
718 print "NOT found.\n";
721 print "Looking for working utimensat()... ";
723 if (has_utimensat()) {
725 $DEFINE .= ' -DHAS_UTIMENSAT';
728 if ($has_utimensat) {
731 print "NOT found.\n";
734 my $has_hires_utime = ($has_futimens || $has_utimensat);
735 if ($has_hires_utime) {
736 $DEFINE .= ' -DTIME_HIRES_UTIME';
737 print "You seem to have subsecond timestamp setting.\n";
739 print "You do NOT seem to have subsecond timestamp setting.\n";
742 print "Looking for stat() subsecond timestamps...\n";
744 print "Trying struct stat st_atimespec.tv_nsec...";
745 my $has_stat_st_xtimespec;
746 if (try_compile_and_link(<<EOM)) {
748 #include <sys/stat.h>
749 int main(int argc, char** argv) {
751 st.st_atimespec.tv_nsec = 0;
754 $has_stat_st_xtimespec++;
755 DEFINE('TIME_HIRES_STAT_ST_XTIMESPEC'); # 1
758 if ($has_stat_st_xtimespec) {
761 print "NOT found.\n";
764 print "Trying struct stat st_atimensec...";
765 my $has_stat_st_xtimensec;
766 if (try_compile_and_link(<<EOM)) {
768 #include <sys/stat.h>
769 int main(int argc, char** argv) {
774 $has_stat_st_xtimensec++;
775 DEFINE('TIME_HIRES_STAT_ST_XTIMENSEC'); # 2
778 if ($has_stat_st_xtimensec) {
781 print "NOT found.\n";
784 print "Trying struct stat st_atime_n...";
785 my $has_stat_st_xtime_n;
786 if (try_compile_and_link(<<EOM)) {
788 #include <sys/stat.h>
789 int main(int argc, char** argv) {
794 $has_stat_st_xtime_n++;
795 DEFINE('TIME_HIRES_STAT_ST_XTIME_N'); # 3
798 if ($has_stat_st_xtime_n) {
801 print "NOT found.\n";
804 print "Trying struct stat st_atim.tv_nsec...";
805 my $has_stat_st_xtim;
806 if (try_compile_and_link(<<EOM)) {
808 #include <sys/stat.h>
809 int main(int argc, char** argv) {
811 st.st_atim.tv_nsec = 0;
815 DEFINE('TIME_HIRES_STAT_XTIM'); # 4
818 if ($has_stat_st_xtim) {
821 print "NOT found.\n";
824 print "Trying struct stat st_uatime...";
825 my $has_stat_st_uxtime;
826 if (try_compile_and_link(<<EOM)) {
828 #include <sys/stat.h>
829 int main(int argc, char** argv) {
834 $has_stat_st_uxtime++;
835 DEFINE('TIME_HIRES_STAT_ST_UXTIME'); # 5
838 if ($has_stat_st_uxtime) {
841 print "NOT found.\n";
844 # See HiRes.xs hrstatns()
845 if ($has_stat_st_xtimespec) {
846 DEFINE('TIME_HIRES_STAT', 1);
847 } elsif ($has_stat_st_xtimensec) {
848 DEFINE('TIME_HIRES_STAT', 2);
849 } elsif ($has_stat_st_xtime_n) {
850 DEFINE('TIME_HIRES_STAT', 3);
851 } elsif ($has_stat_st_xtim) {
852 DEFINE('TIME_HIRES_STAT', 4);
853 } elsif ($has_stat_st_uxtime) {
854 DEFINE('TIME_HIRES_STAT', 5);
857 my $has_hires_stat = ($DEFINE =~ /-DTIME_HIRES_STAT=(\d+)/) ? $1 : 0;
858 if ($has_hires_stat) {
859 print "You seem to have subsecond timestamp reading.\n";
860 print "(Your struct stat has them, but the filesystems must help.)\n";
861 unless ($has_hires_utime) {
862 print "However, you do NOT seem to have subsecond timestamp setting.\n";
865 print "You do NOT seem to have subsecond timestamp reading.\n";
868 my $has_w32api_windows_h;
870 if ($^O eq 'cygwin') {
871 print "Looking for <w32api/windows.h>... ";
872 if (has_include('w32api/windows.h')) {
873 $has_w32api_windows_h++;
874 DEFINE('HAS_W32API_WINDOWS_H');
876 if ($has_w32api_windows_h) {
879 print "NOT found.\n";
885 if (open(XDEFINE, '>', 'xdefine')) {
886 print XDEFINE $DEFINE, "\n";
893 my @makefileopts = ();
897 'AUTHOR' => 'Jarkko Hietaniemi <jhi@iki.fi>',
898 'ABSTRACT_FROM' => 'HiRes.pm',
900 DEFINE('ATLEASTFIVEOHOHFIVE');
904 'NAME' => 'Time::HiRes',
905 'VERSION_FROM' => 'HiRes.pm', # finds $VERSION
906 'LIBS' => $LIBS, # e.g., '-lm'
907 'DEFINE' => $DEFINE, # e.g., '-DHAS_SOMETHING'
909 # Do not even think about 'INC' => '-I/usr/ucbinclude',
910 # Solaris will avenge.
911 'INC' => '', # e.g., '-I/usr/include/other'
912 'INSTALLDIRS' => ($] >= 5.008 && $] < 5.011 ? 'perl' : 'site'),
917 'ExtUtils::MakeMaker' => 0,
924 'COMPRESS' => 'gzip -9f',
927 clean => { FILES => "xdefine" },
928 realclean => { FILES=> 'const-c.inc const-xs.inc' },
931 if ($^O eq "MSWin32" && !(grep { /\ALD[A-Z]*=/ } @ARGV)) {
932 my $libperl = $Config{libperl} || "";
933 my $gccversion = $Config{gccversion} || "";
934 if ($gccversion =~ /\A3\.4\.[0-9]+/ and $libperl =~ /\.lib\z/) {
935 # Avoid broken linkage with ActivePerl, by linking directly
936 # against the Perl DLL rather than the import library.
937 (my $llibperl = "-l$libperl") =~ s/\.lib\z//;
938 my $lddlflags = $Config{lddlflags} || "";
939 my $ldflags = $Config{ldflags} || "";
940 s/-L(?:".*?"|\S+)//g foreach $lddlflags, $ldflags;
941 my $libdirs = join ' ',
942 map { s/(?<!\\)((?:\\\\)*")/\\$1/g; qq[-L"$_"] }
943 @Config{qw/bin sitebin/};
944 push @makefileopts, macro => {
945 LDDLFLAGS => "$lddlflags $libdirs $llibperl",
946 LDFLAGS => "$ldflags $libdirs $llibperl",
952 if ($ENV{PERL_CORE}) {
953 push @makefileopts, MAN3PODS => {};
956 if ($ExtUtils::MakeMaker::VERSION >= 6.48) {
957 push @makefileopts, (MIN_PERL_VERSION => '5.006',);
960 if ($ExtUtils::MakeMaker::VERSION >= 6.31) {
961 push @makefileopts, (LICENSE => 'perl_5');
964 WriteMakefile(@makefileopts);
968 if (eval {require ExtUtils::Constant; 1}) {
969 # More or less this same list is in HiRes.pm. Should unify.
975 CLOCK_MONOTONIC_COARSE
977 CLOCK_MONOTONIC_PRECISE
980 CLOCK_PROCESS_CPUTIME_ID
982 CLOCK_REALTIME_COARSE
984 CLOCK_REALTIME_PRECISE
988 CLOCK_THREAD_CPUTIME_ID
1002 foreach (qw (d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
1003 d_nanosleep d_clock_gettime d_clock_getres
1004 d_clock d_clock_nanosleep d_hires_stat
1005 d_futimens d_utimensat d_hires_utime)) {
1007 if ($macro =~ /^(d_nanosleep|d_clock)$/) {
1008 $macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
1009 } elsif ($macro =~ /^(d_hires_stat)$/) {
1010 my $d_hires_stat = $1 if ($DEFINE =~ /-DTIME_HIRES_STAT=(\d+)/);
1011 if (defined $d_hires_stat) {
1012 push @names, {name => $_, macro => "TIME_HIRES_STAT", value => $d_hires_stat,
1013 default => ["IV", "0"]};
1016 } elsif ($macro =~ /^(d_hires_utime)$/) {
1018 ($DEFINE =~ /-DHAS_FUTIMENS/ ||
1019 $DEFINE =~ /-DHAS_UTIMENSAT/);
1020 push @names, {name => $_, macro => "TIME_HIRES_UTIME", value => $d_hires_utime,
1021 default => ["IV", "0"]};
1023 } elsif ($macro =~ /^(d_clock_gettime|d_clock_getres|d_clock_nanosleep)$/) {
1024 $macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
1025 my $val = ($DEFINE =~ /-D$macro\b/) ? 1 : 0;
1026 push @names, {name => $_, macro => $macro, value => $val,
1027 default => ["IV", "0"]};
1030 $macro =~ s/^d_(.+)/HAS_\U$1/;
1032 push @names, {name => $_, macro => $macro, value => 1,
1033 default => ["IV", "0"]};
1035 ExtUtils::Constant::WriteConstants(
1036 NAME => 'Time::HiRes',
1041 foreach $file ('const-c.inc', 'const-xs.inc') {
1042 my $fallback = File::Spec->catfile('fallback', $file);
1044 open IN, '<', $fallback or die "Can't open $fallback: $!";
1045 open OUT, '>', $file or die "Can't open $file: $!";
1046 print OUT <IN> or die $!;
1047 close OUT or die "Can't close $file: $!";
1048 close IN or die "Can't close $fallback: $!";
1054 if (-f "xdefine" && !(@ARGV && $ARGV[0] =~ /^--(?:configure|force)$/)) {
1055 print qq[$0: The "xdefine" exists, skipping the configure step.\n];
1056 print qq[Use "$^X $0 --configure"\n];
1057 print qq[or: "$^X $0 --force\n];
1058 print qq[to force the configure step.\n];
1060 print "Configuring Time::HiRes...\n";
1061 1 while unlink("define");
1062 if ($^O =~ /Win32/i) {
1063 DEFINE('SELECT_IS_BROKEN');
1065 print "System is $^O, skipping full configure...\n";
1066 open(XDEFINE, '>', 'xdefine') or die "$0: Cannot create xdefine: $!\n";
1074 my $make = $Config{'make'} || "make";
1075 unless (exists $ENV{PERL_CORE} && $ENV{PERL_CORE}) {
1077 Now you may issue '$make'. Do not forget also '$make test'.
1080 ((exists $ENV{LC_ALL} && $ENV{LC_ALL} =~ /utf-?8/i) ||
1081 (exists $ENV{LC_CTYPE} && $ENV{LC_CTYPE} =~ /utf-?8/i) ||
1082 (exists $ENV{LANG} && $ENV{LANG} =~ /utf-?8/i))) {
1085 NOTE: if you get an error like this (the Makefile line number may vary):
1086 Makefile:91: *** missing separator
1087 then set the environment variable LC_ALL to "C" and retry
1088 from scratch (re-run perl "Makefile.PL").
1089 (And consider upgrading your Perl to, say, at least Perl 5.8.8.)
1090 (You got this message because you seem to have
1091 an UTF-8 locale active in your shell environment, this used
1092 to cause broken Makefiles to be created from Makefile.PLs)