Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Clean up Time::HiRes #17096

Closed
p5pRT opened this issue Jul 16, 2019 · 9 comments
Closed

[PATCH] Clean up Time::HiRes #17096

p5pRT opened this issue Jul 16, 2019 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 16, 2019

Migrated from rt.perl.org#134288 (status was 'pending release')

Searchable as RT134288$

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2019

From @xenu

I have prepared a series of patches that clean up Time​::HiRes​:

1. Normalize indentation
2. Remove code for perls older than 5.6
3. Remove the remains of MacOS classic support
4. Remove workaround for an ancient Devel​::PPPort bug

(there are more details in the commit messages)

I have tested them without issues as far back as 5.6.1.

The patches will be attached to the first reply to this ticket.

perl # circumvent perlbug's spam filter

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2019

From @xenu

On Tue, 16 Jul 2019, at 03​:06, Tomasz Konojacki (via RT) wrote​:

# New Ticket Created by Tomasz Konojacki
# Please include the string​: [perl #134288]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134288 >

I have prepared a series of patches that clean up Time​::HiRes​:

1. Normalize indentation
2. Remove code for perls older than 5.6
3. Remove the remains of MacOS classic support
4. Remove workaround for an ancient Devel​::PPPort bug

(there are more details in the commit messages)

I have tested them without issues as far back as 5.6.1.

The patches will be attached to the first reply to this ticket.

perl # circumvent perlbug's spam filter

The patches are attached.

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2019

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2019

From @xenu

0002-Time-HiRes-remove-code-for-perls-older-than-5.6.patch
From e532261d64915883129a9319aaf34011548d9c17 Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Mon, 15 Jul 2019 23:36:40 +0200
Subject: [PATCH 2/4] Time::HiRes: remove code for perls older than 5.6

Both Makefile.PL and HiRes.pm contain "use 5.006", so it was dead
code anyway.

[perl #134288]
---
 dist/Time-HiRes/HiRes.xs    | 13 +-------
 dist/Time-HiRes/Makefile.PL | 61 +++----------------------------------
 2 files changed, 6 insertions(+), 68 deletions(-)

diff --git a/dist/Time-HiRes/HiRes.xs b/dist/Time-HiRes/HiRes.xs
index de2061aae1..3cc70533e9 100644
--- a/dist/Time-HiRes/HiRes.xs
+++ b/dist/Time-HiRes/HiRes.xs
@@ -229,15 +229,6 @@ _gettimeofday(pTHX_ struct timeval *tp, void *not_used)
 }
 #endif /* #if defined(WIN32) || defined(CYGWIN_WITH_W32API) */
 
-#if defined(WIN32) && !defined(ATLEASTFIVEOHOHFIVE)
-static unsigned int
-sleep(unsigned int t)
-{
-    Sleep(t*1000);
-    return 0;
-}
-#endif
-
 #if !defined(HAS_GETTIMEOFDAY) && defined(VMS)
 #  define HAS_GETTIMEOFDAY
 
@@ -1023,15 +1014,13 @@ BOOT:
 #ifdef MY_CXT_KEY
         MY_CXT_INIT;
 #endif
-#ifdef ATLEASTFIVEOHOHFIVE
-#  ifdef HAS_GETTIMEOFDAY
+#ifdef HAS_GETTIMEOFDAY
         {
             (void) hv_store(PL_modglobal, "Time::NVtime", 12,
                             newSViv(PTR2IV(myNVtime)), 0);
             (void) hv_store(PL_modglobal, "Time::U2time", 12,
                             newSViv(PTR2IV(myU2time)), 0);
         }
-#  endif
 #endif
 #if defined(PERL_DARWIN)
 #  if defined(USE_ITHREADS) && defined(PERL_DARWIN_MUTEX)
diff --git a/dist/Time-HiRes/Makefile.PL b/dist/Time-HiRes/Makefile.PL
index 0245eaa8d9..da5c1b53f5 100644
--- a/dist/Time-HiRes/Makefile.PL
+++ b/dist/Time-HiRes/Makefile.PL
@@ -11,6 +11,8 @@ use Config;
 use ExtUtils::MakeMaker;
 use strict;
 
