Ancient

 view release on metacpan or  search on metacpan

bench/count.pl  view on Meta::CPAN

    while (($pos = index($str, $needle, $pos)) != -1) {
        $count++;
        $pos += $len;
    }
    return $count;
}

print "=== count 'the' in short string (4 occurrences) ===\n";
cmpthese(-2, {
    'util::count'   => sub { count($str, "the") },
    'regex_global'  => sub { scalar(() = $str =~ /the/g) },
    'index_loop'    => sub { pure_count_index($str, "the") },
});

print "\n=== count 'the' in long string (400 occurrences) ===\n";
cmpthese(-2, {
    'util::count'   => sub { count($long_str, "the") },
    'regex_global'  => sub { scalar(() = $long_str =~ /the/g) },
    'index_loop'    => sub { pure_count_index($long_str, "the") },
});

print "\n=== count 'xyz' (not found) ===\n";
cmpthese(-2, {
    'util::count'   => sub { count($str, "xyz") },
    'regex_global'  => sub { scalar(() = $str =~ /xyz/g) },
    'index_loop'    => sub { pure_count_index($str, "xyz") },
});

print "\nDONE\n";

bench/is_extended.pl  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(cmpthese);
use lib 'blib/lib', 'blib/arch';
use Scalar::Util qw(blessed looks_like_number);
use util qw(is_num is_int is_blessed is_scalar_ref is_regex is_glob);

print "=" x 60, "\n";
print "Extended Type Predicates Benchmark\n";
print "=" x 60, "\n\n";

my $num = 42.5;
my $int = 42;
my $str = "hello";
my $obj = bless {}, 'MyClass';
my $sref = \my $x;

lib/doubly.pm  view on Meta::CPAN

runs approximately 3x faster.

This implementation is not thread-safe, the lists cannot be shared across threads.

=head2 Architecture

=over 4

=item * Dynamic SV-based node storage (no serialization overhead)

=item * Index-based linking with global registry

=item * Reference counting for automatic garbage collection

=back

=head1 METHODS

=head2 new

    my $list = doubly->new();

lib/slot.pm  view on Meta::CPAN

use warnings;
our $VERSION = '0.18';
require XSLoader;
XSLoader::load('slot', $VERSION);
1;

__END__

=head1 NAME

slot - global reactive state slots with optional watchers

=head1 SYNOPSIS

    # Define and use slots
    package Config;
    use slot qw(app_name debug);
    
    app_name("MyApp");
    debug(1);
    

lib/slot.pm  view on Meta::CPAN

    # Watchers (reactive)
    slot::watch('app_name', sub {
        my ($name, $value) = @_;
        print "app_name changed to: $value\n";
    });
    
    slot::unwatch('app_name');  # Remove all watchers

=head1 DESCRIPTION

C<slot> provides fast, globally shared named storage slots.
Slots are shared across all packages - importing the same slot name in different
packages gives access to the same underlying value.

Key features:

=over 4

=item * B<Fast> - Custom ops with compile-time optimization

=item * B<Global> - Slots are shared across packages by name

lib/slot.pm  view on Meta::CPAN

        threads->create(sub {
            my $cfg = config();
            lock(%$cfg);
            $cfg->{counter}++;
        });
    } 1..10;

    $_->join for @threads;
    print config()->{counter};  # 10

The slot provides the global accessor; C<threads::shared> provides the
thread-safe storage.

=head1 FORK BEHAVIOR

After C<fork()>, child processes get a copy of slot values (copy-on-write).
Changes in child processes do not affect the parent, and vice versa.

=head1 AUTHOR

LNATION <email@lnation.org>

lib/util.pm  view on Meta::CPAN

        nvl coalesce first any all none
        first_gt first_lt first_ge first_le first_eq first_ne
        final final_gt final_lt final_ge final_le final_eq final_ne
        any_gt any_lt any_ge any_le any_eq any_ne
        all_gt all_lt all_ge all_le all_eq all_ne
        none_gt none_lt none_ge none_le none_eq none_ne
        uniq partition pick omit pluck defaults count replace_all negate once
        is_ref is_array is_hash is_code is_defined is_string
        is_empty starts_with ends_with trim ltrim rtrim
        is_true is_false bool
        is_num is_int is_blessed is_scalar_ref is_regex is_glob
        is_positive is_negative is_zero
        is_even is_odd is_between
        is_empty_array is_empty_hash array_len hash_size
        array_first array_last
        maybe sign min2 max2
    );

    # Type predicates - compile-time optimized
    if (is_array($data)) { ... }
    if (is_hash($config)) { ... }

lib/util.pm  view on Meta::CPAN

    if (is_true($value)) { ... }   # Perl truth semantics
    if (is_false($value)) { ... }  # Perl false semantics
    my $normalized = bool($value); # Normalize to 1 or ''

    # Extended type predicates
    if (is_num($value)) { ... }        # Numeric value or looks like number
    if (is_int($value)) { ... }        # Integer value
    if (is_blessed($obj)) { ... }      # Blessed reference
    if (is_scalar_ref($ref)) { ... }   # Scalar reference
    if (is_regex($qr)) { ... }         # Compiled regex (qr//)
    if (is_glob(*FH)) { ... }          # Glob

    # Numeric predicates
    if (is_positive($num)) { ... }     # > 0
    if (is_negative($num)) { ... }     # < 0
    if (is_zero($num)) { ... }         # == 0
    if (is_even($num)) { ... }         # n & 1 == 0
    if (is_odd($num)) { ... }          # n & 1 == 1
    if (is_between($n, 1, 10)) { ... } # Range check (inclusive)

    # Collection predicates - direct AvFILL/HvKEYS access

lib/util.pm  view on Meta::CPAN

B<Custom ops> (compile-time optimization, no function call overhead):

=over 4

=item * C<identity> - eliminated entirely at compile time

=item * C<is_ref>, C<is_array>, C<is_hash>, C<is_code>, C<is_defined> - single SV flag check

=item * C<is_true>, C<is_false>, C<bool> - direct SvTRUE check

=item * C<is_num>, C<is_int>, C<is_blessed>, C<is_scalar_ref>, C<is_regex>, C<is_glob> - extended type checks

=item * C<is_positive>, C<is_negative>, C<is_zero> - numeric comparisons

=item * C<is_even>, C<is_odd> - single bitwise AND

=item * C<is_between> - range check (two comparisons)

=item * C<is_empty_array>, C<is_empty_hash> - direct AvFILL/HvKEYS check

=item * C<array_len>, C<hash_size> - direct AvFILL/HvKEYS access

lib/util.pm  view on Meta::CPAN

    my $bool = is_scalar_ref($value);

Returns true if C<$value> is a scalar reference (not array/hash/code).

=head2 is_regex

    my $bool = is_regex($value);

