Move the temporary definitions for PERLVAR* macros inside #ifdef MULTIPLICITY
authorNicholas Clark <nick@ccl4.org>
Sat, 30 Apr 2011 15:10:20 +0000 (16:10 +0100)
committerNicholas Clark <nick@ccl4.org>
Sun, 12 Jun 2011 14:15:21 +0000 (16:15 +0200)
Under MULTIPLICITY, intrpvar.h is included "early", as:

struct interpreter {
#  include "intrpvar.h"
};

with local definitions of PERLVAR{,A,I,IS,ISC} that generate output text for the
"variables" as structure members. Additionally, under PERL_GLOBAL_STRUCT
"perlvars.h" is included within struct perl_vars { ... }.

Move the definition/undefining of these 5 macros to within the
#ifdef MULTIPLICITY block, to clarify the limited intent of their scope.

Move some additional related PERL_GLOBAL_STRUCT setup to within the block.

perl.h

diff --git a/perl.h b/perl.h
index fceb220..0be51a4 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -4830,13 +4830,6 @@ typedef void (*XSINIT_t) (pTHX);
 typedef void (*ATEXIT_t) (pTHX_ void*);
 typedef void (*XSUBADDR_t) (pTHX_ CV *);
 
-/* Set up PERLVAR macros for populating structs */
-#define PERLVAR(var,type) type var;
-#define PERLVARA(var,n,type) type var[n];
-#define PERLVARI(var,type,init) type var;
-#define PERLVARIC(var,type,init) type var;
-#define PERLVARISC(var,init) const char var[sizeof(init)];
-
 typedef OP* (*Perl_ppaddr_t)(pTHX);
 typedef OP* (*Perl_check_t) (pTHX_ OP*);
 typedef void(*Perl_ophook_t)(pTHX_ OP*);
@@ -4875,51 +4868,64 @@ typedef struct exitlistentry {
                                STRINGIFY(PERL_API_VERSION) "." \
                                STRINGIFY(PERL_API_SUBVERSION)
 
-#ifdef PERL_GLOBAL_STRUCT
-struct perl_vars {
-#  include "perlvars.h"
+#if !defined(MULTIPLICITY)
+
+struct interpreter {
+    char broiled;
 };
 
-#  ifdef PERL_CORE
-#    ifndef PERL_GLOBAL_STRUCT_PRIVATE
-EXT struct perl_vars PL_Vars;
-EXT struct perl_vars *PL_VarsPtr INIT(&PL_Vars);
-#      undef PERL_GET_VARS
-#      define PERL_GET_VARS() PL_VarsPtr
-#    endif /* !PERL_GLOBAL_STRUCT_PRIVATE */
-#  else /* PERL_CORE */
-#    if !defined(__GNUC__) || !defined(WIN32)
-EXT
-#    endif /* WIN32 */
-struct perl_vars *PL_VarsPtr;
-#    define PL_Vars (*((PL_VarsPtr) \
-                      ? PL_VarsPtr : (PL_VarsPtr = Perl_GetVars(aTHX))))
-#  endif /* PERL_CORE */
-#endif /* PERL_GLOBAL_STRUCT */
+#else
 
-#if defined(MULTIPLICITY)
 /* If we have multiple interpreters define a struct
    holding variables which must be per-interpreter
    If we don't have threads anything that would have
    be per-thread is per-interpreter.
 */
 
+/* Set up PERLVAR macros for populating structs */
+#  define PERLVAR(var,type) type var;
+#  define PERLVARA(var,n,type) type var[n];
+#  define PERLVARI(var,type,init) type var;
+#  define PERLVARIC(var,type,init) type var;
+#  define PERLVARISC(var,init) const char var[sizeof(init)];
+
 struct interpreter {
 #  include "intrpvar.h"
 };
 
-#else
-struct interpreter {
-    char broiled;
+#  ifdef PERL_GLOBAL_STRUCT
+/* MULTIPLICITY is automatically defined when PERL_GLOBAL_STRUCT is defined,
+   hence it's safe and sane to nest this within #ifdef MULTIPLICITY  */
+
+struct perl_vars {
+#    include "perlvars.h"
 };
-#endif /* MULTIPLICITY */
+
+#    ifdef PERL_CORE
+#      ifndef PERL_GLOBAL_STRUCT_PRIVATE
+EXT struct perl_vars PL_Vars;
+EXT struct perl_vars *PL_VarsPtr INIT(&PL_Vars);
+#        undef PERL_GET_VARS
+#        define PERL_GET_VARS() PL_VarsPtr
+#      endif /* !PERL_GLOBAL_STRUCT_PRIVATE */
+#    else /* PERL_CORE */
+#      if !defined(__GNUC__) || !defined(WIN32)
+EXT
+#      endif /* WIN32 */
+struct perl_vars *PL_VarsPtr;
+#      define PL_Vars (*((PL_VarsPtr) \
+                      ? PL_VarsPtr : (PL_VarsPtr = Perl_GetVars(aTHX))))
+#    endif /* PERL_CORE */
+#  endif /* PERL_GLOBAL_STRUCT */
 
 /* Done with PERLVAR macros for now ... */
-#undef PERLVAR
-#undef PERLVARA
-#undef PERLVARI
-#undef PERLVARIC
-#undef PERLVARISC
+#  undef PERLVAR
+#  undef PERLVARA
+#  undef PERLVARI
+#  undef PERLVARIC
+#  undef PERLVARISC
+
+#endif /* MULTIPLICITY */
 
 struct tempsym; /* defined in pp_pack.c */