This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
merge two similar MY_CXT code branches
authorDavid Mitchell <davem@iabyn.com>
Wed, 1 Sep 2010 10:59:01 +0000 (11:59 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 1 Sep 2010 11:24:44 +0000 (12:24 +0100)
No functional changes

perl.h

diff --git a/perl.h b/perl.h
index 5eeb912..44cf99e 100644 (file)
--- 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 */