Blob Blame History Raw
From 33cc1afd407885bd671f97ef6c7277f4ed31ac3c Mon Sep 17 00:00:00 2001
From: Jitka Plesnikova <jplesnik@redhat.com>
Date: Thu, 18 May 2023 20:18:16 +0200
Subject: [PATCH] Upgrade to 1.9774

---
 Changes     | 11 +++++++++++
 HiRes.pm    |  2 +-
 HiRes.xs    | 12 +++++-------
 Makefile.PL | 20 ++++++++++++++++----
 t/stat.t    |  6 +++++-
 5 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/Changes b/Changes
index 96f058a..e63892a 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,17 @@ Revision history for the Perl extension Time::HiRes.
 
  - Remove obsolete vms code
  - Use core version compare
+ - Use GIMME_V instead of the deprecated GIMME
+ - t/utime.t: dragonflybsd has only microsecond precision
+ - t/utime.t: dragonflybsd is noatime by default
+ - t/stat.t: skip testing access times on HaikuOS, it doesn't support
+   atime
+ - darwin: make sure the compiler can find the system perl headers
+   https://github.com/Perl/perl5/issues/20362
+ - darwin: make sure PERL_DARWIN is defined on darwin.
+ - don't compare stat and lstat atime if PERL_FILE_ATIME_CHANGES is set in
+   the environment.
+   https://github.com/Perl/perl5/issues/19321
 
 1.9764 [2020-08-10]
  - Fix a bunch of repeated-word typos
diff --git a/HiRes.pm b/HiRes.pm
index 7e21047..22660cb 100644
--- a/HiRes.pm
+++ b/HiRes.pm
@@ -50,7 +50,7 @@ our @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
                  stat lstat utime
                 );
 
-our $VERSION = '1.9770';
+our $VERSION = '1.9774';
 our $XS_VERSION = $VERSION;
 $VERSION = eval $VERSION;
 
diff --git a/HiRes.xs b/HiRes.xs
index 1eb7de3..e108848 100644
--- a/HiRes.xs
+++ b/HiRes.xs
@@ -19,10 +19,10 @@ extern "C" {
 #include "perl.h"
 #include "XSUB.h"
 #include "reentr.h"
-#ifdef USE_PPPORT_H
+#if !defined(IS_SAFE_PATHNAME) && defined(TIME_HIRES_UTIME) && defined(HAS_UTIMENSAT)
 #define NEED_ck_warner
-#  include "ppport.h"
 #endif
+#include "ppport.h"
 #if defined(__CYGWIN__) && defined(HAS_W32API_WINDOWS_H)
 #  include <w32api/windows.h>
 #  define CYGWIN_WITH_W32API
@@ -263,8 +263,6 @@ _gettimeofday(pTHX_ struct timeval *tp, void *not_used)
 static int
 _clock_gettime(pTHX_ clockid_t clock_id, struct timespec *tp)
 {
-    FT_t ft;
-
     switch (clock_id) {
     case CLOCK_REALTIME: {
         FT_t ft;
@@ -1193,7 +1191,7 @@ gettimeofday()
         int status;
         status = gettimeofday (&Tp, NULL);
         if (status == 0) {
-            if (GIMME == G_LIST) {
+            if (GIMME_V == G_LIST) {
                 EXTEND(sp, 2);
                 PUSHs(sv_2mortal(newSViv(Tp.tv_sec)));
                 PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
@@ -1250,7 +1248,7 @@ setitimer(which, seconds, interval = 0)
         if (setitimer(which, &newit, &oldit) == 0) {
             EXTEND(sp, 1);
             PUSHs(sv_2mortal(newSVnv(TV2NV(oldit.it_value))));
-            if (GIMME == G_LIST) {
+            if (GIMME_V == G_LIST) {
                 EXTEND(sp, 1);
                 PUSHs(sv_2mortal(newSVnv(TV2NV(oldit.it_interval))));
             }
@@ -1270,7 +1268,7 @@ getitimer(which)
         if (getitimer(which, &nowit) == 0) {
             EXTEND(sp, 1);
             PUSHs(sv_2mortal(newSVnv(TV2NV(nowit.it_value))));
-            if (GIMME == G_LIST) {
+            if (GIMME_V == G_LIST) {
                 EXTEND(sp, 1);
                 PUSHs(sv_2mortal(newSVnv(TV2NV(nowit.it_interval))));
             }
diff --git a/Makefile.PL b/Makefile.PL
index e5ba503..5803daf 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -68,8 +68,17 @@ __EOD__
             }
         }
 
-        my $ccflags = $Config{'ccflags'} . ' ' . "-I$COREincdir"
-         . ' -DPERL_NO_INLINE_FUNCTIONS';
+        my $ccflags = $Config{'ccflags'} . ' ';
+        my @osvers = split /\./, $Config{osvers};
+        if ($^O eq "darwin"
+            && $^X eq "/usr/bin/perl"
+            && $osvers[0] >= 18) {
+            $ccflags .= qq(-iwithsysroot "$COREincdir");
+        }
+        else {
+            $ccflags .= "-I$COREincdir"
+        }
+        $ccflags .= ' -DPERL_NO_INLINE_FUNCTIONS';
 
         if ($^O eq 'VMS') {
             $cccmd = "$Config{'cc'} /include=($COREincdir) $tmp.c";
@@ -841,6 +850,11 @@ EOM
             print "NOT found.\n";
         }
     }
+    if ($^O eq "darwin") {
+        # the system perl on darwin doesn't seem to include -DPERL_DARWIN
+        # which breaks setting up emulation
+        DEFINE("PERL_DARWIN");
+    }
 
     if ($DEFINE) {
         $DEFINE =~ s/^\s+//;
@@ -854,8 +868,6 @@ EOM
 sub doMakefile {
     my @makefileopts = ();
 
-    DEFINE('USE_PPPORT_H') unless $ENV{PERL_CORE};
-
     push (@makefileopts,
         'NAME'  => 'Time::HiRes',
         'AUTHOR'    => 'Jarkko Hietaniemi <jhi@iki.fi>',
diff --git a/t/stat.t b/t/stat.t
index 1f1fa96..2f72fdc 100644
--- a/t/stat.t
+++ b/t/stat.t
@@ -36,7 +36,11 @@ for (1..5) {
     SKIP: {
         if($^O eq "haiku") {
             skip "testing stat access time on Haiku", 2;
-        }  
+        }
+        if ($ENV{PERL_FILE_ATIME_CHANGES}) {
+            # something else might access the file, changing atime
+            $lstat->[8] = $stat->[8];
+        }
         is_deeply $lstat, $stat, "write: stat and lstat returned same values";
         Time::HiRes::sleep(rand(0.1) + 0.1);
         open(X, '<', $$);
-- 
2.40.1