diff --git a/backport-Upgrade-2.22.patch b/backport-Upgrade-2.22.patch new file mode 100644 index 0000000..bc0e53a --- /dev/null +++ b/backport-Upgrade-2.22.patch @@ -0,0 +1,82 @@ +From a0eaa97e59b5b2ad8e2a83f8509da3787ff4b4bf Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova +Date: Thu, 24 May 2018 11:32:01 +0200 +Subject: [PATCH] Upgrade to 2.22 + +--- + lib/threads.pm | 29 ++++++++++++++++++++++++++++- + threads.xs | 4 ++++ + 2 files changed, 32 insertions(+), 1 deletion(-) + +diff --git a/lib/threads.pm b/lib/threads.pm +index 2eb926a..1b99567 100644 +--- a/lib/threads.pm ++++ b/lib/threads.pm +@@ -5,7 +5,7 @@ use 5.008; + use strict; + use warnings; + +-our $VERSION = '2.21'; # remember to update version in POD! ++our $VERSION = '2.22'; # remember to update version in POD! + my $XS_VERSION = $VERSION; + $VERSION = eval $VERSION; + +@@ -937,6 +937,33 @@ C) will affect all the threads in the application. + On MSWin32, each thread maintains its own the current working directory + setting. + ++=item Locales ++ ++Prior to Perl 5.28, locales could not be used with threads, due to various ++race conditions. Starting in that release, on systems that implement ++thread-safe locale functions, threads can be used, with some caveats. ++This includes Windows starting with Visual Studio 2005, and systems compatible ++with POSIX 2008. See L. ++ ++Each thread (except the main thread) is started using the C locale. The main ++thread is started like all other Perl programs; see L. ++You can switch locales in any thread as often as you like. ++ ++If you want to inherit the parent thread's locale, you can, in the parent, set ++a variable like so: ++ ++ $foo = POSIX::setlocale(LC_ALL, NULL); ++ ++and then pass to threads->create() a sub that closes over C<$foo>. Then, in ++the child, you say ++ ++ POSIX::setlocale(LC_ALL, $foo); ++ ++Or you can use the facilities in L to pass C<$foo>; ++or if the environment hasn't changed, in the child, do ++ ++ POSIX::setlocale(LC_ALL, ""); ++ + =item Environment variables + + Currently, on all platforms except MSWin32, all I calls (e.g., using +diff --git a/threads.xs b/threads.xs +index 4e9e31f..3da9165 100644 +--- a/threads.xs ++++ b/threads.xs +@@ -580,6 +580,8 @@ S_ithread_run(void * arg) + S_set_sigmask(&thread->initial_sigmask); + #endif + ++ thread_locale_init(); ++ + PL_perl_destruct_level = 2; + + { +@@ -665,6 +667,8 @@ S_ithread_run(void * arg) + MUTEX_UNLOCK(&thread->mutex); + MUTEX_UNLOCK(&MY_POOL.create_destruct_mutex); + ++ thread_locale_term(); ++ + /* Exit application if required */ + if (exit_app) { + (void)S_jmpenv_run(aTHX_ 2, thread, NULL, &exit_app, &exit_code); +-- +2.14.3 + diff --git a/backport-Upgrade-2.25.patch b/backport-Upgrade-2.25.patch new file mode 100644 index 0000000..02ac54e --- /dev/null +++ b/backport-Upgrade-2.25.patch @@ -0,0 +1,103 @@ +From 0bb2d0b00e011f1d77d1766fac4777c6bc376af7 Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova +Date: Mon, 1 Jun 2020 13:23:16 +0200 +Subject: [PATCH] Upgrade to 2.25 + +--- + lib/threads.pm | 22 +++++++++++----------- + threads.xs | 2 +- + 2 files changed, 12 insertions(+), 12 deletions(-) + +diff --git a/lib/threads.pm b/lib/threads.pm +index 1b99567..ee201a2 100644 +--- a/lib/threads.pm ++++ b/lib/threads.pm +@@ -5,7 +5,7 @@ use 5.008; + use strict; + use warnings; + +-our $VERSION = '2.22'; # remember to update version in POD! ++our $VERSION = '2.25'; # remember to update version in POD! + my $XS_VERSION = $VERSION; + $VERSION = eval $VERSION; + +@@ -134,13 +134,13 @@ threads - Perl interpreter-based threads + + =head1 VERSION + +-This document describes threads version 2.21 ++This document describes threads version 2.25 + + =head1 WARNING + + The "interpreter-based threads" provided by Perl are not the fast, lightweight + system for multitasking that one might expect or hope for. Threads are +-implemented in a way that make them easy to misuse. Few people know how to ++implemented in a way that makes them easy to misuse. Few people know how to + use them correctly or will be able to provide help. + + The use of interpreter-based threads in perl is officially +@@ -914,7 +914,7 @@ C<-Eimport()>) after any threads are started, and in such a way that no + other threads are started afterwards. + + If the above does not work, or is not adequate for your application, then file +-a bug report on L against the problematic module. ++a bug report on L against the problematic module. + + =item Memory consumption + +@@ -1090,7 +1090,7 @@ determine whether your system supports it. + + In prior perl versions, spawning threads with open directory handles would + crash the interpreter. +-L<[perl #75154]|http://rt.perl.org/rt3/Public/Bug/Display.html?id=75154> ++L<[perl #75154]|https://rt.perl.org/rt3/Public/Bug/Display.html?id=75154> + + =item Detached threads and global destruction + +@@ -1118,8 +1118,8 @@ unreferenced scalars. However, such warnings are harmless, and may safely be + ignored. + + You can search for L related bug reports at +-L. If needed submit any new bugs, problems, +-patches, etc. to: L ++L. If needed submit any new bugs, problems, ++patches, etc. to: L + + =back + +@@ -1137,14 +1137,14 @@ L + + L, L + +-L and +-L ++L and ++L + + Perl threads mailing list: +-L ++L + + Stack size discussion: +-L ++L + + Sample code in the I directory of this distribution on CPAN. + +diff --git a/threads.xs b/threads.xs +index 3da9165..ab64dc0 100644 +--- a/threads.xs ++++ b/threads.xs +@@ -676,7 +676,7 @@ S_ithread_run(void * arg) + } + + /* At this point, the interpreter may have been freed, so call +- * free in the the context of of the 'main' interpreter which ++ * free in the context of the 'main' interpreter which + * can't have been freed due to the veto_cleanup mechanism. + */ + aTHX = MY_POOL.main_thread.interp; +-- +2.25.4 + diff --git a/backport-Upgrade-2.26.patch b/backport-Upgrade-2.26.patch new file mode 100644 index 0000000..142dea2 --- /dev/null +++ b/backport-Upgrade-2.26.patch @@ -0,0 +1,134 @@ +From 9334f9fbc3fe291eb1791ff7f2bf93b9e713d4b0 Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova +Date: Thu, 6 May 2021 10:02:15 +0200 +Subject: [PATCH] Upgrade to 2.26 + +--- + lib/threads.pm | 4 ++-- + t/libc.t | 6 ++++++ + threads.xs | 18 +++++++++--------- + 3 files changed, 17 insertions(+), 11 deletions(-) + +diff --git a/lib/threads.pm b/lib/threads.pm +index ee201a2..4453a8d 100644 +--- a/lib/threads.pm ++++ b/lib/threads.pm +@@ -5,7 +5,7 @@ use 5.008; + use strict; + use warnings; + +-our $VERSION = '2.25'; # remember to update version in POD! ++our $VERSION = '2.26'; # remember to update version in POD! + my $XS_VERSION = $VERSION; + $VERSION = eval $VERSION; + +@@ -134,7 +134,7 @@ threads - Perl interpreter-based threads + + =head1 VERSION + +-This document describes threads version 2.25 ++This document describes threads version 2.26 + + =head1 WARNING + +diff --git a/t/libc.t b/t/libc.t +index 4f6f6ed..6595894 100644 +--- a/t/libc.t ++++ b/t/libc.t +@@ -9,6 +9,12 @@ BEGIN { + skip_all(q/Perl not compiled with 'useithreads'/); + } + ++ my $time_out_factor = $ENV{PERL_TEST_TIME_OUT_FACTOR} || 1; ++ $time_out_factor = 1 if $time_out_factor < 1; ++ ++ # Guard against bugs that result in deadlock ++ watchdog(1 * 60 * $time_out_factor); ++ + plan(11); + } + +diff --git a/threads.xs b/threads.xs +index ab64dc0..e544eba 100644 +--- a/threads.xs ++++ b/threads.xs +@@ -421,7 +421,7 @@ STATIC const MGVTBL ithread_vtbl = { + ithread_mg_free, /* free */ + 0, /* copy */ + ithread_mg_dup, /* dup */ +-#if (PERL_VERSION > 8) || (PERL_VERSION == 8 && PERL_SUBVERSION > 8) ++#if PERL_VERSION_GT(5,8,8) + 0 /* local */ + #endif + }; +@@ -751,7 +751,7 @@ S_ithread_create( + AV *params; + SV **array; + +-#if PERL_VERSION <= 8 && PERL_SUBVERSION <= 7 ++#if PERL_VERSION_LE(5,8,7) + SV **tmps_tmp = PL_tmps_stack; + IV tmps_ix = PL_tmps_ix; + #endif +@@ -849,7 +849,7 @@ S_ithread_create( + * context for the duration of our work for new interpreter. + */ + { +-#if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION > 1) ++#if PERL_VERSION_GE(5,13,2) + CLONE_PARAMS *clone_param = Perl_clone_params_new(aTHX, thread->interp); + #else + CLONE_PARAMS clone_param_s; +@@ -859,7 +859,7 @@ S_ithread_create( + + MY_CXT_CLONE; + +-#if (PERL_VERSION < 13) || (PERL_VERSION == 13 && PERL_SUBVERSION <= 1) ++#if PERL_VERSION_LT(5,13,2) + clone_param->flags = 0; + #endif + +@@ -886,7 +886,7 @@ S_ithread_create( + perl_clone() and sv_dup_inc(). Hence copy the parameters + somewhere under our control first, before duplicating. */ + if (num_params) { +-#if (PERL_VERSION > 8) ++#if PERL_VERSION_GE(5,9,0) + Copy(parent_perl->Istack_base + params_start, array, num_params, SV *); + #else + Copy(parent_perl->Tstack_base + params_start, array, num_params, SV *); +@@ -897,11 +897,11 @@ S_ithread_create( + } + } + +-#if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION > 1) ++#if PERL_VERSION_GE(5,13,2) + Perl_clone_params_del(clone_param); + #endif + +-#if PERL_VERSION <= 8 && PERL_SUBVERSION <= 7 ++#if PERL_VERSION_LT(5,8,8) + /* The code below checks that anything living on the tmps stack and + * has been cloned (so it lives in the ptr_table) has a refcount + * higher than 0. +@@ -1339,7 +1339,7 @@ ithread_join(...) + /* Get the return value from the call_sv */ + /* Objects do not survive this process - FIXME */ + if ((thread->gimme & G_WANT) != G_VOID) { +-#if (PERL_VERSION < 13) || (PERL_VERSION == 13 && PERL_SUBVERSION <= 1) ++#if PERL_VERSION_LT(5,13,2) + AV *params_copy; + PerlInterpreter *other_perl; + CLONE_PARAMS clone_params; +@@ -1766,7 +1766,7 @@ ithread_error(...) + + /* If thread died, then clone the error into the calling thread */ + if (thread->state & PERL_ITHR_DIED) { +-#if (PERL_VERSION < 13) || (PERL_VERSION == 13 && PERL_SUBVERSION <= 1) ++#if PERL_VERSION_LT(5,13,2) + PerlInterpreter *other_perl; + CLONE_PARAMS clone_params; + ithread *current_thread; +-- +2.30.2 + diff --git a/perl-threads.spec b/perl-threads.spec index 4be349e..e92b557 100644 --- a/perl-threads.spec +++ b/perl-threads.spec @@ -1,11 +1,17 @@ +%global base_version 2.21 Name: perl-threads Epoch: 2 -Version: 2.21 -Release: 3 +Version: 2.26 +Release: 1 Summary: Perl interpreter-based threads License: GPL+ or Artistic URL: https://metacpan.org/release/threads Source0: https://cpan.metacpan.org/authors/id/J/JD/JDHEDDEN/threads-%{version}.tar.gz#/threads-2.21.tar.gz + +Patch6000: backport-Upgrade-2.22.patch +Patch6001: backport-Upgrade-2.25.patch +Patch6002: backport-Upgrade-2.26.patch + BuildRequires: perl-devel perl-generators perl-interpreter gcc BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 perl(ExtUtils::testlib) perl(Test::More) Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) @@ -29,7 +35,8 @@ Requires: man The %{name}-help package contains doc files for %{name}. %prep -%autosetup -n threads-%{version} +%autosetup -n threads-%{base_version} -p1 + chmod -x examples/* %build @@ -53,6 +60,9 @@ make test %{_mandir}/man3/* %changelog +* Sun Dec 26 2021 guozhaorui - 2:2.26-1 +- update version to 2.26 + * Mon Jun 28 2021 yuanxin - 2:2.21-3 - add buildrequires gcc