Returns true if C<$value> is a compiled regular expression (qr//).

=head2 is_glob

    my $bool = is_glob($value);

Returns true if C<$value> is a glob (like *STDIN, *main::foo).

=head1 NUMERIC PREDICATES

These functions use custom ops for numeric comparisons.
They first check if the value is numeric, then perform the comparison.

=head2 is_positive

    my $bool = is_positive($value);

t/1008-types.t  view on Meta::CPAN

# These should be false - not plain scalars
ok(!is_string(undef), 'undef is not a string');
ok(!is_string([]), 'arrayref is not a string');
ok(!is_string({}), 'hashref is not a string');
ok(!is_string(sub {}), 'coderef is not a string');
ok(!is_string(\1), 'scalar ref is not a string');
ok(!is_string(\$obj), 'ref to object is not a string');
ok(!is_string($obj), 'blessed ref is not a string');

# Edge cases
# Note: globs are technically "defined and not a ref" so is_string returns true
# Use is_glob to specifically detect globs if needed
ok(is_string(*STDIN), 'glob is technically a string (defined, not ref)');
ok(!is_string(qr/test/), 'regex is not a string');

# ============================================
# Ternary context tests - ensure return values work in conditionals
# ============================================

# is_ref ternary
is((is_ref([]) ? 'yes' : 'no'), 'yes', 'is_ref([]) works in ternary');
is((is_ref({}) ? 'yes' : 'no'), 'yes', 'is_ref({}) works in ternary');
is((is_ref('hello') ? 'yes' : 'no'), 'no', 'is_ref(string) works in ternary');

t/1014-extended-types.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use lib 'blib/lib', 'blib/arch';

use_ok('util', qw(is_num is_int is_blessed is_scalar_ref is_regex is_glob));

# ============================================
# is_num tests - check if value is numeric
# ============================================

ok(is_num(42), '42 is numeric');
ok(is_num(-42), '-42 is numeric');
ok(is_num(3.14), '3.14 is numeric');
ok(is_num(0), '0 is numeric');
ok(is_num("42"), '"42" string is numeric');

t/1014-extended-types.t  view on Meta::CPAN

ok(is_regex(qr/^$/), 'inline qr// is regex');

ok(!is_regex("hello"), 'string is not regex');
ok(!is_regex({}), 'hashref is not regex');
ok(!is_regex([]), 'arrayref is not regex');
ok(!is_regex(sub {}), 'coderef is not regex');
ok(!is_regex(42), 'number is not regex');
ok(!is_regex(undef), 'undef is not regex');

# ============================================
# is_glob tests
# ============================================

ok(is_glob(*STDIN), '*STDIN is glob');
ok(is_glob(*STDOUT), '*STDOUT is glob');
ok(is_glob(*STDERR), '*STDERR is glob');
{
    no strict 'refs';
    ok(is_glob(*{"main::is_glob"}), 'function glob is glob');
}

ok(!is_glob(\*STDIN), '\\*STDIN (globref) is not glob');
ok(!is_glob("hello"), 'string is not glob');
ok(!is_glob({}), 'hashref is not glob');
ok(!is_glob([]), 'arrayref is not glob');
ok(!is_glob(sub {}), 'coderef is not glob');
ok(!is_glob(42), 'number is not glob');
ok(!is_glob(undef), 'undef is not glob');

# ============================================
# Test with variables (ensures custom ops work)
# ============================================

my $num = 42;
my $float = 3.14;
my $int = 100;
my $notnum = "hello";

t/1030-util-predicates-valid.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use lib 'blib/lib', 'blib/arch';

use_ok('util');
use util qw(
    is_ref is_array is_hash is_code is_defined is_string
    is_num is_int is_blessed is_scalar_ref is_regex is_glob
    is_true is_false bool
);

# ============================================
# is_ref - any reference type
# ============================================

subtest 'is_ref basic types' => sub {
    # Non-references
    ok(!is_ref(undef), 'is_ref: undef');

t/1030-util-predicates-valid.t  view on Meta::CPAN

    ok(!is_regex({}), 'is_regex: hash');

    # Regex
    ok(is_regex(qr//), 'is_regex: empty regex');
    ok(is_regex(qr/test/), 'is_regex: simple regex');
    ok(is_regex(qr/test/i), 'is_regex: regex with flags');
    ok(is_regex(qr/^\d+$/), 'is_regex: complex regex');
};

# ============================================
# is_glob
# ============================================

subtest 'is_glob basic' => sub {
    # Not globs
    ok(!is_glob(undef), 'is_glob: undef');
    ok(!is_glob(42), 'is_glob: number');
    ok(!is_glob('*STDOUT'), 'is_glob: string');
    ok(!is_glob([]), 'is_glob: array');
    ok(!is_glob({}), 'is_glob: hash');

    # Globs
    ok(is_glob(*STDOUT), 'is_glob: STDOUT');
    ok(is_glob(*STDERR), 'is_glob: STDERR');
    ok(is_glob(*STDIN), 'is_glob: STDIN');
};

# ============================================
# is_true / is_false / bool
# ============================================

subtest 'is_true basic' => sub {
    # False values
    ok(!is_true(undef), 'is_true: undef');
    ok(!is_true(0), 'is_true: 0');

t/1048-util-type-checks.t  view on Meta::CPAN

ok(util::is_ref(sub { 1 }), 'is_ref: coderef is ref');
ok(!util::is_ref('hello'), 'is_ref: string is not ref');
ok(!util::is_ref(42), 'is_ref: number is not ref');

# Test is_regex
my $rx = qr/test/;
ok(util::is_regex($rx), 'is_regex: qr// is regex');
ok(!util::is_regex('test'), 'is_regex: string is not regex');
ok(!util::is_regex([1, 2]), 'is_regex: arrayref is not regex');

# Test is_glob
ok(util::is_glob(*STDOUT), 'is_glob: *STDOUT is glob');
ok(!util::is_glob('hello'), 'is_glob: string is not glob');

# Test is_blessed
my $obj = bless {}, 'MyClass';
ok(util::is_blessed($obj), 'is_blessed: blessed ref is blessed');
ok(!util::is_blessed({a => 1}), 'is_blessed: unblessed hashref is not blessed');
ok(!util::is_blessed('hello'), 'is_blessed: string is not blessed');

done_testing();

t/1065-map-grep-context.t  view on Meta::CPAN

    # So both \$scalar_ref and qr/foo/ are counted as scalar refs
    my @scalars = grep { util::is_scalar_ref($_) } @mixed;
    is(scalar(@scalars), 2, 'is_scalar_ref in grep finds 2 scalar refs (includes regex)');
};

subtest 'is_regex in map/grep' => sub {
    my @regexes = grep { util::is_regex($_) } @mixed;
    is(scalar(@regexes), 1, 'is_regex in grep finds 1 regex');
};

subtest 'is_glob in map/grep' => sub {
    my @items = (*STDOUT, 'str', 1);
    my @globs = grep { util::is_glob($_) } @items;
    is(scalar(@globs), 1, 'is_glob in grep finds 1 glob');
};

# ============================================
# Numeric predicates
# ============================================
subtest 'is_positive in map/grep' => sub {
    my @pos = grep { util::is_positive($_) } @nums;
    is(scalar(@pos), 3, 'is_positive in grep finds 3 positive nums');
};

t/9015-cross-all-modules.t  view on Meta::CPAN

use lru;
use const;
use doubly;
use object;
use util qw(memo is_hash);

# Setup: Create an application-like structure using multiple modules

# 1. Global cache via slot
app_cache(lru::new(100));
ok(defined app_cache(), 'global cache created via slot');

# 2. Immutable config via const stored in slot
app_config(const::c({
    app_name => 'TestApp',
    version => '1.0.0',
    max_items => 50
}));

is(app_config()->{app_name}, 'TestApp', 'config accessible via slot');
ok(is_hash(app_config()) ? 1 : 0, 'config is a hash');

t/9022-leak-util-predicates.t  view on Meta::CPAN

use Test::More;

BEGIN {
    eval { require Test::LeakTrace };
    plan skip_all => 'Test::LeakTrace required' if $@;
}
use Test::LeakTrace;

use util qw(
    is_array is_hash is_code is_defined is_ref
    is_scalar_ref is_glob is_regex is_blessed
);

# Warmup
for (1..10) {
    is_array([]);
    is_hash({});
}

subtest 'is_array' => sub {
    my $arr = [1, 2, 3];

t/9022-leak-util-predicates.t  view on Meta::CPAN

    my $obj = bless {}, 'MyClass';
    no_leaks_ok {
        for (1..1000) {
            my $r = is_blessed($obj);
            my $r2 = is_blessed({});
            my $r3 = is_blessed("string");
        }
    } 'is_blessed does not leak';
};

subtest 'is_glob' => sub {
    no_leaks_ok {
        for (1..1000) {
            my $r = is_glob(*STDOUT);
            my $r2 = is_glob("string");
            my $r3 = is_glob([]);
        }
    } 'is_glob does not leak';
};

subtest 'is_regex' => sub {
    my $regex = qr/test/;
    no_leaks_ok {
        for (1..1000) {
            my $r = is_regex($regex);
            my $r2 = is_regex("string");
            my $r3 = is_regex({});
        }

xs/const/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/const/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/const/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/const/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/const/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/const/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/const/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/const/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/const/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/const/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/const/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/const/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/const/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/const/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/const/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/const/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/const/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/const/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/const/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/const/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/const/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/const/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/const/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/const/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/const/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/const/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/doubly/doubly.c  view on Meta::CPAN

}

/* Free a node slot (add to free list) */
static void free_node(pTHX_ IV idx) {
    DoublyNodeSlot* node;

    if (idx < 0 || idx >= g_nodes_count) return;

    node = &g_nodes[idx];

    /* Decrement SV refcount if not during global destruction
     * and only if we're in the interpreter that owns the SV */
    if (node->data && !PL_dirty) {
#ifdef USE_ITHREADS
        /* Only free if this interpreter owns the SV */
        if (node->data_interp == PERL_GET_THX) {
            SvREFCNT_dec(node->data);
        }
        /* Note: if we're not the owner, we "leak" this SV intentionally.
         * The owning interpreter will clean it up during its destruction. */
#else

xs/doubly/doubly.c  view on Meta::CPAN

    SV** id_sv;
    IV list_idx;
#ifdef USE_ITHREADS
    SV** owner_tid_sv;
    UV owner_tid;
    UV my_tid;
#endif

    PERL_UNUSED_VAR(items);

    /* Skip cleanup during global destruction */
    if (PL_dirty) {
        XSRETURN_EMPTY;
    }

    hash = (HV*)SvRV(ST(0));
    id_sv = hv_fetch(hash, "_id", 3, 0);
    list_idx = id_sv ? SvIV(*id_sv) : -1;

#ifdef USE_ITHREADS
    owner_tid_sv = hv_fetch(hash, "_owner_tid", 10, 0);

xs/doubly/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/doubly/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/doubly/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/doubly/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/doubly/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/doubly/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/doubly/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/doubly/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/doubly/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/doubly/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/doubly/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/doubly/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/doubly/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/doubly/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/doubly/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/doubly/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/doubly/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/doubly/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/doubly/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/doubly/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/doubly/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/doubly/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/doubly/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/doubly/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/doubly/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/doubly/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/file/file.c  view on Meta::CPAN

        s++;
        len--;
    }
    return len > 0 && *s == '#';
}

static bool pred_is_not_comment(pTHX_ SV *line) {
    return !pred_is_comment(aTHX_ line);
}

/* Cleanup callback registry during global destruction */
static void file_cleanup_callback_registry(pTHX_ void *data) {
    PERL_UNUSED_ARG(data);

    /* During global destruction, just NULL out pointers.
     * Perl handles SV cleanup; trying to free them ourselves
     * can cause crashes due to destruction order. */
    if (PL_dirty) {
        g_file_callback_registry = NULL;
        return;
    }

    /* Normal cleanup - not during global destruction */
    g_file_callback_registry = NULL;
}

static void file_init_callback_registry(pTHX) {
    SV *sv;
    FileLineCallback *cb;

    if (g_file_callback_registry) return;
    g_file_callback_registry = newHV();

xs/file/file.c  view on Meta::CPAN

    newXS("file::mmap::close", xs_mmap_close, __FILE__);
    newXS("file::mmap::DESTROY", xs_mmap_DESTROY, __FILE__);

    /* Line iterators */
    newXS("file::lines_iter", xs_lines_iter, __FILE__);
    newXS("file::lines::next", xs_lines_iter_next, __FILE__);
    newXS("file::lines::eof", xs_lines_iter_eof, __FILE__);
    newXS("file::lines::close", xs_lines_iter_close, __FILE__);
    newXS("file::lines::DESTROY", xs_lines_iter_DESTROY, __FILE__);

    /* Register cleanup for global destruction */
    Perl_call_atexit(aTHX_ file_cleanup_callback_registry, NULL);

    Perl_xs_boot_epilog(aTHX_ ax);
}

xs/file/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/file/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/file/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/file/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/file/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/file/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/file/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/file/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/file/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/file/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/file/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/file/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/file/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/file/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/file/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/file/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/file/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/file/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/file/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/file/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/file/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/file/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/file/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/file/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/file/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/file/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/heap/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/heap/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/heap/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/heap/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/heap/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/heap/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/heap/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/heap/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/heap/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/heap/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/heap/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/heap/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/heap/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/heap/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/heap/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/heap/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/heap/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/heap/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/heap/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/heap/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/heap/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/heap/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/heap/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/heap/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/heap/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/heap/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/lru/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/lru/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/lru/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/lru/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/lru/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/lru/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/lru/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/lru/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/lru/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/lru/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/lru/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/lru/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/lru/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/lru/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/lru/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/lru/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/lru/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/lru/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/lru/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/lru/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/lru/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/lru/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/lru/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/lru/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/lru/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/lru/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/noop/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/noop/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/noop/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/noop/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/noop/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/noop/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/noop/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/noop/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/noop/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/noop/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/noop/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/noop/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/noop/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/noop/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/noop/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/noop/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/noop/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/noop/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/noop/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/noop/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/noop/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/noop/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/noop/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/noop/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/noop/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/noop/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/nvec/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/nvec/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/nvec/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/nvec/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/nvec/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/nvec/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/nvec/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/nvec/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/nvec/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/nvec/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/nvec/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/nvec/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/nvec/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/nvec/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/nvec/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/nvec/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/nvec/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/nvec/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/nvec/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/nvec/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/nvec/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/nvec/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/nvec/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/nvec/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/nvec/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/nvec/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/object/object.c  view on Meta::CPAN


    av_store(av, idx, newSVsv(val));

    SETs(val);  /* Replace object with value */
    RETURN;
}

/* Check if an op is "simple" (can be safely used in optimized accessor) */
OBJECT_INLINE bool is_simple_op(OP *op) {
    if (!op) return false;
    /* Simple ops: pad variables, constants, global variables */
    switch (op->op_type) {
        case OP_PADSV:    /* $lexical */
        case OP_CONST:    /* literal value */
        case OP_GV:       /* *glob */
        case OP_GVSV:     /* $global */
        case OP_AELEMFAST:/* $array[const] */
#if defined(OP_AELEMFAST_LEX) && OP_AELEMFAST_LEX != OP_AELEMFAST
        case OP_AELEMFAST_LEX:
#endif
        case OP_NULL:     /* Often wraps simple ops */
            return true;
        default:
            return false;
    }
}

xs/object/object.c  view on Meta::CPAN

    }

    ST(0) = sv_2mortal(newRV_noinc((SV*)info));
    XSRETURN(1);
}

/* ============================================
   Global cleanup
   ============================================ */

/* Cleanup during global destruction */
static void object_cleanup_globals(pTHX_ void *data) {
    PERL_UNUSED_ARG(data);

    /* During global destruction, just NULL out pointers.
     * Perl handles SV cleanup. Trying to free them ourselves
     * can cause crashes due to destruction order. */
    if (PL_dirty) {
        g_type_registry = NULL;
        g_class_registry = NULL;
        g_func_accessor_registry = NULL;
        return;
    }

    /* Normal cleanup - not during global destruction */
    /* Note: Full cleanup omitted for simplicity; Perl handles SV refcounts */
    g_type_registry = NULL;
    g_class_registry = NULL;
    g_func_accessor_registry = NULL;
}

/* ============================================
   Type Registry API
   ============================================ */

xs/object/object.c  view on Meta::CPAN

    newXS("object::role", xs_role, __FILE__);
    newXS("object::requires", xs_requires, __FILE__);
    newXS("object::with", xs_with, __FILE__);
    newXS("object::does", xs_does, __FILE__);
    
    /* Method modifier API */
    newXS("object::before", xs_before, __FILE__);
    newXS("object::after", xs_after, __FILE__);
    newXS("object::around", xs_around, __FILE__);

    /* Register cleanup for global destruction */
    Perl_call_atexit(aTHX_ object_cleanup_globals, NULL);

    Perl_xs_boot_epilog(aTHX_ ax);
}