+use File::Spec;
+
 my $VERBOSE = $ENV{VERBOSE};
 my $DEFINE;
 my $LIBS = [];
@@ -29,55 +31,6 @@ unless($ENV{PERL_CORE}) {
     $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
 }
 
-# Perls 5.002 and 5.003 did not have File::Spec, fake what we need.
-
-sub my_dirsep {
-    $^O eq 'VMS' ? '.' :
-        $^O =~ /mswin32|netware|djgpp/i ? '\\' :
-            $^O eq 'MacOS' ? ':'
-                : '/';
-}
-
-sub my_catdir {
-    shift;
-    my $catdir = join(my_dirsep, @_);
-    $^O eq 'VMS' ? "[$catdir]" : $catdir;
-}
-
-sub my_catfile {
-    shift;
-    return join(my_dirsep, @_) unless $^O eq 'VMS';
-    my $file = pop;
-    return my_catdir (undef, @_) . $file;
-}
-
-sub my_updir {
-    shift;
-    $^O eq 'VMS' ? "-" : "..";
-}
-
-BEGIN {
-    eval { require File::Spec };
-    if ($@) {
-        *File::Spec::catdir  = \&my_catdir;
-        *File::Spec::updir   = \&my_updir;
-        *File::Spec::catfile = \&my_catfile;
-    }
-}
-
-# Avoid 'used only once' warnings.
-my $nop1 = *File::Spec::catdir;
-my $nop2 = *File::Spec::updir;
-my $nop3 = *File::Spec::catfile;
-
-# if you have 5.004_03 (and some slightly older versions?), xsubpp
-# tries to generate line numbers in the C code generated from the .xs.
-# unfortunately, it is a little buggy around #ifdef'd code.
-# my choice is leave it in and have people with old perls complain
-# about the "Usage" bug, or leave it out and be unable to compile myself
-# without changing it, and then I'd always forget to change it before a
-# release. Sorry, Edward :)
-
 sub try_compile_and_link {
     my ($c, %args) = @_;
 
@@ -889,17 +842,12 @@ EOM
 sub doMakefile {
     my @makefileopts = ();
 
-    if ($] >= 5.005) {
-        push (@makefileopts,
-            'AUTHOR'    => 'Jarkko Hietaniemi <jhi@iki.fi>',
-            'ABSTRACT_FROM' => 'HiRes.pm',
-        );
-        DEFINE('ATLEASTFIVEOHOHFIVE');
-    }
     DEFINE('USE_PPPORT_H') unless $ENV{PERL_CORE};
 
     push (@makefileopts,
         'NAME'  => 'Time::HiRes',
+        'AUTHOR'    => 'Jarkko Hietaniemi <jhi@iki.fi>',
+        'ABSTRACT_FROM' => 'HiRes.pm',
         'VERSION_FROM' => 'HiRes.pm', # finds $VERSION
         'LIBS'  => $LIBS,   # e.g., '-lm'
         'DEFINE'        => $DEFINE,     # e.g., '-DHAS_SOMETHING'
@@ -916,6 +864,7 @@ sub doMakefile {
             'Test::More' => 0,
             'XSLoader' => 0,
             'strict' => 0,
+            'File::Spec' => 0,
         },
         'dist'      => {
             'CI'       => 'ci -l',
-- 
2.21.0.windows.1

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2019

From @xenu

0003-Time-HiRes-remove-the-remains-of-MacOS-classic-suppo.patch
From c48c881b42d48a297b92519326bbf408b984c18d Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Mon, 15 Jul 2019 23:44:08 +0200
Subject: [PATCH 3/4] Time::HiRes: remove the remains of MacOS classic support

Perl dropped MacOS classic support ages ago.

[perl #134288]
---
 dist/Time-HiRes/HiRes.xs | 41 ----------------------------------------
 1 file changed, 41 deletions(-)

diff --git a/dist/Time-HiRes/HiRes.xs b/dist/Time-HiRes/HiRes.xs
index 3cc70533e9..beafd8ed33 100644
--- a/dist/Time-HiRes/HiRes.xs
+++ b/dist/Time-HiRes/HiRes.xs
@@ -1277,47 +1277,7 @@ alarm(seconds,interval=0)
 #endif /* #ifdef HAS_UALARM */
 
 #ifdef HAS_GETTIMEOFDAY
-#  ifdef MACOS_TRADITIONAL    /* fix epoch TZ and use unsigned time_t */
-void
-gettimeofday()
-    PREINIT:
-        struct timeval Tp;
-        struct timezone Tz;
-    PPCODE:
-        int status;
-        status = gettimeofday (&Tp, &Tz);
-
-        if (status == 0) {
-            Tp.tv_sec += Tz.tz_minuteswest * 60;       /* adjust for TZ */
-            if (GIMME == G_ARRAY) {
-                EXTEND(sp, 2);
-                /* Mac OS (Classic) has unsigned time_t */
-                PUSHs(sv_2mortal(newSVuv(Tp.tv_sec)));
-                PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
-            } else {
-                EXTEND(sp, 1);
-                PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / NV_1E6))));
-            }
-        }
-
-NV
-time()
-    PREINIT:
-        struct timeval Tp;
-        struct timezone Tz;
-    CODE:
-        int status;
-        status = gettimeofday (&Tp, &Tz);
-        if (status == 0) {
-            Tp.tv_sec += Tz.tz_minuteswest * 60;        /* adjust for TZ */
-            RETVAL = Tp.tv_sec + (Tp.tv_usec / NV_1E6);
-        } else {
-            RETVAL = -1.0;
-        }
-    OUTPUT:
-        RETVAL
 
