summaryrefslogtreecommitdiff
path: root/dist/threads
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-11 14:37:59 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-11 15:42:04 +0000
commit447f000ef4448b16c51bcbc3e4e9a3714327c66c (patch)
tree5f2f3ef55d64f483bd43ae8e00dcbdbac61aef68 /dist/threads
parent211dff67fdc23c274b7c373b1d8463c98361e11f (diff)
downloadperl-447f000ef4448b16c51bcbc3e4e9a3714327c66c.tar.gz
In S_ithread_create, reduce the amount of conditionally compiled C code.
With a small amount of refactoring, compatibility across different perl versions can be achieved with less duplication.
Diffstat (limited to 'dist/threads')
-rw-r--r--dist/threads/lib/threads.pm2
-rw-r--r--dist/threads/threads.xs41
2 files changed, 12 insertions, 31 deletions
diff --git a/dist/threads/lib/threads.pm b/dist/threads/lib/threads.pm
index 35bed52ad0..b48ef7ee49 100644
--- a/dist/threads/lib/threads.pm
+++ b/dist/threads/lib/threads.pm
@@ -5,7 +5,7 @@ use 5.008;
use strict;
use warnings;
-our $VERSION = '1.82';
+our $VERSION = '1.83';
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
diff --git a/dist/threads/threads.xs b/dist/threads/threads.xs
index 029540cda3..9ee714ddf4 100644
--- a/dist/threads/threads.xs
+++ b/dist/threads/threads.xs
@@ -22,6 +22,9 @@
# include "ppport.h"
# include "threads.h"
#endif
+#ifndef sv_dup_inc
+# define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t))
+#endif
#ifdef USE_ITHREADS
@@ -776,37 +779,14 @@ S_ithread_create(
* context for the duration of our work for new interpreter.
*/
{
-#if (PERL_VERSION < 13) || (PERL_VERSION == 13 && PERL_SUBVERSION <= 1)
- CLONE_PARAMS clone_param;
-
- dTHXa(thread->interp);
-
- MY_CXT_CLONE;
-
- /* Here we remove END blocks since they should only run in the thread
- * they are created
- */
- SvREFCNT_dec(PL_endav);
- PL_endav = NULL;
-
- clone_param.flags = 0;
- if (SvPOK(init_function)) {
- thread->init_function = newSV(0);
- sv_copypv(thread->init_function, init_function);
- } else {
- thread->init_function =
- SvREFCNT_inc(sv_dup(init_function, &clone_param));
- }
-
- thread->params = params = newAV();
- av_extend(params, params_end - params_start - 1);
- AvFILLp(params) = params_end - params_start - 1;
- array = AvARRAY(params);
- while (params_start < params_end) {
- *array++ = SvREFCNT_inc(sv_dup(*params_start++, &clone_param));
- }
-#else
+#if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION > 1)
CLONE_PARAMS *clone_param = Perl_clone_params_new(aTHX, thread->interp);
+#else
+ CLONE_PARAMS clone_param_s;
+ CLONE_PARAMS *clone_param = &clone_param_s;
+
+ clone_param->flags = 0;
+#endif
dTHXa(thread->interp);
@@ -832,6 +812,7 @@ S_ithread_create(
while (params_start < params_end) {
*array++ = SvREFCNT_inc(sv_dup(*params_start++, clone_param));
}
+#if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION > 1)
Perl_clone_params_del(clone_param);
#endif