xs/object/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/object/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/object/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/object/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/object/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/object/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/object/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/object/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/object/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/object/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/object/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/object/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/object/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/object/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/object/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/object/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/object/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/object/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/object/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/object/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/object/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/object/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/object/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/object/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/object/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/object/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/slot/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

Although the purpose of F<ppport.h> is to keep you from having to concern
yourself with what version you are running under, there may arise instances
where you have to do so.  These macros, the same ones as in base Perl, are
available to you in all versions, and are what you should use:

xs/slot/ppport.h  view on Meta::CPAN


If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    caller_cx()               NEED_caller_cx               NEED_caller_cx_GLOBAL
    ck_warner()               NEED_ck_warner               NEED_ck_warner_GLOBAL
    ck_warner_d()             NEED_ck_warner_d             NEED_ck_warner_d_GLOBAL
    croak_xs_usage()          NEED_croak_xs_usage          NEED_croak_xs_usage_GLOBAL
    die_sv()                  NEED_die_sv                  NEED_die_sv_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL

xs/slot/ppport.h  view on Meta::CPAN

    # Returns a floating point representation of the input version

    my $version = int_parse_version(shift);
    $version =~ s/ ^  ( $r_pat ) \B /$1./x;
    return $version;
}

BEGIN {
  if ("$]" < "5.006" ) {
    # On early perls, the implicit pass by reference doesn't work, so we have
    # to use the globals to initialize.
    eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ];
  } elsif ("$]" < "5.022" ) {
    eval q[sub dictionary_order($$) { _dictionary_order(@_) } ];
  } else {
    eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ];
  }
}

