Skip to content

Commit

Permalink
Adjust threads.xs to use PERL_VERSION_GE and PERL_VERSION_LT
Browse files Browse the repository at this point in the history
Fixes #5

probably want to split PERL_VERSION_DECIMAL and co to their ownn .h file
  • Loading branch information
atoomic committed Jun 29, 2020
1 parent 0854b73 commit 65ce00c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions dist/threads/threads.xs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#endif
#include "EXTERN.h"
#include "perl.h"
#define PERL_CORE 1
#include "vutil.h"
#include "XSUB.h"
/* Workaround for XSUB.h bug under WIN32 */
#ifdef WIN32
Expand Down Expand Up @@ -421,7 +423,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_GE(5,8,9)
0 /* local */
#endif
};
Expand Down Expand Up @@ -751,7 +753,7 @@ S_ithread_create(
AV *params;
SV **array;

#if PERL_VERSION <= 8 && PERL_SUBVERSION <= 7
#if PERL_VERSION_LT(5,8,8)
SV **tmps_tmp = PL_tmps_stack;
IV tmps_ix = PL_tmps_ix;
#endif
Expand Down Expand Up @@ -849,7 +851,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;
Expand All @@ -859,7 +861,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

Expand All @@ -886,7 +888,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 *);
Expand All @@ -897,11 +899,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.
Expand Down Expand Up @@ -1339,7 +1341,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;
Expand Down Expand Up @@ -1766,7 +1768,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;
Expand Down

0 comments on commit 65ce00c

Please sign in to comment.