From 4eddb8565f3490423e0fa2575ccc24b4e2cd168a Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 1 Sep 2010 11:59:01 +0100 Subject: merge two similar MY_CXT code branches No functional changes --- perl.h | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/perl.h b/perl.h index 5eeb912359..44cf99e49d 100644 --- a/perl.h +++ b/perl.h @@ -5802,14 +5802,18 @@ typedef struct am_table_short AMTS; #if defined(PERL_IMPLICIT_CONTEXT) -#ifdef PERL_GLOBAL_STRUCT_PRIVATE - -/* This must appear in all extensions that define a my_cxt_t structure, +/* START_MY_CXT must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ +#ifdef PERL_GLOBAL_STRUCT_PRIVATE #define START_MY_CXT #define MY_CXT_INDEX Perl_my_cxt_index(aTHX_ MY_CXT_KEY) #define MY_CXT_INIT_ARG MY_CXT_KEY +#else +#define START_MY_CXT static int my_cxt_index = -1; +#define MY_CXT_INDEX my_cxt_index +#define MY_CXT_INIT_ARG &my_cxt_index +#endif /* #ifdef PERL_GLOBAL_STRUCT_PRIVATE */ /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when @@ -5834,40 +5838,6 @@ typedef struct am_table_short AMTS; Copy(PL_my_cxt_list[MY_CXT_INDEX], my_cxtp, 1, my_cxt_t);\ PL_my_cxt_list[MY_CXT_INDEX] = my_cxtp \ -#else /* #ifdef PERL_GLOBAL_STRUCT_PRIVATE */ - -/* This must appear in all extensions that define a my_cxt_t structure, - * right after the definition (i.e. at file scope). The non-threads - * case below uses it to declare the data as static. */ -#define START_MY_CXT static int my_cxt_index = -1; -#define MY_CXT_INDEX my_cxt_index -#define MY_CXT_INIT_ARG &my_cxt_index - -/* This declaration should be used within all functions that use the - * interpreter-local data. */ -#define dMY_CXT \ - my_cxt_t *my_cxtp = (my_cxt_t *)PL_my_cxt_list[MY_CXT_INDEX] -#define dMY_CXT_INTERP(my_perl) \ - my_cxt_t *my_cxtp = (my_cxt_t *)(my_perl)->Imy_cxt_list[MY_CXT_INDEX] - -/* Creates and zeroes the per-interpreter data. - * (We allocate my_cxtp in a Perl SV so that it will be released when - * the interpreter goes away.) */ -#define MY_CXT_INIT \ - my_cxt_t *my_cxtp = \ - (my_cxt_t*)Perl_my_cxt_init(aTHX_ MY_CXT_INIT_ARG, sizeof(my_cxt_t)) -#define MY_CXT_INIT_INTERP(my_perl) \ - my_cxt_t *my_cxtp = \ - (my_cxt_t*)Perl_my_cxt_init(my_perl, MY_CXT_INIT_ARG, sizeof(my_cxt_t)) - -/* Clones the per-interpreter data. */ -#define MY_CXT_CLONE \ - my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ - Copy(PL_my_cxt_list[MY_CXT_INDEX], my_cxtp, 1, my_cxt_t);\ - PL_my_cxt_list[MY_CXT_INDEX] = my_cxtp \ - -#endif /* #ifdef PERL_GLOBAL_STRUCT_PRIVATE */ -#undef MY_CXT_INIT_ARG /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ -- cgit v1.2.1