From 25c1e563a38db88cefc73b339885bb4c748d4635 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <[email protected]>
Date: Tue, 24 May 2016 15:57:08 +0200
Subject: Make Coro compatible with Perl 5.24

---
 Coro-6.49-perl_5_24.patch | 153 ++++++++++++++++++++++++++++++++++++++++++++++
 perl-Coro.spec            |  23 ++++++-
 2 files changed, 175 insertions(+), 1 deletion(-)
 create mode 100644 Coro-6.49-perl_5_24.patch

diff --git a/Coro-6.49-perl_5_24.patch b/Coro-6.49-perl_5_24.patch
new file mode 100644
index 0000000..f0234c1
--- /dev/null
+++ b/Coro-6.49-perl_5_24.patch
@@ -0,0 +1,153 @@
+Description: fix for Coro with 5.22 and 5.24
+Bug: https://rt.cpan.org/Public/Bug/Display.html?id=101063
+Bug-Debian: https://bugs.debian.org/787500
+Author: Anonymous
+Origin: https://paste.debian.net/688072
+Last-Update: 2016-05-20
+
+--- a/Coro/State.xs
++++ b/Coro/State.xs
+@@ -39,6 +39,10 @@
+ #ifdef PadARRAY
+ # define NEWPADAPI 1
+ # define newPADLIST(var)      (Newz (0, var, 1, PADLIST), Newx (PadlistARRAY 
(var), 2, PAD *))
++# if PERL_VERSION_ATLEAST(5,22,0) && !PERL_VERSION_ATLEAST(5,24,0)
++#  undef PadlistNAMES
++#  define PadlistNAMES(pl)    *((PADNAMELIST **)PadlistARRAY(pl))
++# endif
+ #else
+ typedef AV PADNAMELIST;
+ # if !PERL_VERSION_ATLEAST(5,8,0)
+@@ -951,7 +955,13 @@ coro_init_stacks (pTHX)
+ 
+     New(54,PL_savestack,24,ANY);
+     PL_savestack_ix = 0;
++#ifdef SS_MAXPUSH
++    /* Of course, if you clone the code, you have to track the changes... */
++    /*PL_savestack_max lies: it always has SS_MAXPUSH more than it claims */
++    PL_savestack_max = 24 - SS_MAXPUSH;
++#else
+     PL_savestack_max = 24;
++#endif
+ 
+ #if !PERL_VERSION_ATLEAST (5,10,0)
+     New(54,PL_retstack,4,OP*);
+@@ -1029,10 +1039,6 @@ coro_rss (pTHX_ struct coro *coro)
+ 
+ /** coroutine stack handling ************************************************/
+ 
+-static int (*orig_sigelem_get) (pTHX_ SV *sv, MAGIC *mg);
+-static int (*orig_sigelem_set) (pTHX_ SV *sv, MAGIC *mg);
+-static int (*orig_sigelem_clr) (pTHX_ SV *sv, MAGIC *mg);
+-
+ /* apparently < 5.8.8 */
+ #ifndef MgPV_nolen_const
+ #define MgPV_nolen_const(mg)    (((((int)(mg)->mg_len)) == HEf_SVKEY) ?   \
+@@ -1074,7 +1080,7 @@ coro_sigelem_get (pTHX_ SV *sv, MAGIC *m
+         }
+     }
+ 
+-  return orig_sigelem_get ? orig_sigelem_get (aTHX_ sv, mg) : 0;
++  return PL_vtbl_sigelem.svt_get ? PL_vtbl_sigelem.svt_get (aTHX_ sv, mg) : 0;
+ }
+ 
+ static int ecb_cold
+@@ -1098,7 +1104,7 @@ coro_sigelem_clr (pTHX_ SV *sv, MAGIC *m
+         }
+     }
+ 
+-  return orig_sigelem_clr ? orig_sigelem_clr (aTHX_ sv, mg) : 0;
++  return PL_vtbl_sigelem.svt_clear ? PL_vtbl_sigelem.svt_clear (aTHX_ sv, mg) 
: 0;
+ }
+ 
+ static int ecb_cold
+@@ -1122,9 +1128,42 @@ coro_sigelem_set (pTHX_ SV *sv, MAGIC *m
+         }
+     }
+ 
+-  return orig_sigelem_set ? orig_sigelem_set (aTHX_ sv, mg) : 0;
++  return PL_vtbl_sigelem.svt_set ? PL_vtbl_sigelem.svt_set (aTHX_ sv, mg) : 0;
++}
++
++static MGVTBL sigelem_vtbl = {
++    coro_sigelem_get,           /* get */
++    coro_sigelem_set,           /* set */
++    0,                          /* len */
++    coro_sigelem_clr,           /* clear */
++    0,                          /* free */
++    0,                          /* copy */
++    0,                          /* dup */
++#ifdef MGf_LOCAL
++    0,                          /* local */
++#endif
++};
++
++static int ecb_cold
++coro_sig_copy (pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *key, I32 klen)
++{
++  sv_magicext (nsv, mg->mg_obj, 'u', &sigelem_vtbl, key, klen);
++  return 1;
+ }
+ 
++static MGVTBL sig_vtbl = {
++    0,                          /* get */
++    0,                          /* set */
++    0,                          /* len */
++    0,                          /* clear */
++    0,                          /* free */
++    coro_sig_copy,              /* copy */
++    0,                          /* dup */
++#ifdef MGf_LOCAL
++    0,                          /* local */
++#endif
++};
++
+ static void
+ prepare_nop (pTHX_ struct coro_transfer_args *ta)
+ {
+@@ -1395,7 +1434,11 @@ runops_trace (pTHX)
+                           PUSHMARK (SP);
+                           PUSHs (&PL_sv_yes);
+                           PUSHs (fullname);
++# if PERL_VERSION_ATLEAST(5,24,0)
++                          PUSHs (CxHASARGS (cx) ? sv_2mortal (newRV_inc 
(PL_curpad[0])) : &PL_sv_undef);
++#else
+                           PUSHs (CxHASARGS (cx) ? sv_2mortal (newRV_inc ((SV 
*)cx->blk_sub.argarray)) : &PL_sv_undef);
++#endif
+                           PUTBACK;
+                           cb = hv_fetch ((HV *)SvRV (coro_current), 
"_trace_sub_cb", sizeof ("_trace_sub_cb") - 1, 0);
+                           if (cb) call_sv (*cb, G_KEEPERR | G_EVAL | G_VOID | 
G_DISCARD);
+@@ -1488,7 +1531,11 @@ transfer_tail (pTHX)
+ static void ecb_noinline ecb_cold
+ perlish_exit (pTHX)
+ {
+-  int exitstatus = perl_destruct (PL_curinterp);
++  int exitstatus;
++  /* Because we've skipped the "not essential" things, we've not popped all */
++  /* the scopes, and perl_destruct has an assert() that checks this. */
++  PL_scopestack_ix = 1;
++  exitstatus = perl_destruct (PL_curinterp);
+   perl_free (PL_curinterp);
+   exit (exitstatus);
+ }
+@@ -3596,15 +3643,16 @@ BOOT:
+         DEFSV;
+         ERRSV;
+ 
++        HV *sig = GvHV (gv_fetchpv ("SIG", GV_ADD|GV_NOTQUAL, SVt_PVHV));
++
++        sv_unmagic ((SV *)sig, PERL_MAGIC_sig);
++        sv_magicext ((SV *)sig, NULL, PERL_MAGIC_uvar, &sig_vtbl, NULL, 
0)->mg_flags |= MGf_COPY;
++
+         cctx_current = cctx_new_empty ();
+ 
+         irsgv    = gv_fetchpv ("/"     , GV_ADD|GV_NOTQUAL, SVt_PV);
+         stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO);
+ 
+-        orig_sigelem_get = PL_vtbl_sigelem.svt_get;   PL_vtbl_sigelem.svt_get 
  = coro_sigelem_get;