sub _dictionary_order { # Sort caselessly, ignoring punct
    my ($valid_a, $valid_b) = @_;

xs/slot/ppport.h  view on Meta::CPAN

ASCII_TO_NATIVE|5.007001||Viu
ASCII_TO_NEED|5.019004||dcVnu
asctime|5.009000||Viu
ASCTIME_R_PROTO|5.008000|5.008000|Vn
assert|5.003007||Viu
__ASSERT_|5.019007|5.008008|p
ASSERT_CURPAD_ACTIVE|5.008001||Viu
ASSERT_CURPAD_LEGAL|5.008001||Viu
ASSERT_IS_LITERAL|||Viu
ASSERT_IS_PTR|||Viu
assert_not_glob|5.009004||Viu
ASSERT_NOT_PTR|5.035004||Viu
assert_not_ROK|5.008001||Viu
assert_uft8_cache_coherent|5.013003||Viu
assignment_type|5.021005||Viu
ASSUME|5.019006|5.003007|p
atfork_lock|5.007003|5.007003|nu
atfork_unlock|5.007003|5.007003|nu
aTHX|5.006000|5.003007|p
aTHX_|5.006000|5.003007|p
aTHXa|5.017006||Viu

xs/slot/ppport.h  view on Meta::CPAN

G_FAKINGEVAL|5.009004||Viu
Gid_t|5.003007|5.003007|Vn
Gid_t_f|5.006000|5.006000|Vn
Gid_t_sign|5.006000|5.006000|Vn
Gid_t_size|5.006000|5.006000|Vn
GIMME|5.003007|5.003007|d
GIMME_V|5.004000|5.004000|
gimme_V|5.031005||xcVu
G_KEEPERR|5.003007|5.003007|
G_LIST|5.035001|5.003007|
glob_2number|5.009004||Viu
GLOBAL_PAT_MOD|5.009005||Viu
glob_assign_glob|5.009004||Viu
G_METHOD|5.006001|5.003007|p
G_METHOD_NAMED|5.019002|5.019002|
gmtime|5.031011||Viu
GMTIME_MAX|5.010001|5.010001|Vn
GMTIME_MIN|5.010001|5.010001|Vn
GMTIME_R_PROTO|5.008000|5.008000|Vn
G_NOARGS|5.003007|5.003007|
G_NODEBUG|5.004005||Viu
GOSUB|5.009005||Viu
GOSUB_t8|5.035004||Viu

xs/slot/ppport.h  view on Meta::CPAN

KEY_getpwent|5.003007||Viu
KEY_getpwnam|5.003007||Viu
KEY_getpwuid|5.003007||Viu
KEY_getservbyname|5.003007||Viu
KEY_getservbyport|5.003007||Viu
KEY_getservent|5.003007||Viu
KEY_getsockname|5.003007||Viu
KEY_getsockopt|5.003007||Viu
KEY_getspnam|5.031011||Viu
KEY_given|5.009003||Viu
KEY_glob|5.003007||Viu
KEY_gmtime|5.003007||Viu
KEY_goto|5.003007||Viu
KEY_grep|5.003007||Viu
KEY_gt|5.003007||Viu
KEY_hex|5.003007||Viu
KEY_if|5.003007||Viu
KEY_index|5.003007||Viu
KEY_INIT|5.005000||Viu
KEY_int|5.003007||Viu
KEY_ioctl|5.003007||Viu

xs/slot/ppport.h  view on Meta::CPAN

magic_clearhint|5.009004||Vi
magic_clearhints|5.011000||Vi
magic_clearisa|5.010001||Viu
magic_clearpack|5.003007||Viu
magic_clearsig|5.003007||Viu
magic_copycallchecker|5.017000||Viu
magic_dump|5.006000|5.006000|u
magic_existspack|5.003007||Viu
magic_freearylen_p|5.009003||Viu
magic_freecollxfrm|5.033004||Viu
magic_freemglob|5.033004||Viu
magic_freeovrld|5.007001||Viu
magic_freeutf8|5.033004||Viu
magic_get|5.003007||Viu
magic_getarylen|5.003007||Viu
magic_getdebugvar|5.021005||Viu
magic_getdefelem|5.004000||Viu
magic_getnkeys|5.004005||Viu
magic_getpack|5.003007||Viu
magic_getpos|5.003007||Viu
magic_getsig|5.003007||Viu

xs/slot/ppport.h  view on Meta::CPAN

magic_setarylen|5.003007||Viu
magic_setcollxfrm|5.004000||Viu
magic_setdbline|5.003007||Viu
magic_setdebugvar|5.021005||Viu
magic_setdefelem|5.004000||Viu
magic_setenv|5.003007||Viu
magic_sethint|5.009004||Vi
magic_sethint_feature|5.031007||Viu
magic_setisa|5.003007||Viu
magic_setlvref|5.021005||Viu
magic_setmglob|5.003007||Viu
magic_setnkeys|5.003007||Viu
magic_setnonelem|5.027009||Viu
magic_setpack|5.003007||Viu
magic_setpos|5.003007||Viu
magic_setregexp|5.008001||Viu
magic_setsig|5.003007||Viu
magic_setsigall|5.035001||Viu
magic_setsubstr|5.003007||Viu
magic_settaint|5.003007||Viu
magic_setutf8|5.008001||Viu

xs/slot/ppport.h  view on Meta::CPAN

MgBYTEPOS_set|5.019004||Viu
mg_clear|5.003007|5.003007|
mg_copy|5.003007|5.003007|
mg_dup|5.007003|5.007003|u
MGf_BYTES|5.019004||Viu
MGf_COPY|5.007003||Viu
MGf_DUP|5.007003||Viu
MGf_GSKIP|5.003007||Viu
mg_find|5.003007|5.003007|n
mg_findext|5.013008|5.003007|pn
mg_find_mglob|5.019002||cViu
MGf_LOCAL|5.009003||Viu
MGf_MINMATCH|5.003007||Viu
MGf_PERSIST|5.021005||Viu
mg_free|5.003007|5.003007|
mg_freeext|5.027004|5.027004|
mg_free_type|5.013006|5.013006|
MGf_REFCOUNTED|5.003007||Viu
MGf_REQUIRE_GV|5.021004||Viu
MGf_TAINTEDDIR|5.003007||Viu
mg_get|5.003007|5.003007|

xs/slot/ppport.h  view on Meta::CPAN

PERL_MAGIC_checkcall|5.013006|5.013006|
PERL_MAGIC_collxfrm|5.007002|5.003007|p
PERL_MAGIC_dbfile|5.007002|5.003007|p
PERL_MAGIC_dbline|5.007002|5.003007|p
PERL_MAGIC_debugvar|5.021005|5.021005|
PERL_MAGIC_defelem|5.007002|5.003007|p
PERL_MAGIC_env|5.007002|5.003007|p
PERL_MAGIC_envelem|5.007002|5.003007|p
PERL_MAGIC_ext|5.007002|5.003007|p
PERL_MAGIC_fm|5.007002|5.003007|p
PERL_MAGIC_glob||5.003007|ponu
PERL_MAGIC_hints|5.009004|5.009004|
PERL_MAGIC_hintselem|5.009004|5.009004|
PERL_MAGIC_isa|5.007002|5.003007|p
PERL_MAGIC_isaelem|5.007002|5.003007|p
PERL_MAGIC_lvref|5.021005|5.021005|
PERL_MAGIC_mutex||5.003007|ponu
PERL_MAGIC_nkeys|5.007002|5.003007|p
PERL_MAGIC_nonelem|5.027009|5.027009|
PERL_MAGIC_overload||5.003007|ponu
PERL_MAGIC_overload_elem||5.003007|ponu
PERL_MAGIC_overload_table|5.007002|5.003007|p
PERL_MAGIC_pos|5.007002|5.003007|p
PERL_MAGIC_qr|5.007002|5.003007|p
PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu
PERL_MAGIC_regdata|5.007002|5.003007|p
PERL_MAGIC_regdatum|5.007002|5.003007|p
PERL_MAGIC_regex_global|5.007002|5.003007|p
PERL_MAGIC_rhash|5.009003|5.009003|
PERL_MAGIC_shared|5.007003|5.003007|p
PERL_MAGIC_shared_scalar|5.007003|5.003007|p
PERL_MAGIC_sig|5.007002|5.003007|p
PERL_MAGIC_sigelem|5.007002|5.003007|p
PERL_MAGIC_substr|5.007002|5.003007|p
PERL_MAGIC_sv|5.007002|5.003007|p
PERL_MAGIC_symtab|5.009003|5.009003|
PERL_MAGIC_taint|5.007002|5.003007|p
PERL_MAGIC_tied|5.007002|5.003007|p

xs/slot/ppport.h  view on Meta::CPAN

PL_exitlistlen|5.005000||Viu
PL_expect||5.003007|ponu
PL_fdpid|5.005000||Viu
PL_filemode|5.005000||Viu
PL_firstgv|5.005000||Viu
PL_forkprocess|5.005000||Viu
PL_formtarget|5.005000||Viu
PL_GCB_invlist|5.021009||Viu
PL_generation|5.005000||Viu
PL_gensym|5.005000||Viu
PL_globalstash|5.005000||Viu
PL_globhook|5.015005||Viu
PL_hash_rand_bits|5.017010||Viu
PL_HASH_RAND_BITS_ENABLED|5.018000||Viu
PL_hash_rand_bits_enabled|5.018000||Viu
PL_hash_seed|5.033007||Viu
PL_hash_state|5.033007||Viu
PL_HasMultiCharFold|5.017005||Viu
PL_hexdigit||5.003007|pn
PL_hintgv|5.005000||Viu
PL_hints|5.005000|5.003007|poVnu
PL_hv_fetch_ent_mh|5.005000||Viu

xs/slot/ppport.h  view on Meta::CPAN

PL_mess_sv|5.005000|5.004000|poVnu
PL_min_intro_pending|5.005000||Viu
PL_minus_a|5.005000||Viu
PL_minus_c|5.005000||Viu
PL_minus_E|5.009003||Viu
PL_minus_F|5.005000||Viu
PL_minus_l|5.005000||Viu
PL_minus_n|5.005000||Viu
PL_minus_p|5.005000||Viu
PL_modcount|5.005000||Viu
PL_modglobal|5.005000|5.005000|
PL_multideref_pc|5.021007||Viu
PL_my_cxt_list|5.009003||Viu
PL_my_cxt_size|5.009003||Viu
PL_na|5.004005|5.003007|p
PL_nomemok|5.005000||Viu
PL_no_modify||5.003007|ponu
PL_numeric_name|5.005000||Viu
PL_numeric_radix_sv|5.007002||Viu
PL_numeric_standard|5.005000||Viu
PL_numeric_underlying|5.027006||Viu

xs/slot/ppport.h  view on Meta::CPAN

PL_vtbl_debugvar|5.021005||Viu
PL_vtbl_defelem|5.015000||Viu
PL_vtbl_env|5.015000||Viu
PL_vtbl_envelem|5.015000||Viu
PL_vtbl_fm|5.015000||Viu
PL_vtbl_hints|5.015000||Viu
PL_vtbl_hintselem|5.015000||Viu
PL_vtbl_isa|5.015000||Viu
PL_vtbl_isaelem|5.015000||Viu
PL_vtbl_lvref|5.021005||Viu
PL_vtbl_mglob|5.015000||Viu
PL_vtbl_nkeys|5.015000||Viu
PL_vtbl_nonelem|5.027009||Viu
PL_vtbl_ovrld|5.015000||Viu
PL_vtbl_pack|5.015000||Viu
PL_vtbl_packelem|5.015000||Viu
PL_vtbl_pos|5.015000||Viu
PL_vtbl_regdata|5.015000||Viu
PL_vtbl_regdatum|5.015000||Viu
PL_vtbl_regexp|5.015000||Viu
PL_vtbl_sig|5.035001||Viu

xs/slot/ppport.h  view on Meta::CPAN

Stack_off_t|||piu
STANDARD_C|5.003007||Viu
STAR|5.003007||Viu
STAR_t8|5.035004||Viu
STAR_t8_p8|5.033003||Viu
STAR_t8_pb|5.033003||Viu
STAR_tb|5.035004||Viu
STAR_tb_p8|5.033003||Viu
STAR_tb_pb|5.033003||Viu
START_EXTERN_C|5.005000|5.003007|pV
start_glob|||xi
START_MY_CXT|5.010000|5.010000|p
STARTPERL|5.003007|5.003007|Vn
start_subparse|5.004000|5.003007|pu
StashHANDLER|5.007001||Viu
Stat|5.003007||Viu
stat|5.005000||Viu
STATIC|5.005000||Viu
STATIC_ASSERT_1|5.021007||Viu
STATIC_ASSERT_2|5.021007||Viu
STATIC_ASSERT_DECL|5.027001||Viu

xs/slot/ppport.h  view on Meta::CPAN

sv_len_utf8|5.006000|5.006000|p
sv_len_utf8_nomg||5.006000|p
SvLENx|5.003007||Viu
SvLOCK|5.007003|5.007003|
sv_magic|5.003007|5.003007|
SvMAGIC|5.003007||Viu
SvMAGICAL|5.003007||Viu
SvMAGICAL_off|5.003007||Viu
SvMAGICAL_on|5.003007||Viu
sv_magicext|5.007003|5.007003|
sv_magicext_mglob|5.019002||cViu
sv_magic_portable||5.004000|pou
SvMAGIC_set|5.009003|5.003007|p
sv_mortalcopy|5.003007|5.003007|
sv_mortalcopy_flags|5.031001|5.003007|p
SV_MUTABLE_RETURN|5.009003|5.003007|poVnu
sv_ncmp|5.009003||Viu
sv_ncmp_desc|5.031011||Viu
sv_newmortal|5.003007|5.003007|
sv_newref|5.003007||cV
SvNIOK|5.003007|5.003007|

xs/slot/ppport.h  view on Meta::CPAN

SvTRUE_NN|5.017007|5.017007|
SvTRUE_nomg|5.013006|5.003007|p
SvTRUE_nomg_NN|5.017007|5.017007|
SvTRUEx|5.003007|5.003007|
SvTRUEx_nomg|5.017002||Viu
SVt_RV|5.011000||Viu
SvTYPE|5.003007|5.003007|
SVTYPEMASK|5.003007||Viu
SvUID|5.019001||Viu
SV_UNDEF_RETURNS_NULL|5.011000||Viu
sv_unglob|5.005000||Viu
sv_uni_display|5.007003|5.007003|
SvUNLOCK|5.007003|5.007003|
sv_unmagic|5.003007|5.003007|
sv_unmagicext|5.013008|5.003007|p
sv_unref|5.003007|5.003007|
sv_unref_flags|5.007001|5.007001|
sv_untaint|5.004000||cV
SvUOK|5.007001|5.006000|p
SvUOK_nog|5.017002||Viu
SvUOK_nogthink|5.017002||Viu

xs/slot/ppport.h  view on Meta::CPAN

sv_vsetpvfn|5.004000|5.004000|
sv_vstring_get|||p
SvVSTRING_mg|5.009004|5.003007|p
SvVSTRING|||piu
SvWEAKREF|5.006000||Viu
SvWEAKREF_off|5.006000||Viu
SvWEAKREF_on|5.006000||Viu
swallow_bom|5.006001||Viu
switch_category_locale_to_template|5.027009||Viu
SWITCHSTACK|5.003007||Viu
switch_to_global_locale|5.027009|5.003007|pn
sync_locale|5.027009|5.003007|pn
sys_init3|||cnu
sys_init|||cnu
sys_intern_clear|5.006001||Vu
sys_intern_dup|5.006000||Vu
sys_intern_init|5.006001||Vu
SYSTEM_GMTIME_MAX|5.011000||Viu
SYSTEM_GMTIME_MIN|5.011000||Viu
SYSTEM_LOCALTIME_MAX|5.011000||Viu
SYSTEM_LOCALTIME_MIN|5.011000||Viu

xs/slot/ppport.h  view on Meta::CPAN

VTBL_amagic|5.005003||Viu
VTBL_amagicelem|5.005003||Viu
VTBL_arylen|5.005003||Viu
VTBL_bm|5.005003||Viu
VTBL_collxfrm|5.005003||Viu
VTBL_dbline|5.005003||Viu
VTBL_defelem|5.005003||Viu
VTBL_env|5.005003||Viu
VTBL_envelem|5.005003||Viu
VTBL_fm|5.005003||Viu
VTBL_glob|5.005003||Viu
VTBL_isa|5.005003||Viu
VTBL_isaelem|5.005003||Viu
VTBL_mglob|5.005003||Viu
VTBL_nkeys|5.005003||Viu
VTBL_pack|5.005003||Viu
VTBL_packelem|5.005003||Viu
VTBL_pos|5.005003||Viu
VTBL_regdata|5.006000||Viu
VTBL_regdatum|5.006000||Viu
VTBL_regexp|5.005003||Viu
VTBL_sigelem|5.005003||Viu
VTBL_substr|5.005003||Viu
VTBL_sv|5.005003||Viu

xs/slot/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/slot/ppport.h  view on Meta::CPAN

      {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/slot/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort dictionary_order keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort dictionary_order keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/slot/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/slot/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/slot/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
        SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
        SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
                                  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT \
        dMY_CXT_SV;                                                     \
        my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/slot/ppport.h  view on Meta::CPAN


    if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
	return 0;
    mgp = &(SvMAGIC(sv));
    for (mg = *mgp; mg; mg = *mgp) {
	const MGVTBL* const virt = mg->mg_virtual;
	if (mg->mg_type == type && virt == vtbl) {
	    *mgp = mg->mg_moremagic;
	    if (virt && virt->svt_free)
		virt->svt_free(aTHX_ sv, mg);
	    if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) {
		if (mg->mg_len > 0)
		    Safefree(mg->mg_ptr);
		else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */
		    SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr));
		else if (mg->mg_type == PERL_MAGIC_utf8)
		    Safefree(mg->mg_ptr);
            }
	    if (mg->mg_flags & MGf_REFCOUNTED)
		SvREFCNT_dec(mg->mg_obj);
	    Safefree(mg);

xs/slot/ppport.h  view on Meta::CPAN

/* The names of these changed in 5.28 */
#ifndef LOCK_LC_NUMERIC_STANDARD
#  define LOCK_LC_NUMERIC_STANDARD       LOCK_NUMERIC_STANDARD
#endif

#ifndef UNLOCK_LC_NUMERIC_STANDARD
#  define UNLOCK_LC_NUMERIC_STANDARD     UNLOCK_NUMERIC_STANDARD
#endif

/* If this doesn't exist, it's not needed, so is void noop */
#ifndef switch_to_global_locale
#  define switch_to_global_locale()
#endif

/* Originally, this didn't return a value, but in perls like that, the value
 * should always be TRUE.  Add a return to Perl_sync_locale() when it's
 * available.  And actually do a sync when its not, if locales are available on
 * this system. */
#ifdef sync_locale
#  if (PERL_BCDVERSION < 0x5027009)
#    if (PERL_BCDVERSION >= 0x5021003)
#      undef sync_locale

xs/util/ppport.h  view on Meta::CPAN

access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use

    perl ppport.h --list-provided

to see which API elements are provided by ppport.h.

=item *

You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C<PL_> prefix is deprecated. Also,
some API functions used to have a C<perl_> prefix. Using this form is
also deprecated. You can safely use the supported API, as F<ppport.h>
will provide wrappers for older Perl versions.

=item *

If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F<ppport.h>.

These functions or variables will be marked C<explicit> in the list shown
by C<--list-provided>.

Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C<static> or global
variants.

For a C<static> function or variable (used only in a single source
file), use:

    #define NEED_function
    #define NEED_variable

For a global function or variable (used in multiple source files),
use:

    #define NEED_function_GLOBAL
    #define NEED_variable_GLOBAL

Note that you mustn't have more than one global request for the
same function or variable in your project.

    Function / Variable       Static Request               Global Request
    -----------------------------------------------------------------------------------------
    PL_parser                 NEED_PL_parser               NEED_PL_parser_GLOBAL
    PL_signals                NEED_PL_signals              NEED_PL_signals_GLOBAL
    eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL
    grok_bin()                NEED_grok_bin                NEED_grok_bin_GLOBAL
    grok_hex()                NEED_grok_hex                NEED_grok_hex_GLOBAL
    grok_number()             NEED_grok_number             NEED_grok_number_GLOBAL

xs/util/ppport.h  view on Meta::CPAN

PERL_MAGIC_backref|5.007002||p
PERL_MAGIC_bm|5.007002||p
PERL_MAGIC_collxfrm|5.007002||p
PERL_MAGIC_dbfile|5.007002||p
PERL_MAGIC_dbline|5.007002||p
PERL_MAGIC_defelem|5.007002||p
PERL_MAGIC_envelem|5.007002||p
PERL_MAGIC_env|5.007002||p
PERL_MAGIC_ext|5.007002||p
PERL_MAGIC_fm|5.007002||p
PERL_MAGIC_glob|5.011000||p
PERL_MAGIC_isaelem|5.007002||p
PERL_MAGIC_isa|5.007002||p
PERL_MAGIC_mutex|5.011000||p
PERL_MAGIC_nkeys|5.007002||p
PERL_MAGIC_overload_elem|5.007002||p
PERL_MAGIC_overload_table|5.007002||p
PERL_MAGIC_overload|5.007002||p
PERL_MAGIC_pos|5.007002||p
PERL_MAGIC_qr|5.007002||p
PERL_MAGIC_regdata|5.007002||p
PERL_MAGIC_regdatum|5.007002||p
PERL_MAGIC_regex_global|5.007002||p
PERL_MAGIC_shared_scalar|5.007003||p
PERL_MAGIC_shared|5.007003||p
PERL_MAGIC_sigelem|5.007002||p
PERL_MAGIC_sig|5.007002||p
PERL_MAGIC_substr|5.007002||p
PERL_MAGIC_sv|5.007002||p
PERL_MAGIC_taint|5.007002||p
PERL_MAGIC_tiedelem|5.007002||p
PERL_MAGIC_tiedscalar|5.007002||p
PERL_MAGIC_tied|5.007002||p

xs/util/ppport.h  view on Meta::CPAN

PL_expect|5.011000||p
PL_hexdigit|5.005000||p
PL_hints|5.005000||p
PL_in_my_stash|5.011000||p
PL_in_my|5.011000||p
PL_last_in_gv|||n
PL_laststatval|5.005000||p
PL_lex_state|5.011000||p
PL_lex_stuff|5.011000||p
PL_linestr|5.011000||p
PL_modglobal||5.005000|n
PL_na|5.004050||pn
PL_no_modify|5.006000||p
PL_ofsgv|||n
PL_parser|5.009005||p
PL_perl_destruct_level|5.004050||p
PL_perldb|5.004050||p
PL_ppaddr|5.006000||p
PL_rsfp_filters|5.004050||p
PL_rsfp|5.004050||p
PL_rs|||n

xs/util/ppport.h  view on Meta::CPAN

ck_delete|||
ck_die|||
ck_each|||
ck_eof|||
ck_eval|||
ck_exec|||
ck_exists|||
ck_exit|||
ck_ftst|||
ck_fun|||
ck_glob|||
ck_grep|||
ck_index|||
ck_join|||
ck_lfun|||
ck_listiob|||
ck_match|||
ck_method|||
ck_null|||
ck_open|||
ck_readline|||

xs/util/ppport.h  view on Meta::CPAN

force_ident|||
force_list|||
force_next|||
force_version|||
force_word|||
forget_pmop|||
form_nocontext|||vn
form||5.004000|v
fp_dup|||
fprintf_nocontext|||vn
free_global_struct|||
free_tied_hv_pool|||
free_tmps|||
gen_constant_list|||
get_arena|||
get_aux_mg|||
get_av|5.006000||p
get_context||5.006000|n
get_cvn_flags||5.009005|
get_cv|5.006000||p
get_db_sub|||

xs/util/ppport.h  view on Meta::CPAN

get_num|||
get_op_descs||5.005000|
get_op_names||5.005000|
get_opargs|||
get_ppaddr||5.006000|
get_re_arg|||
get_sv|5.006000||p
get_vtbl||5.005030|
getcwd_sv||5.007002|
getenv_len|||
glob_2number|||
glob_assign_glob|||
glob_assign_ref|||
gp_dup|||
gp_free|||
gp_ref|||
grok_bin|5.007003||p
grok_hex|5.007003||p
grok_number|5.007002||p
grok_numeric_radix|5.007002||p
grok_oct|5.007003||p
group_end|||
gv_AVadd|||

xs/util/ppport.h  view on Meta::CPAN

ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
incpush|||
ingroup|||
init_argv_symbols|||
init_debugger|||
init_global_struct|||
init_i18nl10n||5.006000|
init_i18nl14n||5.006000|
init_ids|||
init_interp|||
init_main_stash|||
init_perllib|||
init_postdump_symbols|||
init_predump_symbols|||
init_stacks||5.005000|
init_tm||5.007002|

xs/util/ppport.h  view on Meta::CPAN

magic_scalarpack|||
magic_set_all_env|||
magic_setamagic|||
magic_setarylen|||
magic_setcollxfrm|||
magic_setdbline|||
magic_setdefelem|||
magic_setenv|||
magic_sethint|||
magic_setisa|||
magic_setmglob|||
magic_setnkeys|||
magic_setpack|||
magic_setpos|||
magic_setregexp|||
magic_setsig|||
magic_setsubstr|||
magic_settaint|||
magic_setutf8|||
magic_setuvar|||
magic_setvec|||

xs/util/ppport.h  view on Meta::CPAN

softref2xv|||
sortcv_stacked|||
sortcv_xsub|||
sortcv|||
sortsv_flags||5.009003|
sortsv||5.007003|
space_join_names_mortal|||
ss_dup|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stashpv_hvname_match||5.011000|
stdize_locale|||
store_cop_label|||
strEQ|||
strGE|||
strGT|||
strLE|||
strLT|||
strNE|||

xs/util/ppport.h  view on Meta::CPAN

sv_setsv_cow|||
sv_setsv_flags||5.007002|
sv_setsv_mg|5.004050||p
sv_setsv_nomg|5.007002||p
sv_setsv|||
sv_setuv_mg|5.004050||p
sv_setuv|5.004000||p
sv_tainted||5.004000|
sv_taint||5.004000|
sv_true||5.005000|
sv_unglob|||
sv_uni_display||5.007003|
sv_unmagic|||
sv_unref_flags||5.007001|
sv_unref|||
sv_untaint||5.004000|
sv_upgrade|||
sv_usepvn_flags||5.009004|
sv_usepvn_mg|5.004050||p
sv_usepvn|||
sv_utf8_decode||5.006000|

xs/util/ppport.h  view on Meta::CPAN

if (@ARGV) {
  my %seen;
  for (@ARGV) {
    if (-e) {
      if (-f) {
        push @files, $_ unless $seen{$_}++;
      }
      else { warn "'$_' is not a file.\n" }
    }
    else {
      my @new = grep { -f } glob $_
          or warn "'$_' does not exist.\n";
      push @files, grep { !$seen{$_}++ } @new;
    }
  }
}
else {
  eval {
    require File::Find;
    File::Find::find(sub {
      $File::Find::name =~ /($srcext)$/i
          and push @files, $File::Find::name;
    }, '.');
  };
  if ($@) {
    @files = map { glob "*$_" } @srcext;
  }
}

if (!@ARGV || $opt{filter}) {
  my(@in, @out);
  my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
  for (@files) {
    my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
    push @{ $out ? \@out : \@in }, $_;
  }
  if (@ARGV && @out) {
    warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
  }
  @files = @in;
}

die "No input files given!\n" unless @files;

my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;

for $filename (@files) {
  unless (open IN, "<$filename") {
    warn "Unable to read from $filename: $!\n";
    next;
  }

xs/util/ppport.h  view on Meta::CPAN

      if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
        if ($c =~ /\b$func\b/) {
          $file{uses_todo}{$func}++;
        }
      }
    }
  }

  while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
    if (exists $need{$2}) {
      $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
    }
    else { warning("Possibly wrong #define $1 in $filename") }
  }

  for (qw(uses needs uses_todo needed_global needed_static)) {
    for $func (keys %{$file{$_}}) {
      push @{$global{$_}{$func}}, $filename;
    }
  }

  $files{$filename} = \%file;
}

# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
  if (@{$global{needs}{$need}} > 1) {
    my @targets = @{$global{needs}{$need}};
    my @t = grep $files{$_}{needed_global}{$need}, @targets;
    @targets = @t if @t;
    @t = grep /\.xs$/i, @targets;
    @targets = @t if @t;
    my $target = shift @targets;
    $files{$target}{needs}{$need} = 'global';
    for (@{$global{needs}{$need}}) {
      $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
    }
  }
}

for $filename (@files) {
  exists $files{$filename} or next;

  info("=== Analyzing $filename ===");

xs/util/ppport.h  view on Meta::CPAN

      $warnings++;
    }
  }

  for $func (sort keys %{$file{needed_static}}) {
    my $message = '';
    if (not exists $file{uses}{$func}) {
      $message = "No need to define NEED_$func if $func is never used";
    }
    elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
      $message = "No need to define NEED_$func when already needed globally";
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
    }
  }

  for $func (sort keys %{$file{needed_global}}) {
    my $message = '';
    if (not exists $global{uses}{$func}) {
      $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
    }
    elsif (exists $file{needs}{$func}) {
      if ($file{needs}{$func} eq 'extern') {
        $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
      }
      elsif ($file{needs}{$func} eq 'static') {
        $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
      }
    }
    if ($message) {
      diag($message);
      $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
    }
  }

  $file{needs_inc_ppport} = keys %{$file{uses}};

  if ($file{needs_inc_ppport}) {
    my $pp = '';

    for $func (sort keys %{$file{needs}}) {
      my $type = $file{needs}{$func};
      next if $type eq 'extern';
      my $suffix = $type eq 'global' ? '_GLOBAL' : '';
      unless (exists $file{"needed_$type"}{$func}) {
        if ($type eq 'global') {
          diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
        }
        else {
          diag("File needs $func, adding static request");
        }
        $pp .= "#define NEED_$func$suffix\n";
      }
    }

    if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
      $pp = '';

xs/util/ppport.h  view on Meta::CPAN

 * 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

#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
	SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
	SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,		\
				  sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */

/* This declaration should be used within all functions that use the
 * interpreter-local data. */
#define dMY_CXT	\
	dMY_CXT_SV;							\
	my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))

/* Creates and zeroes the per-interpreter data.

xs/util/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_envelem
#  define PERL_MAGIC_envelem             'e'
#endif

#ifndef PERL_MAGIC_fm
#  define PERL_MAGIC_fm                  'f'
#endif

#ifndef PERL_MAGIC_regex_global
#  define PERL_MAGIC_regex_global        'g'
#endif

#ifndef PERL_MAGIC_isa
#  define PERL_MAGIC_isa                 'I'
#endif

#ifndef PERL_MAGIC_isaelem
#  define PERL_MAGIC_isaelem             'i'
#endif

xs/util/ppport.h  view on Meta::CPAN

#endif

#ifndef PERL_MAGIC_substr
#  define PERL_MAGIC_substr              'x'
#endif

#ifndef PERL_MAGIC_defelem
#  define PERL_MAGIC_defelem             'y'
#endif

#ifndef PERL_MAGIC_glob
#  define PERL_MAGIC_glob                '*'
#endif

#ifndef PERL_MAGIC_arylen
#  define PERL_MAGIC_arylen              '#'
#endif

#ifndef PERL_MAGIC_pos
#  define PERL_MAGIC_pos                 '.'
#endif

xs/util/util.c  view on Meta::CPAN

static XOP is_true_xop;
static XOP is_false_xop;
static XOP bool_xop;

/* Extended type predicate custom ops */
static XOP is_num_xop;
static XOP is_int_xop;
static XOP is_blessed_xop;
static XOP is_scalar_ref_xop;
static XOP is_regex_xop;
static XOP is_glob_xop;
static XOP is_string_xop;

