summaryrefslogtreecommitdiff
path: root/perlapi.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-08-19 15:54:12 +0100
committerNicholas Clark <nick@ccl4.org>2010-09-21 11:28:07 +0100
commit87b9e16005b9e39b8a24388159e899fe54b95979 (patch)
treea169b5176afb3e487997abf9759ba5ee0cc8af7f /perlapi.c
parent4e9f151b596c7350249666fbb39df1a4283b8b9c (diff)
downloadperl-87b9e16005b9e39b8a24388159e899fe54b95979.tar.gz
Eliminate PL_* accessor functions under ithreads.
When MULTIPLICITY was first developed, and interpreter state moved into an interpreter struct, thread and interpreter local PL_* variables were defined as macros that called accessor functions, returning the address of the value, outside of the perl core. The intent was to allow members within the interpreter struct to change size without breaking binary compatibility, so that bug fixes could be merged to a maintenance branch that necessitated such a size change. However, some non-core code defines PERL_CORE, sometimes intentionally to bypass this mechanism for speed reasons, sometimes for other reasons but with the inadvertent side effect of bypassing this mechanism. As some of this code is widespread in production use, the result is that the core *can't* change the size of members of the interpreter struct, as it will break such modules compiled against a previous release on that maintenance branch. The upshot is that this mechanism is redundant, and well-behaved code is penalised by it. Hence it can and should be removed. Accessor functions are still needed for globals when PERL_GLOBAL_STRUCT is defined.
Diffstat (limited to 'perlapi.c')
-rw-r--r--perlapi.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/perlapi.c b/perlapi.c
index 15a6b53945..ff7d628ba6 100644
--- a/perlapi.c
+++ b/perlapi.c
@@ -28,28 +28,13 @@
#include "perl.h"
#include "perlapi.h"
-#if defined (MULTIPLICITY)
+#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
-/* accessor functions for Perl variables (provides binary compatibility) */
+/* accessor functions for Perl "global" variables */
START_EXTERN_C
-#undef PERLVAR
-#undef PERLVARA
#undef PERLVARI
-#undef PERLVARIC
-#undef PERLVARISC
-
-#define PERLVAR(v,t) t* Perl_##v##_ptr(pTHX) \
- { dVAR; PERL_UNUSED_CONTEXT; return &(aTHX->v); }
-#define PERLVARA(v,n,t) PL_##v##_t* Perl_##v##_ptr(pTHX) \
- { dVAR; PERL_UNUSED_CONTEXT; return &(aTHX->v); }
-
-#define PERLVARI(v,t,i) PERLVAR(v,t)
-#define PERLVARIC(v,t,i) PERLVAR(v, const t)
-#define PERLVARISC(v,i) PL_##v##_t* Perl_##v##_ptr(pTHX) \
- { dVAR; PERL_UNUSED_CONTEXT; return &(aTHX->v); }
-
-#include "intrpvar.h"
+#define PERLVARI(v,t,i) PERLVAR(v,t)
#undef PERLVAR
#undef PERLVARA
@@ -72,30 +57,8 @@ START_EXTERN_C
#undef PERLVARIC
#undef PERLVARISC
-#ifndef PERL_GLOBAL_STRUCT
-/* A few evil special cases. Could probably macrofy this. */
-#undef PL_ppaddr
-#undef PL_check
-#undef PL_fold_locale
-Perl_ppaddr_t** Perl_Gppaddr_ptr(pTHX) {
- static Perl_ppaddr_t* const ppaddr_ptr = PL_ppaddr;
- PERL_UNUSED_CONTEXT;
- return (Perl_ppaddr_t**)&ppaddr_ptr;
-}
-Perl_check_t** Perl_Gcheck_ptr(pTHX) {
- static Perl_check_t* const check_ptr = PL_check;
- PERL_UNUSED_CONTEXT;
- return (Perl_check_t**)&check_ptr;
-}
-unsigned char** Perl_Gfold_locale_ptr(pTHX) {
- static unsigned char* const fold_locale_ptr = PL_fold_locale;
- PERL_UNUSED_CONTEXT;
- return (unsigned char**)&fold_locale_ptr;
-}
-#endif
-
END_EXTERN_C
-#endif /* MULTIPLICITY */
+#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
/* ex: set ro: */