+-        orig_sigelem_set = PL_vtbl_sigelem.svt_set;   PL_vtbl_sigelem.svt_set 
  = coro_sigelem_set;
+-        orig_sigelem_clr = PL_vtbl_sigelem.svt_clear; 
PL_vtbl_sigelem.svt_clear = coro_sigelem_clr;
+-
+         rv_diehook  = newRV_inc ((SV *)gv_fetchpv ("Coro::State::diehook" , 
0, SVt_PVCV));
+         rv_warnhook = newRV_inc ((SV *)gv_fetchpv ("Coro::State::warnhook", 
0, SVt_PVCV));
+ 
diff --git a/perl-Coro.spec b/perl-Coro.spec
index 9fd8739..c789e2c 100644
--- a/perl-Coro.spec
+++ b/perl-Coro.spec
@@ -1,6 +1,6 @@
 Name:           perl-Coro
 Version:        6.49
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        The only real threads in perl
 # Coro/libcoro:    GPLv2 or BSD
 # Rest of package: GPL+ or Artistic
@@ -9,6 +9,22 @@ Group:          Development/Libraries
 URL:            http://search.cpan.org/dist/Coro/
 Source0:        
http://search.cpan.org/CPAN/authors/id/M/ML/MLEHMANN/Coro-%{version}.tar.gz
 Patch0:         %{name}-5.25-ucontext-default.patch
+# Make Coro compatible with Perl 5.24. This is a comprehensive Debian patch
+# resolving three issues:
+# (1) The signal vtbl was consted before 5.22, proposed fix
+# <http://permalink.gmane.org/gmane.comp.lang.perl.perl5.porters/158431>,
+# bug #1231165.
+# (2) the argarray was removed before 5.24,
+# code equivalence displayed in e2657e180a66b618ece78ca6b9c1f9e9b361a948
+# Perl5 commit,
+# <http://www.nntp.perl.org/group/perl.perl5.porters/2016/05/msg236178.html>,
+# bug #1338707
+# (3) Some eval tests aborted in the destructor, corrected by changing the
+# PL_savestack_max, bug #1338707
+# See <http://blogs.perl.org/users/aristotle/2016/05/coro-vs-5022.html>, patch
+# copied from
+# 
<https://anonscm.debian.org/cgit/pkg-perl/packages/libcoro-perl.git/plain/debian/patches/coro-5.22.patch?id=dcd10ba9611b38e0ef19ef597b42b635fa23d942>.
+Patch1:         Coro-6.49-perl_5_24.patch
 BuildRequires:  coreutils
 BuildRequires:  findutils
 BuildRequires:  libecb-static
@@ -112,6 +128,8 @@ programming much safer and easier than using other thread 
models.
 %patch0 -p1 -b .ucontext-default
 %endif
 
+%patch1 -p1
+
 # Unbundle libecb
 rm Coro/ecb.h
 sed -i '/^Coro\/ecb\.h$/d' MANIFEST
@@ -159,6 +177,9 @@ make test
 %{_mandir}/man3/*
 
 %changelog
+* Fri May 20 2016 Petr Pisar <[email protected]> - 6.49-4
+- Make Coro compatible with Perl 5.24 (bug #1338707)
+
 * Tue May 17 2016 Jitka Plesnikova <[email protected]> - 6.49-3
 - Perl 5.24 rebuild
 
-- 
cgit v0.12


        
http://pkgs.fedoraproject.org/cgit/perl-Coro.git/commit/?h=epel7&id=25c1e563a38db88cefc73b339885bb4c748d4635
_______________________________________________
perl-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to