/* Numeric predicate custom ops */
static XOP is_positive_xop;
static XOP is_negative_xop;
static XOP is_zero_xop;

/* Numeric utility custom ops */
static XOP is_even_xop;
static XOP is_odd_xop;

xs/util/util.c  view on Meta::CPAN

/* ============================================
   Callback registry functions
   ============================================ */

static void init_callback_registry(pTHX) {
    if (!g_callback_registry) {
        g_callback_registry = newHV();
    }
}

/* Cleanup callback registry during global destruction */
static void cleanup_callback_registry(pTHX_ void *data) {
    HE *entry;
    PERL_UNUSED_ARG(data);

    if (!g_callback_registry) return;

    /* During global destruction, just NULL out the registry pointer.
     * Perl will handle freeing the SVs. Trying to free them ourselves
     * can cause crashes due to destruction order issues. */
    if (PL_dirty) {
        g_callback_registry = NULL;
        return;
    }

    /* Normal cleanup (not during global destruction) */
    hv_iterinit(g_callback_registry);
    while ((entry = hv_iternext(g_callback_registry))) {
        SV *sv = HeVAL(entry);
        if (sv && SvOK(sv)) {
            RegisteredCallback *cb = (RegisteredCallback*)SvIVX(sv);
            if (cb) {
                if (cb->perl_callback) {
                    SvREFCNT_dec(cb->perl_callback);
                    cb->perl_callback = NULL;
                }

xs/util/util.c  view on Meta::CPAN


/* is_regex: check if value is a compiled regex */
static OP* pp_is_regex(pTHX) {
    dSP;
    SV *sv = TOPs;
    /* SvRXOK: check if SV is a regex (qr//) - available since Perl 5.10 */
    SETs(SvRXOK(sv) ? &PL_sv_yes : &PL_sv_no);
    RETURN;
}

/* is_glob: check if value is a glob (*foo) */
static OP* pp_is_glob(pTHX) {
    dSP;
    SV *sv = TOPs;
    SETs((SvTYPE(sv) == SVt_PVGV) ? &PL_sv_yes : &PL_sv_no);
    RETURN;
}

/* is_string: check if value is a plain scalar (defined, not a reference) */
static OP* pp_is_string(pTHX) {
    dSP;
    SV *sv = TOPs;

xs/util/util.c  view on Meta::CPAN

}

static OP* is_scalar_ref_call_checker(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) {
    return type_predicate_call_checker(aTHX_ entersubop, namegv, ckobj, pp_is_scalar_ref);
}

static OP* is_regex_call_checker(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) {
    return type_predicate_call_checker(aTHX_ entersubop, namegv, ckobj, pp_is_regex);
}

static OP* is_glob_call_checker(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) {
    return type_predicate_call_checker(aTHX_ entersubop, namegv, ckobj, pp_is_glob);
}

static OP* is_string_call_checker(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) {
    return type_predicate_call_checker(aTHX_ entersubop, namegv, ckobj, pp_is_string);
}

/* Numeric predicate call checkers */
static OP* is_positive_call_checker(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) {
    return type_predicate_call_checker(aTHX_ entersubop, namegv, ckobj, pp_is_positive);
}

xs/util/util.c  view on Meta::CPAN

    XSRETURN(1);
}

static XS(xs_is_regex) {
    dXSARGS;
    if (items != 1) croak("Usage: util::is_regex($value)");
    ST(0) = SvRXOK(ST(0)) ? &PL_sv_yes : &PL_sv_no;
    XSRETURN(1);
}

static XS(xs_is_glob) {
    dXSARGS;
    if (items != 1) croak("Usage: util::is_glob($value)");
    ST(0) = (SvTYPE(ST(0)) == SVt_PVGV) ? &PL_sv_yes : &PL_sv_no;
    XSRETURN(1);
}

static XS(xs_is_string) {
    dXSARGS;
    if (items != 1) croak("Usage: util::is_string($value)");
    SV *sv = ST(0);
    ST(0) = (SvOK(sv) && !SvROK(sv)) ? &PL_sv_yes : &PL_sv_no;
    XSRETURN(1);

xs/util/util.c  view on Meta::CPAN

    register_export(aTHX_ "is_true", xs_is_true, is_true_call_checker);
    register_export(aTHX_ "is_false", xs_is_false, is_false_call_checker);
    register_export(aTHX_ "bool", xs_bool, bool_call_checker);

    /* Extended type predicates */
    register_export(aTHX_ "is_num", xs_is_num, is_num_call_checker);
    register_export(aTHX_ "is_int", xs_is_int, is_int_call_checker);
    register_export(aTHX_ "is_blessed", xs_is_blessed, is_blessed_call_checker);
    register_export(aTHX_ "is_scalar_ref", xs_is_scalar_ref, is_scalar_ref_call_checker);
    register_export(aTHX_ "is_regex", xs_is_regex, is_regex_call_checker);
    register_export(aTHX_ "is_glob", xs_is_glob, is_glob_call_checker);

    /* Numeric predicates */
    register_export(aTHX_ "is_positive", xs_is_positive, is_positive_call_checker);
    register_export(aTHX_ "is_negative", xs_is_negative, is_negative_call_checker);
    register_export(aTHX_ "is_zero", xs_is_zero, is_zero_call_checker);
    register_export(aTHX_ "is_even", xs_is_even, is_even_call_checker);
    register_export(aTHX_ "is_odd", xs_is_odd, is_odd_call_checker);
    register_export(aTHX_ "is_between", xs_is_between, is_between_call_checker);

    /* Collection predicates */

xs/util/util.c  view on Meta::CPAN

             * Users who want compile-time optimization should call util::func()
             * directly instead of importing. */
            CV *cv = newXS(full, entry->xs_func, __FILE__);
            PERL_UNUSED_VAR(cv);
        } else if (entry->perl_cv) {
            /* Perl coderef: create alias in caller's namespace */
            GV *gv = gv_fetchpv(full, GV_ADD, SVt_PVCV);
            if (gv) {
                /* Get the actual CV from the reference */
                CV *src_cv = (CV*)SvRV(entry->perl_cv);
                /* Assign the CV to the glob's CODE slot */
                SvREFCNT_inc((SV*)src_cv);
                GvCV_set(gv, src_cv);
            }
        }
    }

    XSRETURN_EMPTY;
}

/* ============================================

xs/util/util.c  view on Meta::CPAN

    Perl_custom_op_register(aTHX_ pp_is_blessed, &is_blessed_xop);

    XopENTRY_set(&is_scalar_ref_xop, xop_name, "is_scalar_ref");
    XopENTRY_set(&is_scalar_ref_xop, xop_desc, "check if value is scalar reference");
    Perl_custom_op_register(aTHX_ pp_is_scalar_ref, &is_scalar_ref_xop);

    XopENTRY_set(&is_regex_xop, xop_name, "is_regex");
    XopENTRY_set(&is_regex_xop, xop_desc, "check if value is compiled regex");
    Perl_custom_op_register(aTHX_ pp_is_regex, &is_regex_xop);

    XopENTRY_set(&is_glob_xop, xop_name, "is_glob");
    XopENTRY_set(&is_glob_xop, xop_desc, "check if value is glob");
    Perl_custom_op_register(aTHX_ pp_is_glob, &is_glob_xop);

    XopENTRY_set(&is_string_xop, xop_name, "is_string");
    XopENTRY_set(&is_string_xop, xop_desc, "check if value is plain scalar");
    Perl_custom_op_register(aTHX_ pp_is_string, &is_string_xop);

    /* Register numeric predicate custom ops */
    XopENTRY_set(&is_positive_xop, xop_name, "is_positive");
    XopENTRY_set(&is_positive_xop, xop_desc, "check if value is positive");
    Perl_custom_op_register(aTHX_ pp_is_positive, &is_positive_xop);

xs/util/util.c  view on Meta::CPAN

    }
    {
        CV *cv = newXS("util::is_scalar_ref", xs_is_scalar_ref, __FILE__);
        cv_set_call_checker(cv, is_scalar_ref_call_checker, (SV*)cv);
    }
    {
        CV *cv = newXS("util::is_regex", xs_is_regex, __FILE__);
        cv_set_call_checker(cv, is_regex_call_checker, (SV*)cv);
    }
    {
        CV *cv = newXS("util::is_glob", xs_is_glob, __FILE__);
        cv_set_call_checker(cv, is_glob_call_checker, (SV*)cv);
    }

    /* Numeric predicates with call checkers */
    {
        CV *cv = newXS("util::is_positive", xs_is_positive, __FILE__);
        cv_set_call_checker(cv, is_positive_call_checker, (SV*)cv);
    }
    {
        CV *cv = newXS("util::is_negative", xs_is_negative, __FILE__);
        cv_set_call_checker(cv, is_negative_call_checker, (SV*)cv);

xs/util/util.c  view on Meta::CPAN

    }
    {
        CV *cv = newXS("util::min2", xs_min2, __FILE__);
        cv_set_call_checker(cv, min2_call_checker, (SV*)cv);
    }
    {
        CV *cv = newXS("util::max2", xs_max2, __FILE__);
        cv_set_call_checker(cv, max2_call_checker, (SV*)cv);
    }

    /* Register cleanup for global destruction */
    Perl_call_atexit(aTHX_ cleanup_callback_registry, NULL);

    Perl_xs_boot_epilog(aTHX_ ax);
}