-#  else       /* MACOS_TRADITIONAL */
 void
 gettimeofday()
     PREINIT:
@@ -1351,7 +1311,6 @@ time()
     OUTPUT:
         RETVAL
 
-#  endif      /* MACOS_TRADITIONAL */
 #endif /* #ifdef HAS_GETTIMEOFDAY */
 
 #if defined(HAS_GETITIMER) && defined(HAS_SETITIMER)
-- 
2.21.0.windows.1

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2019

From @xenu

0004-Time-HiRes-remove-workaround-for-an-ancient-Devel-PP.patch
From ab8e58a720b959a47316b44a04911064815f0013 Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Tue, 16 Jul 2019 01:42:07 +0200
Subject: [PATCH 4/4] Time::HiRes: remove workaround for an ancient
 Devel::PPPort bug

It was fixed in Devel::PPPort 3.13_02.

[perl #134288]
---
 dist/Time-HiRes/HiRes.xs | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/dist/Time-HiRes/HiRes.xs b/dist/Time-HiRes/HiRes.xs
index beafd8ed33..836e0c598a 100644
--- a/dist/Time-HiRes/HiRes.xs
+++ b/dist/Time-HiRes/HiRes.xs
@@ -57,13 +57,6 @@ extern "C" {
 #  define GCC_DIAG_RESTORE_STMT GCC_DIAG_RESTORE NOOP
 #endif
 
-/* At least ppport.h 3.13 gets this wrong: one really cannot
- * have NVgf as anything else than "g" under Perl 5.6.x. */
-#if PERL_REVISION == 5 && PERL_VERSION == 6
-#  undef NVgf
-#  define NVgf "g"
-#endif
-
 #if PERL_VERSION_GE(5,7,3) && !PERL_VERSION_GE(5,10,1)
 #  undef SAVEOP
 #  define SAVEOP() SAVEVPTR(PL_op)
-- 
2.21.0.windows.1

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

From @tonycoz

On Mon, 15 Jul 2019 18​:17​:01 -0700, me@​xenu.pl wrote​:

On Tue, 16 Jul 2019, at 03​:06, Tomasz Konojacki (via RT) wrote​:

# New Ticket Created by Tomasz Konojacki
# Please include the string​: [perl #134288]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134288 >

I have prepared a series of patches that clean up Time​::HiRes​:

1. Normalize indentation
2. Remove code for perls older than 5.6
3. Remove the remains of MacOS classic support
4. Remove workaround for an ancient Devel​::PPPort bug

(there are more details in the commit messages)

I have tested them without issues as far back as 5.6.1.

The patches will be attached to the first reply to this ticket.

perl # circumvent perlbug's spam filter

The patches are attached.

Thanks, applied as merge commit 1715411.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

@tonycoz - Status changed from 'open' to 'pending release'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant