summaryrefslogtreecommitdiff
path: root/XSUB.h
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-11-13 01:59:06 -0500
committerFather Chrysostomos <sprout@cpan.org>2014-11-13 04:41:46 -0800
commit9a18979311347ab1c45e2ef16113bb5abe4cbd26 (patch)
tree22590b8dffe9c4de5f1bf101111d04690033aea1 /XSUB.h
parented6401c5fdd50fe275e7ed0d9af99dff6ec7c1fb (diff)
downloadperl-9a18979311347ab1c45e2ef16113bb5abe4cbd26.tar.gz
add filename handling to xs handshake
- this improves the error message on ABI incompatibility, per [perl #123136] - reduce the number of gv_fetchfile calls in newXS over registering many XSUBs - "v" was not stripped from PERL_API_VERSION_STRING since string "vX.XX.X\0", a typical version number is 8 bytes long, and aligned to 4/8 by most compilers in an image. A double digit maint release is extremely unlikely. - newXS_deffile saves on machine code in bootstrap functions by not passing arg filename - move newXS to where the rest of the newXS*()s live - move the "no address" panic closer to the start to get it out of the way sooner flow wise (it nothing to do with var gv or cv) - move CvANON_on to not check var name twice - change die message to use %p, more efficient on 32 ptr/64 IV platforms see ML post "about commit "util.c: fix comiler warnings"" - vars cv/xs_spp (stack pointer pointer)/xs_interp exist for inspection by a C debugger in an unoptimized build
Diffstat (limited to 'XSUB.h')
-rw-r--r--XSUB.h60
1 files changed, 44 insertions, 16 deletions
diff --git a/XSUB.h b/XSUB.h
index 547cd46eb9..8e38df2291 100644
--- a/XSUB.h
+++ b/XSUB.h
@@ -170,16 +170,23 @@ is a lexical $_ in scope.
#else
# define dXSARGS \
dSP; dAXMARK; dITEMS
-/* These 2 macros are specialized replacements for dXSARGS macro. They may be
- replaced with dXSARGS if no version checking is desired. The 2 macros factor
- out common code in every BOOT XSUB. Computation of vars mark and items will
- optimize away in most BOOT functions. Var ax can never be optimized away
- since BOOT must return &PL_sv_yes by default from xsubpp */
+/* These 3 macros are replacements for dXSARGS macro only in bootstrap.
+ They factor out common code in every BOOT XSUB. Computation of vars mark
+ and items will optimize away in most BOOT functions. Var ax can never be
+ optimized away since BOOT must return &PL_sv_yes by default from xsubpp.
+ Note these macros are not drop in replacements for dXSARGS since they set
+ PL_xsubfilename. */
# define dXSBOOTARGSXSAPIVERCHK \
- I32 ax = XS_BOTHVERSION_POPMARK_BOOTCHECK; \
+ I32 ax = XS_BOTHVERSION_SETXSUBFN_POPMARK_BOOTCHECK; \
SV **mark = PL_stack_base + ax; dSP; dITEMS
# define dXSBOOTARGSAPIVERCHK \
- I32 ax = XS_APIVERSION_POPMARK_BOOTCHECK; \
+ I32 ax = XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK; \
+ SV **mark = PL_stack_base + ax; dSP; dITEMS
+/* dXSBOOTARGSNOVERCHK has no API in xsubpp to choose it so do
+#undef dXSBOOTARGSXSAPIVERCHK
+#define dXSBOOTARGSXSAPIVERCHK dXSBOOTARGSNOVERCHK */
+# define dXSBOOTARGSNOVERCHK \
+ I32 ax = XS_SETXSUBFN_POPMARK; \
SV **mark = PL_stack_base + ax; dSP; dITEMS
#endif
@@ -336,37 +343,58 @@ Rethrows a previously caught exception. See L<perlguts/"Exception Handling">.
#ifdef XS_VERSION
# define XS_VERSION_BOOTCHECK \
- Perl_xs_handshake(HS_KEY(FALSE, "", XS_VERSION), HS_CXT, items, ax, XS_VERSION)
+ Perl_xs_handshake(HS_KEY(FALSE, FALSE, "", XS_VERSION), HS_CXT, __FILE__, \
+ items, ax, XS_VERSION)
#else
# define XS_VERSION_BOOTCHECK
#endif
#define XS_APIVERSION_BOOTCHECK \
- Perl_xs_handshake(HS_KEY(FALSE, "v" PERL_API_VERSION_STRING, ""), HS_CXT, items, ax, "v" PERL_API_VERSION_STRING)
+ Perl_xs_handshake(HS_KEY(FALSE, FALSE, "v" PERL_API_VERSION_STRING, ""), \
+ HS_CXT, __FILE__, items, ax, "v" PERL_API_VERSION_STRING)
/* public API, this is a combination of XS_VERSION_BOOTCHECK and
XS_APIVERSION_BOOTCHECK in 1, and is backportable */
#ifdef XS_VERSION
# define XS_BOTHVERSION_BOOTCHECK \
- Perl_xs_handshake(HS_KEY(FALSE, "v" PERL_API_VERSION_STRING, XS_VERSION) \
- , HS_CXT, items, ax, "v" PERL_API_VERSION_STRING, XS_VERSION)
+ Perl_xs_handshake(HS_KEY(FALSE, FALSE, "v" PERL_API_VERSION_STRING, XS_VERSION), \
+ HS_CXT, __FILE__, items, ax, "v" PERL_API_VERSION_STRING, XS_VERSION)
#else
/* should this be a #error? if you want both checked, you better supply XS_VERSION right? */
# define XS_BOTHVERSION_BOOTCHECK XS_APIVERSION_BOOTCHECK
#endif
/* private API */
-# define XS_APIVERSION_POPMARK_BOOTCHECK \
- Perl_xs_handshake(HS_KEY(TRUE, "v" PERL_API_VERSION_STRING, "") \
- , HS_CXT, "v" PERL_API_VERSION_STRING)
+#define XS_APIVERSION_POPMARK_BOOTCHECK \
+ Perl_xs_handshake(HS_KEY(FALSE, TRUE, "v" PERL_API_VERSION_STRING, ""), \
+ HS_CXT, __FILE__, "v" PERL_API_VERSION_STRING)
#ifdef XS_VERSION
# define XS_BOTHVERSION_POPMARK_BOOTCHECK \
- Perl_xs_handshake(HS_KEY(TRUE, "v" PERL_API_VERSION_STRING, XS_VERSION) \
- , HS_CXT, "v" PERL_API_VERSION_STRING, XS_VERSION)
+ Perl_xs_handshake(HS_KEY(FALSE, TRUE, "v" PERL_API_VERSION_STRING, XS_VERSION), \
+ HS_CXT, __FILE__, "v" PERL_API_VERSION_STRING, XS_VERSION)
#else
/* should this be a #error? if you want both checked, you better supply XS_VERSION right? */
# define XS_BOTHVERSION_POPMARK_BOOTCHECK XS_APIVERSION_POPMARK_BOOTCHECK
#endif
+#define XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK \
+ Perl_xs_handshake(HS_KEY(TRUE, TRUE, "v" PERL_API_VERSION_STRING, ""), \
+ HS_CXT, __FILE__, "v" PERL_API_VERSION_STRING)
+#ifdef XS_VERSION
+# define XS_BOTHVERSION_SETXSUBFN_POPMARK_BOOTCHECK \
+ Perl_xs_handshake(HS_KEY(TRUE, TRUE, "v" PERL_API_VERSION_STRING, XS_VERSION),\
+ HS_CXT, __FILE__, "v" PERL_API_VERSION_STRING, XS_VERSION)
+#else
+/* should this be a #error? if you want both checked, you better supply XS_VERSION right? */
+# define XS_BOTHVERSION_SETXSUBFN_POPMARK_BOOTCHECK XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK
+#endif
+
+/* For a normal bootstrap without API or XS version checking.
+ Useful for static XS modules or debugging/testing scenarios.
+ If this macro gets heavily used in the future, it should separated into
+ a separate function independent of Perl_xs_handshake for efficiency */
+#define XS_SETXSUBFN_POPMARK \
+ Perl_xs_handshake(HS_KEY(TRUE, TRUE, "", "") | HSf_NOCHK, HS_CXT, __FILE__)
+
#ifdef NO_XSLOCKS
# define dXCPT dJMPENV; int rEtV = 0
# define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)