In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/69d1f2c2cdaa4ac2f37372e8c15c679848df2252?hp=aadb82e0ec97e7fc243dcacb81423f82c41eb512>

- Log -----------------------------------------------------------------
commit 69d1f2c2cdaa4ac2f37372e8c15c679848df2252
Author: Jarkko Hietaniemi <j...@iki.fi>
Date:   Sun Oct 16 16:33:23 2016 -0400

    macOS Sierra (10.12) does have clockid_t.
    
    Scan for it in all platforms.
-----------------------------------------------------------------------

Summary of changes:
 dist/Time-HiRes/HiRes.xs    |  6 ++++--
 dist/Time-HiRes/Makefile.PL | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/dist/Time-HiRes/HiRes.xs b/dist/Time-HiRes/HiRes.xs
index de63b93..eb48aee 100644
--- a/dist/Time-HiRes/HiRes.xs
+++ b/dist/Time-HiRes/HiRes.xs
@@ -87,6 +87,10 @@ extern "C" {
 #   undef ITIMER_REALPROF
 #endif
 
+#ifndef TIME_HIRES_CLOCKID_T
+typedef int clockid_t;
+#endif
+
 #if defined(TIME_HIRES_CLOCK_GETTIME) && defined(_STRUCT_ITIMERSPEC)
 
 /* HP-UX has CLOCK_XXX values but as enums, not as defines.
@@ -802,8 +806,6 @@ static int darwin_time_init() {
   return success;
 }
 
-typedef int clockid_t; /* to conform with POSIX prototypes */
-
 #ifdef TIME_HIRES_CLOCK_GETTIME_EMULATION
 static int clock_gettime(clockid_t clock_id, struct timespec *ts) {
   if (darwin_time_init() && timebase_info.denom) {
diff --git a/dist/Time-HiRes/Makefile.PL b/dist/Time-HiRes/Makefile.PL
index 1c1ce1f..340ee99 100644
--- a/dist/Time-HiRes/Makefile.PL
+++ b/dist/Time-HiRes/Makefile.PL
@@ -389,6 +389,22 @@ 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 <sys/time.h>
+#include <fcntl.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 ;
@@ -569,6 +585,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;

--
Perl5 Master Repository

Reply via email to