Skip to content

Commit

Permalink
Backport XS_(IN|EX)TERNAL, be explicit about linkage
Browse files Browse the repository at this point in the history
With XS(name) defaulting to exporting symbols again since the
previous commit, ExtUtils::ParseXS will now instead use explicit
XS_EXTERNAL/XS_INTERNAL in its place. This allows backporting
of the linkage changes to perls as old as 5.10.0 (and possibly
further).
  • Loading branch information
tsee committed Aug 28, 2011
1 parent 0cb93b3 commit a62da8e
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Porting/Maintainers.pl
Expand Up @@ -753,7 +753,7 @@ package Maintainers;
'ExtUtils::ParseXS' =>
{
'MAINTAINER' => 'smueller',
'DISTRIBUTION' => 'SMUELLER/ExtUtils-ParseXS-3.03_02.tar.gz',
'DISTRIBUTION' => 'SMUELLER/ExtUtils-ParseXS-3.04_01.tar.gz',
'FILES' => q[dist/ExtUtils-ParseXS],
'UPSTREAM' => 'blead',
},
Expand Down
12 changes: 12 additions & 0 deletions dist/ExtUtils-ParseXS/Changes
@@ -1,5 +1,17 @@
Revision history for Perl extension ExtUtils::ParseXS.

3.04_01 - Sun Aug 28 17:50:00 CET 2011

- The XSUB.h changes to make XS(name) use XS_INTERNAL(name)
by default (which were in the 5.15.2 dev release of perl)
have been reverted since too many CPAN modules expect to
be able to refer to XSUBs declared with XS(name).
Instead, ExtUtils::ParseXS will define a copy of the
XS_INTERNAL/XS_EXTERNAL macros as necessary going back to
perl 5.10.0 (which is the oldest perl I had for testing).
By default, ExtUtils::ParseXS will use XS_INTERNAL(name)
instead of XS(name).

3.04 - Thu Aug 25 08:20:00 CET 2011

- Stable release based on 3.03_03, no functional changes.
Expand Down
16 changes: 7 additions & 9 deletions dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
Expand Up @@ -11,7 +11,7 @@ use Symbol;

our $VERSION;
BEGIN {
$VERSION = '3.04';
$VERSION = '3.04_01';
}
use ExtUtils::ParseXS::Constants $VERSION;
use ExtUtils::ParseXS::CountLines $VERSION;
Expand Down Expand Up @@ -502,8 +502,8 @@ EOM
# print function header
print Q(<<"EOF");
#$externC
#XS(XS_${Full_func_name}); /* prototype to pass -Wmissing-prototypes */
#XS(XS_${Full_func_name})
#XS_EUPXS(XS_${Full_func_name}); /* prototype to pass -Wmissing-prototypes */
#XS_EUPXS(XS_${Full_func_name})
#[[
##ifdef dVAR
# dVAR; dXSARGS;
Expand Down Expand Up @@ -880,8 +880,8 @@ EOF

if ($self->{Overload}) { # make it findable with fetchmethod
print Q(<<"EOF");
#XS(XS_$self->{Packid}_nil); /* prototype to pass -Wmissing-prototypes */
#XS(XS_$self->{Packid}_nil)
#XS_EUPXS(XS_$self->{Packid}_nil); /* prototype to pass -Wmissing-prototypes */
#XS_EUPXS(XS_$self->{Packid}_nil)
#{
# dXSARGS;
# XSRETURN_EMPTY;
Expand Down Expand Up @@ -1476,10 +1476,8 @@ sub EXPORT_XSUB_SYMBOLS_handler {
my $xs_impl = $1 eq 'ENABLE' ? 'XS_EXTERNAL' : 'XS_INTERNAL';

print Q(<<"EOF");
##if (PERL_REVISION == 5 && (PERL_VERSION > 15 || (PERL_VERSION == 15 && PERL_SUBVERSION > 0)))
##undef XS
##define XS(name) $xs_impl(name)
##endif
##undef XS_EUPXS
##define XS_EUPXS(name) $xs_impl(name)
EOF
}

Expand Down
2 changes: 1 addition & 1 deletion dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm
Expand Up @@ -3,7 +3,7 @@ use strict;
use warnings;
use Symbol;

our $VERSION = '3.04';
our $VERSION = '3.04_01';

=head1 NAME
Expand Down
2 changes: 1 addition & 1 deletion dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/CountLines.pm
@@ -1,7 +1,7 @@
package ExtUtils::ParseXS::CountLines;
use strict;

our $VERSION = '3.04';
our $VERSION = '3.04_01';

our $SECTION_END_MARKER;

Expand Down
80 changes: 77 additions & 3 deletions dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm
Expand Up @@ -6,7 +6,7 @@ use File::Spec;
use lib qw( lib );
use ExtUtils::ParseXS::Constants ();

our $VERSION = '3.04';
our $VERSION = '3.04_01';

our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter);
Expand Down Expand Up @@ -455,14 +455,88 @@ sub standard_XS_defs {
# define PERL_UNUSED_VAR(var) if (0) var = var
#endif
/* Starting from 5.15.2, XS(name) defines a static function (==internal)
* and the XS_EXTERNAL macro is used for functions that must not be static
/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
# define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
# define PERL_DECIMAL_VERSION \\
PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
# define PERL_VERSION_GE(r,v,s) \\
(PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
# define PERL_VERSION_LE(r,v,s) \\
(PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif
/* XS_INTERNAL is the explicit static-linkage variant of the default
* XS macro.
*
* XS_EXTERNAL is the same as XS_INTERNAL except it does not include
* "STATIC", ie. it exports XSUB symbols. You probably don't want that
* for anything but the BOOT XSUB.
*
* See XSUB.h in core!
*/
/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
# undef XS_EXTERNAL
# undef XS_INTERNAL
# if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
# define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
# define XS_INTERNAL(name) __declspec(dllexport) STATIC XSPROTO(name)
# endif
# if defined(__SYMBIAN32__)
# define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
# define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
# endif
# ifndef XS_EXTERNAL
# if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
# define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
# define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
# else
# ifdef __cplusplus
# define XS_EXTERNAL(name) extern "C" XSPROTO(name)
# define XS_INTERNAL(name) static XSPROTO(name)
# else
# define XS_EXTERNAL(name) XSPROTO(name)
# define XS_INTERNAL(name) STATIC XSPROTO(name)
# endif
# endif
# endif
#endif
/* perl >= 5.10.0 && perl <= 5.15.1 */
/* The XS_EXTERNAL macro is used for functions that must not be static
* like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
* macro defined, the best we can do is assume XS is the same.
* Dito for XS_INTERNAL.
*/
#ifndef XS_EXTERNAL
# define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
# define XS_INTERNAL(name) XS(name)
#endif
/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
* internal macro that we're free to redefine for varying linkage due
* to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
* XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
*/
/* default to internal */
#undef XS_EUPXS
#define XS_EUPXS(name) XS_INTERNAL(name)
EOF

print <<"EOF";
Expand Down

0 comments on commit a62da8e

Please sign in to comment.