xt/c-compat.t  view on Meta::CPAN

        severity => 'info',
        message => '__builtin_* functions are GCC specific',
    },
    
    # === PERL XS ISSUES ===
    
    # NOTE: PERL_NO_GET_CONTEXT is a micro-optimization for threaded perls.
    # Most XS code works fine without it. Only flag if explicitly requested.
    # Disabled by default as it's too noisy.
    
    # NOTE: PL_sv_undef, PL_sv_yes, PL_sv_no, etc. are standard Perl globals
    # that are perfectly safe to use in XS code. They're thread-safe constants.
    # Disabled as it creates too much noise for legitimate XS patterns.
    
    # === MEMORY/SAFETY ISSUES ===
    
    # sprintf without size limit (buffer overflow risk)
    'unsafe_sprintf' => {
        pattern => qr/\bsprintf\s*\(/,
        severity => 'warning',
        message => 'sprintf is unsafe - use snprintf or sv_catpvf for safety',

xt/c-compat.t  view on Meta::CPAN

                        severity => 'warning',
                        message => 'Uses true/false but may not include compat header',
                    };
                }
            }
        }
    }
}

# Check that all compat headers have the fixed pattern
my @compat_headers = glob("xs/*/*.h");
@compat_headers = grep { /_compat\.h$/ } @compat_headers;

for my $compat (@compat_headers) {
    my $content = eval { read_file($compat) };
    next unless defined $content;
    
    # Get the corresponding .c file to check if bool is used
    my $c_file = $compat;
    $c_file =~ s/_compat\.h$/.c/;
    my $c_content = eval { read_file($c_file) } // '';



( run in 2.032 seconds using v1.01-cache-2.11-cpan-df04353d9ac )